diffsol 0.19.0

A library for solving ordinary differential equations (ODEs) in Rust.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
use crate::{Matrix, OdeBuilder, OdeEquationsImplicit, OdeSolverProblem, Scalar};
use num_traits::One;

/// A NaN right-hand side forces every nonlinear solve to fail.
pub fn nonlinear_failure_problem<M: Matrix + 'static>(
) -> OdeSolverProblem<impl OdeEquationsImplicit<M = M, V = M::V, T = M::T, C = M::C>> {
    OdeBuilder::<M>::new()
        .rhs_implicit(
            |_y, _p, _t, dy| dy[0] = M::T::NAN,
            |_y, _p, _t, v, jv| jv[0] = -v[0],
        )
        .init(|_p, _t, y| y[0] = M::T::one(), 1)
        .build()
        .unwrap()
}