40 const int eul_max_count = 7;
41 const double eul_err_coef = 1.0/150.0;
42 const double eul_step_coef = 0.25;
43 const double eul_step_rat = 0.01;
44 const int fw_max_count = 7;
45 const double fw_err_coef = 1.0/150.0;
46 const double fw_err_rnghi = 1.5;
47 const double fw_err_rnglo = 0.75;
50 bool EulDoubleStepFlag;
51 bool FWDoubleStepFlag;
56 static int FWDoubleCount;
57 static int EulDoubleCount;
58 static double Eul_StepSize;
59 static double PrevStep;
61 Dprintf((
" Fowler-Warten integration step "));
66 FWDoubleStepFlag =
true;
67 EulDoubleStepFlag =
true;
68 FWHalveStepFlag =
false;
100 (*ip)->SetState((*ip)->GetOldState()+Eul_StepSize*(*ip)->GetOldDiff());
117 eerr = Eul_StepSize*fabs((*ip)->GetDiff() - (*ip)->GetOldDiff());
120 if(eerr < eul_err_coef*terr)
123 EulDoubleStepFlag =
false;
133 _Print(
"\n Integrator[%i] ",i);
155 Dprintf((
"E_F: %d, E_C: %d",EulDoubleStepFlag, EulDoubleCount));
158 if(EulDoubleStepFlag) {
165 if(EulDoubleCount >= eul_max_count) {
170 Dprintf((
"E_S: %g", Eul_StepSize));
185 yia =
FW_First ? 0 : (((*ip)->GetOldState() -
Y1[i]) / PrevStep);
186 d1 = (*ip)->GetOldDiff() - yia;
187 d2 = ((*ip)->GetDiff() - (*ip)->GetOldDiff())/Eul_StepSize;
188 ll = (d1<=prec && d1>=-
prec) ? 0 : (d2/d1);
190 c1 = (denom >= -
prec)
191 ? (1.0 + 0.5 * denom)
192 : ((exp(denom) - 1.0) / denom);
193 c0 = (ll>=0) ? (1.0 + denom)
196 (*ip)->SetState((*ip)->GetOldState() +
SIMLIB_StepSize * (yia + c1 * d1));
197 ERR[i] = yia + c0 * d1;
217 if(eerr > fw_err_rnghi*terr) {
220 FWDoubleStepFlag =
false;
232 _Print(
"\n Integrator[%lu] ",(
unsigned long)i);
234 else if(eerr > fw_err_rnglo*terr) {
237 FWHalveStepFlag =
true;
238 FWDoubleStepFlag =
false;
240 else if(eerr < fw_err_coef*terr) {
250 FWDoubleStepFlag = FWDoubleStepFlag && FWMayDouble;
269 Y1[i] = (*ip)->GetOldDiff();
275 if(FWHalveStepFlag) {
280 else if(FWDoubleStepFlag) {
289 if(FWDoubleCount >= fw_max_count) {