Crates.io | diffsl |
lib.rs | diffsl |
version | |
source | src |
created_at | 2024-03-06 10:41:08.207393 |
updated_at | 2024-12-11 14:29:24.983968 |
description | A compiler for a domain-specific language for ordinary differential equations (ODE). |
homepage | |
repository | https://github.com/martinjrobins/diffsl |
max_upload_size | |
id | 1164634 |
Cargo.toml error: | TOML parse error at line 19, column 1 | 19 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include` |
size | 0 |
A compiler for a domain-specific language for ordinary differential equations (ODEs) of the following form:
$$ M(t) \frac{d\mathbf{u}}{dt} = F(\mathbf{u}, t) $$
As an example, the following code defines a classic DAE testcase, the Robertson (1966) problem, which models the kinetics of an autocatalytic reaction, given by the following set of equations:
$$ \begin{align} \frac{dx}{dt} &= -0.04x + 10^4 y z \ \frac{dy}{dt} &= 0.04x - 10^4 y z - 3 \cdot 10^7 y^2 \ 0 &= x + y + z - 1 \end{align} $$
The DiffSL code for this problem is as follows:
in = [k1, k2, k3]
k1 { 0.04 }
k2 { 10000 }
k3 { 30000000 }
u_i {
x = 1,
y = 0,
z = 0,
}
dudt_i {
dxdt = 1,
dydt = 0,
dzdt = 0,
}
M_i {
dxdt,
dydt,
0,
}
F_i {
-k1 * x + k2 * y * z,
k1 * x - k2 * y * z - k3 * y * y,
1 - x - y - z,
}
out_i {
x,
y,
z,
}
See the DiffSL language documentation for a full description.
Generally the easiest way to make use of DiffSL is via an ode solver that supports the language, for example the diffsol library. Please see the diffsol documentation and consult the DiffSL language documentation for more information.
If you are writing your own ode solver and want to make use of the DiffSL compiler, please either get in touch by opening an issue, contacting the author or by looking at the diffsol source code.
You will need to install the LLVM project. The easiest way to install this is to use the package manager for your operating system. For example, on Ubuntu you can install these with the following command:
sudo apt-get install llvm
You can install DiffSL using cargo. You will need to indicate the llvm version you have installed using a feature flag. For example, for llvm 14:
cargo add diffsl --features llvm14-0
Other versions of llvm are also supported given by the features llvm13-0
, llvm14-0
, llvm15-0
, llvm16-0
, llvm17-0
.