/** * Test Case XX.1 - XX * Use Case: XX.1 - XX */ TEST_F(ODESolverTest, twoStateModel) { double kon = 10; double koff = 1; shared_ptr<Matrix>::type transition_matrix(new Matrix(2,2)); (*transition_matrix)(0, 0) = kon * -1; (*transition_matrix)(0, 1) = koff; (*transition_matrix)(1, 0) = kon; (*transition_matrix)(1, 1) = koff * -1; std::vector<double> ic; ic.push_back(0); ODESolver solver; solver.initialize(ic); std::vector<double>tspan; for(double i = 0.001; i < 0.5; i+=0.001){ tspan.push_back(i); } Matrix results; solver.solve(tspan, transition_matrix, results); // Not quite sure how to verify this. }
/** * Test Case XX.1 - XX * Use Case: XX.1 - XX */ TEST_F(ODESolverTest, destructorTest) { ODESolver* solver; solver = new ODESolver(); delete solver; solver = new ODESolver(); std::vector<double> ic; ic.push_back(0.1); ic.push_back(0.9); solver->initialize(ic); delete solver; }
/** * Test Case XX.1 - XX * Use Case: XX.1 - XX */ TEST_F(ODESolverTest, solveNotInitializedTest) { ODESolver* solver; solver = new ODESolver(); shared_ptr<Matrix>::type transition_matrix(new Matrix(3,3)); std::vector<double> ic; std::vector<double>tspan; for(double i = 0.001; i < 0.5; i+=0.001){ tspan.push_back(i); } Matrix results; ASSERT_THROW(solver->solve(tspan, transition_matrix, results), std::runtime_error); delete solver; }
/** * Test Case XX.1 - XX * Use Case: XX.1 - XX */ TEST_F(ODESolverTest, createSuccess) { double rate1 = 0.1; double rate2 = 0.2; double rate3 = 0.3; double rate4 = 0.4; shared_ptr<Matrix>::type transition_matrix(new Matrix(3,3)); (*transition_matrix)(0, 0) = rate1 * -1; (*transition_matrix)(0, 1) = rate2; (*transition_matrix)(0, 2) = 0; (*transition_matrix)(1, 0) = rate1; (*transition_matrix)(1, 1) = -1*(rate2 + rate3); (*transition_matrix)(1, 2) = rate4; (*transition_matrix)(2, 0) = 0; (*transition_matrix)(2, 1) = rate3; (*transition_matrix)(2, 2) = rate4 * -1; std::vector<double> ic; ic.push_back(0.1); ic.push_back(0.9); ODESolver solver; solver.initialize(ic); std::vector<double>tspan; for(double i = 0.001; i < 0.5; i+=0.001){ tspan.push_back(i); } Matrix results; solver.solve(tspan, transition_matrix, results); // Not quite sure how to verify this. }
int main(int argc, char** argv) { Matrix<inDouble>::memCheck.initialize(MByte(1.0), Byte(0)); Vector<inDouble>::memCheck.initialize(MByte(1.0), Byte(0)); DVec x(2); x[0] = 1.0; // start at x=1.0, p=0.0 x[1] = 0.0; // harm_osc rhs(0.15); TestModel model; Problem p(model); p.setInitialValue(x). // setRhs(&rhs). setTimeRange(0.0, 10.0). setPrecision(1.0e-10, 1.0e-8); ODESolver solver; Trajectory t; solver.solve(p, t); for (size_t i = 0; i < t.size(); i++) { cout << t.getTime(i) << '\t' << t.getState(i)[0] << '\t' << t.getState(i)[1] << '\n'; } return 0; }
// TEST balODESolver calculating Lyapunov Spectrum int main(int argc, char *argv[]) { /** parameters **/ realtype x0[3] = {0.5,0.5,0.5}; BifurcationParameters * bp = BifurcationParameters::Create(); bp->SetNumber(4); // chaos //bp->At(0) = 2.96; //bp->At(1) = 3.0; // limit cycle //bp->At(0) = 4.0; //bp->At(1) = 5.0; // equilibrium bp->At(0) = 4.0; bp->At(1) = 1.0; bp->At(2) = 0.01; bp->At(3) = 4.0; HindmarshRose * hr = HindmarshRose::Create(); hr->SetParameters(bp); ODESolver * solver = ODESolver::Create(); solver->SetDynamicalSystem(hr); solver->SetIntegrationMode(LYAP); solver->SetTimeStep(0.01); solver->SetTransientDuration(500); solver->SetLyapunovTimeStep(0.5); solver->SetFinalTime(2e3); solver->SetX0(x0); solver->Solve(); for(int i=0; i<hr->GetOriginalDimension(); i++){ printf("%e ",solver->GetLyapunovExponents()[i]); } printf("\n"); solver->Destroy(); hr->Destroy(); bp->Destroy(); return 0; }