Changeset 16227


Ignore:
Timestamp:
10/10/18 12:00:19 (14 months ago)
Author:
gkronber
Message:

#2925: changed test case to linear oscillator

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2925_AutoDiffForDynamicalModels/AutoDiffForDynamicalModelsTest/TestCvodes.cs

    r16226 r16227  
    3030
    3131
    32       // simple temperature annealing
    33       int numberOfEquations = 1;
     32      // linear oscillator
     33      int numberOfEquations = 2;
    3434      var y = Problem.N_VNew_Serial(numberOfEquations);
    3535      // y must be initialized before calling CVodeInit
    3636      // Problem.N_VConst_Serial(100.0, y);
    37       Problem.NV_Set_Ith_S(y, 0, 100.0);
     37      Problem.NV_Set_Ith_S(y, 0, 0.5); // x
     38      Problem.NV_Set_Ith_S(y, 1, 1);  // v
    3839
    3940      var cvode_mem = Problem.CVodeCreate(Problem.MultistepMethod.CV_ADAMS, Problem.NonlinearSolverIteration.CV_FUNCTIONAL);
     
    6566        flag = Problem.CVode(cvode_mem, tout, y, ref t, Problem.CV_NORMAL);
    6667        Assert.AreEqual(Problem.CV_SUCCESS, flag);
    67         Console.WriteLine("t={0} y={1}", t, Problem.N_VL1Norm_Serial(y));
     68        Console.WriteLine("{0} {1} {2}", t, Problem.NV_Get_Ith_S(y, 0), Problem.NV_Get_Ith_S(y, 1));
    6869        // Problem.N_VPrint_Serial(y);
    6970        tout += 0.1;
     
    8788      IntPtr user_data) {
    8889
    89       Problem.NV_Set_Ith_S(ydot, 0, -0.1 * Problem.NV_Get_Ith_S(y, 0));
     90      Problem.NV_Set_Ith_S(ydot, 0, Problem.NV_Get_Ith_S(y, 1));
     91      Problem.NV_Set_Ith_S(ydot, 1, -0.3 * Problem.NV_Get_Ith_S(y, 0));
    9092      return 0;
    9193      ;
Note: See TracChangeset for help on using the changeset viewer.