Struct chemfiles::UnitCell
[−]
[src]
pub struct UnitCell { /* fields omitted */ }
An UnitCell
represent the box containing the atoms, and its periodicity.
An unit cell is fully represented by three lengths (a, b, c); and three angles (alpha, beta, gamma). The angles are stored in degrees, and the lengths in Angstroms.
A cell also has a matricial representation, by projecting the three base vector into an orthonormal base. We choose to represent such matrix as an upper triangular matrix:
| a_x b_x c_x |
| 0 b_y c_y |
| 0 0 c_z |
Methods
impl UnitCell
[src]
fn new(a: f64, b: f64, c: f64) -> Result<UnitCell>
Create an Orthorhombic
UnitCell
from the three lengths, in Angstroms.
Example
let cell = UnitCell::new(30.0, 30.0, 23.0).unwrap(); assert_eq!(cell.lengths(), Ok((30.0, 30.0, 23.0))); assert_eq!(cell.angles(), Ok((90.0, 90.0, 90.0))); assert_eq!(cell.shape(), Ok(CellShape::Orthorhombic));
fn infinite() -> Result<UnitCell>
Create an Infinite
UnitCell
.
Example
let cell = UnitCell::infinite().unwrap(); assert_eq!(cell.lengths(), Ok((0.0, 0.0, 0.0))); assert_eq!(cell.angles(), Ok((90.0, 90.0, 90.0))); assert_eq!(cell.shape(), Ok(CellShape::Infinite));
fn triclinic(
a: f64,
b: f64,
c: f64,
alpha: f64,
beta: f64,
gamma: f64
) -> Result<UnitCell>
a: f64,
b: f64,
c: f64,
alpha: f64,
beta: f64,
gamma: f64
) -> Result<UnitCell>
Create an Triclinic
UnitCell
from the three lengths (in Angstroms)
and three angles (in degree). alpha
is the angle between the vectors
b
and c
; beta
is the between the vectors a
and c
and gamma
is the angle between the vectors a
and b
.
Example
let cell = UnitCell::triclinic(10.0, 10.0, 10.0, 98.0, 99.0, 90.0).unwrap(); assert_eq!(cell.lengths(), Ok((10.0, 10.0, 10.0))); assert_eq!(cell.angles(), Ok((98.0, 99.0, 90.0))); assert_eq!(cell.shape(), Ok(CellShape::Triclinic));
fn lengths(&self) -> Result<(f64, f64, f64)>
Get the three lengths of the cell, in Angstroms.
Example
let cell = UnitCell::new(30.0, 30.0, 23.0).unwrap(); assert_eq!(cell.lengths(), Ok((30.0, 30.0, 23.0)));
fn set_lengths(&mut self, a: f64, b: f64, c: f64) -> Result<()>
Set the three lengths of the cell, in Angstroms.
Example
let mut cell = UnitCell::new(30.0, 30.0, 23.0).unwrap(); cell.set_lengths(10.0, 30.0, 42.0).unwrap(); assert_eq!(cell.lengths(), Ok((10.0, 30.0, 42.0)));
fn angles(&self) -> Result<(f64, f64, f64)>
Get the three angles of the cell, in degrees.
Example
let cell = UnitCell::new(20.0, 20.0, 20.0).unwrap(); assert_eq!(cell.angles(), Ok((90.0, 90.0, 90.0))); let cell = UnitCell::triclinic(20.0, 20.0, 20.0, 100.0, 120.0, 90.0).unwrap(); assert_eq!(cell.angles(), Ok((100.0, 120.0, 90.0)));
fn set_angles(&mut self, alpha: f64, beta: f64, gamma: f64) -> Result<()>
Set the three angles of the cell, in degrees. This is only possible
with Triclinic
cells.
Example
let mut cell = UnitCell::triclinic(20.0, 20.0, 20.0, 100.0, 120.0, 90.0).unwrap(); assert_eq!(cell.angles(), Ok((100.0, 120.0, 90.0))); cell.set_angles(90.0, 90.0, 90.0).unwrap(); assert_eq!(cell.angles(), Ok((90.0, 90.0, 90.0)));
fn matrix(&self) -> Result<[[f64; 3]; 3]>
Get the unit cell matricial representation.
The unit cell representation is obtained by aligning the a vector along the x axis and putting the b vector in the xy plane. This make the matrix an upper triangular matrix:
| a_x b_x c_x |
| 0 b_y c_y |
| 0 0 c_z |
Example
let mut cell = UnitCell::new(10.0, 20.0, 30.0).unwrap(); let matrix = cell.matrix().unwrap(); assert_eq!(matrix[0][0], 10.0); assert_eq!(matrix[1][1], 20.0); assert_eq!(matrix[2][2], 30.0); assert!(matrix[1][2].abs() < 1e-9);
fn shape(&self) -> Result<CellShape>
Get the shape of the unit cell.
Example
let cell = UnitCell::new(10.0, 20.0, 30.0).unwrap(); assert_eq!(cell.shape(), Ok(CellShape::Orthorhombic));
fn set_shape(&mut self, shape: CellShape) -> Result<()>
Set the shape of the unit cell to shape
.
Example
let mut cell = UnitCell::new(10.0, 20.0, 30.0).unwrap(); assert_eq!(cell.shape(), Ok(CellShape::Orthorhombic)); cell.set_shape(CellShape::Infinite).unwrap(); assert_eq!(cell.shape(), Ok(CellShape::Infinite));
fn volume(&self) -> Result<f64>
Get the volume of the unit cell.
Example
let cell = UnitCell::new(10.0, 20.0, 30.0).unwrap(); assert_eq!(cell.volume(), Ok(10.0 * 20.0 * 30.0));
Trait Implementations
impl Clone for UnitCell
[src]
fn clone(&self) -> UnitCell
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