Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify/Fix Adaptivity for Small Errors or no CFL #548

Open
wants to merge 71 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 57 commits
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
14ecd14
Remove special case of negative base in SUNRpowerR
Steven-Roberts Jul 30, 2024
dcb14bc
Fix assert condition
Steven-Roberts Jul 30, 2024
19f2dc9
Remove magic constant
Steven-Roberts Jul 30, 2024
53f3dde
Remove TINY parameter
Steven-Roberts Jul 30, 2024
e838c4e
Remove TINY from imexgus controller
Steven-Roberts Jul 30, 2024
9cde50a
Switch to assert
Steven-Roberts Jul 30, 2024
2c2444c
Fix sign of controller in nan case
Steven-Roberts Jul 30, 2024
9cb7bba
Start adaptivity unit test
Steven-Roberts Jul 31, 2024
743913a
Add const and comments to test
Steven-Roberts Aug 1, 2024
b75e78e
Simplify Soderlind controller and handle inf/nan better
Steven-Roberts Aug 1, 2024
2caec18
Clean up controllers
Steven-Roberts Aug 1, 2024
3fbda5b
Apply formatter
Steven-Roberts Aug 1, 2024
ef01f92
Merge branch 'develop' into feature/min-err
Steven-Roberts Aug 23, 2024
299cd5c
Variable initialization cleanup
Steven-Roberts Sep 6, 2024
405ff41
Use I controller on first 2 steps of Soderlind
Steven-Roberts Sep 6, 2024
bc9f312
Remove assert for pow testing
Steven-Roberts Sep 6, 2024
54aa1d5
Update docs
Steven-Roberts Sep 6, 2024
bfdf75e
Update IMEX controller docs
Steven-Roberts Sep 6, 2024
dde1379
Update changelog
Steven-Roberts Sep 6, 2024
facfc39
Clean up time step sign
Steven-Roberts Sep 6, 2024
7badd78
Additional simplifications
Steven-Roberts Sep 6, 2024
641ad92
Merge branch 'develop' into feature/min-err
Steven-Roberts Sep 6, 2024
c472ffe
Additional testing of controller
Steven-Roberts Sep 6, 2024
2452bd6
Remove unnecessary header
Steven-Roberts Sep 6, 2024
13cce12
Correct function names
Steven-Roberts Sep 6, 2024
1950356
Convert SUNRpowerR to macro
Steven-Roberts Sep 6, 2024
5bd4790
Update comments based on @drreynolds suggestions
Steven-Roberts Sep 10, 2024
8d7a267
Fix typos in changelog
Steven-Roberts Sep 10, 2024
a02ca62
Merge branch 'develop' into feature/min-err
Steven-Roberts Sep 10, 2024
7d5161b
Update test/unit_tests/arkode/C_serial/ark_test_adapt.c
Steven-Roberts Sep 11, 2024
fcb7dc6
Add missing SUN_RCONST
Steven-Roberts Sep 11, 2024
1db5b33
Update test/unit_tests/arkode/C_serial/ark_test_adapt.c
Steven-Roberts Sep 11, 2024
f81a60d
Merge branch 'develop' into feature/min-err
Steven-Roberts Sep 11, 2024
7669c93
Add more asserts to controllers
Steven-Roberts Sep 11, 2024
ed094a8
Merge branch 'develop' into feature/min-err
Steven-Roberts Sep 16, 2024
3671f0e
Add non-default controllers in test
Steven-Roberts Sep 26, 2024
a3bac98
Merge branch 'develop' into feature/min-err
Steven-Roberts Sep 26, 2024
fdb3d4a
Fix assertion to allow order 0
Steven-Roberts Sep 26, 2024
2702c35
Merge branch 'develop' into feature/min-err
Steven-Roberts Jan 29, 2025
247f83c
Simplify ARKodeSetStepDirection check with SUNRcopysign
Steven-Roberts Jan 29, 2025
ed3bc5c
Merge branch 'develop' into feature/min-err
Steven-Roberts Jan 29, 2025
cb9fc6e
Remove infinities to run with -ffast-math
Steven-Roberts Jan 31, 2025
3ee22a3
Merge branch 'develop' into feature/min-err
Steven-Roberts Jan 31, 2025
f3439ec
Simplify if statements
Steven-Roberts Jan 31, 2025
0b6dc6a
Add missing void
Steven-Roberts Jan 31, 2025
571611c
Merge branch 'develop' into feature/min-err
Steven-Roberts Feb 12, 2025
d4ef61f
Reduce initial step size to ensure no rejected step
Steven-Roberts Feb 12, 2025
3f3b1c5
Update logging out files
Steven-Roberts Feb 12, 2025
6c63b95
Update out files
Steven-Roberts Feb 12, 2025
b677f1f
Fix broken link
Steven-Roberts Feb 12, 2025
98ec037
Allow floatCompare to handle inf
Steven-Roberts Feb 12, 2025
9a3c9ef
Fix roundoff quantity
Steven-Roberts Feb 12, 2025
34289a5
Resolve todo
Steven-Roberts Feb 13, 2025
e997b17
Update address sanitizer out files
Steven-Roberts Feb 13, 2025
ae54ed3
Temporary fix so ark_bruss_f2003 runs without failure
Steven-Roberts Feb 13, 2025
6113c22
Update ark_bruss_f2003 out file
Steven-Roberts Feb 13, 2025
d6630f3
More out file updates
Steven-Roberts Feb 13, 2025
678412d
update output files
gardner48 Feb 13, 2025
bc111ab
update output files
gardner48 Feb 13, 2025
ab14980
Apply suggestions from code review
Steven-Roberts Feb 13, 2025
1654ee6
Update malloc style
Steven-Roberts Feb 13, 2025
d6ce8c8
Apply formatter
Steven-Roberts Feb 13, 2025
61d8ef5
Fix wrong alloc size
Steven-Roberts Feb 13, 2025
f56e000
Increase max steps
Steven-Roberts Feb 13, 2025
c165857
Update stability function info in out file
Steven-Roberts Feb 13, 2025
56cc965
update output files
gardner48 Feb 14, 2025
ae1cc01
update output file
gardner48 Feb 14, 2025
f1d0f5c
Make floatCompare use relative error
Steven-Roberts Feb 14, 2025
cd10201
Merge branch 'feature/min-err' of github.com:LLNL/sundials into featu…
Steven-Roberts Feb 14, 2025
a6ef7b6
Add abs_tol in floatCompare
Steven-Roberts Feb 14, 2025
f09a521
Handle precision == 0 correctly
Steven-Roberts Feb 14, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ Improved the efficiency of default ARKODE methods with the following changes:

