Skip to content

Commit

Permalink
docs: update sundials bench, new python bench (#116)
Browse files Browse the repository at this point in the history
* docs: update sundials bench, new python bench

* misc updates

* misc fixes
  • Loading branch information
martinjrobins authored Dec 16, 2024
1 parent 55b14cf commit 091a8af
Show file tree
Hide file tree
Showing 12 changed files with 1,772 additions and 367 deletions.
6 changes: 3 additions & 3 deletions benches/ode_solvers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,8 @@ fn criterion_benchmark(c: &mut Criterion) {
c.bench_function(stringify!($name), |b| {
use diffsol::ode_solver::test_models::robertson::*;
use diffsol::LlvmModule;
let (problem, soln) = robertson_diffsl_problem::<$matrix, LlvmModule>();
b.iter(|| {
let (problem, soln) = robertson_diffsl_problem::<$matrix, LlvmModule>();
benchmarks::$solver::<_, $linear_solver<_>>(
&problem,
soln.solution_points.last().unwrap().t,
Expand Down Expand Up @@ -426,8 +426,8 @@ fn criterion_benchmark(c: &mut Criterion) {
c.bench_function(concat!(stringify!($name), "_", $N), |b| {
use diffsol::ode_solver::test_models::heat2d::*;
use diffsol::LlvmModule;
let (problem, soln) = heat2d_diffsl_problem::<$matrix, LlvmModule, $N>();
b.iter(|| {
let (problem, soln) = heat2d_diffsl_problem::<$matrix, LlvmModule, $N>();
benchmarks::$solver::<_, $linear_solver<_>>(&problem, soln.solution_points.last().unwrap().t)
})
});)+
Expand Down Expand Up @@ -500,8 +500,8 @@ fn criterion_benchmark(c: &mut Criterion) {
c.bench_function(concat!(stringify!($name), "_", $N), |b| {
use diffsol::ode_solver::test_models::foodweb::*;
use diffsol::LlvmModule;
let (problem, soln) = foodweb_diffsl_problem::<$matrix, LlvmModule, $N>();
b.iter(|| {
let (problem, soln) = foodweb_diffsl_problem::<$matrix, LlvmModule, $N>();
benchmarks::$solver::<_, $linear_solver<_>>(&problem, soln.solution_points.last().unwrap().t)
})
});)+
Expand Down
6 changes: 3 additions & 3 deletions benches/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"name": "robertson",
"reference_name": "roberts_dns",
"arg": None,
"solvers": ["nalgebra_esdirk34", "nalgebra_tr_bdf2", "nalgebra_bdf", "nalgebra_bdf_diffsl"],
"solvers": ["nalgebra_esdirk34", "nalgebra_tr_bdf2", "nalgebra_bdf", "nalgebra_bdf_diffsl"]
},
{
"name": "robertson_ode",
Expand All @@ -24,7 +24,7 @@
"name": "heat2d",
"reference_name": "heat2d_klu",
"arg": [5, 10, 20, 30],
"solvers": ["faer_sparse_esdirk", "faer_sparse_tr_bdf2", "faer_sparse_bdf", "faer_sparse_bdf", "faer_sparse_bdf_diffsl"]
"solvers": ["faer_sparse_esdirk", "faer_sparse_tr_bdf2", "faer_sparse_bdf", "faer_sparse_bdf_diffsl"]
#"solvers": ["faer_sparse_esdirk_klu", "faer_sparse_tr_bdf2_klu", "faer_sparse_bdf_klu", "faer_sparse_bdf_klu_diffsl"]
},
{
Expand Down Expand Up @@ -115,7 +115,7 @@
ax3.set_title("BDF solver")
ax4.set_title("BDF solver + DiffSL")

basedir = "book/src/images/benchmarks"
basedir = "book/src/benchmarks/images"
fig1.savefig(f"{basedir}/bench_tr_bdf2_esdirk.svg")
fig2.savefig(f"{basedir}/bench_bdf.svg")
fig3.savefig(f"{basedir}/bench_bdf_diffsl.svg")
Expand Down
4 changes: 3 additions & 1 deletion book/src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,6 @@
- [Sparse problems](./specify/sparse_problems.md)
- [Choosing a solver](./choosing_a_solver.md)
- [Solving the problem](./solving_the_problem.md)
- [Benchmarks](./benchmarks.md)
- [Benchmarks](./benchmarks/benchmarks.md)
- [Sundials](./benchmarks/sundials.md)
- [Python (Diffrax & Casadi)](./benchmarks/python.md)
10 changes: 10 additions & 0 deletions book/src/benchmarks/benchmarks.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Benchmarks

The goal of this chapter is to compare the performance of the DiffSol implementation with other similar ode solver libraries.

The libraries we will compare against are:
- [Sundials](https://computing.llnl.gov/projects/sundials): A suite of advanced numerical solvers for ODEs and DAEs, implemented in C.
- [Diffrax](https://docs.kidger.site/diffrax/): A Python library for solving ODEs and SDEs implemented using JAX.
- [Casadi](https://web.casadi.org/): A C++ library with Python anbd MATLAB bindings, for solving ODEs and DAEs, nonlinear optimisation and algorithmic differentiation.

The comparison with Sundials will be done in Rust by wrapping C functions and comparing them to Rust implementations. The comparsion with the Python libraries (Diffrax and Casadi) will be done by wrapping DiffSol in Python using the PyO3 library, and comparing the performance of the wrapped functions. As well as benchmarking the DiffSol solvers, this also serves [as an example](https://github.com/martinjrobins/diffsol_python_benchmark) of how to wrap and use DiffSol in other languages.
Loading

0 comments on commit 091a8af

Please sign in to comment.