oxilean_std/nonlinear_dynamics/types.rs
1//! Types for nonlinear dynamical systems.
2
3/// A nonlinear dynamical system of a given `dimension`.
4#[derive(Clone, Debug)]
5pub struct DynamicalSystem {
6 /// State-space dimension.
7 pub dimension: usize,
8 /// The concrete type / parameters of the system.
9 pub system_type: SystemType,
10}
11
12/// Specifies whether a system evolves in continuous or discrete time, or
13/// as a Hamiltonian system.
14#[derive(Clone, Debug)]
15pub enum SystemType {
16 /// Continuous-time ODE ẋ = f(x), represented by truncated polynomial
17 /// coefficients (one row per dimension).
18 Continuous {
19 /// Polynomial ODE coefficients (one vector per state variable).
20 ode_coefficients: Vec<Vec<f64>>,
21 },
22 /// Discrete-time map x_{n+1} = F(x_n).
23 Discrete {
24 /// The specific map type and parameters.
25 map_type: MapType,
26 },
27 /// Hamiltonian system ẋ = ∂H/∂p, ṗ = -∂H/∂q.
28 HamiltonianSystem {
29 /// Coefficients of the Hamiltonian polynomial.
30 hamiltonian_coeffs: Vec<f64>,
31 },
32}
33
34/// Specific discrete-time maps with named parameter sets.
35#[derive(Clone, Debug, PartialEq)]
36pub enum MapType {
37 /// The logistic map x_{n+1} = r·x_n·(1 − x_n).
38 Logistic {
39 /// Growth parameter r ∈ \[0, 4\].
40 r: f64,
41 },
42 /// The Hénon map (x, y) → (1 − a·x² + y, b·x).
43 Henon {
44 /// Quadratic coefficient a.
45 a: f64,
46 /// Dissipation coefficient b.
47 b: f64,
48 },
49 /// Chirikov standard map (p, q) → (p + k·sin(q), q + p + k·sin(q)) mod 2π.
50 Standard {
51 /// Nonlinearity parameter k.
52 k: f64,
53 },
54 /// The tent map x_{n+1} = μ·min(x, 1-x).
55 Tent {
56 /// Slope parameter μ ∈ \[0, 2\].
57 mu: f64,
58 },
59 /// The Bernoulli shift map x_{n+1} = m·x mod 1.
60 Bernoulli {
61 /// Integer multiplier m >= 2.
62 m: usize,
63 },
64}
65
66/// A time-parametrized trajectory in phase space.
67#[derive(Clone, Debug)]
68pub struct Trajectory {
69 /// State vectors at each time step; `points\[i\]` is the state at `times\[i\]`.
70 pub points: Vec<Vec<f64>>,
71 /// Time values corresponding to each state point.
72 pub times: Vec<f64>,
73}
74
75/// A fixed point of a dynamical system, together with its linear stability
76/// classification.
77#[derive(Clone, Debug)]
78pub struct FixedPoint {
79 /// Location in phase space.
80 pub location: Vec<f64>,
81 /// Stability type determined by linearization.
82 pub stability: Stability,
83 /// Eigenvalues of the Jacobian at the fixed point.
84 pub eigenvalues: Vec<f64>,
85}
86
87/// Stability classification for a fixed point.
88#[derive(Clone, Debug, PartialEq, Eq)]
89pub enum Stability {
90 /// All eigenvalues have negative real part (stable node / focus).
91 StableNode,
92 /// All eigenvalues have positive real part (unstable node / focus).
93 UnstableNode,
94 /// Mixed-sign eigenvalues (hyperbolic saddle point).
95 SaddlePoint,
96 /// Purely imaginary eigenvalues (center, undamped oscillations).
97 Center,
98 /// Complex eigenvalues, negative real part (stable spiral focus).
99 StableFocus,
100 /// Complex eigenvalues, positive real part (unstable spiral focus).
101 UnstableFocus,
102 /// Cannot be determined from available data.
103 Unknown,
104}
105
106/// The Lyapunov exponent spectrum of a dynamical system.
107#[derive(Clone, Debug)]
108pub struct LyapunovExponents {
109 /// Lyapunov exponents in non-increasing order.
110 pub exponents: Vec<f64>,
111 /// Dimension of the system state space.
112 pub system_dimension: usize,
113}
114
115/// Asymptotic attractor type of a dynamical system.
116#[derive(Clone, Debug)]
117pub enum AttractorType {
118 /// Stable equilibrium (fixed point attractor).
119 FixedPoint,
120 /// Periodic orbit (limit cycle) with the given period.
121 LimitCycle {
122 /// Temporal period.
123 period: f64,
124 },
125 /// Quasi-periodic motion on a torus with the given fundamental frequencies.
126 Torus {
127 /// Incommensurate frequencies.
128 frequencies: Vec<f64>,
129 },
130 /// Strange (chaotic) attractor with fractal dimension.
131 Strange {
132 /// Fractal (Hausdorff/Lyapunov) dimension.
133 dimension: f64,
134 },
135 /// Repelling set (source in phase space).
136 Repeller,
137}
138
139/// A bifurcation point: the parameter value at which the system's qualitative
140/// behavior changes.
141#[derive(Clone, Debug)]
142pub struct BifurcationPoint {
143 /// The value of the bifurcation parameter.
144 pub parameter_value: f64,
145 /// The type of bifurcation occurring.
146 pub bifurcation_type: BifurcationType,
147}
148
149/// Standard local bifurcation types.
150#[derive(Clone, Debug, PartialEq, Eq)]
151pub enum BifurcationType {
152 /// Saddle-node (fold) bifurcation: two fixed points collide and annihilate.
153 SaddleNode,
154 /// Transcritical bifurcation: two fixed points exchange stability.
155 Transcritical,
156 /// Pitchfork bifurcation: one fixed point splits into three.
157 Pitchfork,
158 /// Hopf bifurcation: fixed point loses stability to a limit cycle.
159 HopfBifurcation,
160 /// Period-doubling (flip) bifurcation: period of a limit cycle doubles.
161 PeriodDoubling,
162}
163
164/// Result of intersecting a trajectory with a Poincaré section hyperplane.
165#[derive(Clone, Debug)]
166pub struct PoincareSectionResult {
167 /// Points on the Poincaré section (one per crossing event).
168 pub points: Vec<Vec<f64>>,
169 /// Time intervals between consecutive crossings (return times).
170 pub recurrence_times: Vec<f64>,
171}
172
173/// Fractal dimension of an attractor computed by a specific method.
174#[derive(Clone, Debug)]
175pub struct FractalDimension {
176 /// Computed fractal dimension value.
177 pub value: f64,
178 /// The numerical method used.
179 pub method: DimensionMethod,
180}
181
182/// Method used to estimate the fractal dimension.
183#[derive(Clone, Debug, PartialEq, Eq)]
184pub enum DimensionMethod {
185 /// Box-counting (Minkowski–Bouligand) dimension.
186 BoxCounting,
187 /// Correlation dimension (Grassberger–Procaccia).
188 CorrelationDimension,
189 /// Lyapunov (Kaplan–Yorke) dimension.
190 LyapunovDimension,
191}