pub trait PhaseSpaceRepr: Send + Sync {
Show 13 methods
// Required methods
fn compute_density(&self) -> DensityField;
fn advect_x(&mut self, displacement: &DisplacementField, dt: f64);
fn advect_v(&mut self, acceleration: &AccelerationField, dt: f64);
fn moment(&self, position: &[f64; 3], order: usize) -> Tensor;
fn total_mass(&self) -> f64;
fn casimir_c2(&self) -> f64;
fn entropy(&self) -> f64;
fn stream_count(&self) -> StreamCountField;
fn velocity_distribution(&self, position: &[f64; 3]) -> Vec<f64>;
fn as_any(&self) -> &dyn Any;
// Provided methods
fn total_kinetic_energy(&self) -> f64 { ... }
fn to_snapshot(&self, time: f64) -> PhaseSpaceSnapshot { ... }
fn load_snapshot(&mut self, snap: PhaseSpaceSnapshot) { ... }
}Expand description
Central trait for all phase-space storage and manipulation strategies.
Implementations differ in memory layout and algorithmic complexity:
UniformGrid6D: O(N⁶) brute-force gridTensorTrain: O(N³r³) low-rank decompositionSheetTracker: O(N³) Lagrangian cold sheet
Required Methods§
Sourcefn compute_density(&self) -> DensityField
fn compute_density(&self) -> DensityField
Integrate f over all velocities: ρ(x) = ∫f dv³. This is the coupling moment to the Poisson equation.
Sourcefn advect_x(&mut self, displacement: &DisplacementField, dt: f64)
fn advect_x(&mut self, displacement: &DisplacementField, dt: f64)
Drift sub-step: advect f in spatial coordinates by displacement Δx = v·dt. Pure translation in x at constant v.
Sourcefn advect_v(&mut self, acceleration: &AccelerationField, dt: f64)
fn advect_v(&mut self, acceleration: &AccelerationField, dt: f64)
Kick sub-step: advect f in velocity coordinates by Δv = g·dt. Pure translation in v at constant x.
Sourcefn moment(&self, position: &[f64; 3], order: usize) -> Tensor
fn moment(&self, position: &[f64; 3], order: usize) -> Tensor
Compute velocity moment of order n at given spatial position. Order 0 = density, 1 = mean velocity, 2 = dispersion tensor.
Sourcefn total_mass(&self) -> f64
fn total_mass(&self) -> f64
Total mass M = ∫f dx³dv³. Should be conserved to machine precision.
Sourcefn casimir_c2(&self) -> f64
fn casimir_c2(&self) -> f64
Casimir invariant C₂ = ∫f² dx³dv³. Increase over time indicates numerical diffusion.
Sourcefn entropy(&self) -> f64
fn entropy(&self) -> f64
Boltzmann entropy S = −∫f ln f dx³dv³. Should be exactly conserved; growth = numerical error.
Sourcefn stream_count(&self) -> StreamCountField
fn stream_count(&self) -> StreamCountField
Number of distinct velocity streams at each spatial point. Detects caustic surfaces (sheet folds).
Provided Methods§
Sourcefn total_kinetic_energy(&self) -> f64
fn total_kinetic_energy(&self) -> f64
Total kinetic energy T = ½∫fv² dx³dv³.
Sourcefn to_snapshot(&self, time: f64) -> PhaseSpaceSnapshot
fn to_snapshot(&self, time: f64) -> PhaseSpaceSnapshot
Extract a full 6D snapshot of the current state.
Sourcefn load_snapshot(&mut self, snap: PhaseSpaceSnapshot)
fn load_snapshot(&mut self, snap: PhaseSpaceSnapshot)
Replace the current state with data from a dense 6D snapshot.
Required for unsplit (method-of-lines) time integration, which manipulates the distribution function directly rather than through drift/kick sub-steps. Default implementation panics; not all representations support this efficiently.