differential_equations/solout/mod.rs
1//! Solout trait and common implementations for controlling the output of differential equation solvers.
2//!
3//! ## Includes
4//! * `DefaultSolout` for capturing all solver steps
5//! * `EvenSolout` for capturing evenly spaced solution points
6//! * `DenseSolout` for capturing a dense set of interpolated points
7//! * `TEvalSolout` for capturing points based on a user-defined function
8//! * `CrossingSolout` for capturing points when crossing a specified value
9//! * `HyperplaneCrossingSolout` for capturing points when crossing a hyperplane
10//!
11use crate::{
12 control::ControlFlag,
13 interpolate::Interpolation,
14 solution::Solution,
15 traits::{Real, State},
16};
17
18mod crossing;
19mod default;
20mod dense;
21mod even;
22mod event;
23mod hyperplane;
24mod solout;
25mod t_eval;
26
27pub use crossing::CrossingSolout;
28pub use default::DefaultSolout;
29pub use dense::DenseSolout;
30pub use even::EvenSolout;
31pub use event::{Event, EventConfig, EventSolout, EventWrappedSolout};
32pub use hyperplane::HyperplaneCrossingSolout;
33pub use solout::Solout;
34pub use t_eval::TEvalSolout;
35
36/// Defines the direction of threshold crossing to detect.
37#[derive(Debug, Clone, Copy, PartialEq, Eq)]
38pub enum CrossingDirection {
39 /// Detect crossings in both directions
40 Both,
41 /// Detect only crossings from below to above the threshold (positive direction)
42 Positive,
43 /// Detect only crossings from above to below the threshold (negative direction)
44 Negative,
45}
46
47impl From<i8> for CrossingDirection {
48 fn from(value: i8) -> Self {
49 match value {
50 1 => CrossingDirection::Positive,
51 -1 => CrossingDirection::Negative,
52 _ => CrossingDirection::Both,
53 }
54 }
55}