### Bug Fixes

Removed error floors from the `SUNAdaptController` implementations which could
unnecessarily limit the time size growth, particularly after the first step.

On the first two time steps, the Soderlind controller uses an I controller
instead of omitting unavailable terms.

Fixed bug in `ARKodeSetFixedStep` where it could return `ARK_SUCCESS` despite
an error occurring.

Expand Down
7 changes: 7 additions & 0 deletions doc/shared/RecentChanges.rst
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@ Improved the efficiency of default ARKODE methods with the following changes:

**Bug Fixes**

Removed error floors from the ```SUNAdaptController`` implementations
which could unnecessarily limit the time size growth, particularly after the
first step.

On the first two time steps, the Soderlind controller uses an I controller
instead of omitting unavailable terms.

Fixed bug in :c:func:`ARKodeSetFixedStep` where it could return ``ARK_SUCCESS``
despite an error occurring.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,7 @@ with the form

In the above formulas, the default values of :math:`k_1^E`, :math:`k_2^E`,
:math:`k_1^I`, and :math:`k_2^I` are 0.367, 0.268, 0.98, and 0.95, respectively,
and :math:`p` is the global order of the time integration method. In these
estimates, a floor of :math:`\varepsilon_* > 10^{-10}` is enforced to avoid
division-by-zero errors.
and :math:`p` is the global order of the time integration method.

The SUNAdaptController_ImExGus controller implements both formulas
:eq:`expGusController` and :eq:`impGusController`, and sets its recommended step
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,10 @@ and :cite:p:`Sod:06`. This controller has the form

with default parameter values :math:`k_1 = 1.25`, :math:`k_2 = 0.5`,
:math:`k_3 = -0.75`, :math:`k_4 = 0.25`, and :math:`k_5 = 0.75`, where
:math:`p` is the global order of the time integration method. In this estimate,
a floor of :math:`\varepsilon_* > 10^{-10}` is enforced to avoid division-by-zero
errors. During the first two steps (when :math:`\varepsilon_{n-2}`,
:math:`\varepsilon_{n-1}`, :math:`h_{n-2}`, and :math:`h_{n-2}` may be unavailable),
the corresponding terms are merely omitted during estimation of :math:`h'`.
:math:`p` is the global order of the time integration method. During the first
two steps (when :math:`\varepsilon_{n-2}`, :math:`\varepsilon_{n-1}`,
:math:`h_{n-2}`, and :math:`h_{n-2}` may be unavailable), the I controller
:math:`h' = h_n \varepsilon_1^{-1/(p+1)}` is used.

