Skip to main content

TemperatureTable

Struct TemperatureTable 

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

A monotone-in-temperature lookup table with linear interpolation and end-clamping.

Upstream’s Function1<scalar> table entry. Two knots are the usual case for a phase-change coefficient — one value below the freezing point, another above it — which makes the function ramp linearly across the interval between them instead of stepping discontinuously.

§Units

temperatures are kelvin [K]. values have whatever unit the owning model gives them — a rate [1/s] for SolidificationPorosity’s drag D(T), a dimensionless fraction [-] for VofSolidificationMelting’s alphaSolid(T). The table itself does not know and does not check.

§Valid ranges

temperatures must be strictly ascending; values need not be monotone in either direction (the drag table descends, and a fraction table may do either). A query outside the tabulated range returns the nearest end value rather than extrapolating, which is Function1’s table behaviour and is what lets a two-knot table act as a smoothed step.

Implementations§

Source§

impl TemperatureTable

Source

pub fn new(temperatures: Vec<f64>, values: Vec<f64>) -> Self

Build a table from ascending temperatures [K] and their values.

§Panics

Panics if the two vectors differ in length, if either is empty, or if the temperatures are not strictly ascending. All three are case-setup errors that would otherwise yield a silently wrong coefficient, so they fail loudly at construction rather than at the first lookup.

Source

pub fn two_knot( t_cold: f64, t_hot: f64, cold_value: f64, hot_value: f64, ) -> Self

A two-knot table: cold_value at and below t_cold, hot_value at and above t_hot, linear in between.

This is the shape both upstream examples use — (330 10000) (330.5 0) for the drag table, (330 1) (335 0) for the solid-fraction table.

§Panics

Panics if t_hot <= t_cold.

Source

pub fn value(&self, t: f64) -> f64

The tabulated value at temperature t [K], clamped at both ends.

Source

pub fn temperatures(&self) -> &[f64]

The tabulated temperatures [K], ascending.

Source

pub fn values(&self) -> &[f64]

The tabulated values, in the unit the owning model assigns them.

Trait Implementations§

Source§

impl Clone for TemperatureTable

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for TemperatureTable

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for TemperatureTable

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for TemperatureTable

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<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.