1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
//! Interface that electronic structure codes should implement.
use transmute;
use ;
use *;
/// Gradient output from the electronic structure code.
///
/// - `energy`: The energy of the system, scalar.
/// - `gradient`: The gradient of the system, flattened (natom * 3), with
/// dimension of coordinate (3) to be contiguous.
/// Trait API to be implemented in electronic structure code for geomeTRIC PyO3
/// binding.
/// Python wrapper for the `GeomDriverAPI` trait implementations.
///
/// `GeomDriverAPI` is defined as rust trait, which is not directly usable in
/// Python. This makes the glue between the rust trait and the python class.
///
/// # Safety
///
/// This struct is marked as `unsafe` because it uses `transmute` to convert
/// local lifetime to static lifetime.
///
/// If your class (to be implemented with trait `GeomDriverAPI`) have lifetime
/// parameters, then this lifetime will be transmuted to static lifetime when it
/// is converted to python object. As long as you don't disturb the lifetime of
/// reference, this transmute should be safe.