Struct chemfiles::Atom
[−]
[src]
pub struct Atom { /* fields omitted */ }
An Atom
is a particle in the current Frame
. It stores the following
atomic properties:
- atom name;
- atom type;
- atom mass;
- atom charge.
The atom name is usually an unique identifier (H1
, C_a
) while the
atom type will be shared between all particles of the same type: H
,
Ow
, CH3
.
Methods
impl Atom
[src]
fn new<'a, S>(name: S) -> Result<Atom> where
S: Into<&'a str>,
S: Into<&'a str>,
Create an atom with the given name
, and set the atom type to name
.
Example
let atom = Atom::new("He").unwrap(); assert_eq!(atom.name(), Ok(String::from("He")));
fn mass(&self) -> Result<f64>
Get the atom mass, in atomic mass units.
Example
let atom = Atom::new("He").unwrap(); assert_eq!(atom.mass(), Ok(4.002602));
fn set_mass(&mut self, mass: f64) -> Result<()>
Set the atom mass to mass
, in atomic mass units.
Example
let mut atom = Atom::new("He").unwrap(); atom.set_mass(34.9).unwrap(); assert_eq!(atom.mass(), Ok(34.9));
fn charge(&self) -> Result<f64>
Get the atom charge, in number of the electron charge e.
Example
let atom = Atom::new("He").unwrap(); assert_eq!(atom.charge(), Ok(0.0));
fn set_charge(&mut self, charge: f64) -> Result<()>
Set the atom charge to charge
, in number of the electron charge e.
Example
let mut atom = Atom::new("He").unwrap(); atom.set_charge(-2.0).unwrap(); assert_eq!(atom.charge(), Ok(-2.0));
fn name(&self) -> Result<String>
Get the atom name.
Example
let atom = Atom::new("He").unwrap(); assert_eq!(atom.name(), Ok(String::from("He")));
fn atomic_type(&self) -> Result<String>
Get the atom type.
Example
let atom = Atom::new("He").unwrap(); assert_eq!(atom.atomic_type(), Ok(String::from("He")));
fn set_name<'a, S>(&mut self, name: S) -> Result<()> where
S: Into<&'a str>,
S: Into<&'a str>,
Set the atom name to name
.
Example
let mut atom = Atom::new("He").unwrap(); atom.set_name("Zn3").unwrap(); assert_eq!(atom.name(), Ok(String::from("Zn3")));
fn set_atomic_type<'a, S>(&mut self, atomic_type: S) -> Result<()> where
S: Into<&'a str>,
S: Into<&'a str>,
Set the atom type to atomic_type
.
Example
let mut atom = Atom::new("He").unwrap(); atom.set_atomic_type("F").unwrap(); assert_eq!(atom.atomic_type(), Ok(String::from("F")));
fn full_name(&self) -> Result<String>
Try to get the full name of the atom from the atomic type. For example, the full name of "He" is "Helium", and so on. If the name can not be found, this function returns the empty string.
Example
let atom = Atom::new("Zn").unwrap(); assert_eq!(atom.full_name(), Ok(String::from("Zinc")));
fn vdw_radius(&self) -> Result<f64>
Try to get the Van der Waals radius of the atom from the atomic type. If the radius can not be found, returns -1.
Example
let atom = Atom::new("He").unwrap(); assert_eq!(atom.vdw_radius(), Ok(1.4));
fn covalent_radius(&self) -> Result<f64>
Try to get the covalent radius of the atom from the atomic type. If the radius can not be found, returns -1.
Example
let atom = Atom::new("He").unwrap(); assert_eq!(atom.covalent_radius(), Ok(0.32));
fn atomic_number(&self) -> Result<i64>
Try to get the atomic number of the atom from the atomic type. If the number can not be found, returns -1.
Example
let atom = Atom::new("He").unwrap(); assert_eq!(atom.atomic_number(), Ok(2));
Trait Implementations
impl Clone for Atom
[src]
fn clone(&self) -> Atom
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more