tau2 1.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- tau2/__init__.py +0 -0
- tau2/__main__.py +5 -0
- tau2/__version__.py +3 -0
- tau2/calculation_setup.py +73 -0
- tau2/cli.py +799 -0
- tau2/constants.py +17 -0
- tau2/electronic_structure.py +181 -0
- tau2/files.py +424 -0
- tau2/hysteresis.py +625 -0
- tau2/lineshapes.py +141 -0
- tau2/main.py +494 -0
- tau2/orbach_calculator.py +421 -0
- tau2/parameters.py +48 -0
- tau2/plotting.py +1121 -0
- tau2/raman_calculator.py +1148 -0
- tau2/rates_calculator.py +238 -0
- tau2/utils.py +99 -0
- tau2-1.0.0.dist-info/METADATA +124 -0
- tau2-1.0.0.dist-info/RECORD +22 -0
- tau2-1.0.0.dist-info/WHEEL +5 -0
- tau2-1.0.0.dist-info/entry_points.txt +2 -0
- tau2-1.0.0.dist-info/top_level.txt +1 -0
tau2/__init__.py
ADDED
|
File without changes
|
tau2/__main__.py
ADDED
tau2/__version__.py
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import numpy as np
|
|
2
|
+
from scipy.spatial.transform import Rotation
|
|
3
|
+
|
|
4
|
+
from .constants import MU_B_CM_T, G_E
|
|
5
|
+
|
|
6
|
+
def setup_field_orientation(args, angmom, spin, orientations=1):
|
|
7
|
+
"""Determines the field direction and magnitudes for the calculation.
|
|
8
|
+
|
|
9
|
+
This function handles the g-tensor reorientation to align the calculation's
|
|
10
|
+
z-axis with the principal magnetic axis of the ground state doublet. It also
|
|
11
|
+
interprets user-provided field vectors and magnitudes from the command line.
|
|
12
|
+
|
|
13
|
+
Args:
|
|
14
|
+
args (argparse.Namespace): The parsed command-line arguments.
|
|
15
|
+
angmom (np.ndarray): The angular momentum matrices (L_x, L_y, L_z).
|
|
16
|
+
spin (np.ndarray): The spin matrices (S_x, S_y, S_z).
|
|
17
|
+
orientations (int): The number of orientations being calculated.
|
|
18
|
+
|
|
19
|
+
Returns:
|
|
20
|
+
tuple: A tuple containing:
|
|
21
|
+
- B_unit (np.ndarray): The normalised field direction vector for a single calculation.
|
|
22
|
+
- magnitudes_to_run (list): A list of field magnitudes (in Tesla).
|
|
23
|
+
- rotation_matrix (np.ndarray): The matrix to rotate from the input to the principal axis frame.
|
|
24
|
+
"""
|
|
25
|
+
rotation_matrix = np.identity(3)
|
|
26
|
+
principal_frame_z_axis = np.array([0.0, 0.0, 1.0])
|
|
27
|
+
|
|
28
|
+
if args.reorient:
|
|
29
|
+
print("\nReorienting: z-axis will be aligned with the principal g-tensor axis.")
|
|
30
|
+
mu_op = MU_B_CM_T * (angmom + G_E * spin)
|
|
31
|
+
mu_op_doublet = mu_op[:, 0:2, 0:2]
|
|
32
|
+
g_tensor = 2 * np.real(np.einsum('kab,lba->kl', mu_op_doublet, mu_op_doublet))
|
|
33
|
+
g_squared = g_tensor.T @ g_tensor
|
|
34
|
+
eigvals, eigvecs = np.linalg.eigh(g_squared)
|
|
35
|
+
|
|
36
|
+
principal_axis = eigvecs[:, np.argmax(eigvals)]
|
|
37
|
+
print(f"Principal g-axis in input frame: [{principal_axis[0]:.4f}, {principal_axis[1]:.4f}, {principal_axis[2]:.4f}]")
|
|
38
|
+
|
|
39
|
+
r, _ = Rotation.align_vectors([principal_axis], [principal_frame_z_axis])
|
|
40
|
+
rotation_matrix = r.as_matrix()
|
|
41
|
+
|
|
42
|
+
if args.field_direction:
|
|
43
|
+
if orientations == 1:
|
|
44
|
+
print("Using user-provided --field_direction relative to the principal axis frame.")
|
|
45
|
+
field_direction_principal_frame = np.array(args.field_direction)
|
|
46
|
+
else:
|
|
47
|
+
field_direction_principal_frame = principal_frame_z_axis
|
|
48
|
+
|
|
49
|
+
field_direction_input_frame = rotation_matrix @ field_direction_principal_frame
|
|
50
|
+
norm = np.linalg.norm(field_direction_principal_frame)
|
|
51
|
+
|
|
52
|
+
if norm < 1e-9:
|
|
53
|
+
if orientations == 1:
|
|
54
|
+
print("Warning: Field direction vector has zero magnitude. Using principal frame z-axis.")
|
|
55
|
+
B_unit = rotation_matrix.T @ principal_frame_z_axis
|
|
56
|
+
B_unit_principal = principal_frame_z_axis
|
|
57
|
+
else:
|
|
58
|
+
B_unit = field_direction_input_frame / np.linalg.norm(field_direction_input_frame)
|
|
59
|
+
B_unit_principal = field_direction_principal_frame / norm
|
|
60
|
+
|
|
61
|
+
if orientations == 1:
|
|
62
|
+
print("\nNormalised field direction:")
|
|
63
|
+
print(f" principal axis frame:\t[{B_unit_principal[0]:.4f}, {B_unit_principal[1]:.4f}, {B_unit_principal[2]:.4f}]")
|
|
64
|
+
print(f" input frame:\t\t[{B_unit[0]:.4f}, {B_unit[1]:.4f}, {B_unit[2]:.4f}]")
|
|
65
|
+
|
|
66
|
+
if args.field_magnitudes:
|
|
67
|
+
magnitudes_to_run = args.field_magnitudes
|
|
68
|
+
elif args.field_direction:
|
|
69
|
+
magnitudes_to_run = [norm]
|
|
70
|
+
else:
|
|
71
|
+
magnitudes_to_run = [0.0002]
|
|
72
|
+
|
|
73
|
+
return B_unit, magnitudes_to_run, rotation_matrix
|