pub struct Molecule {
pub atoms: Vec<Atom>,
pub electric_atoms: Option<Vec<Atom>>,
pub magnetic_atoms: Option<Vec<Atom>>,
pub threshold: f64,
}
Expand description
Structure containing the atoms constituting a molecule.
Fields§
§atoms: Vec<Atom>
The atoms constituting this molecule.
electric_atoms: Option<Vec<Atom>>
Optional special atom to represent the electric fields applied to this molecule.
magnetic_atoms: Option<Vec<Atom>>
Optional special atoms to represent the magnetic fields applied to this molecule.
threshold: f64
A threshold for approximate equality comparisons.
Implementations§
source§impl Molecule
impl Molecule
sourcepub fn to_xyz<P: AsRef<Path>>(&self, filename: P) -> Result<(), Error>
pub fn to_xyz<P: AsRef<Path>>(&self, filename: P) -> Result<(), Error>
Writes the ordinary atoms in the molecule to an XYZ file.
§Arguments
filename
- The XYZ file to be written.
sourcepub fn from_atoms(all_atoms: &[Atom], thresh: f64) -> Self
pub fn from_atoms(all_atoms: &[Atom], thresh: f64) -> Self
Construct a molecule from an array of atoms.
§Arguments
all_atoms
- The atoms (of all types) constituting this molecule.threshold
- A threshold for approximate equality comparisons.
§Returns
The constructed Molecule
struct.
§Panics
Panics when the numbers of fictitious special atoms, if any, are invalid. It is expected that, when present, there are two magnetic special atoms and/or one electric special atom.
sourcepub fn molecule_ordinary_atoms(&self) -> Self
pub fn molecule_ordinary_atoms(&self) -> Self
Constructs a new molecule containing only the ordinary atoms in this molecule.
sourcepub fn molecule_magnetic_atoms(&self) -> Option<Self>
pub fn molecule_magnetic_atoms(&self) -> Option<Self>
Constructs a new molecule containing only the fictitious magnetic atoms in this molecule, if any.
§Returns
Returns None
if this molecule has no fictitious magnetic atoms.
sourcepub fn molecule_electric_atoms(&self) -> Option<Self>
pub fn molecule_electric_atoms(&self) -> Option<Self>
Constructs a new molecule containing only the fictitious electric atoms in this molecule, if any.
§Returns
Returns None
if this molecule has no fictitious electric atoms.
sourcepub fn get_all_atoms(&self) -> Vec<&Atom>
pub fn get_all_atoms(&self) -> Vec<&Atom>
Retrieves a vector of references to all atoms in this molecule, including special ones, if any.
§Returns
All atoms in this molecule.
sourcepub fn get_all_atoms_mut(&mut self) -> Vec<&mut Atom>
pub fn get_all_atoms_mut(&mut self) -> Vec<&mut Atom>
Retrieves a vector of mutable references to all atoms in this molecule, including special ones, if any.
§Returns
All atoms in this molecule.
sourcepub fn calc_com(&self) -> Point3<f64>
pub fn calc_com(&self) -> Point3<f64>
Calculates the centre of mass of the molecule.
This does not take into account fictitious special atoms.
§Returns
The centre of mass.
sourcepub fn calc_interatomic_distance_matrix(&self) -> (Array2<f64>, Vec<Vec<usize>>)
pub fn calc_interatomic_distance_matrix(&self) -> (Array2<f64>, Vec<Vec<usize>>)
Determines the interatomic distance matrix and the indices of symmetry-equivalent atoms.
This does take into account fictitious special atoms.
§Returns
- The interatomic distance matrix where the distances in each column are sorted in ascending
order. Column $
j
$ contains the interatomic distances from atom $j
$ to all other atoms (both ordinary and fictitious) in the molecule. Also note that all atoms (both ordinary and fictitious) are included here, so the matrix is square. - A vector of vectors of symmetry-equivalent atom indices. Each inner vector contains indices of atoms in one SEA group.
sourcepub fn calc_sea_groups(&self) -> Vec<Vec<Atom>>
pub fn calc_sea_groups(&self) -> Vec<Vec<Atom>>
sourcepub fn set_magnetic_field(&mut self, magnetic_field: Option<Vector3<f64>>)
pub fn set_magnetic_field(&mut self, magnetic_field: Option<Vector3<f64>>)
sourcepub fn set_electric_field(&mut self, electric_field: Option<Vector3<f64>>)
pub fn set_electric_field(&mut self, electric_field: Option<Vector3<f64>>)
sourcepub fn adjust_threshold(&self, thresh: f64) -> Self
pub fn adjust_threshold(&self, thresh: f64) -> Self
sourcepub fn reorientate_mut(&mut self, moi_thresh: f64)
pub fn reorientate_mut(&mut self, moi_thresh: f64)
Reorientates the molecule in-place into a canonical alignment with the space-fixed axes of the coordinate system.
Fictitious special atoms are also moved during the reorientation.
If the molecule has a unique principal axis, then this axis becomes aligned with the
$z
$-axis and the other two degenerate axes become aligned with the $x
$- and $y
$-axes
of the coordinate system. If the molecule has no unique principal axes, then the axes are
aligned with $x
$-, $y
$-, and $z
$-axes in ascending order of moments of inertia.
§Arguments
moi_thresh
- Threshold for comparing moments of inertia.
sourcepub fn reorientate(&self, moi_thresh: f64) -> Self
pub fn reorientate(&self, moi_thresh: f64) -> Self
Clones and reorientates the molecule into a canonical alignment with the space-fixed axes of the coordinate system.
Fictitious special atoms are also moved during the reorientation.
If the molecule has a unique principal axis, then this axis becomes aligned with the
$z
$-axis and the other two degenerate axes become aligned with the $x
$- and $y
$-axes
of the coordinate system. If the molecule has no unique principal axes, then the axes are
aligned with $x
$-, $y
$-, and $z
$-axes in ascending order of moments of inertia.
§Arguments
moi_thresh
- Threshold for comparing moments of inertia.
§Returns
A reoriented copy of the molecule.
Trait Implementations§
source§impl<'de> Deserialize<'de> for Molecule
impl<'de> Deserialize<'de> for Molecule
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<PyMolecule> for Molecule
impl From<PyMolecule> for Molecule
source§fn from(pymol: PyMolecule) -> Self
fn from(pymol: PyMolecule) -> Self
source§impl PartialEq for Molecule
impl PartialEq for Molecule
source§impl PermutableCollection for Molecule
impl PermutableCollection for Molecule
source§fn get_perm_of(&self, other: &Self) -> Option<Permutation<Self::Rank>>
fn get_perm_of(&self, other: &Self) -> Option<Permutation<Self::Rank>>
Determines the permutation of all atoms to map self
to other
. Special fictitious
atoms are included after ordinary atoms, with magnetic atoms before electric atoms.
§Arguments
other
- Another molecule to be compared withself
.
§Returns
Returns a permutation that permutes all atoms of self
to give other
, or None
if no
such permutation exists.
source§fn permute(&self, perm: &Permutation<Self::Rank>) -> Result<Self, Error>
fn permute(&self, perm: &Permutation<Self::Rank>) -> Result<Self, Error>
Permutes all atoms in this molecule (including special fictitious atoms) and places them in a new molecule to be returned.
§Arguments
perm
- A permutation for the atoms. Special fictitious atoms are included after ordinary atoms, with magnetic atoms before electric atoms.
§Returns
A new molecule with the permuted atoms.
§Panics
Panics if the rank of perm
does not match the number of atoms in this molecule, or if the
permutation results in atoms of different kind (e.g. ordinary and magnetic) are permuted
into each other.
source§fn permute_mut(&mut self, perm: &Permutation<Self::Rank>) -> Result<(), Error>
fn permute_mut(&mut self, perm: &Permutation<Self::Rank>) -> Result<(), Error>
Permutes in-place all atoms in this molecule (including special fictitious atoms).
The in-place rearrangement implementation is taken from here.
§Arguments
perm
- A permutation for the atoms. Special fictitious atoms are included after ordinary atoms, with magnetic atoms before electric atoms.
§Panics
Panics if the rank of perm
does not match the number of atoms in this molecule, or if the
permutation results in atoms of different kind (e.g. ordinary and magnetic) are permuted
into each other.
source§impl Transform for Molecule
impl Transform for Molecule
source§fn transform_mut(&mut self, mat: &Matrix3<f64>)
fn transform_mut(&mut self, mat: &Matrix3<f64>)
source§fn improper_rotate_mut(
&mut self,
angle: f64,
axis: &Vector3<f64>,
kind: &ImproperRotationKind,
)
fn improper_rotate_mut( &mut self, angle: f64, axis: &Vector3<f64>, kind: &ImproperRotationKind, )
source§fn translate_mut(&mut self, tvec: &Vector3<f64>)
fn translate_mut(&mut self, tvec: &Vector3<f64>)
source§fn recentre_mut(&mut self)
fn recentre_mut(&mut self)
source§fn reverse_time_mut(&mut self)
fn reverse_time_mut(&mut self)
source§fn transform(&self, mat: &Matrix3<f64>) -> Self
fn transform(&self, mat: &Matrix3<f64>) -> Self
source§fn improper_rotate(
&self,
angle: f64,
axis: &Vector3<f64>,
kind: &ImproperRotationKind,
) -> Self
fn improper_rotate( &self, angle: f64, axis: &Vector3<f64>, kind: &ImproperRotationKind, ) -> Self
source§fn translate(&self, tvec: &Vector3<f64>) -> Self
fn translate(&self, tvec: &Vector3<f64>) -> Self
source§fn recentre(&self) -> Self
fn recentre(&self) -> Self
source§fn reverse_time(&self) -> Self
fn reverse_time(&self) -> Self
Auto Trait Implementations§
impl Freeze for Molecule
impl RefUnwindSafe for Molecule
impl Send for Molecule
impl Sync for Molecule
impl Unpin for Molecule
impl UnwindSafe for Molecule
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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)§impl<T> Conv for T
impl<T> Conv for T
§impl<T> FmtForward for T
impl<T> FmtForward for T
§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self
to use its Binary
implementation when Debug
-formatted.§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self
to use its Display
implementation when
Debug
-formatted.§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self
to use its LowerExp
implementation when
Debug
-formatted.§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self
to use its LowerHex
implementation when
Debug
-formatted.§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self
to use its Octal
implementation when Debug
-formatted.§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self
to use its Pointer
implementation when
Debug
-formatted.§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self
to use its UpperExp
implementation when
Debug
-formatted.§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self
to use its UpperHex
implementation when
Debug
-formatted.§fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read more§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read more§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self
, then passes self.as_ref()
into the pipe function.§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self
, then passes self.as_mut()
into the pipe
function.§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self
, then passes self.deref()
into the pipe function.§impl<T> Pointable for T
impl<T> Pointable for T
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self
from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self
is actually part of its subset T
(and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset
but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self
to the equivalent element of its superset.§impl<T> Tap for T
impl<T> Tap for T
§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B>
of a value. Read more§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B>
of a value. Read more§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R>
view of a value. Read more§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R>
view of a value. Read more§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target
of a value. Read more§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target
of a value. Read more§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap()
only in debug builds, and is erased in release builds.§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut()
only in debug builds, and is erased in release
builds.§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow()
only in debug builds, and is erased in release
builds.§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut()
only in debug builds, and is erased in release
builds.§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref()
only in debug builds, and is erased in release
builds.§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut()
only in debug builds, and is erased in release
builds.§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref()
only in debug builds, and is erased in release
builds.