Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
- calcTinyStep now uses (stop-start) as its basis for choosing epsilon


git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@7508 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
sjoelund committed Dec 20, 2010
1 parent c53004f commit 9689222
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 21 deletions.
12 changes: 7 additions & 5 deletions c_runtime/solver_dasrt.cpp
Expand Up @@ -59,15 +59,17 @@ int dummyJacobianDASSL(double *t, double *y, double *yprime, double *pd, double
* A tiny step is taken at initialization to check events. The tiny step is calculated as
* 200*uround*max(abs(T0),abs(T1)) = 200*uround*abs(T1), when simulating from T0 to T1, and uround is the machine precision.
*/
double calcTinyStep(double tout)
double calcTinyStep(double start, double stop)
{
double uround = dlamch_("P",1);
double uround = dlamch_((char*)"P",1);
double tout = stop-start;
if (tout == 0.0) {
return 1000.0*uround;
} else {
return 1000.0*uround*fabs(tout);
}
}

/* Returns the index of the first root that is active*/
int activeEvent(int nRoots, fortran_integer *jroot)
{
Expand All @@ -90,7 +92,7 @@ int dassl_main(int argc, char**argv,double &start, double &stop, double &step,
double tout;
double rtol = 1.0e-5;
double atol = 1.0e-5;
double uround = dlamch_("P",1);
double uround = dlamch_((char*)"P",1);
fortran_integer idid = 0;


Expand Down Expand Up @@ -196,7 +198,7 @@ int dassl_main(int argc, char**argv,double &start, double &stop, double &step,
}


tout = globalData->timeValue+calcTinyStep(globalData->timeValue); // take tiny step.
tout = globalData->timeValue+calcTinyStep(start,stop); // take tiny step.
//saveall();

function_updateDependents();
Expand Down Expand Up @@ -255,7 +257,7 @@ int dassl_main(int argc, char**argv,double &start, double &stop, double &step,
//This is needed since state events are found by numerical interpolation and therefore it is not
// certain that the event will cause the relation to trigger, e.g x < 0 might correspond to 0.000000000000000145 < 0
info[0]=1;
tout=globalData->timeValue+calcTinyStep(tout);
tout=globalData->timeValue+calcTinyStep(start,stop);
{
long *tmp_jroot = new long[globalData->nZeroCrossing];
int i;
Expand Down
18 changes: 2 additions & 16 deletions c_runtime/solver_main.cpp
Expand Up @@ -89,21 +89,7 @@ int dummy_zeroCrossing(fortran_integer *neqm, double *t, double *y, fortran_inte
}
bool continue_MINE(fortran_integer* idid, double* atol, double *rtol);

/* \brief
* calculates a tiny step
*
* A tiny step is taken at initialization to check events. The tiny step is calculated as
* 200*uround*max(abs(T0),abs(T1)) = 200*uround*abs(T1), when simulating from T0 to T1, and uround is the machine precision.
*/
double calcTiny(double tout)
{
double uround = dlamch_((char*)"P",1);
if (tout == 0.0) {
return 1000.0*uround;
} else {
return 1000.0*uround*fabs(tout);
}
}
double calcTinyStep(double start, double stop);

fortran_integer info[15];
double reltol = 1.0e-5;
Expand Down Expand Up @@ -266,7 +252,7 @@ int solver_main(int argc, char** argv, double &start, double &stop, double &ste
}

// Do a tiny step to initialize ZeroCrossing that are fulfilled
globalData->current_stepsize = calcTiny(globalData->timeValue);
globalData->current_stepsize = calcTinyStep(start,stop);
solver_main_step(flag,start,stop,reset);
functionAlgebraics();

Expand Down

0 comments on commit 9689222

Please sign in to comment.