rk_module Module

Runge-Kutta integration.


Uses

  • module~~rk_module~~UsesGraph module~rk_module rk_module module~kind_module kind_module module~rk_module->module~kind_module module~numbers_module numbers_module module~rk_module->module~numbers_module iso_fortran_env iso_fortran_env module~kind_module->iso_fortran_env module~numbers_module->module~kind_module

Used by

  • module~~rk_module~~UsedByGraph module~rk_module rk_module module~fortran_astrodynamics_toolkit fortran_astrodynamics_toolkit module~fortran_astrodynamics_toolkit->module~rk_module proc~compute_halo_monodromy_matrix halo_orbit_module::compute_halo_monodromy_matrix proc~compute_halo_monodromy_matrix->module~rk_module proc~halo_to_rv_diffcorr halo_orbit_module::halo_to_rv_diffcorr proc~halo_to_rv_diffcorr->module~rk_module

Interfaces

interface

  • private subroutine deriv_func(me, t, x, xdot)

    derivative function

    Arguments

    Type IntentOptional Attributes Name
    class(rk_class), intent(inout) :: me
    real(kind=wp), intent(in) :: t

    time

    real(kind=wp), intent(in), dimension(me%n) :: x

    state vector

    real(kind=wp), intent(out), dimension(me%n) :: xdot

    derivative of state vector

interface

  • private subroutine event_func(me, t, x, g)

    event function

    Arguments

    Type IntentOptional Attributes Name
    class(rk_class), intent(inout) :: me
    real(kind=wp), intent(in) :: t

    time

    real(kind=wp), intent(in), dimension(me%n) :: x

    state vector

    real(kind=wp), intent(out) :: g

    g(t,x). The goal is to stop the integration when g=0.

interface

  • private subroutine report_func(me, t, x)

    report function

    Arguments

    Type IntentOptional Attributes Name
    class(rk_class), intent(inout) :: me
    real(kind=wp), intent(in) :: t

    time

    real(kind=wp), intent(in), dimension(me%n) :: x

    state vector

interface

  • private subroutine step_func(me, t, x, h, xf)

    rk step function

    Arguments

    Type IntentOptional Attributes Name
    class(rk_class), intent(inout) :: me
    real(kind=wp), intent(in) :: t

    initial time

    real(kind=wp), intent(in), dimension(me%n) :: x

    initial state vector

    real(kind=wp), intent(in) :: h

    time step

    real(kind=wp), intent(out), dimension(me%n) :: xf

    final state vector


Derived Types

type, public ::  rk_class

main integration class:

Components

Type Visibility Attributes Name Initial
integer, public :: n = 0

user specified number of variables

procedure(deriv_func), public, pointer :: f => null()

user-specified derivative function

procedure(report_func), public, pointer :: report => null()

user-specified report function

procedure(event_func), public, pointer :: g => null()

event function (stop when this is zero)

Type-Bound Procedures

procedure, public :: initialize ../../

initialize the class (set n,f, and report)

procedure, public, non_overridable :: integrate ../../

main integration routine

procedure, public, non_overridable :: integrate_to_event ../../

integration with event finding

procedure(step_func), public, deferred :: step ../../

the step routine for the rk method

procedure, public :: destroy ../../

destructor

type, public, extends(rk_class) ::  rk4_class

4th order Runge-Kutta method.

Components

Type Visibility Attributes Name Initial
integer, public :: n = 0

user specified number of variables

procedure(deriv_func), public, pointer :: f => null()

user-specified derivative function

procedure(report_func), public, pointer :: report => null()

user-specified report function

procedure(event_func), public, pointer :: g => null()

event function (stop when this is zero)

Type-Bound Procedures

procedure, public :: initialize ../../

initialize the class (set n,f, and report)

procedure, public, non_overridable :: integrate ../../

main integration routine

procedure, public, non_overridable :: integrate_to_event ../../

integration with event finding

