GithubHelp home page GithubHelp logo

pauljxtan / odeint Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 395 KB

An easily extensible ODE integrator

Home Page: http://pauljxtan.github.io/odeint

License: MIT License

C 60.02% Java 13.75% Makefile 0.99% Python 25.24%

odeint's Introduction

odeint

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.

Currently implemented

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)

Quick start

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.)

Real-time plotting

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

Adding systems

  1. Declare the function in ./include/eoms.h
  2. Define the constants in ./include/eoms.h
  3. Add the function to the function table and function list in ./src/eoms.c
  4. Define the function in ./src/eoms.c
  5. All set!

GUI

A Tkinter-based GUI is located at ./python/odeintgui.py. Requires Python and matplotlib 1.0.0+ with the Tk backend. Try it out!

Java version

A Java object-oriented implementation may be found in ./java/. Working, but still under heavy construction.

To-do

  • Add "kwargs" functionality for passing additional parameters (e.g. constants) to integrator
  • Adaptive methods

odeint's People

Contributors

pauljxtan avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.