pub struct Material { /* private fields */ }Expand description
A material: a list of elements, a mass density and per-element energies.
Serializes (serde) to the canonical form of MaterialSpec with atom
fractions and explicit densities and energies; deserializes from any valid
spec, so a TOML file may give atom or mass fractions.
Implementations§
Source§impl Material
impl Material
Sourcepub fn from_atom_fractions(
parts: &[(u8, f64)],
density_kg_m3: Option<f64>,
) -> Result<Self, MaterialError>
pub fn from_atom_fractions( parts: &[(u8, f64)], density_kg_m3: Option<f64>, ) -> Result<Self, MaterialError>
Build from (Z, atom fraction) pairs. Fractions are relative weights
(see the module docs). density_kg_m3 may be None only for a single
element with a tabulated density.
Sourcepub fn from_mass_fractions(
parts: &[(u8, f64)],
density_kg_m3: Option<f64>,
) -> Result<Self, MaterialError>
pub fn from_mass_fractions( parts: &[(u8, f64)], density_kg_m3: Option<f64>, ) -> Result<Self, MaterialError>
Build from (Z, mass fraction) pairs. Same rules as
Material::from_atom_fractions.
Sourcepub fn with_name(self, name: impl Into<String>) -> Self
pub fn with_name(self, name: impl Into<String>) -> Self
Set a display name (does not affect physics).
Sourcepub fn components(&self) -> &[Component]
pub fn components(&self) -> &[Component]
Components in the order they were given.
Sourcepub fn mass_density(&self) -> f64
pub fn mass_density(&self) -> f64
Mass density, kg/m³.
Sourcepub fn set_mass_density(
&mut self,
density_kg_m3: f64,
) -> Result<(), MaterialError>
pub fn set_mass_density( &mut self, density_kg_m3: f64, ) -> Result<(), MaterialError>
Override the mass density, kg/m³.
Sourcepub fn mean_atomic_weight(&self) -> f64
pub fn mean_atomic_weight(&self) -> f64
Mean atomic weight sum(x_j M_j), g/mol.
Sourcepub fn atom_number_density(&self) -> f64
pub fn atom_number_density(&self) -> f64
Total atom number density, atoms per m³.
Sourcepub fn number_density_of(&self, z: u8) -> Result<f64, MaterialError>
pub fn number_density_of(&self, z: u8) -> Result<f64, MaterialError>
Number density of one element, atoms per m³.
Sourcepub fn atom_fractions(&self) -> Vec<(u8, f64)>
pub fn atom_fractions(&self) -> Vec<(u8, f64)>
Atom fractions in component order.
Sourcepub fn mass_fractions(&self) -> Vec<(u8, f64)>
pub fn mass_fractions(&self) -> Vec<(u8, f64)>
Mass fractions in component order.
Sourcepub fn displacement_energy_ev(&self, z: u8) -> Result<f64, MaterialError>
pub fn displacement_energy_ev(&self, z: u8) -> Result<f64, MaterialError>
Displacement energy E_d of element z in this material, eV.
Sourcepub fn lattice_binding_energy_ev(&self, z: u8) -> Result<f64, MaterialError>
pub fn lattice_binding_energy_ev(&self, z: u8) -> Result<f64, MaterialError>
Lattice binding energy E_b of element z, eV.
Sourcepub fn surface_binding_energy_ev(&self, z: u8) -> Result<f64, MaterialError>
pub fn surface_binding_energy_ev(&self, z: u8) -> Result<f64, MaterialError>
Surface binding energy E_s of element z, eV.
Sourcepub fn set_displacement_energy_ev(
&mut self,
z: u8,
ev: f64,
) -> Result<(), MaterialError>
pub fn set_displacement_energy_ev( &mut self, z: u8, ev: f64, ) -> Result<(), MaterialError>
Set E_d for element z, eV.
Sourcepub fn set_lattice_binding_energy_ev(
&mut self,
z: u8,
ev: f64,
) -> Result<(), MaterialError>
pub fn set_lattice_binding_energy_ev( &mut self, z: u8, ev: f64, ) -> Result<(), MaterialError>
Set E_b for element z, eV.
Sourcepub fn set_surface_binding_energy_ev(
&mut self,
z: u8,
ev: f64,
) -> Result<(), MaterialError>
pub fn set_surface_binding_energy_ev( &mut self, z: u8, ev: f64, ) -> Result<(), MaterialError>
Set E_s for element z, eV.
Sourcepub fn unset_energies(&self) -> Vec<(u8, EnergyKind)>
pub fn unset_energies(&self) -> Vec<(u8, EnergyKind)>
Energies that still have no value, in component order: a run should refuse to start while this is non-empty.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Material
impl<'de> Deserialize<'de> for Material
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 From<Material> for MaterialSpec
impl From<Material> for MaterialSpec
impl StructuralPartialEq for Material
Source§impl TryFrom<MaterialSpec> for Material
impl TryFrom<MaterialSpec> for Material
Source§type Error = MaterialError
type Error = MaterialError
Source§fn try_from(spec: MaterialSpec) -> Result<Self, MaterialError>
fn try_from(spec: MaterialSpec) -> Result<Self, MaterialError>
Auto Trait Implementations§
impl Freeze for Material
impl RefUnwindSafe for Material
impl Send for Material
impl Sync for Material
impl Unpin for Material
impl UnsafeUnpin for Material
impl UnwindSafe for Material
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