procedure, public :: destroy ../../

destructor

procedure, public :: step => rk4

type, public, extends(rk_class) ::  rk8_10_class

8th order Runge-Kutta method.

Components

Type Visibility Attributes Name Initial
integer, public :: n = 0

user specified number of variables

procedure(deriv_func), public, pointer :: f => null()

user-specified derivative function

procedure(report_func), public, pointer :: report => null()

user-specified report function

procedure(event_func), public, pointer :: g => null()

event function (stop when this is zero)

Type-Bound Procedures

procedure, public :: initialize ../../

initialize the class (set n,f, and report)

procedure, public, non_overridable :: integrate ../../

main integration routine

procedure, public, non_overridable :: integrate_to_event ../../

integration with event finding

procedure, public :: destroy ../../

destructor

procedure, public :: step => rk8_10

Subroutines

private subroutine initialize(me, n, f, report, g)

Initialize the rk_class.

Arguments

Type IntentOptional Attributes Name
class(rk_class), intent(inout) :: me
integer, intent(in) :: n

number of variables

procedure(deriv_func) :: f

derivative function

procedure(report_func), optional :: report

for reporting the steps

procedure(event_func), optional :: g

for stopping at an event

private subroutine destroy(me)

Destructor for rk_class.

Arguments

Type IntentOptional Attributes Name
class(rk_class), intent(out) :: me

private subroutine integrate(me, t0, x0, h, tf, xf)

Main integration routine for the rk_class.

Arguments

Type IntentOptional Attributes Name
class(rk_class), intent(inout) :: me
real(kind=wp), intent(in) :: t0

initial time

real(kind=wp), intent(in), dimension(me%n) :: x0

initial state

real(kind=wp), intent(in) :: h

abs(time step)

real(kind=wp), intent(in) :: tf

final time

real(kind=wp), intent(out), dimension(me%n) :: xf

final state

private subroutine integrate_to_event(me, t0, x0, h, tmax, tol, tf, xf, gf)

Event-finding integration routine for the rk_class. Integrates until g(t,x)=0, or until t=tf (whichever happens first).

Read more…

Arguments

Type IntentOptional Attributes Name
class(rk_class), intent(inout) :: me
real(kind=wp), intent(in) :: t0

initial time

real(kind=wp), intent(in), dimension(me%n) :: x0

initial state

real(kind=wp), intent(in) :: h

abs(time step)

real(kind=wp), intent(in) :: tmax

max final time if event not located

real(kind=wp), intent(in) :: tol

function tolerance for root finding

real(kind=wp), intent(out) :: tf

actual final time reached

real(kind=wp), intent(out), dimension(me%n) :: xf

final state (at tf)

real(kind=wp), intent(out) :: gf

g value at tf

private subroutine rk4(me, t, x, h, xf)

Take one Runge Kutta 4 integration step: t -> t+h (x -> xf)

Arguments

Type IntentOptional Attributes Name
class(rk4_class), intent(inout) :: me
real(kind=wp), intent(in) :: t

initial time

real(kind=wp), intent(in), dimension(me%n) :: x

initial state

real(kind=wp), intent(in) :: h

time step

real(kind=wp), intent(out), dimension(me%n) :: xf

state at time t+h

private subroutine rk8_10(me, t, x, h, xf)

Take one Runge Kutta 8 integration step: t -> t+h (x -> xf) This is Formula (8-10) from Reference [1].

Read more…

Arguments

Type IntentOptional Attributes Name
class(rk8_10_class), intent(inout) :: me
real(kind=wp), intent(in) :: t

initial time

real(kind=wp), intent(in), dimension(me%n) :: x

initial state

real(kind=wp), intent(in) :: h

time step

real(kind=wp), intent(out), dimension(me%n) :: xf

state at time t+h

public subroutine rk_test()

Unit test of the rk_module. Integrate a two-body orbit around the Earth.

Arguments

None