pub struct PhysicsSimulationLibrary { /* private fields */ }Expand description
Physics Simulation Library Manager
Implementations§
Source§impl PhysicsSimulationLibrary
impl PhysicsSimulationLibrary
Sourcepub fn run_cfd_simulation(
&mut self,
simulation: &mut Simulation,
) -> Result<PhysicsSimulationResult<Vec<PhysicsField>>, PhysicsError>
pub fn run_cfd_simulation( &mut self, simulation: &mut Simulation, ) -> Result<PhysicsSimulationResult<Vec<PhysicsField>>, PhysicsError>
Run CFD simulation
pub fn initialize_cfd_fields( &self, simulation: &Simulation, ) -> Result<Vec<PhysicsField>, PhysicsError>
pub fn check_convergence(&self, solver_result: &SolverResult) -> bool
Source§impl PhysicsSimulationLibrary
impl PhysicsSimulationLibrary
Sourcepub fn run_distributed_simulation(
&mut self,
simulation: &mut Simulation,
) -> Result<PhysicsSimulationResult<Vec<PhysicsField>>, PhysicsError>
pub fn run_distributed_simulation( &mut self, simulation: &mut Simulation, ) -> Result<PhysicsSimulationResult<Vec<PhysicsField>>, PhysicsError>
Run distributed simulation
Source§impl PhysicsSimulationLibrary
impl PhysicsSimulationLibrary
Sourcepub fn run_heat_diffusion_1d(
&self,
initial: Vec<f64>,
alpha: f64,
dx: f64,
total_time: f64,
num_samples: usize,
) -> Result<HeatDiffusionResult, PhysicsError>
pub fn run_heat_diffusion_1d( &self, initial: Vec<f64>, alpha: f64, dx: f64, total_time: f64, num_samples: usize, ) -> Result<HeatDiffusionResult, PhysicsError>
HeatTransfer — 1D heat/diffusion equation u_t = α·u_xx on a grid with insulated
(Neumann) ends, so total heat is conserved and the profile relaxes toward its mean.
The spatial Laplacian is assembled here; time integration is integrate_dopri5.
Sourcepub fn run_wave_equation_1d(
&self,
initial_displacement: Vec<f64>,
initial_velocity: Vec<f64>,
c: f64,
dx: f64,
total_time: f64,
num_samples: usize,
) -> Result<WaveResult, PhysicsError>
pub fn run_wave_equation_1d( &self, initial_displacement: Vec<f64>, initial_velocity: Vec<f64>, c: f64, dx: f64, total_time: f64, num_samples: usize, ) -> Result<WaveResult, PhysicsError>
CEM — 1D scalar wave equation u_tt = c²·u_xx (a plane-wave field component) on a
grid with fixed (Dirichlet) ends. Posed as the first-order system u_t = v,
v_t = c²·u_xx and integrated by integrate_dopri5. Total wave energy is reported.
Sourcepub fn run_advection_diffusion_1d(
&self,
initial: Vec<f64>,
advection_velocity: f64,
diffusion_coeff: f64,
dx: f64,
total_time: f64,
num_samples: usize,
) -> Result<AdvectionDiffusionResult, PhysicsError>
pub fn run_advection_diffusion_1d( &self, initial: Vec<f64>, advection_velocity: f64, diffusion_coeff: f64, dx: f64, total_time: f64, num_samples: usize, ) -> Result<AdvectionDiffusionResult, PhysicsError>
MultiPhysics — coupled 1D advection–diffusion u_t + c·u_x = α·u_xx on a periodic
grid: a prescribed flow (fluid transport) coupled to diffusion (thermal spreading).
First-order upwind advection + central diffusion assembled here; integrated by
integrate_dopri5. The periodic scheme conserves Σ u_i·dx; the pure-diffusion
limit (c = 0) relaxes toward the mean.
Source§impl PhysicsSimulationLibrary
impl PhysicsSimulationLibrary
Sourcepub fn initialize(&mut self) -> Result<(), PhysicsError>
pub fn initialize(&mut self) -> Result<(), PhysicsError>
Initialize the library
Sourcepub fn create_simulation(
&mut self,
config: SimulationConfig,
) -> Result<Simulation, PhysicsError>
pub fn create_simulation( &mut self, config: SimulationConfig, ) -> Result<Simulation, PhysicsError>
Create a new simulation
Sourcepub fn get_performance_stats(&self) -> PhysicsPerformanceMetrics
pub fn get_performance_stats(&self) -> PhysicsPerformanceMetrics
Get performance statistics
Source§impl PhysicsSimulationLibrary
impl PhysicsSimulationLibrary
Sourcepub fn run_projectile_motion(
&self,
v0: f64,
angle_rad: f64,
g: f64,
drag: f64,
num_samples: usize,
max_time: f64,
) -> Result<ProjectileResult, PhysicsError>
pub fn run_projectile_motion( &self, v0: f64, angle_rad: f64, g: f64, drag: f64, num_samples: usize, max_time: f64, ) -> Result<ProjectileResult, PhysicsError>
ParticlePhysics — 2D projectile / ballistic motion with optional quadratic drag.
State [x, y, vx, vy]; dvx = -k·|v|·vx, dvy = -g - k·|v|·vy where k = drag
(drag per unit mass). Integrated by integrate_dopri5. With drag = 0 the range
recovers the analytic v0²·sin(2θ)/g.
Sourcepub fn run_harmonic_oscillator(
&self,
mass: f64,
k_spring: f64,
x0: f64,
v0: f64,
total_time: f64,
num_samples: usize,
) -> Result<OscillatorResult, PhysicsError>
pub fn run_harmonic_oscillator( &self, mass: f64, k_spring: f64, x0: f64, v0: f64, total_time: f64, num_samples: usize, ) -> Result<OscillatorResult, PhysicsError>
StructuralDynamics — 1D spring–mass harmonic oscillator, integrated by the
symplectic integrate_symplectic (Störmer–Verlet). Hamiltonian
H = p²/(2m) + ½k·q², so dq/dt = p/m, dp/dt = -k·q. Reports both the analytic
period 2π√(m/k) and the one measured from the integrated trajectory, plus the
bounded energy drift that is the hallmark of a symplectic integrator.
Sourcepub fn run_pendulum(
&self,
length: f64,
g: f64,
theta0: f64,
omega0: f64,
total_time: f64,
num_samples: usize,
) -> Result<PendulumResult, PhysicsError>
pub fn run_pendulum( &self, length: f64, g: f64, theta0: f64, omega0: f64, total_time: f64, num_samples: usize, ) -> Result<PendulumResult, PhysicsError>
Nonlinear rigid-body dynamics — a simple gravity pendulum (point mass on a rigid
rod). State [θ, ω]; dθ/dt = ω, dω/dt = -(g/L)·sin θ. Integrated by
integrate_dopri5. Energy E = ½L²ω² + gL(1−cos θ) (unit mass) is conserved; the
small-angle period is 2π√(L/g).
Source§impl PhysicsSimulationLibrary
impl PhysicsSimulationLibrary
Sourcepub fn run_molecular_dynamics(
&self,
positions: Vec<f64>,
velocities: Vec<f64>,
epsilon: f64,
sigma: f64,
mass: f64,
total_time: f64,
num_samples: usize,
) -> Result<MolecularDynamicsResult, PhysicsError>
pub fn run_molecular_dynamics( &self, positions: Vec<f64>, velocities: Vec<f64>, epsilon: f64, sigma: f64, mass: f64, total_time: f64, num_samples: usize, ) -> Result<MolecularDynamicsResult, PhysicsError>
MolecularDynamics — 2D Lennard-Jones particles. positions/velocities flat
[x0,y0,…] (length 2·N). Pair potential U(r)=4ε[(σ/r)¹²−(σ/r)⁶], force
magnitude 24ε(2(σ/r)¹²−(σ/r)⁶)/r assembled here; integrated by integrate_dopri5.
Total energy is conserved; kinetic temperature reported in reduced units (kB=1).
Source§impl PhysicsSimulationLibrary
impl PhysicsSimulationLibrary
Sourcepub fn run_nbody_gravitation(
&self,
masses: Vec<f64>,
positions: Vec<f64>,
velocities: Vec<f64>,
g: f64,
softening: f64,
total_time: f64,
num_samples: usize,
) -> Result<NBodyResult, PhysicsError>
pub fn run_nbody_gravitation( &self, masses: Vec<f64>, positions: Vec<f64>, velocities: Vec<f64>, g: f64, softening: f64, total_time: f64, num_samples: usize, ) -> Result<NBodyResult, PhysicsError>
Astrophysics — Newtonian N-body gravitation in 2D by direct force summation.
positions and velocities are flat [x0,y0,x1,y1,…] (length 2·N), masses
length N. Accelerations aᵢ = Σⱼ G·mⱼ·(rⱼ−rᵢ)/(|rⱼ−rᵢ|²+ε²)^{3/2} are assembled
here; the time integration is integrate_dopri5. Total energy and angular momentum
are reported for conservation checks.
Source§impl PhysicsSimulationLibrary
impl PhysicsSimulationLibrary
Sourcepub fn run_logistic_growth(
&self,
n0: f64,
growth_rate: f64,
carrying_capacity: f64,
total_time: f64,
num_samples: usize,
) -> Result<PopulationDynamicsResult, PhysicsError>
pub fn run_logistic_growth( &self, n0: f64, growth_rate: f64, carrying_capacity: f64, total_time: f64, num_samples: usize, ) -> Result<PopulationDynamicsResult, PhysicsError>
Biophysics — logistic population dynamics dN/dt = r·N·(1 − N/K), integrated by
integrate_dopri5. Matches the analytic logistic curve
N(t) = K / (1 + ((K−N₀)/N₀)·e^{−r·t}).
Source§impl PhysicsSimulationLibrary
impl PhysicsSimulationLibrary
Sourcepub fn run_quantum_stationary_states_1d(
&self,
potential: Vec<f64>,
dx: f64,
mass: f64,
hbar: f64,
num_levels: usize,
) -> Result<QuantumSpectrumResult, PhysicsError>
pub fn run_quantum_stationary_states_1d( &self, potential: Vec<f64>, dx: f64, mass: f64, hbar: f64, num_levels: usize, ) -> Result<QuantumSpectrumResult, PhysicsError>
QuantumMechanics — 1D time-independent Schrödinger equation
[-ħ²/(2m)·d²/dx² + V(x)]·ψ = E·ψ discretised by second-order finite differences
(Dirichlet walls). The resulting symmetric tridiagonal Hamiltonian is diagonalised
by the tested symmetric_eigen; the lowest num_levels energies are returned.
Auto Trait Implementations§
impl Freeze for PhysicsSimulationLibrary
impl RefUnwindSafe for PhysicsSimulationLibrary
impl Send for PhysicsSimulationLibrary
impl Sync for PhysicsSimulationLibrary
impl Unpin for PhysicsSimulationLibrary
impl UnsafeUnpin for PhysicsSimulationLibrary
impl UnwindSafe for PhysicsSimulationLibrary
Blanket Implementations§
§impl<S, A> Aggregate<Result<S, Error>> for Awhere
A: Aggregate<S>,
impl<S, A> Aggregate<Result<S, Error>> for Awhere
A: Aggregate<S>,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more