ITP root solver
Type | Visibility | Attributes | Name | Initial | |||
---|---|---|---|---|---|---|---|
real(kind=wp), | private | :: | k1 | = | 0.1_wp |
from (0, inf) |
|
real(kind=wp), | private | :: | k2 | = | 0.98_wp*(1.0_wp+golden_ratio) |
from [1, 1+phi] |
|
integer, | private | :: | n0 | = | 1 |
initialize the class [must be called first]
Initialize the root_solver class.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(root_solver), | intent(out) | :: | me | |||
procedure(func) | :: | f |
user function |
|||
real(kind=wp), | intent(in), | optional | :: | ftol |
absolute tolerance for |
|
real(kind=wp), | intent(in), | optional | :: | rtol |
relative tol for x |
|
real(kind=wp), | intent(in), | optional | :: | atol |
absolute tol for x |
|
integer, | intent(in), | optional | :: | maxiter |
maximum number of iterations |
main routine for finding the root
Main wrapper routine for all the methods.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(root_solver), | intent(inout) | :: | me | |||
real(kind=wp), | intent(in) | :: | ax |
left endpoint of initial interval |
||
real(kind=wp), | intent(in) | :: | bx |
right endpoint of initial interval |
||
real(kind=wp), | intent(out) | :: | xzero |
abscissa approximating a zero of |
||
real(kind=wp), | intent(out) | :: | fzero |
value of |
||
integer, | intent(out) | :: | iflag |
status flag ( |
||
real(kind=wp), | intent(in), | optional | :: | fax |
if |
|
real(kind=wp), | intent(in), | optional | :: | fbx |
if |
|
logical, | intent(in), | optional | :: | bisect_on_failure |
if true, then if the specified method fails,
it will be retried using the bisection method.
(default is False). Note that this can use up
to |
Compute the zero of the function f(x) in the interval ax,bx using the Interpolate Truncate and Project (ITP) method.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(itp_solver), | intent(inout) | :: | me | |||
real(kind=wp), | intent(in) | :: | ax |
left endpoint of initial interval |
||
real(kind=wp), | intent(in) | :: | bx |
right endpoint of initial interval |
||
real(kind=wp), | intent(in) | :: | fax |
|
||
real(kind=wp), | intent(in) | :: | fbx |
|
||
real(kind=wp), | intent(out) | :: | xzero |
abscissa approximating a zero of |
||
real(kind=wp), | intent(out) | :: | fzero |
value of |
||
integer, | intent(out) | :: | iflag |
status flag ( |
For the itp method, set the optional inputs.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(itp_solver), | intent(inout) | :: | me | |||
real(kind=wp), | intent(in), | optional | :: | k1 |
from (0, inf) [Default is 0.1] |
|
real(kind=wp), | intent(in), | optional | :: | k2 |
from [1, 1+phi] [Default is 0.98*(1+phi)] |
|
integer, | intent(in), | optional | :: | n0 |
[Default is 1 |
type,extends(root_solver),public :: itp_solver !! ITP root solver private ! tuning parameters for ITP: real(wp) :: k1 = 0.1_wp !! from (0, inf) real(wp) :: k2 = 0.98_wp * (1.0_wp + golden_ratio) !! from [1, 1+phi] integer :: n0 = 1 contains private procedure,public :: find_root => itp procedure,public :: set_optional_inputs => itp_optional_inputs end type itp_solver