Skip to content

A simple compiler and an interactive shell to play with Ordinary Differential Equations (ODEs).

License

Notifications You must be signed in to change notification settings

rsachetto/odecompiler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

odecompiler

A simple compiler and an interactive shell to play with Ordinary Differential Equations (ODEs). The ODEs can be described using a very simple language and compiled to C code (more languages will be available). It is also possible to use the interactive shell to load, solve and plot the ODEs.

This software is in constant development. Keep it updated to have access to newer commands!

Using

Below, we have the SIR (Susceptible, Infectious, or Recovered) epidemiological model written using the ODE language (more examples can be found in the examples folder):

global n = 1000
global init_i = 3

beta = 0.4/n
gamma = 0.04

#Variables used in initial conditions have to be marked as global
initial S = n - init_i
initial I = init_i
initial R = 0

ode S' = -beta*S*I
ode I' = beta*S*I - gamma*I
ode R' = gamma*I

To download and compile

git clone https://github.com/rsachetto/odecompiler
cd odecompiler
make

To update and compile

cd odecompiler
git pull
make

Using the interactive shell (needs gnuplot in path for the plot command)

$ ./bin/ode_shell
Current directory odecompiler
ode_shell> cd examples
ode_shell> load sir.ode
ode_shell> solve 100
ode_shell> plot

plot image

ode_shell> vars
╭──────────────────╮
│       sir        │
├──────────┬───────┤
│ Var name │ Index │
├──────────┼───────┤
│    t     │   1   │
├──────────┼───────┤
│    S     │   2   │
├──────────┼───────┤
│    I     │   3   │
├──────────┼───────┤
│    R     │   4   │
╰──────────┴───────╯
ode_shell> setploty I
╭───────────────────────────────────────────────╮
│ 'I' variable will be plotted along the Y axis │
╰───────────────────────────────────────────────╯
ode_shell> replot

plot image

ode_shell> setploty R
╭───────────────────────────────────────────────╮
│ 'R' variable will be plotted along the Y axis │
╰───────────────────────────────────────────────╯
ode_shell> replot
ode_shell> exit

plot image

Running commands stored in a file

It is possible to run commands stored in a text file (one command per line):

./bin/ode_shell examples/run_examples.od

About

A simple compiler and an interactive shell to play with Ordinary Differential Equations (ODEs).

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages