Skip to content
This repository has been archived by the owner on Nov 3, 2022. It is now read-only.

Commit

Permalink
Added one more test with ODE system described in
Browse files Browse the repository at this point in the history
  • Loading branch information
Dilawar Singh committed Aug 11, 2018
1 parent bfdd73a commit a8b55c0
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 3 deletions.
5 changes: 2 additions & 3 deletions ksolve/LSODA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,12 @@ using namespace std;

LSODA::LSODA( )
{

// Initialize arrays.
mord = {0, 12, 5};
sm1 = { 0., 0.5, 0.575, 0.55, 0.45, 0.35, 0.25, 0.2, 0.15, 0.1, 0.075, 0.05, 0.025 };
sm1 = { 0., 0.5, 0.575, 0.55, 0.45, 0.35, 0.25, 0.2, 0.15, 0.1, 0.075, 0.05, 0.025 };
el = {0};
cm1 = {0};
cm2 = {0};

}

LSODA::~LSODA()
Expand Down
33 changes: 33 additions & 0 deletions ksolve/test_LSODA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,38 @@ static void system_scipy( double t, double* y, double* ydot, void* data)
ydot[1] = mu * (1- y[0]*y[0])*y[1] - y[0];
}

// This system is described here
// https://github.com/sdwfrost/liblsoda/issues/10
static void system_github_issue_10(double t, double* y, double* ydot, void* data)
{
ydot[0]= 9*y[0] + 24*y[1] + 5*cos(t)-(1/3)*sin(t);
ydot[1]= -24*y[0] -51*y[1] -95*cos(t) + (1/3)*sin(t);
}

int test_github_system( void )
{
cout << "Running test given https://github.com/sdwfrost/liblsoda/issues/10" << endl;
double t = 0e0, tout = 1;

array<double, 2> y = {4.0/3.0, 2.0/3.0};
int istate = 1;

LSODA lsoda;

vector<double> yout;
lsoda.lsoda_update( system_github_issue_10, 2, &y[0], yout, &t, tout, &istate, nullptr );
printf(" at t= %12.4e y= %14.6e %14.6e\n", t, yout[1], yout[2]);

ASSERT_DOUBLE_EQ( "LSODA", -1.210928, yout[1]);
ASSERT_DOUBLE_EQ( "LSODA", 4.722848, yout[2] );
if (istate <= 0)
{
cerr << "error istate = " << istate << endl;
exit(0);
}
return 0;
}

int test_scipy_sys( void )
{
cout << "Running test scipy sys" << endl;
Expand Down Expand Up @@ -139,5 +171,6 @@ int main(int argc, const char *argv[])
{
test_scipy_sys();
test_fex();
test_github_system();
return 0;
}

0 comments on commit a8b55c0

Please sign in to comment.