pub struct StefanProblem {
pub n: usize,
pub dx: f64,
pub temperature: Vec<f64>,
pub interface_pos: f64,
pub latent_heat: f64,
pub stefan_number: f64,
/* private fields */
}Expand description
1D Stefan problem: solidification with a moving solid-liquid interface.
The domain [0, L] contains two phases separated by a sharp interface at
position s(t). In each phase the temperature satisfies the heat equation,
and the interface velocity is determined by the Stefan condition (energy balance).
§Model
∂T/∂t = α ∂²T/∂x² (uniform thermal diffusivity α = 1)
Interface: ρ L ds/dt = -[k ∂T/∂n] (latent heat release)
Stefan condition simplified: ds/dt = (T_x|_s⁺ - T_x|_s⁻) / StThe implementation uses a fixed-grid enthalpy method with a smoothed interface to avoid explicit front tracking.
Fields§
§n: usizeNumber of grid points
dx: f64Grid spacing
temperature: Vec<f64>Temperature field T(x)
interface_pos: f64Current interface position s (lattice coordinate)
latent_heat: f64Latent heat L
stefan_number: f64Stefan number St = c_p * ΔT / L
Implementations§
Source§impl StefanProblem
impl StefanProblem
Sourcepub fn new(
n: usize,
l: f64,
initial_interface: f64,
latent_heat: f64,
stefan_number: f64,
) -> IntegrateResult<Self>
pub fn new( n: usize, l: f64, initial_interface: f64, latent_heat: f64, stefan_number: f64, ) -> IntegrateResult<Self>
Create a new Stefan problem.
§Arguments
n— number of grid pointsl— domain lengthinitial_interface— starting interface position ∈ (0, l)latent_heat— latent heat L (energy/volume)stefan_number— Stefan number St = c_p ΔT / L
Sourcepub fn step(&mut self, dt: f64)
pub fn step(&mut self, dt: f64)
Advance the Stefan problem by one time step using an explicit method.
Uses the enthalpy-based update where interface motion is recovered from the Stefan condition applied at the nearest grid cell to the interface.
Sourcepub fn run(&mut self, t_final: f64, dt: f64) -> Vec<(f64, f64)>
pub fn run(&mut self, t_final: f64, dt: f64) -> Vec<(f64, f64)>
Run the Stefan problem and return the time history of (time, interface_position).
The interface position is returned in physical coordinates (metres).
Sourcepub fn interface_position_phys(&self) -> f64
pub fn interface_position_phys(&self) -> f64
Return the current interface position in physical coordinates.
Sourcepub fn stefan_number(&self) -> f64
pub fn stefan_number(&self) -> f64
Return the Stefan number.
Auto Trait Implementations§
impl Freeze for StefanProblem
impl RefUnwindSafe for StefanProblem
impl Send for StefanProblem
impl Sync for StefanProblem
impl Unpin for StefanProblem
impl UnsafeUnpin for StefanProblem
impl UnwindSafe for StefanProblem
Blanket Implementations§
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§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