1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
use crate::ode::runge_kutta::WeightType;
use thiserror::Error;
#[derive(Error, Debug)]
pub enum OdeError {
#[error("{msg}")]
Uninitialized { msg: String },
#[error("Expected {expected:?} weights, found {found:?} weights")]
InvalidButcherTableauWeightType {
expected: WeightType,
found: WeightType,
},
#[error(
"Encountered NAN after {computation} computations while solving at timestamp {timestamp}"
)]
NAN { computation: usize, timestamp: f64 },
#[error("Zero time span is not allowed")]
ZeroTimeSpan,
#[error("Initial step has wrong sign")]
InvalidInitstep,
#[error("Unable to compute matrix operation")]
InvalidMatrix,
}
impl OdeError {
pub(crate) fn uninitialized<T: ToString>(s: T) -> Self {
OdeError::Uninitialized { msg: s.to_string() }
}
}
#[derive(Error, Debug)]
pub enum IntegrationError {
#[error("Maximum steps reached at {at}, after {n_step} steps")]
MaxNumStepReached { at: f64, n_step: u32 },
#[error("Encountered step size underflow at {at}")]
StepSizeUnderflow { at: f64 },
#[error("Stiffness detected at {at}")]
StiffnessDetected { at: f64 },
}