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 valuexof the sampled variable at which the cumulative distribution at energyenergy_ev[i]reachesprobability[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, andCrossSectionTable::inverse_cdfreturnsElectronDataError::ZeroRatefor it. Every other row has exactlyMentries.
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
impl CrossSectionTable
Sourcepub fn new(parts: CrossSectionTableParts) -> Result<Self, ElectronDataError>
pub fn new(parts: CrossSectionTableParts) -> Result<Self, ElectronDataError>
Build a validated table. See the type docs for the invariants.
Sourcepub fn from_toml_str(text: &str) -> Result<Self, ElectronDataError>
pub fn from_toml_str(text: &str) -> Result<Self, ElectronDataError>
Parse and validate the TOML cache form.
Sourcepub fn to_toml_string(&self) -> Result<String, ElectronDataError>
pub fn to_toml_string(&self) -> Result<String, ElectronDataError>
Serialize to the TOML cache form.
Sourcepub fn from_toml_file(path: impl AsRef<Path>) -> Result<Self, ElectronDataError>
pub fn from_toml_file(path: impl AsRef<Path>) -> Result<Self, ElectronDataError>
Load a TOML cache file.
Sourcepub fn write_toml_file(
&self,
path: impl AsRef<Path>,
) -> Result<(), ElectronDataError>
pub fn write_toml_file( &self, path: impl AsRef<Path>, ) -> Result<(), ElectronDataError>
Write a TOML cache file.
Sourcepub fn format_version(&self) -> u32
pub fn format_version(&self) -> u32
Format version of this table (CACHE_FORMAT_VERSION).
Sourcepub fn provenance(&self) -> &str
pub fn provenance(&self) -> &str
Provenance string.
Sourcepub fn axis(&self) -> SamplingAxis
pub fn axis(&self) -> SamplingAxis
The sampled variable.
Sourcepub fn inverse_mfp_per_m(&self) -> &[f64]
pub fn inverse_mfp_per_m(&self) -> &[f64]
Inverse mean free paths, m⁻¹, one per energy.
Sourcepub fn probability(&self) -> &[f64]
pub fn probability(&self) -> &[f64]
The cumulative-probability axis.
Sourcepub fn quantiles(&self, i: usize) -> Option<&[f64]>
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).
Sourcepub fn inverse_cdf(&self, i: usize, u: f64) -> Result<f64, ElectronDataError>
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.
Sourcepub fn parts(&self) -> &CrossSectionTableParts
pub fn parts(&self) -> &CrossSectionTableParts
The validated contents.
Trait Implementations§
Source§impl Clone for CrossSectionTable
impl Clone for CrossSectionTable
Source§fn clone(&self) -> CrossSectionTable
fn clone(&self) -> CrossSectionTable
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for CrossSectionTable
impl Debug for CrossSectionTable
Source§impl<'de> Deserialize<'de> for CrossSectionTable
impl<'de> Deserialize<'de> for CrossSectionTable
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl PartialEq for CrossSectionTable
impl PartialEq for CrossSectionTable
Source§impl Serialize for CrossSectionTable
impl Serialize for CrossSectionTable
impl StructuralPartialEq for CrossSectionTable
Auto Trait Implementations§
impl Freeze for CrossSectionTable
impl RefUnwindSafe for CrossSectionTable
impl Send for CrossSectionTable
impl Sync for CrossSectionTable
impl Unpin for CrossSectionTable
impl UnsafeUnpin for CrossSectionTable
impl UnwindSafe for CrossSectionTable
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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