Skip to content

Commit

Permalink
ss fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
maggul committed Oct 1, 2024
1 parent 60288dd commit 78355ea
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 45 deletions.
22 changes: 11 additions & 11 deletions examples/arkode/C_serial/ark_analytic_lsrk.out
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,24 @@ Analytical ODE test problem:
---------------------

Final Statistics:
Current time = 10.00665828381666
Steps = 1674
Step attempts = 1683
Current time = 10.01502208413611
Steps = 1655
Step attempts = 1899
Stability limited steps = 0
Accuracy limited steps = 1682
Error test fails = 8
Accuracy limited steps = 1657
Error test fails = 2
NLS step fails = 0
Inequality constraint fails = 0
Initial step size = 1.930101110942615e-10
Last step size = 0.01925923265882638
Current step size = 0.01925923265882638
RHS fn evals = 170959
Last step size = 0.019701
Current step size = 0.019701
RHS fn evals = 168573
RHS fn evals for Dom. Eigs. = 0
Number of dom_eig updates = 1
Avr. num. of stages taken = 101.58
Max. num. of stages taken = 197
Avr. num. of stages taken = 88.77
Max. num. of stages taken = 199
Max. num. of stages allowed = 200
Max. spectral radius = 1010000.00
Min. spectral radius = 1010000.00

ACCURACY at the final time = 1.01918e-13
ACCURACY at the final time = 1.18794e-13
18 changes: 9 additions & 9 deletions examples/arkode/C_serial/ark_analytic_ssprk.out
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,18 @@ Analytical ODE test problem:
---------------------

Final Statistics:
Current time = 10.02392134053359
Steps = 1116
Step attempts = 1119
Current time = 10.02454272679074
Steps = 1113
Step attempts = 1114
Stability limited steps = 0
Accuracy limited steps = 1119
Error test fails = 3
Accuracy limited steps = 1114
Error test fails = 1
NLS step fails = 0
Inequality constraint fails = 0
Initial step size = 1.930101110942615e-10
Last step size = 0.0257563455221273
Current step size = 0.0257563455221273
RHS fn evals = 10071
Last step size = 0.02575789911873572
Current step size = 0.02575789911873572
RHS fn evals = 10028
Current stages taken = 9

ACCURACY at the final time = 2.35984e-09
ACCURACY at the final time = 2.3602e-09
38 changes: 13 additions & 25 deletions src/arkode/arkode_lsrkstep.c
Original file line number Diff line number Diff line change
Expand Up @@ -983,34 +983,22 @@ int lsrkStep_TakeStepRKL(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr)
if (retval != ARK_SUCCESS) { return (retval); }
}

/* determine the number of required stages */
/* Start by finding an ss value which is for sure less than the next req_stages
and still large enough to reduce the number of for iterations*/
int ss = SUNRfloor(
SUNRsqrt(TWO * SUNRabs(ark_mem->h) * step_mem->sprad + THREE) - ONE);
/* Increase ss values by 1 each time to find the least feasible req_stages */
for (; ss <= step_mem->stage_max_limit; ss++)
{
if ((SUNSQR(ss) + ss - TWO) >= TWO * (SUNRabs(ark_mem->h) * step_mem->sprad))
int ss = SUNRceil((SUNRsqrt(SUN_RCONST(9.0) + SUN_RCONST(8.0) * SUNRabs(ark_mem->h) * step_mem->sprad) - ONE) / TWO);
step_mem->req_stages = SUNMAX(2, ss);
if (ss >= step_mem->stage_max_limit)
{
if (!ark_mem->fixedstep)
{
step_mem->req_stages = SUNMAX(ss, 2);
break;
hmax = ark_mem->hadapt_mem->safety * (SUNSQR(ss) + ss - TWO) / (TWO * step_mem->sprad);
ark_mem->eta = hmax / ark_mem->h;
*nflagPtr = ARK_RETRY_STEP;
return (ARK_RETRY_STEP);
}
if (ss >= step_mem->stage_max_limit)
else
{
if (!ark_mem->fixedstep)
{
hmax = ark_mem->hadapt_mem->safety * (SUNSQR(ss) + ss - TWO) / (TWO * step_mem->sprad);
ark_mem->eta = hmax / ark_mem->h;
*nflagPtr = ARK_RETRY_STEP;
return (ARK_RETRY_STEP);
}
else
{
arkProcessError(ark_mem, ARK_STEP_FIXED_SIZE_FAIL, __LINE__, __func__, __FILE__,
"Unable to achieve stable results: Either reduce the step size or increase the stage_max_limit");
return (ARK_STEP_FIXED_SIZE_FAIL);
}
arkProcessError(ark_mem, ARK_STEP_FIXED_SIZE_FAIL, __LINE__, __func__, __FILE__,
"Unable to achieve stable results: Either reduce the step size or increase the stage_max_limit");
return (ARK_STEP_FIXED_SIZE_FAIL);
}
}

Expand Down

0 comments on commit 78355ea

Please sign in to comment.