The SUNAdaptController_Soderlind controller is implemented as a derived
SUNAdaptController class, and defines its *content* field as:
Expand Down
7 changes: 7 additions & 0 deletions examples/arkode/F2003_serial/ark_bruss_f2003.f90
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,13 @@ program main
stop 1
end if

! TODO(SBR): temporary fix until https://github.com/LLNL/sundials/pull/565 merged
ierr = FARKodeSetAdaptivityAdjustment(arkode_mem, 0)
if (ierr /= 0) then
print *, 'Error in FARKodeSetJacFn'
stop 1
end if

sunls => FSUNLinSol_Dense(sunvec_y, sunmat_A, sunctx)
if (.not. associated(sunls)) then
print *, 'ERROR: sunls = NULL'
Expand Down
63 changes: 48 additions & 15 deletions include/sundials/sundials_math.h
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,54 @@ extern "C" {
#endif
#endif

/*
* -----------------------------------------------------------------
* Function : SUNRcopysign
* -----------------------------------------------------------------
* Usage : sunrealtype z;
* z = SUNRcopysign(x, y);
* -----------------------------------------------------------------
* SUNRcopysign(x, y) returns x with the sign of y.
* -----------------------------------------------------------------
*/

#ifndef SUNRcopysign
#if defined(SUNDIALS_DOUBLE_PRECISION)
#define SUNRcopysign(x, y) (copysign((x), (y)))
#elif defined(SUNDIALS_SINGLE_PRECISION)
#define SUNRcopysign(x, y) (copysignf((x), (y)))
#elif defined(SUNDIALS_EXTENDED_PRECISION)
#define SUNRcopysign(x, y) (copysignl((x), (y)))
#else
#error \
"SUNDIALS precision not defined, report to github.com/LLNL/sundials/issues"
#endif
#endif

/*
* -----------------------------------------------------------------
* Function : SUNRpowerR
* -----------------------------------------------------------------
* Usage : sunrealtype base, exponent, ans;
* ans = SUNRpowerR(base,exponent);
* -----------------------------------------------------------------
* SUNRpowerR returns the value of base^exponent, where both base and
* exponent are of type sunrealtype.
* -----------------------------------------------------------------
*/
#ifndef SUNRpowerR
#if defined(SUNDIALS_DOUBLE_PRECISION)
#define SUNRpowerR(base, exponent) (pow(base, exponent))
#elif defined(SUNDIALS_SINGLE_PRECISION)
#define SUNRpowerR(base, exponent) (powf(base, exponent))
#elif defined(SUNDIALS_EXTENDED_PRECISION)
#define SUNRpowerR(base, exponent) (powl(base, exponent))
#else
#error \
"SUNDIALS precision not defined, report to github.com/LLNL/sundials/issues"
#endif
#endif

/*
* -----------------------------------------------------------------
* Function : SUNRround
Expand Down Expand Up @@ -213,21 +261,6 @@ SUNDIALS_EXPORT int SUNIpowerI(int base, int exponent);

SUNDIALS_EXPORT sunrealtype SUNRpowerI(sunrealtype base, int exponent);

/*
* -----------------------------------------------------------------
* Function : SUNRpowerR
* -----------------------------------------------------------------
* Usage : sunrealtype base, exponent, ans;
* ans = SUNRpowerR(base,exponent);
* -----------------------------------------------------------------
* SUNRpowerR returns the value of base^exponent, where both base and
* exponent are of type sunrealtype. If base < ZERO, then SUNRpowerR
* returns ZERO.
* -----------------------------------------------------------------
*/

SUNDIALS_EXPORT sunrealtype SUNRpowerR(sunrealtype base, sunrealtype exponent);

/*
* -----------------------------------------------------------------
* Function : SUNRCompare
Expand Down
14 changes: 0 additions & 14 deletions src/arkode/arkode.c
Original file line number Diff line number Diff line change
Expand Up @@ -3010,20 +3010,6 @@ int arkRwtSetSV(ARKodeMem ark_mem, N_Vector My, N_Vector weight)
return (0);
}

/*---------------------------------------------------------------
arkExpStab is the default explicit stability estimation function
---------------------------------------------------------------*/
int arkExpStab(SUNDIALS_MAYBE_UNUSED N_Vector y,
SUNDIALS_MAYBE_UNUSED sunrealtype t, sunrealtype* hstab,
SUNDIALS_MAYBE_UNUSED void* data)
{
/* explicit stability not used by default,
set to zero to disable */
*hstab = SUN_RCONST(0.0);

return (ARK_SUCCESS);
}

/*---------------------------------------------------------------
arkPredict_MaximumOrder

Expand Down
61 changes: 33 additions & 28 deletions src/arkode/arkode_adapt.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ void arkPrintAdaptMem(ARKodeHAdaptMem hadapt_mem, FILE* outfile)
fprintf(outfile, "ark_hadapt: p = %i\n", hadapt_mem->p);
fprintf(outfile, "ark_hadapt: q = %i\n", hadapt_mem->q);
fprintf(outfile, "ark_hadapt: adjust = %i\n", hadapt_mem->adjust);
if (hadapt_mem->expstab == arkExpStab)
if (hadapt_mem->expstab == NULL)
{
fprintf(outfile, " ark_hadapt: Default explicit stability function\n");
}
Expand All @@ -106,7 +106,7 @@ int arkAdapt(ARKodeMem ark_mem, ARKodeHAdaptMem hadapt_mem, N_Vector ycur,
sunrealtype tcur, sunrealtype hcur, sunrealtype dsm)
{
int retval;
sunrealtype h_acc, h_cfl, int_dir;
sunrealtype h_acc;
int controller_order;

/* Return with no stepsize adjustment if the controller is NULL */
Expand Down Expand Up @@ -138,49 +138,54 @@ int arkAdapt(ARKodeMem ark_mem, ARKodeHAdaptMem hadapt_mem, N_Vector ycur,
return (ARK_CONTROLLER_ERR);
}

/* determine direction of integration */
int_dir = hcur / SUNRabs(hcur);

/* Call explicit stability function */
retval = hadapt_mem->expstab(ycur, tcur, &h_cfl, hadapt_mem->estab_data);
if (retval != ARK_SUCCESS)
{
arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, __FILE__,
"Error in explicit stability function.");
return (ARK_ILL_INPUT);
}
if (h_cfl <= ZERO) { h_cfl = SUN_RCONST(1.0e30) * SUNRabs(hcur); }

SUNLogDebug(ARK_LOGGER, "new-step-before-bounds",
"h_acc = " SUN_FORMAT_G ", h_cfl = " SUN_FORMAT_G, h_acc, h_cfl);
SUNLogDebug(ARK_LOGGER, "new-step-before-bounds", "h_acc = " SUN_FORMAT_G,
h_acc);

/* enforce safety factors */
h_acc *= hadapt_mem->safety;
h_cfl *= hadapt_mem->cfl * int_dir;

/* enforce maximum bound on time step growth */
h_acc = int_dir * SUNMIN(SUNRabs(h_acc), SUNRabs(hadapt_mem->etamax * hcur));
h_acc = SUNMIN(SUNRabs(h_acc), SUNRabs(hadapt_mem->etamax * hcur));

/* enforce minimum bound time step reduction */
h_acc = int_dir * SUNMAX(SUNRabs(h_acc), SUNRabs(hadapt_mem->etamin * hcur));
h_acc = SUNMAX(h_acc, SUNRabs(hadapt_mem->etamin * hcur));

SUNLogDebug(ARK_LOGGER, "new-step-after-max-min-bounds",
"h_acc = " SUN_FORMAT_G ", h_cfl = " SUN_FORMAT_G, h_acc, h_cfl);
if (hadapt_mem->expstab != NULL)
{
sunrealtype h_cfl = ZERO;
retval = hadapt_mem->expstab(ycur, tcur, &h_cfl, hadapt_mem->estab_data);
if (retval != ARK_SUCCESS)
{
arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, __FILE__,
"Error in explicit stability function.");
return (ARK_ILL_INPUT);
}

