qrotor 4.0.0a1__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.
Potentially problematic release.
This version of qrotor might be problematic. Click here for more details.
- qrotor/__init__.py +14 -0
- qrotor/_version.py +14 -0
- qrotor/constants.py +72 -0
- qrotor/plot.py +337 -0
- qrotor/potential.py +473 -0
- qrotor/rotate.py +202 -0
- qrotor/solve.py +271 -0
- qrotor/system.py +275 -0
- qrotor/systems.py +245 -0
- qrotor-4.0.0a1.dist-info/METADATA +167 -0
- qrotor-4.0.0a1.dist-info/RECORD +16 -0
- qrotor-4.0.0a1.dist-info/WHEEL +5 -0
- qrotor-4.0.0a1.dist-info/licenses/LICENSE +661 -0
- qrotor-4.0.0a1.dist-info/top_level.txt +2 -0
- tests/__init__.py +0 -0
- tests/test_qrotor.py +101 -0
tests/test_qrotor.py
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import aton.qrotor as qr
|
|
2
|
+
import aton.api as api
|
|
3
|
+
import aton.txt.extract as extract
|
|
4
|
+
import aton.file as file
|
|
5
|
+
import numpy as np
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
folder = 'tests/samples/'
|
|
9
|
+
structure = folder + 'CH3NH3.in'
|
|
10
|
+
structure_120 = folder + 'CH3NH3_120.in'
|
|
11
|
+
structure_60 = folder + 'CH3NH3_60.in'
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def test_rotate():
|
|
15
|
+
CH3 = [
|
|
16
|
+
'0.100 0.183 0.316',
|
|
17
|
+
'0.151 0.532 0.842',
|
|
18
|
+
'0.118 0.816 0.277',
|
|
19
|
+
]
|
|
20
|
+
# 120 degrees (it should remain the same)
|
|
21
|
+
qr.rotate.structure_qe(filepath=structure, positions=CH3, angle=120, precision=2)
|
|
22
|
+
for coord in CH3:
|
|
23
|
+
rotated_coord = api.qe.get_atom(filepath=structure_120, position=coord, precision=2)
|
|
24
|
+
rotated_coord = extract.coords(rotated_coord)
|
|
25
|
+
coord = extract.coords(coord)
|
|
26
|
+
rotated_coord_rounded = []
|
|
27
|
+
coord_rounded = []
|
|
28
|
+
for i in rotated_coord:
|
|
29
|
+
rotated_coord_rounded.append(round(i, 2))
|
|
30
|
+
for i in coord:
|
|
31
|
+
coord_rounded.append(round(i, 2))
|
|
32
|
+
assert coord_rounded == rotated_coord_rounded
|
|
33
|
+
file.remove(structure_120)
|
|
34
|
+
|
|
35
|
+
# 60 degrees (it should change quite a lot)
|
|
36
|
+
ideal = [
|
|
37
|
+
'0.146468644022416 0.837865866372631 0.641449758215011',
|
|
38
|
+
'0.095062781582172 0.488975944606740 0.115053787468686',
|
|
39
|
+
'0.128156574395412 0.205890189020629 0.680672454316303',
|
|
40
|
+
]
|
|
41
|
+
qr.rotate.structure_qe(filepath=structure, positions=CH3, angle=60, precision=2)
|
|
42
|
+
for coord in ideal:
|
|
43
|
+
rotated_coord = api.qe.get_atom(filepath=structure_60, position=coord, precision=3)
|
|
44
|
+
rotated_coord = extract.coords(rotated_coord)
|
|
45
|
+
coord = extract.coords(coord)
|
|
46
|
+
rotated_coord_rounded = []
|
|
47
|
+
coord_rounded = []
|
|
48
|
+
for i in rotated_coord:
|
|
49
|
+
rotated_coord_rounded.append(round(i, 2))
|
|
50
|
+
for i in coord:
|
|
51
|
+
coord_rounded.append(round(i, 2))
|
|
52
|
+
assert coord_rounded == rotated_coord_rounded
|
|
53
|
+
file.remove(structure_60)
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
def test_solve_zero():
|
|
57
|
+
system = qr.System()
|
|
58
|
+
system.gridsize = 50000
|
|
59
|
+
system.potential_name = 'zero'
|
|
60
|
+
system.B = 1
|
|
61
|
+
system.solve()
|
|
62
|
+
assert round(system.eigenvalues[0], 2) == 0.0
|
|
63
|
+
assert round(system.eigenvalues[1], 2) == 1.0
|
|
64
|
+
assert round(system.eigenvalues[2], 2) == 1.0
|
|
65
|
+
assert round(system.eigenvalues[3], 2) == 4.0
|
|
66
|
+
assert round(system.eigenvalues[4], 2) == 4.0
|
|
67
|
+
assert round(system.eigenvalues[5], 2) == 9.0
|
|
68
|
+
assert round(system.eigenvalues[6], 2) == 9.0
|
|
69
|
+
assert round(system.eigenvalues[7], 2) == 16.0
|
|
70
|
+
assert round(system.eigenvalues[8], 2) == 16.0
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
def test_solve_potential():
|
|
74
|
+
system = qr.System()
|
|
75
|
+
system.gridsize = 500
|
|
76
|
+
system.potential_name = 'sin'
|
|
77
|
+
system.potential_constants = [0, 1, 3, 0]
|
|
78
|
+
system.solve_potential()
|
|
79
|
+
assert round(system.potential_max, 2) == 1.0
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
def test_phase():
|
|
83
|
+
sys = qr.System()
|
|
84
|
+
sys.B = 1.0
|
|
85
|
+
sys.potential_name = 'cos'
|
|
86
|
+
sys.gridsize = 10000
|
|
87
|
+
sys.solve()
|
|
88
|
+
# plus pi/2, which will be -3pi/2
|
|
89
|
+
sys.change_phase(0.5)
|
|
90
|
+
assert round(sys.grid[0], 2) == round(-np.pi * 3/2, 2)
|
|
91
|
+
# The first potential value should be 0,
|
|
92
|
+
# but remember that the potential offset is corrected
|
|
93
|
+
# so it should be half potential_max, so 1.0/2
|
|
94
|
+
assert round(sys.potential_values[0], 2) == 0.5
|
|
95
|
+
# minus pi, which will become -pi/2
|
|
96
|
+
sys.change_phase(-1)
|
|
97
|
+
assert round(sys.grid[0], 2) == round(-np.pi/2, 2)
|
|
98
|
+
assert round(sys.potential_values[0], 2) == 0.5
|
|
99
|
+
# Were eigenvalues calculated?
|
|
100
|
+
assert len(sys.eigenvalues) > 0
|
|
101
|
+
|