qrotor 4.0.1__tar.gz → 4.0.2__tar.gz

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.

@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: qrotor
3
- Version: 4.0.1
3
+ Version: 4.0.2
4
4
  Summary: QRotor
5
5
  Author: Pablo Gila-Herranz
6
6
  Author-email: pgila001@ikasle.ehu.eus
@@ -85,13 +85,13 @@ QRotor contains the following modules:
85
85
 
86
86
  | | |
87
87
  | --- | --- |
88
+ | [qrotor.constants](https://pablogila.github.io/qrotor/qrotor/constants.html) | Common bond lengths and inertias |
88
89
  | [qrotor.system](https://pablogila.github.io/qrotor/qrotor/system.html) | Definition of the quantum `System` object |
89
- | [qrotor.systems](https://pablogila.github.io/qrotor/qrotor/systems.html) | Functions to manage several System objects, such as a list of systems |
90
+ | [qrotor.systems](https://pablogila.github.io/qrotor/qrotor/systems.html) | Utilities to manage several System objects, such as a list of systems |
90
91
  | [qrotor.rotate](https://pablogila.github.io/qrotor/qrotor/rotate.html) | Rotate specific atoms from structural files |
91
- | [qrotor.constants](https://pablogila.github.io/qrotor/qrotor/constants.html) | Common bond lengths and inertias |
92
92
  | [qrotor.potential](https://pablogila.github.io/qrotor/qrotor/potential.html) | Potential definitions and loading functions |
93
93
  | [qrotor.solve](https://pablogila.github.io/qrotor/qrotor/solve.html) | Solve rotation eigenvalues and eigenvectors |
94
- | [qrotor.plot](https://pablogila.github.io/qrotor/qrotor/plot.html) | Plotting functions |
94
+ | [qrotor.plot](https://pablogila.github.io/qrotor/qrotor/plot.html) | Plotting utilities |
95
95
 
96
96
  Check the [full documentation online](https://pablogila.github.io/qrotor/).
97
97
 
@@ -103,7 +103,8 @@ Check the [full documentation online](https://pablogila.github.io/qrotor/).
103
103
 
104
104
  ## Solving quantum rotational systems
105
105
 
106
- A basic calculation of the eigenvalues for a zero potential goes as follows.
106
+ Let's start with a basic calculation of the eigenvalues for a zero potential, corresponding to a free rotor.
107
+ A predefined synthetic potential can be used, see all available options in the [qrotor.potential](https://pablogila.github.io/qrotor/qrotor/potential.html) documentation.
107
108
  Note that the default energy unit is meV unless stated otherwise.
108
109
 
109
110
  ```python
@@ -113,7 +114,7 @@ system.gridsize = 200000 # Size of the potential grid
113
114
  system.B = 1 # Rotational inertia
114
115
  system.potential_name = 'zero'
115
116
  system.solve()
116
- system.eigenvalues
117
+ print(system.eigenvalues)
117
118
  # [0.0, 1.0, 1.0, 4.0, 4.0, 9.0, 9.0, ...] # approx values
118
119
  ```
119
120
 
@@ -126,10 +127,10 @@ in a cosine potential of amplitude 30 meV:
126
127
  ```python
127
128
  import qrotor as qr
128
129
  system = qr.System()
129
- system.gridsize = 200000 # Size of the potential grid
130
+ system.gridsize = 200000
130
131
  system.B = qr.B_CH3 # Rotational inertia of a methyl group
131
132
  system.potential_name = 'cosine'
132
- system.potential_constants = [0, 30, 3, 0] # Offset, max, freq, phase (for cos pot.)
133
+ system.potential_constants = [0, 30, 3, 0] # Offset, max, freq, phase (for cosine potential)
133
134
  system.solve()
134
135
  # Plot potential and eigenvalues
135
136
  qr.plot.energies(system)
@@ -141,7 +142,7 @@ qr.plot.wavefunction(system, levels=[0,1,2], square=True)
141
142
  ## Custom potentials from DFT
142
143
 
143
144
  QRotor can be used to obtain custom rotational potentials from DFT calculations.
144
- Using Quantum ESPRESSO, running an SCF calculation for a methyl rotation every 10 degrees:
145
+ To run a Quantum ESPRESSO SCF calculation for a methyl rotation every 10 degrees:
145
146
 
146
147
  ```python
147
148
  import qrotor as qr
@@ -160,10 +161,8 @@ api.slurm.sbatch(files=scf_files)
160
161
 
161
162
  To load the calculated potential to a QRotor System,
162
163
  ```python
163
- # Compile a 'potential.csv' file with the calculated potential as a function of the angle
164
- qr.potential.from_qe()
165
- # Load to the system
166
- system = qr.potential.load()
164
+ # Compile a 'potential.csv' file with the calculated potential as a function of the angle, and load it into a new system
165
+ system = qr.potential.from_qe()
167
166
  # Solve the system, interpolating to a bigger gridsize
168
167
  system.B = qr.B_CH3
169
168
  system.solve(200000)
@@ -178,9 +177,9 @@ below the potential maximum are also calculated upon solving the system:
178
177
 
179
178
  ```python
180
179
  system.solve()
181
- system.splittings
182
- system.excitations
183
- system.deg
180
+ print(system.splittings)
181
+ print(system.excitations)
182
+ print(system.deg)
184
183
  ```
185
184
 
186
185
  An integer `System.deg` degeneracy (e.g. 3 for methyls)
@@ -49,13 +49,13 @@ QRotor contains the following modules:
49
49
 
50
50
  | | |
51
51
  | --- | --- |
52
+ | [qrotor.constants](https://pablogila.github.io/qrotor/qrotor/constants.html) | Common bond lengths and inertias |
52
53
  | [qrotor.system](https://pablogila.github.io/qrotor/qrotor/system.html) | Definition of the quantum `System` object |
53
- | [qrotor.systems](https://pablogila.github.io/qrotor/qrotor/systems.html) | Functions to manage several System objects, such as a list of systems |
54
+ | [qrotor.systems](https://pablogila.github.io/qrotor/qrotor/systems.html) | Utilities to manage several System objects, such as a list of systems |
54
55
  | [qrotor.rotate](https://pablogila.github.io/qrotor/qrotor/rotate.html) | Rotate specific atoms from structural files |
55
- | [qrotor.constants](https://pablogila.github.io/qrotor/qrotor/constants.html) | Common bond lengths and inertias |
56
56
  | [qrotor.potential](https://pablogila.github.io/qrotor/qrotor/potential.html) | Potential definitions and loading functions |
57
57
  | [qrotor.solve](https://pablogila.github.io/qrotor/qrotor/solve.html) | Solve rotation eigenvalues and eigenvectors |
58
- | [qrotor.plot](https://pablogila.github.io/qrotor/qrotor/plot.html) | Plotting functions |
58
+ | [qrotor.plot](https://pablogila.github.io/qrotor/qrotor/plot.html) | Plotting utilities |
59
59
 
60
60
  Check the [full documentation online](https://pablogila.github.io/qrotor/).
61
61
 
@@ -67,7 +67,8 @@ Check the [full documentation online](https://pablogila.github.io/qrotor/).
67
67
 
68
68
  ## Solving quantum rotational systems
69
69
 
70
- A basic calculation of the eigenvalues for a zero potential goes as follows.
70
+ Let's start with a basic calculation of the eigenvalues for a zero potential, corresponding to a free rotor.
71
+ A predefined synthetic potential can be used, see all available options in the [qrotor.potential](https://pablogila.github.io/qrotor/qrotor/potential.html) documentation.
71
72
  Note that the default energy unit is meV unless stated otherwise.
72
73
 
73
74
  ```python
@@ -77,7 +78,7 @@ system.gridsize = 200000 # Size of the potential grid
77
78
  system.B = 1 # Rotational inertia
78
79
  system.potential_name = 'zero'
79
80
  system.solve()
80
- system.eigenvalues
81
+ print(system.eigenvalues)
81
82
  # [0.0, 1.0, 1.0, 4.0, 4.0, 9.0, 9.0, ...] # approx values
82
83
  ```
83
84
 
@@ -90,10 +91,10 @@ in a cosine potential of amplitude 30 meV:
90
91
  ```python
91
92
  import qrotor as qr
92
93
  system = qr.System()
93
- system.gridsize = 200000 # Size of the potential grid
94
+ system.gridsize = 200000
94
95
  system.B = qr.B_CH3 # Rotational inertia of a methyl group
95
96
  system.potential_name = 'cosine'
96
- system.potential_constants = [0, 30, 3, 0] # Offset, max, freq, phase (for cos pot.)
97
+ system.potential_constants = [0, 30, 3, 0] # Offset, max, freq, phase (for cosine potential)
97
98
  system.solve()
98
99
  # Plot potential and eigenvalues
99
100
  qr.plot.energies(system)
@@ -105,7 +106,7 @@ qr.plot.wavefunction(system, levels=[0,1,2], square=True)
105
106
  ## Custom potentials from DFT
106
107
 
107
108
  QRotor can be used to obtain custom rotational potentials from DFT calculations.
108
- Using Quantum ESPRESSO, running an SCF calculation for a methyl rotation every 10 degrees:
109
+ To run a Quantum ESPRESSO SCF calculation for a methyl rotation every 10 degrees:
109
110
 
110
111
  ```python
111
112
  import qrotor as qr
@@ -124,10 +125,8 @@ api.slurm.sbatch(files=scf_files)
124
125
 
125
126
  To load the calculated potential to a QRotor System,
126
127
  ```python
127
- # Compile a 'potential.csv' file with the calculated potential as a function of the angle
128
- qr.potential.from_qe()
129
- # Load to the system
130
- system = qr.potential.load()
128
+ # Compile a 'potential.csv' file with the calculated potential as a function of the angle, and load it into a new system
129
+ system = qr.potential.from_qe()
131
130
  # Solve the system, interpolating to a bigger gridsize
132
131
  system.B = qr.B_CH3
133
132
  system.solve(200000)
@@ -142,9 +141,9 @@ below the potential maximum are also calculated upon solving the system:
142
141
 
143
142
  ```python
144
143
  system.solve()
145
- system.splittings
146
- system.excitations
147
- system.deg
144
+ print(system.splittings)
145
+ print(system.excitations)
146
+ print(system.deg)
148
147
  ```
149
148
 
150
149
  An integer `System.deg` degeneracy (e.g. 3 for methyls)
@@ -10,5 +10,5 @@ https://semver.org/
10
10
 
11
11
  """
12
12
 
13
- __version__ = 'v4.0.1'
13
+ __version__ = 'v4.0.2'
14
14
 
@@ -271,7 +271,7 @@ def splittings(
271
271
  The different `System.comment` are shown in the horizontal axis.
272
272
  An optional `title` can be specified.
273
273
  Default units shown are $\\mu$eV (`'ueV'`).
274
- Available units are: `'ueV'`, `'meV'`, `'Ry'`.
274
+ Available units are: `'ueV'`, `'meV'`, `'Ry'`, or `'B'` (free rotor units).
275
275
  """
276
276
  title = title if title != None else 'Tunnel splitting energies'
277
277
  calcs = deepcopy(data)
@@ -289,6 +289,9 @@ def splittings(
289
289
  elif units.lower() in alias.units['Ry']:
290
290
  y = [j * constants.meV_to_Ry for j in y]
291
291
  ax.set_ylabel("Energy / Ry")
292
+ elif units.upper() == 'B':
293
+ y = [j / c.B for j, c in zip(y, calcs)]
294
+ ax.set_ylabel("Energy / B")
292
295
  #else: # It's okay let's use meV
293
296
 
294
297
  ax.bar(range(len(y)), y)
@@ -66,6 +66,7 @@ def save(
66
66
  in degrees and meVs by default.
67
67
  The units can be changed with `angle` and `energy`,
68
68
  but only change these defaults if you know what you are doing.
69
+ An optional `comment` can be included in the header of the file.
69
70
  """
70
71
  print('Saving potential data file...')
71
72
  # Check if a previous potential.dat file exists, and ask to overwrite it
@@ -77,7 +78,7 @@ def save(
77
78
  print("Aborted.")
78
79
  return None
79
80
  # Set header
80
- potential_data = f'# {comment}\n' if comment else f'# {system.comment}\n' if system.comment else ''
81
+ potential_data = f'## {comment}\n' if comment else f'## {system.comment}\n' if system.comment else ''
81
82
  potential_data += '# Rotational potential dataset\n'
82
83
  potential_data += f'# Saved with QRotor {__version__}\n'
83
84
  potential_data += '# https://pablogila.github.io/qrotor\n'
@@ -143,6 +144,11 @@ def load(
143
144
  system = System() if system is None else system
144
145
  with open(file_path, 'r') as f:
145
146
  lines = f.readlines()
147
+ # Read the comment
148
+ loaded_comment = ''
149
+ if lines[0].startswith('## '):
150
+ loaded_comment = lines[0][3:].strip()
151
+ # Read data
146
152
  positions = []
147
153
  potentials = []
148
154
  for line in lines:
@@ -171,8 +177,13 @@ def load(
171
177
  system.grid = np.array(positions)
172
178
  system.gridsize = len(positions)
173
179
  system.potential_values = np.array(potentials)
174
- # System comment as the parent folder name
175
- system.comment = os.path.basename(os.path.dirname(file_path)) if comment==None else comment
180
+ # System comment as the loaded comment or the parent folder name
181
+ if comment:
182
+ system.comment = comment
183
+ elif loaded_comment:
184
+ system.comment = loaded_comment
185
+ else:
186
+ system.comment = os.path.basename(os.path.dirname(file_path))
176
187
  print(f"Loaded {filepath}")
177
188
  return system
178
189
 
@@ -184,9 +195,10 @@ def from_qe(
184
195
  exclude:list=['slurm-'],
185
196
  energy:str='meV',
186
197
  comment:str=None,
187
- ) -> None:
198
+ ) -> System:
188
199
  """Compiles a rotational potential CSV file from Quantum ESPRESSO outputs,
189
200
  created with `qrotor.rotate.structure_qe()`.
201
+ Returns a `System` object with the new potential values.
190
202
 
191
203
  The angle in degrees is extracted from the output filenames,
192
204
  which must follow `whatever_ANGLE.out`.
@@ -213,7 +225,7 @@ def from_qe(
213
225
  files = file.get_list(folder=folder, include=include, exclude=exclude, abspath=True)
214
226
  folder_name = os.path.basename(folder)
215
227
  # Set header
216
- potential_data = f'# {comment}\n' if comment else f'# {folder_name}\n'
228
+ potential_data = f'## {comment}\n' if comment else f'## {folder_name}\n'
217
229
  potential_data += '# Rotational potential dataset\n'
218
230
  potential_data += f'# Calculated with QE using QRotor {__version__}\n'
219
231
  potential_data += '# https://pablogila.github.io/qrotor\n'
@@ -273,7 +285,12 @@ def from_qe(
273
285
  # Warn the user if not in default units
274
286
  if energy.lower() not in alias.units['meV']:
275
287
  print(f"WARNING: You saved the potential in '{energy}' units! Remember that QRotor works in meVs!")
276
- return None
288
+ new_system = None
289
+ try:
290
+ new_system = load(filepath=filepath, comment=comment, energy=energy)
291
+ except:
292
+ pass
293
+ return new_system
277
294
 
278
295
 
279
296
  def merge(
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: qrotor
3
- Version: 4.0.1
3
+ Version: 4.0.2
4
4
  Summary: QRotor
5
5
  Author: Pablo Gila-Herranz
6
6
  Author-email: pgila001@ikasle.ehu.eus
@@ -85,13 +85,13 @@ QRotor contains the following modules:
85
85
 
86
86
  | | |
87
87
  | --- | --- |
88
+ | [qrotor.constants](https://pablogila.github.io/qrotor/qrotor/constants.html) | Common bond lengths and inertias |
88
89
  | [qrotor.system](https://pablogila.github.io/qrotor/qrotor/system.html) | Definition of the quantum `System` object |
89
- | [qrotor.systems](https://pablogila.github.io/qrotor/qrotor/systems.html) | Functions to manage several System objects, such as a list of systems |
90
+ | [qrotor.systems](https://pablogila.github.io/qrotor/qrotor/systems.html) | Utilities to manage several System objects, such as a list of systems |
90
91
  | [qrotor.rotate](https://pablogila.github.io/qrotor/qrotor/rotate.html) | Rotate specific atoms from structural files |
91
- | [qrotor.constants](https://pablogila.github.io/qrotor/qrotor/constants.html) | Common bond lengths and inertias |
92
92
  | [qrotor.potential](https://pablogila.github.io/qrotor/qrotor/potential.html) | Potential definitions and loading functions |
93
93
  | [qrotor.solve](https://pablogila.github.io/qrotor/qrotor/solve.html) | Solve rotation eigenvalues and eigenvectors |
94
- | [qrotor.plot](https://pablogila.github.io/qrotor/qrotor/plot.html) | Plotting functions |
94
+ | [qrotor.plot](https://pablogila.github.io/qrotor/qrotor/plot.html) | Plotting utilities |
95
95
 
96
96
  Check the [full documentation online](https://pablogila.github.io/qrotor/).
97
97
 
@@ -103,7 +103,8 @@ Check the [full documentation online](https://pablogila.github.io/qrotor/).
103
103
 
104
104
  ## Solving quantum rotational systems
105
105
 
106
- A basic calculation of the eigenvalues for a zero potential goes as follows.
106
+ Let's start with a basic calculation of the eigenvalues for a zero potential, corresponding to a free rotor.
107
+ A predefined synthetic potential can be used, see all available options in the [qrotor.potential](https://pablogila.github.io/qrotor/qrotor/potential.html) documentation.
107
108
  Note that the default energy unit is meV unless stated otherwise.
108
109
 
109
110
  ```python
@@ -113,7 +114,7 @@ system.gridsize = 200000 # Size of the potential grid
113
114
  system.B = 1 # Rotational inertia
114
115
  system.potential_name = 'zero'
115
116
  system.solve()
116
- system.eigenvalues
117
+ print(system.eigenvalues)
117
118
  # [0.0, 1.0, 1.0, 4.0, 4.0, 9.0, 9.0, ...] # approx values
118
119
  ```
119
120
 
@@ -126,10 +127,10 @@ in a cosine potential of amplitude 30 meV:
126
127
  ```python
127
128
  import qrotor as qr
128
129
  system = qr.System()
129
- system.gridsize = 200000 # Size of the potential grid
130
+ system.gridsize = 200000
130
131
  system.B = qr.B_CH3 # Rotational inertia of a methyl group
131
132
  system.potential_name = 'cosine'
132
- system.potential_constants = [0, 30, 3, 0] # Offset, max, freq, phase (for cos pot.)
133
+ system.potential_constants = [0, 30, 3, 0] # Offset, max, freq, phase (for cosine potential)
133
134
  system.solve()
134
135
  # Plot potential and eigenvalues
135
136
  qr.plot.energies(system)
@@ -141,7 +142,7 @@ qr.plot.wavefunction(system, levels=[0,1,2], square=True)
141
142
  ## Custom potentials from DFT
142
143
 
143
144
  QRotor can be used to obtain custom rotational potentials from DFT calculations.
144
- Using Quantum ESPRESSO, running an SCF calculation for a methyl rotation every 10 degrees:
145
+ To run a Quantum ESPRESSO SCF calculation for a methyl rotation every 10 degrees:
145
146
 
146
147
  ```python
147
148
  import qrotor as qr
@@ -160,10 +161,8 @@ api.slurm.sbatch(files=scf_files)
160
161
 
161
162
  To load the calculated potential to a QRotor System,
162
163
  ```python
163
- # Compile a 'potential.csv' file with the calculated potential as a function of the angle
164
- qr.potential.from_qe()
165
- # Load to the system
166
- system = qr.potential.load()
164
+ # Compile a 'potential.csv' file with the calculated potential as a function of the angle, and load it into a new system
165
+ system = qr.potential.from_qe()
167
166
  # Solve the system, interpolating to a bigger gridsize
168
167
  system.B = qr.B_CH3
169
168
  system.solve(200000)
@@ -178,9 +177,9 @@ below the potential maximum are also calculated upon solving the system:
178
177
 
179
178
  ```python
180
179
  system.solve()
181
- system.splittings
182
- system.excitations
183
- system.deg
180
+ print(system.splittings)
181
+ print(system.excitations)
182
+ print(system.deg)
184
183
  ```
185
184
 
186
185
  An integer `System.deg` degeneracy (e.g. 3 for methyls)
@@ -16,4 +16,8 @@ qrotor.egg-info/dependency_links.txt
16
16
  qrotor.egg-info/requires.txt
17
17
  qrotor.egg-info/top_level.txt
18
18
  tests/__init__.py
19
- tests/test_qrotor.py
19
+ tests/test_constants.py
20
+ tests/test_potential.py
21
+ tests/test_rotate.py
22
+ tests/test_solve.py
23
+ tests/test_system.py
@@ -0,0 +1,13 @@
1
+ import qrotor as qr
2
+
3
+
4
+ def test_constants():
5
+ assert round(qr.B_CH3, 5) == 0.64518
6
+ assert round(qr.B_CD3, 5) == 0.32289
7
+ assert round(qr.B_NH3, 5) == 0.73569
8
+ assert round(qr.B_ND3, 5) == 0.36819
9
+ assert round(qr.Ry_to_eV, 5) == 13.60569
10
+ assert round(qr.Ry_to_meV, 5) == 13605.69312
11
+ assert round(qr.eV_to_Ry, 5) == 0.07350
12
+ assert round(qr.meV_to_Ry, 10) == .0000734986
13
+
@@ -0,0 +1,37 @@
1
+ import qrotor as qr
2
+ import aton
3
+
4
+
5
+ folder = 'tests/samples/'
6
+ structure = folder + 'CH3NH3.in'
7
+ structure_120 = folder + 'CH3NH3_120.in'
8
+ structure_60 = folder + 'CH3NH3_60.in'
9
+
10
+
11
+ def test_save_and_load():
12
+ system = qr.System()
13
+ system.gridsize = 36
14
+ system.potential_name = 'sin'
15
+ system.B = 1
16
+ system.solve_potential()
17
+ potential_file = folder + '_temp_potential.csv'
18
+ # Remove the file if it exists
19
+ try:
20
+ aton.file.remove(potential_file)
21
+ except:
22
+ pass
23
+ qr.potential.save(system, comment='hi', filepath=potential_file)
24
+ system_new = qr.potential.load(potential_file)
25
+ assert system_new.gridsize == system.gridsize
26
+ assert round(system_new.potential_values[0], 5) == round(system.potential_values[0], 5)
27
+ assert round(system_new.potential_values[5], 5) == round(system.potential_values[5], 5)
28
+ assert round(system_new.potential_values[13], 5) == round(system.potential_values[13], 5)
29
+ assert system_new.comment == 'hi'
30
+ aton.file.remove(potential_file)
31
+ # If we don't provide a comment, it should be the name of the folder
32
+ system.comment = None
33
+ qr.potential.save(system, filepath=potential_file)
34
+ system_new = qr.potential.load(potential_file)
35
+ assert system_new.comment == 'samples'
36
+ aton.file.remove(potential_file)
37
+
@@ -2,7 +2,6 @@ import qrotor as qr
2
2
  import aton.api as api
3
3
  import aton.txt.extract as extract
4
4
  import aton.file as file
5
- import numpy as np
6
5
 
7
6
 
8
7
  folder = 'tests/samples/'
@@ -52,50 +51,3 @@ def test_rotate():
52
51
  assert coord_rounded == rotated_coord_rounded
53
52
  file.remove(structure_60)
54
53
 
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
-
@@ -0,0 +1,28 @@
1
+ import qrotor as qr
2
+
3
+
4
+ def test_solve_zero():
5
+ system = qr.System()
6
+ system.gridsize = 50000
7
+ system.potential_name = 'zero'
8
+ system.B = 1
9
+ system.solve()
10
+ assert round(system.eigenvalues[0], 2) == 0.0
11
+ assert round(system.eigenvalues[1], 2) == 1.0
12
+ assert round(system.eigenvalues[2], 2) == 1.0
13
+ assert round(system.eigenvalues[3], 2) == 4.0
14
+ assert round(system.eigenvalues[4], 2) == 4.0
15
+ assert round(system.eigenvalues[5], 2) == 9.0
16
+ assert round(system.eigenvalues[6], 2) == 9.0
17
+ assert round(system.eigenvalues[7], 2) == 16.0
18
+ assert round(system.eigenvalues[8], 2) == 16.0
19
+
20
+
21
+ def test_solve_potential():
22
+ system = qr.System()
23
+ system.gridsize = 500
24
+ system.potential_name = 'sin'
25
+ system.potential_constants = [0, 1, 3, 0]
26
+ system.solve_potential()
27
+ assert round(system.potential_max, 2) == 1.0
28
+
@@ -0,0 +1,24 @@
1
+ import qrotor as qr
2
+ import numpy as np
3
+
4
+
5
+ def test_phase():
6
+ sys = qr.System()
7
+ sys.B = 1.0
8
+ sys.potential_name = 'cos'
9
+ sys.gridsize = 10000
10
+ sys.solve()
11
+ # plus pi/2, which will be -3pi/2
12
+ sys.change_phase(0.5)
13
+ assert round(sys.grid[0], 2) == round(-np.pi * 3/2, 2)
14
+ # The first potential value should be 0,
15
+ # but remember that the potential offset is corrected
16
+ # so it should be half potential_max, so 1.0/2
17
+ assert round(sys.potential_values[0], 2) == 0.5
18
+ # minus pi, which will become -pi/2
19
+ sys.change_phase(-1)
20
+ assert round(sys.grid[0], 2) == round(-np.pi/2, 2)
21
+ assert round(sys.potential_values[0], 2) == 0.5
22
+ # Were eigenvalues calculated?
23
+ assert len(sys.eigenvalues) > 0
24
+
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes