pub struct UnitCell {
pub lattice: [[f64; 3]; 3],
}Expand description
A 3D periodic unit cell defined by lattice vectors.
Fields§
§lattice: [[f64; 3]; 3]Lattice vectors as rows: [[ax,ay,az], [bx,by,bz], [cx,cy,cz]].
Implementations§
Source§impl UnitCell
impl UnitCell
Sourcepub fn new(lattice: [[f64; 3]; 3]) -> Self
pub fn new(lattice: [[f64; 3]; 3]) -> Self
Create a unit cell from three lattice vectors (row vectors).
Sourcepub fn from_parameters(params: &CellParameters) -> Self
pub fn from_parameters(params: &CellParameters) -> Self
Create a cell from crystallographic parameters (a, b, c, α, β, γ in degrees).
Returns a degenerate cell if angles do not produce positive volume.
Sourcepub fn parameters(&self) -> CellParameters
pub fn parameters(&self) -> CellParameters
Extract crystallographic parameters from lattice vectors.
Sourcepub fn frac_to_cart(&self, frac: [f64; 3]) -> [f64; 3]
pub fn frac_to_cart(&self, frac: [f64; 3]) -> [f64; 3]
Convert fractional coordinates to Cartesian (Å). r_cart = f0 * a + f1 * b + f2 * c
Sourcepub fn cart_to_frac(&self, cart: [f64; 3]) -> [f64; 3]
pub fn cart_to_frac(&self, cart: [f64; 3]) -> [f64; 3]
Convert Cartesian coordinates (Å) to fractional. frac_to_cart computes: r = f[0]*a + f[1]*b + f[2]*c = M^T · f So: f = (M^T)^{-1} · r = (M^{-1})^T · r
Sourcepub fn wrap_frac(frac: [f64; 3]) -> [f64; 3]
pub fn wrap_frac(frac: [f64; 3]) -> [f64; 3]
Wrap fractional coordinates into [0, 1) — periodic boundary conditions.
Sourcepub fn wrap_cart(&self, cart: [f64; 3]) -> [f64; 3]
pub fn wrap_cart(&self, cart: [f64; 3]) -> [f64; 3]
Wrap Cartesian coordinates into the unit cell.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for UnitCell
impl<'de> Deserialize<'de> for UnitCell
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>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for UnitCell
impl RefUnwindSafe for UnitCell
impl Send for UnitCell
impl Sync for UnitCell
impl Unpin for UnitCell
impl UnsafeUnpin for UnitCell
impl UnwindSafe for UnitCell
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
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 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>
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.