Skip to content

Commit

Permalink
LSRK - RKC and RKL are ready
Browse files Browse the repository at this point in the history
  • Loading branch information
maggul authored and drreynolds committed Jul 12, 2024
1 parent d57fb38 commit 62bccbd
Show file tree
Hide file tree
Showing 6 changed files with 82 additions and 81 deletions.
6 changes: 3 additions & 3 deletions examples/arkode/C_serial/lsrk_analytic.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*-----------------------------------------------------------------
* Programmer(s): Daniel R. Reynolds @ SMU
* Programmer(s): Mustafa Aggul @ SMU
*---------------------------------------------------------------
* SUNDIALS Copyright Start
* Copyright (c) 2002-2024, Lawrence Livermore National Security
Expand Down Expand Up @@ -129,8 +129,8 @@ int main(void)
if (check_flag(&flag, "LSRKodeSetMaxStageNum", 1)) { return 1; }

/* Specify max number of steps allowed */
flag = LSRKodeSetMaxStepNum(arkode_mem, 1000);
if (check_flag(&flag, "LSRKodeSetMaxStepNum", 1)) { return 1; }
flag = ARKodeSetMaxNumSteps(arkode_mem, 1000);
if (check_flag(&flag, "ARKodeSetMaxNumSteps", 1)) { return 1; }

/* Specify safety factor for user provided SprRad */
flag = LSRKodeSetSprRadSafetyFactor(arkode_mem, 1.01);
Expand Down
57 changes: 36 additions & 21 deletions examples/arkode/C_serial/lsrk_analytic.out
Original file line number Diff line number Diff line change
@@ -1,32 +1,47 @@

Analytical ODE test problem:
reltol = 1.0e-06
abstol = 1.0e-10
lambda = -1e+06
reltol = 1.0e-08
abstol = 1.0e-08


HARD CODED to set interpolation type = ARK_INTERP_LAGRANGE


Solving with RKL method

t u
---------------------
1.000000 0.916291
2.000000 1.609437
3.000000 2.140066
4.000000 2.564949
5.000000 2.917770
6.000000 3.218876
7.000000 3.481240
8.000000 3.713572
9.000000 3.921973
10.000000 4.110874
1.000000 0.785398
2.000000 1.107149
3.000000 1.249046
4.000000 1.325818
5.000000 1.373401
6.000000 1.405648
7.000000 1.428899
8.000000 1.446441
9.000000 1.460139
10.000000 1.471128
---------------------

