Tom0Brien / tinyode

tinyode - A lightweight C++ library for solving ordinary differential equations.

Home Page:https://tom0brien.github.io/tinyode/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

tinyode

tinyode is a lightweight C++ library which provides various ordinary differential equation solvers.

The goal of tinyode is to be as simple as possible while still being incredibly fast and versatile.

Features

  • Solver Methods:

    • Euler
    • RK4
    • RK5
    • RK45
  • Event Detection

Install

1. Install Dependencies

2. Build with cmake

git clone https://github.com/Tom0Brien/tinyode.git && cd tinyode
mkdir build && cd build
cmake ..
make
sudo make install # copies files in the include folder to /usr/local/include*

Examples

Numerous examples are provided in the examples folder.

The code below demonstrates how to

    // Define the ODE function f(t,x)
    auto ode_function = [](const double t, const Eigen::Matrix<double, 1, 1>& x) -> Eigen::Matrix<double, 1, 1> {
        return Eigen::Matrix<double, 1, 1>(-x(0, 0));
    };

    // Specify the initial conditions, time span and solver options
    Eigen::Matrix<double, 1, 1> initial_conditions(1.0);
    TimeSpan<double> time_span(0.0, 1.0);
    Options<double, 1> options;
    options.fixed_time_step    = 0.01;
    options.integration_method = IntegrationMethod::EULER;

    // Solve the ODE!
    auto result = ode(ode_function, time_span, initial_conditions, options);

About

tinyode - A lightweight C++ library for solving ordinary differential equations.

https://tom0brien.github.io/tinyode/


Languages

Language:C++ 94.5%Language:CMake 5.5%