/* increment the relevant step counter, set desired step */
if (SUNRabs(h_acc) < SUNRabs(h_cfl)) { hadapt_mem->nst_acc++; }
else { hadapt_mem->nst_exp++; }
h_acc = int_dir * SUNMIN(SUNRabs(h_acc), SUNRabs(h_cfl));
h_cfl *= hadapt_mem->cfl;
SUNLogDebug(ARK_LOGGER, "new-step-cfl", "h_cfl = " SUN_FORMAT_G, h_cfl);

if (h_cfl > ZERO && h_cfl < h_acc)
{
hadapt_mem->nst_exp++;
h_acc = h_cfl;
}
else { hadapt_mem->nst_acc++; }
}
else { hadapt_mem->nst_acc++; }

/* enforce adaptivity bounds to retain Jacobian/preconditioner accuracy */
if (dsm <= ONE)
{
if ((SUNRabs(h_acc) > SUNRabs(hcur * hadapt_mem->lbound * ONEMSM)) &&
(SUNRabs(h_acc) < SUNRabs(hcur * hadapt_mem->ubound * ONEPSM)))
if ((h_acc > SUNRabs(hcur * hadapt_mem->lbound * ONEMSM)) &&
(h_acc < SUNRabs(hcur * hadapt_mem->ubound * ONEPSM)))
{
h_acc = hcur;
}
}
h_acc = SUNRcopysign(h_acc, hcur);

SUNLogDebug(ARK_LOGGER, "new-step-after-max-min-bounds",
"h_acc = " SUN_FORMAT_G, h_acc);

/* set basic value of ark_eta */
ark_mem->eta = h_acc / hcur;
Expand Down
28 changes: 10 additions & 18 deletions src/arkode/arkode_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,12 @@ int ARKodeSetDefaults(void* arkode_mem)
ark_mem->hadapt_mem->growth = GROWTH; /* step adaptivity growth factor */
ark_mem->hadapt_mem->lbound = HFIXED_LB; /* step adaptivity no-change lower bound */
ark_mem->hadapt_mem->ubound = HFIXED_UB; /* step adaptivity no-change upper bound */
ark_mem->hadapt_mem->expstab = arkExpStab; /* internal explicit stability fn */
ark_mem->hadapt_mem->estab_data = NULL; /* no explicit stability fn data */
ark_mem->hadapt_mem->pq = PQ; /* embedding order */
ark_mem->hadapt_mem->p = 0; /* no default embedding order */
ark_mem->hadapt_mem->q = 0; /* no default method order */
ark_mem->hadapt_mem->adjust = ADJUST; /* controller order adjustment */
ark_mem->hadapt_mem->expstab = NULL; /* internal explicit stability fn */
ark_mem->hadapt_mem->estab_data = NULL; /* no explicit stability fn data */
ark_mem->hadapt_mem->pq = PQ; /* embedding order */
ark_mem->hadapt_mem->p = 0; /* no default embedding order */
ark_mem->hadapt_mem->q = 0; /* no default method order */
ark_mem->hadapt_mem->adjust = ADJUST; /* controller order adjustment */

/* Set stepper defaults (if provided) */
if (ark_mem->step_setdefaults)
Expand Down Expand Up @@ -1290,7 +1290,7 @@ int ARKodeSetStepDirection(void* arkode_mem, sunrealtype stepdir)
return retval;
}

