An easily extensible ODE integrator in C. Mainly a learning project for practicing with pointers, memory allocation and data structures; not really optimized for efficiency, but being C, is still fairly fast.
Documented for Doxygen in Qt style -- pages hosted at http://pauljxtan.github.io/odeint.
Method (struct_name):
- 4th-order Runge-Kutta (rk4)
- Forward Euler (fweuler)
- Bulirsch-Stoer (bulsto)
System (function_name):
- Brusselator (brusselator)
- Chen system (chen)
- Damped spring (damped_spring)
- Double pendulum (double_pendulum)
- Duffing equation (duffing)
- Lorenz attractor (lorenz)
- Lotka-Volterra equations (lotka)
- Parrot system {Borelli & Coleman 1987} (parrot)
- Rossler system (rossler)
- Symmetric top (symmetric_top)
- Van der pol oscillator (vanderpol)
- Van der pol oscillator 2-D (vanderpol2d)
Integrate the Lorenz attractor using RK4, with the following parameters:
- time-step size : 0.01
- initial time : 0.0
- initial state : x=0.01, y=0.01, z=0.01
- number of steps : 10000
- verbose mode : yes (might be a big bottleneck for program speed)
- print parameters: yes
- write to file : yes [filename="lorenz.dat"]
$ ./src/integrate rk4 lorenz -d 0.01 -t 0.0 -x 0.01 -x 0.01 -x 0.01 -n 10000 -v -y -w
Then one could visualize the results with gnuplot, for example: gnuplot> splot "lorenz.dat" using 2:3:4 with lines
(To browse all available systems, run ./integrate without arguments.)
We can plot the time-series for each variable in real-time by piping the integration data into the Python plotting script, e.g.:
$ ./integrate rk4 lotka -d 0.05 -t 0.0 -x 10.0 -x 5.0 -n 1000 -v | ./plot_stdin_timeseries.py
or from a data file:
$ ./plot_stdin_timeseries.py < lotka.dat
- Declare the function in ./include/eoms.h
- Define the constants in ./include/eoms.h
- Add the function to the function table and function list in ./src/eoms.c
- Define the function in ./src/eoms.c
- All set!
A Tkinter-based GUI is located at ./python/odeintgui.py. Requires Python and matplotlib 1.0.0+ with the Tk backend. Try it out!
A Java object-oriented implementation may be found in ./java/. Working, but still under heavy construction.
- Add "kwargs" functionality for passing additional parameters (e.g. constants) to integrator
- Adaptive methods