Skip to main content

DiffusionSubModel

Struct DiffusionSubModel 

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

A SubModel integrating the 1-D diffusion equation on a uniform grid with explicit Euler time stepping.

The discrete semi-discrete system is ∂u/∂t = D · L u + s, where L is the laplacian_1d assembled by tpt_sci_grid, D is the diffusion coefficient, and s is an optional per-node forcing term. The forcing is held in the model’s input buffer, so a coupling can drive the field from another sub-model’s state — the canonical cross-scale pattern (e.g. a fast reaction ODE feeding a slow diffusion field).

Implementations§

Source§

impl DiffusionSubModel

Source

pub fn new( id: &str, grid: UniformGrid1D, coeff: f64, bc: Boundary, u0: Vec<f64>, ) -> Result<Self, SimError>

Build a diffusion sub-model on grid with diffusion coefficient coeff and boundary condition bc. The initial field is u0 (one value per grid node).

§Errors

Returns SimError::Advance if u0’s length does not match the number of grid nodes.

Source

pub fn coeff(&self) -> f64

Diffusion coefficient.

Source

pub fn set_max_step(&mut self, max_step: f64)

Largest stable internal step (derived from the explicit-Euler stability limit on construction; can be overridden with set_max_step).

Trait Implementations§

Source§

impl SubModel for DiffusionSubModel

Source§

fn id(&self) -> &str

Stable identifier, unique within a Simulation.
Source§

fn time(&self) -> f64

The model’s current internal simulation time.
Source§

fn max_step(&self) -> f64

The largest internal step this model can safely take in one advance call. The orchestrator never asks a model to advance by more than this.
Source§

fn advance(&mut self, dt: f64) -> Result<(), SimError>

Advance the model’s internal state by exactly dt (with 0 < dt <= max_step). Read more
Source§

fn state(&self) -> &[f64]

Read-only view of the model’s current state vector (used as coupling output).
Source§

fn input_mut(&mut self) -> Option<&mut [f64]>

Mutable view of the model’s input buffer, if it accepts coupled inputs. Returns None for models that are driven purely internally. The orchestrator writes cross-scale inputs here after every sub-step.
Source§

fn restore_state(&mut self, state: &[f64], time: f64) -> Result<(), SimError>

Restore the model’s state vector and internal time from a checkpoint. Read more

Auto Trait Implementations§

Blanket Implementations§

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

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

Source§

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

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.