mod_integration Module

Module responsible for integration of differential equations, useful when setting equilibria or integrating the equilibrium equation. Contains subroutines to numerically solve the following systems of differential equations: These are solved using a fifth-order Runge-Kutta method.



Contents


Interfaces

interface

  • private function func(x)

    Arguments

    TypeIntentOptionalAttributesName
    real(kind=dp), intent(in) :: x

    Return Value real(kind=dp)


Subroutines

public subroutine integrate_ode_rk45(x0, x1, ax_func, bx_func, nbpoints, yinit, yvalues, xvalues)

Numerically integrates the differential equation using a fifth-order Runge-Kutta method. The functions A(x) and B(x) are passed as arguments and should be conform to the given interface, that is, these should be real(dp) functions which take a single real(dp), intent(in) argument. The integration is performed on the interval [x0, x1] with a stepsize of dh = (x1 - x0) / (nbpoints - 1).

Arguments

TypeIntentOptionalAttributesName
real(kind=dp), intent(in) :: x0

start of x-interval

real(kind=dp), intent(in) :: x1

end of x-interval

procedure(func) :: ax_func

function to calculate A(x)

procedure(func) :: bx_func

function to calculate B(x)

integer, intent(in) :: nbpoints

number of points, determines stepsize

real(kind=dp), intent(in) :: yinit

initial value of y

real(kind=dp), intent(out), allocatable:: yvalues(:)

integrated values of y

real(kind=dp), intent(out), optional allocatable:: xvalues(:)

x-values corresponding to integrated y-values

private subroutine rk45(xi, dh, ax_func, bx_func, yi, ysolrk4, ysolrk5)

Calculates the Runge-Kutta coefficients and calculates the fourth and fifth order solutions for step i+1 based on the values at step i.

Arguments

TypeIntentOptionalAttributesName
real(kind=dp), intent(in) :: xi

current x value

real(kind=dp), intent(in) :: dh

current step size

procedure(func) :: ax_func

function to calculate A(x)

procedure(func) :: bx_func

function to calculate B(x)

real(kind=dp), intent(in) :: yi

current y value

real(kind=dp), intent(out) :: ysolrk4

fourth order solution

real(kind=dp), intent(out) :: ysolrk5

fifth order solution