Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Introduction

diffsol is a Rust library that solves ordinary differential equations (ODEs) and semi-explicit differential algebraic equations (DAEs) of the form

\[ M \frac{dy}{dt} = f(t, y, p), \quad y(t_0) = y_0(t_0, p), \]

where \(M\) is an optional mass matrix (it can be singular), \(y\) is the state vector, \(t\) is the time and \(p\) is a vector of parameters.

You can give the equations to diffsol in one of these forms:

  • Rust closures, which you give to the OdeBuilder.
  • The DiffSL domain-specific language. diffsol compiles DiffSL equations at runtime, and it calculates the Jacobians with automatic differentiation.
  • Your own types that implement the diffsol traits.

The README lists the features of diffsol, and tells you how to install it.

How to use this book

  • Modelling with diffsol is a primer on ODE modelling. Each section introduces a type of model (first-order and higher-order ODEs, events, DAEs, PDEs and sensitivity analysis), and gives examples that you can run.
  • Specifying ODE problems shows the three ways to give your equations to diffsol: the builder with closures, DiffSL, and the diffsol traits.
  • Creating a solver and Solving the problem show how to make a solver and how to get the solution, the sensitivities and the gradients.
  • Performance gives advice about how to make your solves fast.
  • Using diffsol from other languages shows how to use diffsol from Python, C and WebAssembly.
  • Benchmarks compares diffsol with other ODE solvers.

The API documentation on docs.rs gives the full API.

The code for all the examples is in the examples folder of the diffsol repository.