if (h != ZERO && ((h > ZERO) != (stepdir > ZERO)))
if (h != SUNRcopysign(h, stepdir))
{
/* Reverse the sign of h. If adaptive, h will be overwritten anyway by the
* initial step estimation since ARKodeReset must be called before this.
Expand Down Expand Up @@ -1961,16 +1961,8 @@ int ARKodeSetStabilityFn(void* arkode_mem, ARKExpStabFn EStab, void* estab_data)
}

/* NULL argument sets default, otherwise set inputs */
if (EStab == NULL)
{
hadapt_mem->expstab = arkExpStab;
hadapt_mem->estab_data = ark_mem;
}
else
{
hadapt_mem->expstab = EStab;
hadapt_mem->estab_data = estab_data;
}
hadapt_mem->expstab = EStab;
hadapt_mem->estab_data = estab_data;

return (ARK_SUCCESS);
}
Expand Down Expand Up @@ -3143,7 +3135,7 @@ int ARKodeWriteParameters(void* arkode_mem, FILE* fp)
ark_mem->hadapt_mem->lbound);
fprintf(fp, " Step growth upper bound = " SUN_FORMAT_G "\n",
ark_mem->hadapt_mem->ubound);
if (ark_mem->hadapt_mem->expstab == arkExpStab)
if (ark_mem->hadapt_mem->expstab == NULL)
{
fprintf(fp, " Default explicit stability function\n");
}
Expand Down
32 changes: 15 additions & 17 deletions src/sunadaptcontroller/imexgus/sunadaptcontroller_imexgus.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
#define DEFAULT_K1I SUN_RCONST(0.95)
#define DEFAULT_K2I SUN_RCONST(0.95)
#define DEFAULT_BIAS SUN_RCONST(1.5)
#define TINY SUN_RCONST(1.0e-10)

/* -----------------------------------------------------------------
* exported functions
Expand Down Expand Up @@ -128,28 +127,27 @@ SUNErrCode SUNAdaptController_EstimateStep_ImExGus(SUNAdaptController C,
{
SUNFunctionBegin(C->sunctx);

SUNAssert(hnew, SUN_ERR_ARG_CORRUPT);

/* order parameter to use */
const int ord = p + 1;

/* set usable time-step adaptivity parameters -- first step */
const sunrealtype k = -SUN_RCONST(1.0) / ord;
const sunrealtype e = SUNMAX(SACIMEXGUS_BIAS(C) * dsm, TINY);

/* set usable time-step adaptivity parameters -- subsequent steps */
const sunrealtype k1e = -SACIMEXGUS_K1E(C) / ord;
const sunrealtype k2e = -SACIMEXGUS_K2E(C) / ord;
const sunrealtype k1i = -SACIMEXGUS_K1I(C) / ord;
const sunrealtype k2i = -SACIMEXGUS_K2I(C) / ord;
const sunrealtype e1 = SUNMAX(SACIMEXGUS_BIAS(C) * dsm, TINY);
const sunrealtype e2 = e1 / SUNMAX(SACIMEXGUS_EP(C), TINY);
const sunrealtype hrat = h / SACIMEXGUS_HP(C);

/* compute estimated time step size, modifying the first step formula */
if (SACIMEXGUS_FIRSTSTEP(C)) { *hnew = h * SUNRpowerR(e, k); }
if (SACIMEXGUS_FIRSTSTEP(C))
{
/* set usable time-step adaptivity parameters -- first step */
const sunrealtype k = -SUN_RCONST(1.0) / ord;
const sunrealtype e = SACIMEXGUS_BIAS(C) * dsm;
*hnew = h * SUNRpowerR(e, k);
}
else
{
/* set usable time-step adaptivity parameters -- subsequent steps */
const sunrealtype k1e = -SACIMEXGUS_K1E(C) / ord;
const sunrealtype k2e = -SACIMEXGUS_K2E(C) / ord;
const sunrealtype k1i = -SACIMEXGUS_K1I(C) / ord;
const sunrealtype k2i = -SACIMEXGUS_K2I(C) / ord;
const sunrealtype e1 = SACIMEXGUS_BIAS(C) * dsm;
const sunrealtype e2 = e1 / SACIMEXGUS_EP(C);
const sunrealtype hrat = h / SACIMEXGUS_HP(C);
*hnew = h * SUNMIN(hrat * SUNRpowerR(e1, k1i) * SUNRpowerR(e2, k2i),
SUNRpowerR(e1, k1e) * SUNRpowerR(e2, k2e));
}
Expand Down
Loading
Loading