Beispiel #1
0
    public void SetState_ThenReadState_atNonzero_Imprecise()
    {
        //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), 4.963);
        //See if it set the initial state correctly
        Assert.IsTrue(VectorsAreEqual(ivp.GetState(5.071), new VectorND(3, 4, 5)));
    }
Beispiel #2
0
    public void GetState_OutOfBoundsNegative()
    {
        //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);
        //Check the solution data at t=-1 where there is no data
        Assert.IsNull(ivp.GetState(-1));
    }
Beispiel #3
0
    public void GetState_atUpperBound()
    {
        //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);
        //Check the solution data at t=20
        Assert.IsTrue(VectorsAreEqual(ivp.GetState(3), new VectorND(3, 4, 5)));
    }
Beispiel #4
0
    public void SetState_AfterSolving_EndOfInterval()
    {
        //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), 4.963);
        //Solve the problem to t=3
        ivp.SolveTo(3);
        //Set the state
        ivp.SetState(new VectorND(7, 6, 5), 3);
        //See if it set the initial state correctly
        Assert.IsTrue(VectorsAreEqual(ivp.GetState(3), new VectorND(7, 6, 5)));
    }