qsym2/auxiliary/
template_molecules.rs

1//! Template molecules for testing purposes.
2
3#[cfg(test)]
4use crate::auxiliary::atom::{Atom, AtomKind, ElementMap};
5#[cfg(test)]
6use crate::auxiliary::molecule::Molecule;
7#[cfg(test)]
8use nalgebra::Point3;
9
10#[must_use]
11#[cfg(test)]
12pub(crate) fn gen_twisted_h8(theta: f64) -> Molecule {
13    let emap = ElementMap::new();
14    let (atomic_number, atomic_mass) = emap.get("H").expect("Unable to retrieve element.");
15    let atoms: [Atom; 8] = [
16        Atom {
17            kind: AtomKind::Ordinary,
18            atomic_number: *atomic_number,
19            atomic_symbol: "H".to_owned(),
20            atomic_mass: *atomic_mass,
21            coordinates: Point3::new(0.0, 0.0, 0.0),
22            threshold: 1e-7,
23        },
24        Atom {
25            kind: AtomKind::Ordinary,
26            atomic_number: *atomic_number,
27            atomic_symbol: "H".to_owned(),
28            atomic_mass: *atomic_mass,
29            coordinates: Point3::new(1.0, 0.0, 0.0),
30            threshold: 1e-7,
31        },
32        Atom {
33            kind: AtomKind::Ordinary,
34            atomic_number: *atomic_number,
35            atomic_symbol: "H".to_owned(),
36            atomic_mass: *atomic_mass,
37            coordinates: Point3::new(1.0, 1.0, 0.0),
38            threshold: 1e-7,
39        },
40        Atom {
41            kind: AtomKind::Ordinary,
42            atomic_number: *atomic_number,
43            atomic_symbol: "H".to_owned(),
44            atomic_mass: *atomic_mass,
45            coordinates: Point3::new(0.0, 1.0, 0.0),
46            threshold: 1e-7,
47        },
48        Atom {
49            kind: AtomKind::Ordinary,
50            atomic_number: *atomic_number,
51            atomic_symbol: "H".to_owned(),
52            atomic_mass: *atomic_mass,
53            coordinates: Point3::new(
54                1.0 / (2.0_f64.sqrt()) * (5.0 * std::f64::consts::FRAC_PI_4 + theta).cos() + 0.5,
55                1.0 / (2.0_f64.sqrt()) * (5.0 * std::f64::consts::FRAC_PI_4 + theta).sin() + 0.5,
56                2.0,
57            ),
58            threshold: 1e-7,
59        },
60        Atom {
61            kind: AtomKind::Ordinary,
62            atomic_number: *atomic_number,
63            atomic_symbol: "H".to_owned(),
64            atomic_mass: *atomic_mass,
65            coordinates: Point3::new(
66                1.0 / (2.0_f64.sqrt()) * (7.0 * std::f64::consts::FRAC_PI_4 + theta).cos() + 0.5,
67                1.0 / (2.0_f64.sqrt()) * (7.0 * std::f64::consts::FRAC_PI_4 + theta).sin() + 0.5,
68                2.0,
69            ),
70            threshold: 1e-7,
71        },
72        Atom {
73            kind: AtomKind::Ordinary,
74            atomic_number: *atomic_number,
75            atomic_symbol: "H".to_owned(),
76            atomic_mass: *atomic_mass,
77            coordinates: Point3::new(
78                1.0 / (2.0_f64.sqrt()) * (1.0 * std::f64::consts::FRAC_PI_4 + theta).cos() + 0.5,
79                1.0 / (2.0_f64.sqrt()) * (1.0 * std::f64::consts::FRAC_PI_4 + theta).sin() + 0.5,
80                2.0,
81            ),
82            threshold: 1e-7,
83        },
84        Atom {
85            kind: AtomKind::Ordinary,
86            atomic_number: *atomic_number,
87            atomic_symbol: "H".to_owned(),
88            atomic_mass: *atomic_mass,
89            coordinates: Point3::new(
90                1.0 / (2.0_f64.sqrt()) * (3.0 * std::f64::consts::FRAC_PI_4 + theta).cos() + 0.5,
91                1.0 / (2.0_f64.sqrt()) * (3.0 * std::f64::consts::FRAC_PI_4 + theta).sin() + 0.5,
92                2.0,
93            ),
94            threshold: 1e-7,
95        },
96    ];
97    Molecule::from_atoms(&atoms, 1e-7)
98}
99
100#[must_use]
101#[cfg(test)]
102pub(crate) fn gen_arbitrary_half_sandwich(n: u32) -> Molecule {
103    let emap = ElementMap::new();
104    let mut atoms: Vec<Atom> = vec![];
105    let (h_atomic_number, h_atomic_mass) = emap.get("H").expect("Unable to retrieve element.");
106    let (c_atomic_number, c_atomic_mass) = emap.get("C").expect("Unable to retrieve element.");
107    let (v_atomic_number, v_atomic_mass) = emap.get("V").expect("Unable to retrieve element.");
108    atoms.push(Atom {
109        kind: AtomKind::Ordinary,
110        atomic_number: *v_atomic_number,
111        atomic_symbol: "V".to_owned(),
112        atomic_mass: *v_atomic_mass,
113        coordinates: Point3::new(0.0, 0.0, 1.0 + 0.1 * (f64::from(n))),
114        threshold: 1e-7,
115    });
116    for i in 0..n {
117        atoms.push(Atom {
118            kind: AtomKind::Ordinary,
119            atomic_number: *c_atomic_number,
120            atomic_symbol: "C".to_owned(),
121            atomic_mass: *c_atomic_mass,
122            coordinates: Point3::new(
123                1.0 * ((f64::from(i)) * 2.0 * std::f64::consts::PI / (f64::from(n))).cos(),
124                1.0 * ((f64::from(i)) * 2.0 * std::f64::consts::PI / (f64::from(n))).sin(),
125                0.0,
126            ),
127            threshold: 1e-7,
128        });
129        atoms.push(Atom {
130            kind: AtomKind::Ordinary,
131            atomic_number: *h_atomic_number,
132            atomic_symbol: "H".to_owned(),
133            atomic_mass: *h_atomic_mass,
134            coordinates: Point3::new(
135                1.5 * ((f64::from(i)) * 2.0 * std::f64::consts::PI / (f64::from(n))).cos(),
136                1.5 * ((f64::from(i)) * 2.0 * std::f64::consts::PI / (f64::from(n))).sin(),
137                0.0,
138            ),
139            threshold: 1e-7,
140        });
141    }
142    Molecule::from_atoms(&atoms, 1e-7)
143}
144
145#[must_use]
146#[cfg(test)]
147pub(crate) fn gen_arbitrary_eclipsed_sandwich(n: u32) -> Molecule {
148    let emap = ElementMap::new();
149    let mut atoms: Vec<Atom> = vec![];
150    let (h_atomic_number, h_atomic_mass) = emap.get("H").expect("Unable to retrieve element.");
151    let (c_atomic_number, c_atomic_mass) = emap.get("C").expect("Unable to retrieve element.");
152    let (m_atomic_number, m_atomic_mass) = emap.get("Co").expect("Unable to retrieve element.");
153    atoms.push(Atom {
154        kind: AtomKind::Ordinary,
155        atomic_number: *m_atomic_number,
156        atomic_symbol: "Co".to_owned(),
157        atomic_mass: *m_atomic_mass,
158        coordinates: Point3::new(0.0, 0.0, 0.0),
159        threshold: 1e-7,
160    });
161    for i in 0..n {
162        atoms.push(Atom {
163            kind: AtomKind::Ordinary,
164            atomic_number: *c_atomic_number,
165            atomic_symbol: "C".to_owned(),
166            atomic_mass: *c_atomic_mass,
167            coordinates: Point3::new(
168                1.0 * ((f64::from(i)) * 2.0 * std::f64::consts::PI / (f64::from(n))).cos(),
169                1.0 * ((f64::from(i)) * 2.0 * std::f64::consts::PI / (f64::from(n))).sin(),
170                -1.0 - 0.1 * (f64::from(n)),
171            ),
172            threshold: 1e-7,
173        });
174        atoms.push(Atom {
175            kind: AtomKind::Ordinary,
176            atomic_number: *h_atomic_number,
177            atomic_symbol: "H".to_owned(),
178            atomic_mass: *h_atomic_mass,
179            coordinates: Point3::new(
180                1.5 * ((f64::from(i)) * 2.0 * std::f64::consts::PI / (f64::from(n))).cos(),
181                1.5 * ((f64::from(i)) * 2.0 * std::f64::consts::PI / (f64::from(n))).sin(),
182                -1.0 - 0.1 * (f64::from(n)),
183            ),
184            threshold: 1e-7,
185        });
186        atoms.push(Atom {
187            kind: AtomKind::Ordinary,
188            atomic_number: *c_atomic_number,
189            atomic_symbol: "C".to_owned(),
190            atomic_mass: *c_atomic_mass,
191            coordinates: Point3::new(
192                1.0 * ((f64::from(i)) * 2.0 * std::f64::consts::PI / (f64::from(n))).cos(),
193                1.0 * ((f64::from(i)) * 2.0 * std::f64::consts::PI / (f64::from(n))).sin(),
194                1.0 + 0.1 * (f64::from(n)),
195            ),
196            threshold: 1e-7,
197        });
198        atoms.push(Atom {
199            kind: AtomKind::Ordinary,
200            atomic_number: *h_atomic_number,
201            atomic_symbol: "H".to_owned(),
202            atomic_mass: *h_atomic_mass,
203            coordinates: Point3::new(
204                1.5 * ((f64::from(i)) * 2.0 * std::f64::consts::PI / (f64::from(n))).cos(),
205                1.5 * ((f64::from(i)) * 2.0 * std::f64::consts::PI / (f64::from(n))).sin(),
206                1.0 + 0.1 * (f64::from(n)),
207            ),
208            threshold: 1e-7,
209        });
210    }
211    Molecule::from_atoms(&atoms, 1e-7)
212}
213
214#[must_use]
215#[cfg(test)]
216pub fn gen_arbitrary_twisted_sandwich(n: u32, frac: f64) -> Molecule {
217    let emap = ElementMap::new();
218    let mut atoms: Vec<Atom> = vec![];
219    let (h_atomic_number, h_atomic_mass) = emap.get("H").expect("Unable to retrieve element.");
220    let (c_atomic_number, c_atomic_mass) = emap.get("C").expect("Unable to retrieve element.");
221    let (m_atomic_number, m_atomic_mass) = emap.get("Co").expect("Unable to retrieve element.");
222    atoms.push(Atom {
223        kind: AtomKind::Ordinary,
224        atomic_number: *m_atomic_number,
225        atomic_symbol: "Co".to_owned(),
226        atomic_mass: *m_atomic_mass,
227        coordinates: Point3::new(0.0, 0.0, 0.0),
228        threshold: 1e-7,
229    });
230    for i in 0..n {
231        atoms.push(Atom {
232            kind: AtomKind::Ordinary,
233            atomic_number: *c_atomic_number,
234            atomic_symbol: "C".to_owned(),
235            atomic_mass: *c_atomic_mass,
236            coordinates: Point3::new(
237                1.0 * ((f64::from(i)) * 2.0 * std::f64::consts::PI / (f64::from(n))).cos(),
238                1.0 * ((f64::from(i)) * 2.0 * std::f64::consts::PI / (f64::from(n))).sin(),
239                -1.0 - 0.1 * (f64::from(n)),
240            ),
241            threshold: 1e-7,
242        });
243        atoms.push(Atom {
244            kind: AtomKind::Ordinary,
245            atomic_number: *h_atomic_number,
246            atomic_symbol: "H".to_owned(),
247            atomic_mass: *h_atomic_mass,
248            coordinates: Point3::new(
249                1.5 * ((f64::from(i)) * 2.0 * std::f64::consts::PI / (f64::from(n))).cos(),
250                1.5 * ((f64::from(i)) * 2.0 * std::f64::consts::PI / (f64::from(n))).sin(),
251                -1.0 - 0.1 * (f64::from(n)),
252            ),
253            threshold: 1e-7,
254        });
255        atoms.push(Atom {
256            kind: AtomKind::Ordinary,
257            atomic_number: *c_atomic_number,
258            atomic_symbol: "C".to_owned(),
259            atomic_mass: *c_atomic_mass,
260            coordinates: Point3::new(
261                1.0 * ((f64::from(i) + frac) * 2.0 * std::f64::consts::PI / (f64::from(n))).cos(),
262                1.0 * ((f64::from(i) + frac) * 2.0 * std::f64::consts::PI / (f64::from(n))).sin(),
263                1.0 + 0.1 * (f64::from(n)),
264            ),
265            threshold: 1e-7,
266        });
267        atoms.push(Atom {
268            kind: AtomKind::Ordinary,
269            atomic_number: *h_atomic_number,
270            atomic_symbol: "H".to_owned(),
271            atomic_mass: *h_atomic_mass,
272            coordinates: Point3::new(
273                1.5 * ((f64::from(i) + frac) * 2.0 * std::f64::consts::PI / (f64::from(n))).cos(),
274                1.5 * ((f64::from(i) + frac) * 2.0 * std::f64::consts::PI / (f64::from(n))).sin(),
275                1.0 + 0.1 * (f64::from(n)),
276            ),
277            threshold: 1e-7,
278        });
279    }
280    Molecule::from_atoms(&atoms, 1e-7)
281}