chemrust_core/data/lattice/cell_param/
reciprocal_cell.rs

1mod recip_cell_constant;
2mod recip_cell_vectors;
3
4use nalgebra::Matrix3;
5pub use recip_cell_constant::ReciprocalCellConstant;
6pub use recip_cell_vectors::ReciprocalCellVectors;
7
8/// Traits that a struct to represent
9/// reciprocal cell parameters.
10pub trait ReciprocalCellParams {
11    /// Return the reciprocal lattice vectors
12    /// in `nalgebra::Matrix3<f64>`
13    fn lattice_bases(&self) -> Matrix3<f64>;
14    fn length_a(&self) -> f64;
15    fn length_b(&self) -> f64;
16    fn length_c(&self) -> f64;
17    fn angle_alpha(&self) -> f64;
18    fn angle_beta(&self) -> f64;
19    fn angle_gamma(&self) -> f64;
20}
21
22#[cfg(test)]
23mod test {
24    use core::f64;
25
26    use nalgebra::Matrix3;
27
28    use crate::data::lattice::{
29        cell_param::reciprocal_cell::ReciprocalCellVectors, CellConstants, LatticeVectors,
30        ReciprocalCellConstant, UnitCellParameters,
31    };
32
33    #[test]
34    fn test_recip_lat() {
35        let lattice_vectors = LatticeVectors::new(Matrix3::<f64>::new(
36            9.999_213_039_981,
37            0.0,
38            0.0,
39            0.0,
40            9.999_213_039_981,
41            0.0,
42            0.0,
43            0.0,
44            16.395_185_930_251_127,
45        ));
46        println!("{:?}", lattice_vectors);
47        let cell_consts = CellConstants::from(lattice_vectors.tensor);
48        println!("{:?}", cell_consts);
49        println!(
50            "cell_volume from lattice_vectors: {}",
51            lattice_vectors.cell_volume()
52        );
53        println!(
54            "cell_volume from cell_consts: {}",
55            cell_consts.cell_volume()
56        );
57        let recip_vectors = ReciprocalCellVectors::from(lattice_vectors);
58        println!("{:?}", recip_vectors);
59        let recip_consts = ReciprocalCellConstant::from(lattice_vectors);
60        println!("{:?}", recip_consts);
61    }
62}