Struct Lattice

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

Periodic 3D lattice

Implementations§

Source§

impl Lattice

Source

pub fn replicate( &self, ra: impl Iterator<Item = isize> + Clone, rb: impl Iterator<Item = isize> + Clone, rc: impl Iterator<Item = isize> + Clone, ) -> impl Iterator<Item = Vector3f>

Create a supercell along three cell directions.

Source§

impl Lattice

Source

pub fn new<T: Into<Vector3f> + Copy>(tvs: [T; 3]) -> Self

Construct Lattice from three lattice vectors.

Source

pub fn from_matrix<T: Into<Matrix3f>>(tvs: T) -> Self

Construct Lattice from lattice matrix (3x3).

Source

pub fn from_params( a: f64, b: f64, c: f64, alpha: f64, beta: f64, gamma: f64, ) -> Self

Construct lattice from lattice parameters Unit cell angles in degrees, lengths in Angstrom

Source

pub fn widths(&self) -> [f64; 3]

Return the perpendicular widths of the cell along three directions. i.e. the distance between opposite faces of the unit cell

Source

pub fn volume(&self) -> f64

Return the volume of the unit cell the cache will be updated if necessary

Source

pub fn set_origin<T: Into<Vector3f>>(&mut self, loc: T)

Set cell origin in Cartesian coordinates

Source

pub fn lengths(&self) -> [f64; 3]

Lattice length parameters: a, b, c

Source

pub fn angles(&self) -> [f64; 3]

Lattice angle parameters in degrees

Source

pub fn scale_by(&mut self, v: f64)

Scale Lattice by a positive constant v

Source

pub fn scale_by_a(&mut self, v: f64)

Scale Lattice in a direction by a positive constant v

Source

pub fn scale_by_b(&mut self, v: f64)

Scale Lattice in b direction by a positive constant v

Source

pub fn scale_by_c(&mut self, v: f64)

Scale Lattice in c direction by a positive constant v

Source

pub fn origin(&self) -> Vector3f

Get cell origin in Cartesian coordinates

Source

pub fn to_frac<T: Into<Vector3f>>(&self, p: T) -> Vector3f

Returns the fractional coordinates given cartesian coordinates.

Source

pub fn to_cart<T: Into<Vector3f>>(&self, p: T) -> Vector3f

Returns the cartesian coordinates given fractional coordinates.

Source

pub fn vector_a(&self) -> Vector3f

Lattice vector a

Source

pub fn vector_b(&self) -> Vector3f

Lattice vector b

Source

pub fn vector_c(&self) -> Vector3f

Lattice vector c

Source

pub fn vectors(&self) -> [Vector3f; 3]

Three lattice vectors.

Source

pub fn matrix(&self) -> Matrix3f

Lattice vectors

Source

pub fn inv_matrix(&self) -> Matrix3f

inverse of lattice matrix

Source

pub fn is_orthorhombic(&self) -> bool

Check if lattice is orthorhombic

Source

pub fn wrap<T: Into<Vector3f>>(&self, vec: T) -> Vector3f

Wrap a point in cartesian coordinates into unit cell, obeying the periodic boundary conditions. Returns cartesian coordinates.

Source

pub fn wrap_frac<T: Into<Vector3f>>(&self, f: T) -> Vector3f

Wrap a point in fractional coordinates into unit cell, obeying the periodic boundary conditions. Returns fractional coordinates.

Source

pub fn distance<T: Into<Vector3f>>(&self, pi: T, pj: T) -> f64

Return the shortest distance between pi (point i) and the periodic images of pj (point j) under the minimum image convention

§Parameters
  • pi, pj: Cartesian coordinates of point i and point j
Source

pub fn apply_mic<T: Into<[f64; 3]>>(&self, p: T) -> Vector3f

Return the shortest vector obeying the minimum image convention.

Trait Implementations§

Source§

impl Clone for Lattice

Source§

fn clone(&self) -> Lattice

Returns a copy of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Lattice

Source§

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

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

impl Default for Lattice

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for Lattice

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 Serialize for Lattice

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 Copy for Lattice

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, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<T> Configure for T

Source§

fn print_toml(&self)

👎Deprecated: plan to be removed
Print current configuration in toml format.
Source§

fn from_json(s: &str) -> Result<Self, Error>

Deserialize an instance of type T from a string of JSON text.
Source§

fn from_toml(s: &str) -> Result<Self, Error>

Deserialize an instance of type T from a string of TOML text.
Source§

fn to_json(&self) -> Result<String, Error>

Serialize it to a JSON string.
Source§

fn to_toml(&self) -> Result<String, Error>

Serialize self to a TOML string.
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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

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

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
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.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,