Module runge_kutta_45_functional
[hide private]

Module runge_kutta_45_functional

source code

Course: TKP4106 Process Modelling

Task: Implementing a 4th order Runge-Kutta integrator


Author: Tore Haug-Warberg

Contact: haugwarb@nt.ntnu.no

Organization: Department of Chemical Engineering, NTNU, Norway

License: TKP4106 Process Modelling (demo code)

Since: 2015-09-24

Change Log:

Version: 1.1

To Do:  

Requires:

See Also: Seven Topics in Python

Note:  

Functions [hide private]
[ list, list, ... ]
rk45(ydot=[lambda x,y: y [0]], y0=[1.0], x0=0.0, x1=1.0, nx=20)
Numerical integration of a list of ODEs using a 4th order Runge-Kutta scheme:
source code
Variables [hide private]
  __package__ = None

Imports: getopt, sys, math


Function Details [hide private]

rk45(ydot=[lambda x,y: y [0]], y0=[1.0], x0=0.0, x1=1.0, nx=20)

source code 
  1. Numerical integration of a list of ODEs using a 4th order Runge-Kutta scheme:
                     h
     y_{i+1} = y_i + - ( k1 + 2*k2 + 2*k3 + k4 )
                     6
    

    where:

     k1 = f(x_i    , y_i       )
     k2 = f(x_i+h/2, y_i+k1*h/2)
     k3 = f(x_i+h/2, y_i+k2*h/2)
     k4 = f(x_i+h  , y_i+k3    )
    
  2. Application Programming Interface (API):
Parameters:
  • ydot ([ lambda, lambda, ... ]) - a list of ODEs provided as ydot[k] = lambda x,y: fun_k(x,y)
  • y0 ([ float, float, ... ]) - a list of starting values for y
  • x0 (float) - start of integration domain
  • x1 (float) - end of integration domain
  • nx (int) - number of integration steps in addition to x0
Returns: [ list, list, ... ]
Integration history "y" defined by [ y0, y1, ... ynx ]