[][src]Struct gchemol::Molecule

pub struct Molecule {
    pub properties: PropertyStore,
    pub lattice: Option<Lattice>,
    // some fields omitted
}

Molecule is the most important data structure in gchemol, which repsents "any singular entity, irrespective of its nature, used to concisely express any type of chemical particle that can exemplify some process: for example, atoms, molecules, ions, etc. can all undergo a chemical reaction". Molecule may have chemical bonds between atoms.

Reference

  1. http://goldbook.iupac.org/M03986.html
  2. https://en.wikipedia.org/wiki/Molecular_entity

Fields

properties: PropertyStore

Arbitrary property stored in key-value pair. Key is a string type, but it is the responsibility of the user to correctly interpret the value.

lattice: Option<Lattice>

Crystalline lattice for structure using periodic boundary conditions

Methods

impl Molecule[src]

pub fn formula(&self) -> String[src]

Return the molecule formula represented in string Return empty string if molecule containing no atom

pub fn reduced_symbols(&self) -> HashMap<String, usize, RandomState>[src]

Return a hashmap for counting atom symbols.

impl Molecule[src]

pub fn set_lattice(&mut self, lat: Lattice)[src]

Set periodic lattice

pub fn is_periodic(&self) -> bool[src]

Return true if Molecule is a periodic structure.

pub fn unbuild_crystal(&mut self)[src]

Unbuild current crystal structure leaving a nonperiodic structure

pub fn scaled_positions(&self) -> Option<impl Iterator<Item = [f64; 3]>>[src]

Return fractional coordinates relative to unit cell. Return None if not a periodic structure

pub fn set_scaled_positions<T, P>(&mut self, scaled: T) where
    P: Into<Matrix<f64, U3, U1, <DefaultAllocator as Allocator<f64, U3, U1>>::Buffer>>,
    T: IntoIterator<Item = P>, 
[src]

Set fractional coordinates relative to unit cell.

Panics if Molecule is aperiodic structure.

impl Molecule[src]

pub fn new(name: &str) -> Molecule[src]

Create a new empty molecule with specific name

pub fn add_atom(&mut self, a: usize, atom: Atom)[src]

Add atom a into molecule. If Atom numbered as a already exists in molecule, then the associated Atom will be updated with atom.

pub fn remove_atom(&mut self, a: usize) -> Option<Atom>[src]

Remove Atom a from Molecule.

Return the removed Atom on success, and return None if Atom a does not exist.

pub fn natoms(&self) -> usize[src]

Return the number of atoms in the molecule.

pub fn nbonds(&self) -> usize[src]

Return the number of bonds in the molecule.

pub fn add_bond(&mut self, a: usize, b: usize, bond: Bond)[src]

Add bond between Atom a and Atom b into molecule. The existing Bond will be replaced if Atom a already bonded with Atom b.

Panic if the specified atom a or b does not exist

pub fn remove_bond(&mut self, a: usize, b: usize) -> Option<Bond>[src]

Remove the bond between atom a and atom b.

Returns the removed Bond on success

Panic if the specified atom a or b does not exist

pub fn clear(&mut self)[src]

Remove all atoms and bonds.

pub fn atoms(&self) -> impl Iterator<Item = (usize, &Atom)>[src]

Iterate over atoms ordered by serial numbers.

pub fn bonds(&self) -> impl Iterator<Item = (usize, usize, &Bond)>[src]

Iterate over bonds in arbitrary order.

pub fn serial_numbers(&self) -> impl Iterator<Item = usize>[src]

Iterate over atom serial numbers in ascending order.

pub fn symbols(&self) -> impl Iterator<Item = &str>[src]

Iterate over atom symbols ordered by serial numbers.

pub fn numbers(&self) -> impl Iterator<Item = usize>[src]

Iterate over atomic numbers.

pub fn positions(&self) -> impl Iterator<Item = [f64; 3]>[src]

Iterate over atom positions ordered by serial numbers.

pub fn title(&self) -> String[src]

Return the name of the molecule, while is typpically modified for safely storing in various molecular file formats.

impl Molecule[src]

pub fn get_atom(&self, sn: usize) -> Option<&Atom>[src]

Read access to atom by atom serial number.

pub fn get_atom_mut(&mut self, sn: usize) -> Option<&mut Atom>[src]

Mutable access to atom by atom serial number.

pub fn get_bond(&self, sn1: usize, sn2: usize) -> Option<&Bond>[src]

Read access to bond by a pair of atoms.

pub fn get_bond_mut(&mut self, sn1: usize, sn2: usize) -> Option<&mut Bond>[src]

Mutable access to bond by a pair of atoms.

pub fn set_position<P>(&mut self, sn: usize, position: P) where
    P: Into<Matrix<f64, U3, U1, <DefaultAllocator as Allocator<f64, U3, U1>>::Buffer>>, 
[src]

Set atom position.

Panic if atom sn does not exist.

pub fn set_symbol<S>(&mut self, sn: usize, sym: S) where
    S: Into<AtomKind>, 
[src]

Set atom symbol.

Panic if atom sn does not exist.

pub fn add_atoms_from<T, P>(&mut self, atoms: T) where
    P: Into<Atom>,
    T: IntoIterator<Item = (usize, P)>, 
[src]

Add a list of atoms into molecule.

pub fn from_atoms<T>(atoms: T) -> Molecule where
    T: IntoIterator,
    <T as IntoIterator>::Item: Into<Atom>, 
[src]

Build a molecule from a list of atoms numbered from 1.

pub fn set_title(&mut self, title: &str)[src]

Set molecular title.

pub fn add_bonds_from<T>(&mut self, bonds: T) where
    T: IntoIterator<Item = (usize, usize, Bond)>, 
[src]

Add a list of bonds into molecule.

pub fn set_positions<T, P>(&mut self, positions: T) where
    P: Into<Matrix<f64, U3, U1, <DefaultAllocator as Allocator<f64, U3, U1>>::Buffer>>,
    T: IntoIterator<Item = P>, 
[src]

Set positions of atoms in sequential order.

pub fn set_symbols<T, S>(&mut self, symbols: T) where
    S: Into<AtomKind>,
    T: IntoIterator<Item = S>, 
[src]

Set element symbols

pub fn remove_atoms_from(&mut self)[src]

pub fn remove_bonds_from(&mut self)[src]

Trait Implementations

impl Clone for Molecule[src]

impl Debug for Molecule[src]

impl Default for Molecule[src]

impl<'de> Deserialize<'de> for Molecule[src]

impl FromFile for Molecule[src]

fn from_file<P>(path: P) -> Result<Molecule, Error> where
    P: AsRef<Path>, 
[src]

Construct molecule from external text file

impl Serialize for Molecule[src]

impl StringIO for Molecule[src]

fn format_as<S>(&self, fmt: S) -> Result<String, Error> where
    S: AsRef<str>, 
[src]

Format molecule as string in specific molecular file format. Return error if cannot format molecule in fmt.

fn parse_from<R, S>(s: R, fmt: S) -> Result<Molecule, Error> where
    R: Read + Seek,
    S: AsRef<str>, 
[src]

construct molecule from string in specific molecular file format.

impl TemplateRendering for Molecule[src]

impl ToFile for Molecule[src]

fn to_file<T>(&self, path: T) -> Result<(), Error> where
    T: AsRef<Path>, 
[src]

Save molecule to an external file

Auto Trait Implementations

impl !RefUnwindSafe for Molecule

impl Send for Molecule

impl Sync for Molecule

impl Unpin for Molecule

impl UnwindSafe for Molecule

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

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

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

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

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,