Skip to main content

CrossSectionTable

Struct CrossSectionTable 

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

A precomputed cross-section table for one material and one process, cacheable on disk (format version CACHE_FORMAT_VERSION).

§Contents and dimensions

With N incident energies and M probability points:

  • energy_ev[N]: incident electron energies, eV; finite, positive, strictly increasing, N >= 2.
  • inverse_mfp_per_m[N]: inverse mean free path λ⁻¹(E) = n σ(E) for the process, in m⁻¹; finite and non-negative. Zero means no interaction at that energy (for example below a threshold).
  • probability[M]: the cumulative-probability axis shared by every row; finite, strictly increasing, starting at exactly 0 and ending at exactly 1, M >= 2.
  • quantiles[N][..]: inverse-CDF ordinates (the cache stores the inverse CDF, not the forward CDF). quantiles[i][j] is the value x of the sampled variable at which the cumulative distribution at energy energy_ev[i] reaches probability[j]. A row is non-decreasing and lies in the axis’s domain ([0, π] rad for the elastic polar angle, [0, energy_ev[i]] eV for the inelastic energy loss). A row whose inverse mean free path is zero must be empty: there is no distribution to store, and CrossSectionTable::inverse_cdf returns ElectronDataError::ZeroRate for it. Every other row has exactly M entries.

The file also records the model identity, the material, the provenance, the sampling axis and its unit (ordinate_unit, which must match the axis), and the format version.

§Sampling

CrossSectionTable::inverse_cdf evaluates a stored row at a probability u by linear interpolation between neighbouring probability points (exact at the stored points). Interpolation between incident energies is left to the transport code, which owns that choice.

Implementations§

Source§

impl CrossSectionTable

Source

pub fn new(parts: CrossSectionTableParts) -> Result<Self, ElectronDataError>

Build a validated table. See the type docs for the invariants.

Source

pub fn from_toml_str(text: &str) -> Result<Self, ElectronDataError>

Parse and validate the TOML cache form.

Source

pub fn to_toml_string(&self) -> Result<String, ElectronDataError>

Serialize to the TOML cache form.

Source

pub fn from_toml_file(path: impl AsRef<Path>) -> Result<Self, ElectronDataError>

Load a TOML cache file.

Source

pub fn write_toml_file( &self, path: impl AsRef<Path>, ) -> Result<(), ElectronDataError>

Write a TOML cache file.

Source

pub fn format_version(&self) -> u32

Format version of this table (CACHE_FORMAT_VERSION).

Source

pub fn model(&self) -> &str

Model identity.

Source

pub fn material(&self) -> &str

Material identity.

Source

pub fn provenance(&self) -> &str

Provenance string.

Source

pub fn axis(&self) -> SamplingAxis

The sampled variable.

Source

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

Incident energies, eV.

Source

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

Inverse mean free paths, m⁻¹, one per energy.

Source

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

The cumulative-probability axis.

Source

pub fn quantiles(&self, i: usize) -> Option<&[f64]>

The inverse-CDF ordinates at grid energy i, or None for a zero-rate row (or an index past the end).

Source

pub fn inverse_cdf(&self, i: usize, u: f64) -> Result<f64, ElectronDataError>

The inverse CDF of grid row i at cumulative probability u in [0, 1], in the axis’s unit. A zero-rate row is ElectronDataError::ZeroRate: the caller must not sample an interaction that cannot happen.

Source

pub fn parts(&self) -> &CrossSectionTableParts

The validated contents.

Trait Implementations§

Source§

impl Clone for CrossSectionTable

Source§

fn clone(&self) -> CrossSectionTable

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 CrossSectionTable

Source§

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

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

impl<'de> Deserialize<'de> for CrossSectionTable

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for CrossSectionTable

Source§

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

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

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

Inequality operator !=. Read more
Source§

impl Serialize for CrossSectionTable

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for CrossSectionTable

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
§

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,

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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

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> 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> 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> 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 = 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<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V