Exemplo n.º 1
0
    public void SaveTest_Middle()
    {
        //Create an ODE initial value problem
        ODEInitialValueProblem ivp    = new ODEInitialValueProblem(3, 0.2, 0);
        ExpressionParser       parser = new ExpressionParser();

        //Define a system in which the solution will be (3,4,5) at all times
        ivp.F.funcs[0] = parser.EvaluateExpression("0").ToDelegate("t");
        ivp.F.funcs[1] = parser.EvaluateExpression("0").ToDelegate("t");
        ivp.F.funcs[2] = parser.EvaluateExpression("0").ToDelegate("t");
        ivp.SetState(new VectorND(3, 4, 5), 0);
        //Solve the problem
        ivp.SolveTo(3);

        //save this data to file
        StreamWriter fout = new StreamWriter("testing.csv");

        ivp.SaveData(fout);
        fout.Close();

        //Read the data file and check its output
        string       line = "";
        StreamReader fin  = new StreamReader("testing.csv");

        fin.ReadLine();
        fin.ReadLine();
        line = fin.ReadLine();
        fin.Close();
        //Delete the file
        File.Delete("testing.csv");
        Assert.AreEqual("0.4,3,4,5,", line);
    }
Exemplo n.º 2
0
 //Saves object motion data to file
 public void SaveData(StreamWriter fout)
 {
     ivp.SaveData(fout);
 }