예제 #1
0
/**
 * 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.
}
예제 #2
0
/**
 * 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;
}
예제 #3
0
/**
 * 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.
}
예제 #4
0
파일: test02.cpp 프로젝트: miho/iNumerics
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;
}