11
11
from typing import Optional , Tuple
12
12
13
13
import numpy as np
14
+ from numba import float64 , vectorize
14
15
15
- from qha .fitting import polynomial_least_square_fitting , apply_finite_strain_fitting
16
- from qha .type_aliases import Vector , Matrix
16
+ from qha .fitting import apply_finite_strain_fitting , polynomial_least_square_fitting
17
+ from qha .type_aliases import Matrix , Vector
17
18
from qha .unit_conversion import gpa_to_ry_b3
18
19
19
20
# ===================== What can be exported? =====================
25
26
]
26
27
27
28
28
- @np . vectorize
29
+ @vectorize ([ float64 ( float64 , float64 )], nopython = True , cache = True )
29
30
def calculate_eulerian_strain (v0 , vs ):
30
31
"""
31
32
Calculate the Eulerian strain (:math:`f`s) of a given volume vector *vs* with respect to a reference volume *v0*,
@@ -42,7 +43,7 @@ def calculate_eulerian_strain(v0, vs):
42
43
return 1 / 2 * ((v0 / vs ) ** (2 / 3 ) - 1 )
43
44
44
45
45
- @np . vectorize
46
+ @vectorize ([ float64 ( float64 , float64 )], nopython = True , cache = True )
46
47
def from_eulerian_strain (v0 , fs ):
47
48
"""
48
49
Calculate the corresponding volumes :math:`V`s from a vector of given Eulerian strains (*fs*)
@@ -157,9 +158,10 @@ class is created, unless user is clear what is being done.
157
158
# r = v_upper / v_max = v_min / v_lower
158
159
v_lower , v_upper = v_min / self ._ratio , v_max * self ._ratio
159
160
# The *v_max* is a reference value here.
160
- s_upper , s_lower = calculate_eulerian_strain (
161
- v_max , v_lower
162
- ), calculate_eulerian_strain (v_max , v_upper )
161
+ s_upper , s_lower = (
162
+ calculate_eulerian_strain (v_max , v_lower ),
163
+ calculate_eulerian_strain (v_max , v_upper ),
164
+ )
163
165
self ._strains = np .linspace (s_lower , s_upper , self ._out_volumes_num )
164
166
self ._out_volumes = from_eulerian_strain (v_max , self ._strains )
165
167
0 commit comments