//x = y^2/3 public DifferentialSystem(string[] DiffEquations, string[] StaticEquations, double[] startingVals, double startTime = 0) { for (int i = 0; i < DiffEquations.Count(); i++) { DiffEquations[i] = DiffEquations[i].Replace(" ", ""); int EqualsLocation = 0; string var = ""; while (DiffEquations[i][EqualsLocation] != '=') { var += DiffEquations[i][EqualsLocation]; EqualsLocation++; } Equation Equation = new Equation(DiffEquations[i].Substring(EqualsLocation + 1)); variables.Add(new Variable(var, Equation, startingVals[i], startTime)); ; } for (int i = 0; i < StaticEquations.Count(); i++) { StaticEquations[i] = StaticEquations[i].Replace(" ", ""); int EqualsLocation = 0; string var = ""; while (StaticEquations[i][EqualsLocation] != '=') { var += StaticEquations[i][EqualsLocation]; EqualsLocation++; } Equation Equation = new Equation(StaticEquations[i].Substring(EqualsLocation + 1)); staticVariables.Add(new StaticVariable(var, Equation)); } for (int i = 0; i < variables.Count(); i++) { variables[i].DiffEquation.addVariables(variables); variables[i].DiffEquation.addVariables(staticVariables); } }
public StaticVariable(string Name, Equation Equation) { this.Name = Name; this.Equation = Equation; }
public Variable(string Name, Equation DiffEquation, double startingValue, double time) { this.Name = Name; this.DiffEquation = DiffEquation; head = new TimeValueNode(time, startingValue); }