Final Statistics:
Current time = 10.12157090914652
Steps = 82
Step attempts = 83
Current time = 10.01061550413158
Steps = 1681
Step attempts = 1690
Stability limited steps = 0
Accuracy limited steps = 83
Error test fails = 1
Accuracy limited steps = 1690
Error test fails = 9
NLS step fails = 0
Inequality constraint fails = 0
Initial step size = 6.103515625000001e-12
Last step size = 0.4463519264234082
Current step size = 0.4463519264234082
RHS fn evals = 417
Initial step size = 1.930101110942615e-10
Last step size = 0.01627887578334304
Current step size = 0.02442720680359409
RHS fn evals = 174916
RHS fn evals for spr = 0
Number of SPR update calls = 1
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 = 3.54383e-13
15 changes: 6 additions & 9 deletions examples/arkode/C_serial/lsrk_analytic_VarJac.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*-----------------------------------------------------------------
* Programmer(s): Daniel R. Reynolds @ SMU
* Programmer(s): Mustafa Aggul @ SMU
*---------------------------------------------------------------
* SUNDIALS Copyright Start
* Copyright (c) 2002-2024, Lawrence Livermore National Security
Expand All @@ -15,7 +15,8 @@
*
* The following is a simple example problem with analytical
* solution,
* dy/dt = lambda*y + 1/(1+t^2) - lambda*atan(t)
* dy/dt = (lambda - alpha*cos((10 - t)/10*pi)*y + 1/(1+t^2)
* - (lambda - alpha*cos((10 - t)/10*pi)*atan(t)
* for t in the interval [0.0, 10.0], with initial condition: y=0.
*
* The stiffness of the problem is directly proportional to the
Expand Down Expand Up @@ -120,10 +121,6 @@ int main(void)
flag = LSRKodeSetSprRadFn(arkode_mem, spr);
if (check_flag(&flag, "LSRKodeSetSprRadFn", 1)) { return 1; }

// /* Specify Constant Jacobian */
// flag = LSRKodeSetConstJac(arkode_mem);
// if (check_flag(&flag, "LSRKodeSetConstJac", 1)) { return 1; }

/* Specify after how many successful steps SprRad is recomputed */
flag = LSRKodeSetSprRadFrequency(arkode_mem, 25);
if (check_flag(&flag, "LSRKodeSetSprRadFrequency", 1)) { return 1; }
Expand All @@ -133,15 +130,15 @@ int main(void)
if (check_flag(&flag, "LSRKodeSetMaxStageNum", 1)) { return 1; }

/* Specify max number of steps allowed */
flag = LSRKodeSetMaxStepNum(arkode_mem, 1000);
if (check_flag(&flag, "LSRKodeSetMaxStepNum", 1)) { return 1; }
flag = ARKodeSetMaxNumSteps(arkode_mem, 1000);
if (check_flag(&flag, "ARKodeSetMaxNumSteps", 1)) { return 1; }

/* Specify safety factor for user provided SprRad */
flag = LSRKodeSetSprRadSafetyFactor(arkode_mem, 1.01);
if (check_flag(&flag, "LSRKodeSetSprRadSafetyFactor", 1)) { return 1; }

/* Specify the LSRK method */
flag = LSRKodeSetMethod(arkode_mem, 2);
flag = LSRKodeSetMethod(arkode_mem, 1);
if (check_flag(&flag, "LSRKodeSetMethod", 1)) { return 1; }

/* Open output stream for results, output comment line */
Expand Down
58 changes: 37 additions & 21 deletions examples/arkode/C_serial/lsrk_analytic_VarJac.out
Original file line number Diff line number Diff line change
@@ -1,32 +1,48 @@

Analytical ODE test problem:
reltol = 1.0e-06
abstol = 1.0e-10
lambda = -1e+06
alpha = 100
reltol = 1.0e-08
abstol = 1.0e-08


HARD CODED to set interpolation type = ARK_INTERP_LAGRANGE


Solving with RKC method

t u
---------------------
1.000000 0.916291
2.000000 1.609437
3.000000 2.140066
4.000000 2.564949
5.000000 2.917770
6.000000 3.218876
7.000000 3.481240
8.000000 3.713572
9.000000 3.921973
10.000000 4.110874
1.000000 0.785398
2.000000 1.107149
3.000000 1.249046
4.000000 1.325818
5.000000 1.373401
6.000000 1.405648
7.000000 1.428899
8.000000 1.446441
9.000000 1.460139
10.000000 1.471128
---------------------

Final Statistics:
Current time = 10.12157090914652
Steps = 82
Step attempts = 83
Current time = 10.00091506153245
Steps = 1990
Step attempts = 1992
Stability limited steps = 0
Accuracy limited steps = 83
Error test fails = 1
Accuracy limited steps = 1992
Error test fails = 2
NLS step fails = 0
Inequality constraint fails = 0
Initial step size = 6.103515625000001e-12
Last step size = 0.4463519264234082
Current step size = 0.4463519264234082
RHS fn evals = 417
Initial step size = 1.930101110942615e-10
Last step size = 0.01744455979617476
Current step size = 0.01744455979617476
RHS fn evals = 165282
RHS fn evals for spr = 0
Number of SPR update calls = 81
Max. num. of stages taken = 165
Max. num. of stages allowed = 200
Max. spectral radius = 1010101.00
Min. spectral radius = 1009899.00

ACCURACY at the final time = 1.78968e-13
2 changes: 0 additions & 2 deletions include/arkode/arkode_lsrkstep.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@ SUNDIALS_EXPORT int LSRKodeSetSprRadFrequency(void* arkode_mem, int nsteps);

SUNDIALS_EXPORT int LSRKodeSetMaxStageNum(void* arkode_mem, int stagemaxlimit);

SUNDIALS_EXPORT int LSRKodeSetMaxStepNum(void* arkode_mem, int stepmaxlimit);

SUNDIALS_EXPORT int LSRKodeSetSprRadSafetyFactor(void* arkode_mem, sunrealtype sprsfty);

SUNDIALS_EXPORT int LSRKStepReInit(void* arkode_mem, ARKRhsFn fe, ARKRhsFn fi, sunrealtype t0,
Expand Down
25 changes: 0 additions & 25 deletions src/arkode/arkode_lsrkstep_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -173,31 +173,6 @@ int LSRKodeSetMaxStageNum(void* arkode_mem, int stagemaxlimit)
return (ARK_SUCCESS);
}

/*---------------------------------------------------------------
LSRKodeSetMaxStepNum sets the maximum number of steps allowed.
---------------------------------------------------------------*/
int LSRKodeSetMaxStepNum(void* arkode_mem, int stepmaxlimit)
{
ARKodeMem ark_mem;
ARKodeLSRKStepMem step_mem;
int retval;

/* access ARKodeMem and ARKodeLSRKStepMem structures */
retval = lsrkStep_AccessARKODEStepMem(arkode_mem, __func__, &ark_mem, &step_mem);
if (retval != ARK_SUCCESS) { return (retval); }

if(stepmaxlimit < 1)
{
arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__,
__FILE__, "stepmaxlimit must be greater than or equal to 1");
return (ARK_ILL_INPUT);
}

ark_mem->mxstep = stepmaxlimit;

return (ARK_SUCCESS);
}

/*---------------------------------------------------------------
LSRKodeSetSprRadSafetyFactor sets the maximum number of stages allowed.
---------------------------------------------------------------*/
Expand Down

0 comments on commit 62bccbd

Please sign in to comment.