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(lengths: [f64; 3]) -> Result<UnitCell>
[src]
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>
[src]
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(lengths: [f64; 3], angles: [f64; 3]) -> Result<UnitCell>
[src]
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; 3]>
[src]
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, lengths: [f64; 3]) -> Result<()>
[src]
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; 3]>
[src]
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, angles: [f64; 3]) -> Result<()>
[src]
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]>
[src]
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>
[src]
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<()>
[src]
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::Triclinic).unwrap(); assert_eq!(cell.shape(), Ok(CellShape::Triclinic));
fn volume(&self) -> Result<f64>
[src]
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));
fn wrap(&self, vector: &mut [f64; 3]) -> Result<()>
[src]
Wrap a vector
in this unit cell.
Example
let cell = UnitCell::new([10.0, 20.0, 30.0]).unwrap(); let mut vector = [12.0, 5.2, -45.3]; cell.wrap(&mut vector).unwrap(); assert_eq!(vector, [2.0, 5.2, 14.700000000000003]);
Trait Implementations
impl Clone for UnitCell
[src]
fn clone(&self) -> UnitCell
[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more