Skip to main content

PhysicsSimulationLibrary

Struct PhysicsSimulationLibrary 

Source
pub struct PhysicsSimulationLibrary { /* private fields */ }
Expand description

Physics Simulation Library Manager

Implementations§

Source§

impl PhysicsSimulationLibrary

Source

pub fn run_cfd_simulation( &mut self, simulation: &mut Simulation, ) -> Result<PhysicsSimulationResult<Vec<PhysicsField>>, PhysicsError>

Run CFD simulation

Source

pub fn initialize_cfd_fields( &self, simulation: &Simulation, ) -> Result<Vec<PhysicsField>, PhysicsError>

Source

pub fn check_convergence(&self, solver_result: &SolverResult) -> bool

Source§

impl PhysicsSimulationLibrary

Source

pub fn run_distributed_simulation( &mut self, simulation: &mut Simulation, ) -> Result<PhysicsSimulationResult<Vec<PhysicsField>>, PhysicsError>

Run distributed simulation

Source§

impl PhysicsSimulationLibrary

Source

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.

Source

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.

Source

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

Source

pub fn new() -> Self

Create new physics simulation library

Source

pub fn initialize(&mut self) -> Result<(), PhysicsError>

Initialize the library

Source

pub fn create_simulation( &mut self, config: SimulationConfig, ) -> Result<Simulation, PhysicsError>

Create a new simulation

Source

pub fn get_performance_stats(&self) -> PhysicsPerformanceMetrics

Get performance statistics

Source§

impl PhysicsSimulationLibrary

Source

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.

Source

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.

Source

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

Source

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

Source

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

Source

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

Source

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§

Blanket Implementations§

§

impl<S, A> Aggregate<Result<S, Error>> for A
where A: Aggregate<S>,

§

fn from_shares<T>(iter: T) -> Result<A, Error>
where T: IntoIterator<Item = Result<S, Error>>,

Aggregate shares in an MPC protocol.
Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> Downcast<T> for T

§

fn downcast(&self) -> &T

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

impl<T> PolicyExt for T
where T: ?Sized,

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> Upcast<T> for T

§

fn upcast(&self) -> Option<&T>

§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

§

impl<T> WasmNotSend for T
where T: Send,

§

impl<T> WasmNotSendSync for T
where T: WasmNotSend + WasmNotSync,

§

impl<T> WasmNotSync for T
where T: Sync,