Algorithms for adjusting the step size for variable-step Runge-Kutta integrators.
Type | Visibility | Attributes | Name | Initial | |||
---|---|---|---|---|---|---|---|
logical, | private | :: | fixed_step_mode | = | .false. |
if true, then the method runs in fixed step mode with not error estimation |
|
real(kind=wp), | private | :: | hmax | = | 1.0e+6_wp |
maximum allowed step size |
|
real(kind=wp), | private | :: | hmin | = | 1.0e-6_wp |
minimum allowed step size |
|
real(kind=wp), | private | :: | hfactor_reject | = | 0.5_wp |
minimum allowed factor for decreasing step size after rejected step |
|
real(kind=wp), | private | :: | hfactor_accept | = | 2.0_wp |
maximum allowed factor for increasing step size after accepted step |
|
integer, | private | :: | accept_mode | = | 2 |
method to determine if step is accepted [1,2] |
|
integer, | private | :: | max_attempts | = | 10000 |
maximum number of attempts to decrease step size before giving up |
|
logical, | private | :: | relative_err | = | .false. |
to use |
|
real(kind=wp), | private | :: | safety_factor | = | 0.9_wp |
for |
|
integer, | private | :: | p_exponent_offset | = | 1 |
|
|
procedure(norm_func), | private, | nopass, pointer | :: | norm | => | maxval_func |
routine for computing the norm of the state |
Constructor for a stepsize_class.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(stepsize_class), | intent(inout) | :: | me | |||
real(kind=wp), | intent(in), | optional | :: | hmin |
minimum allowed step size (>0) |
|
real(kind=wp), | intent(in), | optional | :: | hmax |
maximum allowed step size (>0) |
|
real(kind=wp), | intent(in), | optional | :: | hfactor_reject |
minimum allowed factor for decreasing step size after rejected step (>0) |
|
real(kind=wp), | intent(in), | optional | :: | hfactor_accept |
maximum allowed factor for decreasing step size after accepted step (>0) |
|
procedure(norm_func), | optional | :: | norm |
the user-specified function |
||
integer, | intent(in), | optional | :: | accept_mode |
method to determine if step is accepted [1,2] |
|
logical, | intent(in), | optional | :: | relative_err |
to use |
|
real(kind=wp), | intent(in), | optional | :: | safety_factor |
for |
|
integer, | intent(in), | optional | :: | p_exponent_offset |
p + this value in the exponent (0 or 1) |
|
integer, | intent(in), | optional | :: | max_attempts |
max step size change attempts after rejected step |
|
logical, | intent(in), | optional | :: | fixed_step_mode |
if true, then the method runs in
fixed step mode with not error estimation.
All the other inputs are ignored. Note that
this requires a |
Compute the new step size using the specific method.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(stepsize_class), | intent(in) | :: | me | |||
integer, | intent(in) | :: | n |
number of variables |
||
real(kind=wp), | intent(in) | :: | h |
current step size (<>0) |
||
real(kind=wp), | intent(in), | dimension(n) | :: | tol |
abs error tolerance (>0) |
|
real(kind=wp), | intent(in), | dimension(n) | :: | err |
truncation error estimate (>0) |
|
integer, | intent(in) | :: | p |
order of the method |
||
real(kind=wp), | intent(out) | :: | hnew |
new step size (<>0) |
||
logical, | intent(out) | :: | accept |
if the step is accepted |
Destructor for stepsize_class.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(stepsize_class), | intent(out) | :: | me |
type,public :: stepsize_class !! Algorithms for adjusting the step size for variable-step !! Runge-Kutta integrators. private logical :: fixed_step_mode = .false. !! if true, then the method runs in !! fixed step mode with not error estimation real(wp) :: hmax = 1.0e+6_wp !! maximum allowed step size real(wp) :: hmin = 1.0e-6_wp !! minimum allowed step size real(wp) :: hfactor_reject = 0.5_wp !! minimum allowed factor for decreasing step size after rejected step real(wp) :: hfactor_accept = 2.0_wp !! maximum allowed factor for increasing step size after accepted step integer :: accept_mode = 2 !! method to determine if step is accepted [1,2] integer :: max_attempts = 10000 !! maximum number of attempts to decrease step size before giving up ! for the `hfactor` equation: logical :: relative_err = .false. !! to use `tol*h` in the `hfactor` equation real(wp) :: safety_factor = 0.9_wp !! for `hfactor` equation (>0) integer :: p_exponent_offset = 1 !! `p` + this value in the exponent (0 or 1) procedure(norm_func),nopass,pointer :: norm => maxval_func !! routine for computing the norm of the state contains private procedure,public :: initialize => stepsize_class_constructor procedure,public :: compute_stepsize procedure,public :: destroy => destroy_stepsize_class end type stepsize_class