diff --git a/aton/_version.py b/aton/_version.py index 856ec7c..7958eab 100644 --- a/aton/_version.py +++ b/aton/_version.py @@ -10,5 +10,5 @@ """ -__version__ = 'v0.0.1rc34' +__version__ = 'v0.0.1' diff --git a/aton/qrotor/classes.py b/aton/qrotor/classes.py index 8d7303e..601fd9a 100644 --- a/aton/qrotor/classes.py +++ b/aton/qrotor/classes.py @@ -30,7 +30,7 @@ def __init__( comment: str = None, group: str = 'CH3', E_levels: int = 5, - units = None, ################ TODO CHECK THAT THIS WORKS. previously = [] + units = None, ################ TODO CHECK THAT THIS WORKS. previously = [] correct_potential_offset: bool = True, save_eigenvectors: bool = False, gridsize: int = None, @@ -122,7 +122,11 @@ def summary(self): } def set_grid(self, gridsize:int=None): - """Sets the `QSys.grid` to the specified `gridsize`.""" + """Sets the `QSys.grid` to the specified `gridsize`. + + It removes the previous grid, + do **not** use this method if the potential was loaded externally! + """ if gridsize is not None: self.gridsize = gridsize if self.gridsize is None: diff --git a/aton/qrotor/constants.py b/aton/qrotor/constants.py index cbcaa66..6647e0c 100644 --- a/aton/qrotor/constants.py +++ b/aton/qrotor/constants.py @@ -37,17 +37,17 @@ """Rotation radius of the amine group, in meters.""" # Inertia, SI units -I_CH = 3 * (phys.atoms['H'].mass * r_CH**2) +I_CH = 3 * (phys.atoms['H'].mass * phys.amu_to_kg * r_CH**2) """Inertia of CH3, in uma·m^2.""" -I_CD = 3 * (phys.atoms['H'].isotope[2].mass * r_CH**2) +I_CD = 3 * (phys.atoms['H'].isotope[2].mass * phys.amu_to_kg * r_CH**2) """Inertia of CD3, in uma·m^2.""" -I_NH = 3 * (phys.atoms['H'].mass * r_NH**2) +I_NH = 3 * (phys.atoms['H'].mass * phys.amu_to_kg * r_NH**2) """Inertia of NH3, in uma·m^2.""" -I_ND = 3 * (phys.atoms['H'].isotope[2].mass * r_NH**2) +I_ND = 3 * (phys.atoms['H'].isotope[2].mass * phys.amu_to_kg * r_NH**2) """Inertia of ND3, in uma·m^2.""" # Rotational energy. -B_CH = ((phys.hbar_eV**2) / (2 * I_CH)) * phys.J_to_eV +B_CH = ((phys.hbar**2) / (2 * I_CH)) * phys.J_to_eV """Rotational energy of CH3, in eV·s/uma·m^2.""" B_CD = ((phys.hbar**2) / (2 * I_CD)) * phys.J_to_eV """Rotational energy of CD3, in eV·s/uma·m^2.""" diff --git a/aton/qrotor/potential.py b/aton/qrotor/potential.py index 73dfa2b..08c7765 100644 --- a/aton/qrotor/potential.py +++ b/aton/qrotor/potential.py @@ -35,13 +35,13 @@ def load( filepath:str='potential.dat', system:QSys=None, - angle:str='deg', - energy:str='eV', + angle_unit:str='deg', + energy_unit:str='eV', ) -> QSys: """Read a potential rotational energy dataset. - The file in `filepath` should contain two columns with `angle` and `potential` values. - Degrees and eV are assumed as default units unless stated in `angle` and `energy`. + The file in `filepath` should contain two columns with angle and potential energy values. + Degrees and eV are assumed as default units unless stated in `angle_unit` and `energy_unit`. Units will be converted automatically to radians and eV. """ file_path = file.get(filepath) @@ -57,21 +57,21 @@ def load( positions.append(float(position.strip())) potentials.append(float(potential.strip())) # Save angles to numpy arrays - if angle.lower() in alias.units['deg']: + if angle_unit.lower() in alias.units['deg']: positions = np.radians(positions) - elif angle.lower() in alias.units['rad']: + elif angle_unit.lower() in alias.units['rad']: positions = np.array(positions) else: - raise ValueError(f"Angle unit '{angle}' not recognized.") + raise ValueError(f"Angle unit '{angle_unit}' not recognized.") # Save energies to numpy arrays - if energy.lower() in alias.units['meV']: + if energy_unit.lower() in alias.units['meV']: potentials = np.array(potentials) * 1000 - elif energy.lower() in alias.units['eV']: + elif energy_unit.lower() in alias.units['eV']: potentials = np.array(potentials) - elif energy.lower() in alias.units['Ry']: + elif energy_unit.lower() in alias.units['Ry']: potentials = np.array(potentials) * phys.Ry_to_eV else: - raise ValueError(f"Energy unit '{energy}' not recognized.") + raise ValueError(f"Energy unit '{energy_unit}' not recognized.") # Set the system system.grid = np.array(positions) system.gridsize = len(positions) @@ -81,23 +81,28 @@ def load( def from_qe( folder=None, - filters:str=None, output:str='potential.dat', + include:list=['.out'], + ignore:list=['slurm-'], ) -> None: """Creates a potential data file from Quantum ESPRESSO outputs. The angle in degrees is extracted from the output filenames, which must follow `whatever_ANGLE.out`. - Outputs from SCF calculations must be located in the provided `folder` (CWD if None), - and can be filtered with `filters`. + Outputs from SCF calculations must be located in the provided `folder` (CWD if None). + Files can be filtered by those containing the specified `filters`, + excluding those containing any string from the `ignore` list. The `output` name is `potential.dat` by default. """ folder = file.get_dir(folder) - files = file.get_list(folder=folder, filters=filters, abspath=True) + files = file.get_list(folder=folder, include=include, ignore=ignore, abspath=True) potential_data = '# Angle/deg Potential/eV\n' potential_data_list = [] print('Extracting the potential as a function of the angle...') + print('----------------------------------') + counter_success = 0 + counter_errors = 0 for filepath in files: filename = os.path.basename(filepath) filepath = file.get(filepath=filepath, filters='.out', return_anyway=True) @@ -105,14 +110,16 @@ def from_qe( continue content = qe.read_out(filepath) if not content['Success']: # Ignore unsuccessful calculations - print(f'{filename} was unsuccessful :(') + print(f'x {filename}') + counter_errors += 1 continue energy = content['Energy'] * phys.Ry_to_eV splits = filename.split('_') angle = splits[-1].replace('.out', '') angle = float(angle) potential_data_list.append((angle, energy)) - print(f'{filename} added') + print(f'OK {filename}') + counter_success += 1 # Sort by angle potential_data_list_sorted = sorted(potential_data_list, key=lambda x: x[0]) # Append the sorted values as a string @@ -120,6 +127,10 @@ def from_qe( potential_data += f'{angle} {energy}\n' with open(output, 'w') as f: f.write(potential_data) + print('----------------------------------') + print(f'Succesful calculations (OK): {counter_success}') + print(f'Faulty calculations (x): {counter_errors}') + print('----------------------------------') print(f'Saved angles and potential values at {output}') return None @@ -153,7 +164,7 @@ def solve(system:QSys): data = deepcopy(system) # Is there a potential_name? if not data.potential_name: - if not data.potential_values.any(): + if not any(data.potential_values): raise ValueError(f'No potential_name and no potential_values found in the system!') elif data.potential_name.lower() == 'titov2023': data.potential_values = titov2023(data) @@ -162,7 +173,7 @@ def solve(system:QSys): elif data.potential_name.lower() == 'sine': data.potential_values = sine(data) # At least there should be potential_values - elif not data.potential_values.any(): + elif not any(data.potential_values): raise ValueError("Unrecognised potential_name '{data.potential_name}' and no potential_values found") return data.potential_values diff --git a/aton/qrotor/solve.py b/aton/qrotor/solve.py index 8e918c0..b74606f 100644 --- a/aton/qrotor/solve.py +++ b/aton/qrotor/solve.py @@ -9,11 +9,11 @@ | | | | --- | --- | -| `laplacian_matrix()` | Calculate the second derivative matrix for a given grid | -| `hamiltonian_matrix()` | Calculate the hamiltonian matrix of the system | +| `energies()` | Solve the system(s) for the `QSys` or `QExp` object | | `potential()` | Solve the potential values of the system | | `schrodinger()` | Solve the Schrödiger equation for the system | -| `energies()` | Solve the system(s) for the `QSys` or `QExp` object | +| `hamiltonian_matrix()` | Calculate the hamiltonian matrix of the system | +| `laplacian_matrix()` | Calculate the second derivative matrix for a given grid | --- """ @@ -29,27 +29,21 @@ import aton -def laplacian_matrix(grid): - """Calculates the Laplacian (second derivative) matrix for a given `grid`.""" - x = grid - diagonals = [-2*np.ones(len(x)), np.ones(len(x)), np.ones(len(x))] - laplacian_matrix = sparse.spdiags(diagonals, [0, -1, 1], format='lil') - # Periodic boundary conditions - laplacian_matrix[0, -1] = 1 - laplacian_matrix[-1, 0] = 1 - dx = x[1] - x[0] - laplacian_matrix /= dx**2 - return laplacian_matrix - - -def hamiltonian_matrix(system:QSys): - """Calculates the Hamiltonian matrix for a given `aton.qrotor.classes.QSys` object.""" - V = system.potential_values.tolist() - potential = sparse.diags(V, format='lil') - B = system.B - x = system.grid - H = -B * laplacian_matrix(x) + potential - return H +def energies(var, filename:str=None) -> QExp: + """Solves the Schrödinger equation for a given `aton.qrotor.classes.QSys` or `aton.qrotor.classes.QExp` object.""" + if isinstance(var, QSys): + data = QExp() + data.systems = [deepcopy(var)] + elif isinstance(var, QExp): + data = deepcopy(var) + else: + raise TypeError('Input must be a QSys or QExp object.') + for system in data.systems: + system = potential(system) + system = schrodinger(system) + if filename: + aton.st.file.save(data, filename) + return data def potential(system:QSys) -> QSys: @@ -97,19 +91,25 @@ def schrodinger(system:QSys) -> QSys: return system -def energies(var, filename:str=None) -> QExp: - """Solves the Schrödinger equation for a given `aton.qrotor.classes.QSys` or `aton.qrotor.classes.QExp` object.""" - if isinstance(var, QSys): - data = QExp() - data.systems = [deepcopy(var)] - elif isinstance(var, QExp): - data = deepcopy(var) - else: - raise TypeError('Input must be a QSys or QExp object.') - for system in data.systems: - system = potential(system) - system = schrodinger(system) - if filename: - aton.st.file.save(data, filename) - return data +def hamiltonian_matrix(system:QSys): + """Calculates the Hamiltonian matrix for a given `aton.qrotor.classes.QSys` object.""" + V = system.potential_values.tolist() + potential = sparse.diags(V, format='lil') + B = system.B + x = system.grid + H = -B * laplacian_matrix(x) + potential + return H + + +def laplacian_matrix(grid): + """Calculates the Laplacian (second derivative) matrix for a given `grid`.""" + x = grid + diagonals = [-2*np.ones(len(x)), np.ones(len(x)), np.ones(len(x))] + laplacian_matrix = sparse.spdiags(diagonals, [0, -1, 1], format='lil') + # Periodic boundary conditions + laplacian_matrix[0, -1] = 1 + laplacian_matrix[-1, 0] = 1 + dx = x[1] - x[0] + laplacian_matrix /= dx**2 + return laplacian_matrix diff --git a/aton/st/file.py b/aton/st/file.py index e59ea06..3bdab92 100644 --- a/aton/st/file.py +++ b/aton/st/file.py @@ -49,7 +49,7 @@ def get( if os.path.isfile(filepath): return os.path.abspath(filepath) elif os.path.isdir(filepath): - files = get_list(filepath, filters, abspath=True) + files = get_list(folder=filepath, include=filters, abspath=True) elif return_anyway: return None else: @@ -66,36 +66,55 @@ def get( def get_list( - folder:str, - filters=None, - abspath:bool=True + folder:str=None, + include=None, + ignore=None, + abspath:bool=True, + also_folders:bool=False, ) -> list: - """Return the files inside a `folder`, applying optional `filters`. + """Return the files inside a `folder`, applying optional filters. + + Only filenames containing all strings in the `include` list will be returned. + Filenames containing any string from the `ignore` list will be ignored. The full paths are returned by default; to get only the base names, set `abspath = False`. + The CWD folder is used by default if no `folder` is provided. + It also returns folders if `also_folders = True`. """ + if not folder: + folder = os.getcwd() if os.path.isfile(folder): folder = os.path.dirname(folder) if not os.path.isdir(folder): raise FileNotFoundError('Directory not found: ' + folder) folder = os.path.abspath(folder) files = os.listdir(folder) - # Apply filters or not - if filters is not None: - target_files = [] - if not isinstance(filters, list): - filters = [str(filters)] - for filter_i in filters: - filter_i = os.path.basename(filter_i) - for f in files: - if filter_i in f: - target_files.append(f) - files = target_files + if not files: + return [] + # Absolute paths? if abspath: - filepaths = [] - for f in files: - filepaths.append(os.path.join(folder, f)) - files = filepaths + files = [os.path.join(folder, f) for f in files] + # Should we keep only files? + if not also_folders: + files = [f for f in files if not os.path.isdir(f if abspath else os.path.join(folder, f))] + # Apply filters if provided + if include is not None: + # Ensure include filters is always a list + if not isinstance(include, list): + include = [str(include)] + # Normalize filter names + include = [os.path.basename(i) for i in include] + # Only keep files that contain all filters + files = [f for f in files if all(filter_str in os.path.basename(f) for filter_str in include)] + # Remove files containing any string from the ignore list + if ignore is not None: + # Ensure ignore filters is always a list + if not isinstance(ignore, list): + ignore = [str(ignore)] + # Normalize ignoring filter names + ignore = [os.path.basename(i) for i in ignore] + # Exclude the corresponding files + files = [f for f in files if not any(filter_str in os.path.basename(f) for filter_str in ignore)] return files @@ -223,7 +242,7 @@ def copy_to_folders( """ if folder is None: folder = os.getcwd() - old_files = get_list(folder, extension) + old_files = get_list(folder=folder, include=extension) if old_files is None: raise ValueError('No ' + extension + ' files found in path!') for old_file in old_files: diff --git a/docs/aton.html b/docs/aton.html index 4a70aa6..1cefc34 100644 --- a/docs/aton.html +++ b/docs/aton.html @@ -98,7 +98,7 @@
125 def set_grid(self, gridsize:int=None): -126 """Sets the `QSys.grid` to the specified `gridsize`.""" -127 if gridsize is not None: -128 self.gridsize = gridsize -129 if self.gridsize is None: -130 raise ValueError('QSys.gridsize is not set yet!.') -131 self.grid = np.linspace(0, 2*np.pi, self.gridsize) -132 return self +126 """Sets the `QSys.grid` to the specified `gridsize`. +127 +128 It removes the previous grid, +129 do **not** use this method if the potential was loaded externally! +130 """ +131 if gridsize is not None: +132 self.gridsize = gridsize +133 if self.gridsize is None: +134 raise ValueError('QSys.gridsize is not set yet!.') +135 self.grid = np.linspace(0, 2*np.pi, self.gridsize) +136 return self
Sets the QSys.grid
to the specified gridsize
.
It removes the previous grid, +do not use this method if the potential was loaded externally!
134 def set_group(self, group:str=None, B:float=None): -135 """Normalise `QSys.group` name, and set `QSys.B` based on it.""" -136 for name in alias.chemical['CH3']: -137 if group.lower() == name: -138 self.group = 'CH3' -139 if not B: -140 B = B_CH -141 self.B = B -142 return self -143 for name in alias.chemical['CD3']: -144 if group.lower() == name: -145 self.group = 'CD3' -146 if not B: -147 B = B_CD -148 self.B = B -149 return self -150 for name in alias.chemical['NH3']: -151 if group.lower() == name: -152 self.group = 'NH3' -153 if not B: -154 B = B_NH -155 self.B = B -156 return self -157 for name in alias.chemical['ND3']: -158 if group.lower() == name: -159 self.group = 'ND3' -160 if not B: -161 B = B_ND -162 self.B = B -163 return self -164 self.group = group # No match was found -165 return self +@@ -1222,131 +1237,131 @@138 def set_group(self, group:str=None, B:float=None): +139 """Normalise `QSys.group` name, and set `QSys.B` based on it.""" +140 for name in alias.chemical['CH3']: +141 if group.lower() == name: +142 self.group = 'CH3' +143 if not B: +144 B = B_CH +145 self.B = B +146 return self +147 for name in alias.chemical['CD3']: +148 if group.lower() == name: +149 self.group = 'CD3' +150 if not B: +151 B = B_CD +152 self.B = B +153 return self +154 for name in alias.chemical['NH3']: +155 if group.lower() == name: +156 self.group = 'NH3' +157 if not B: +158 B = B_NH +159 self.B = B +160 return self +161 for name in alias.chemical['ND3']: +162 if group.lower() == name: +163 self.group = 'ND3' +164 if not B: +165 B = B_ND +166 self.B = B +167 return self +168 self.group = group # No match was found +169 return selfIndex
168class QExp: -169 def __init__(self, -170 comment: str = None, -171 systems: list = [], -172 plotting: Plotting = None, -173 ): -174 self.version = __version__ -175 """Version of the package used to generate the data.""" -176 self.comment: str = comment -177 """Custom comment for the dataset.""" -178 if isinstance(systems, QSys): -179 systems = [systems] -180 self.systems = systems -181 """List containing the calculated `QSys` objects.""" -182 self.plotting: Plotting = plotting -183 """`aton.spx.classes.Plotting` object (not implemented).""" -184 -185 def add(self, *args): -186 """Adds more systems to `self.systems` from the introduced `QSys` or `QExp` objects.""" -187 for value in args: -188 if isinstance(value, QExp): -189 self.systems.extend(value.systems) -190 self.version = value.version if len(self.systems) == 0 else self.version -191 self.comment = value.comment if self.comment is None else self.comment -192 self.plotting = value.plotting if self.plotting is None else self.plotting -193 elif isinstance(value, QSys): -194 self.systems.append(value) -195 else: -196 raise TypeError(f'QExp.add() can only add QExp and/or QSys objects, not {type(value)}.') -197 -198 def get_energies(self): -199 """Returns a list with all `QSys.eigenvalues` values.""" -200 energies = [] -201 for i in self.systems: -202 if all(i.eigenvalues): -203 energies.append(i.eigenvalues) -204 else: -205 energies.append(None) -206 return energies -207 -208 def get_gridsizes(self): -209 """Returns a list with all `QSys.gridsize` values.""" -210 gridsizes = [] -211 for i in self.systems: -212 if i.gridsize: -213 gridsizes.append(i.gridsize) -214 else: -215 gridsizes.append(None) -216 return gridsizes -217 -218 def get_runtimes(self): -219 """Returns a list with all `QSys.runtime` values.""" -220 runtimes = [] -221 for i in self.systems: -222 if i.runtime: -223 runtimes.append(i.runtime) -224 else: -225 runtimes.append(None) -226 return runtimes -227 -228 def get_gropus(self): -229 """Returns a list with all `QSys.group` values.""" -230 groups = [] -231 for i in self.systems: -232 if i.group not in groups: -233 groups.append(i.group) -234 return groups -235 -236 def sort_by_potential_values(self): -237 """Returns the `QExp` object, sorted by `QSys.potential_values`.""" -238 grouped_data = self.group_by_potential_values() -239 data = QExp( -240 version = self.version, -241 comment = self.comment, -242 plotting = self.plotting, -243 ) -244 for dataset in grouped_data: -245 data.add(dataset) -246 return data -247 -248 def group_by_potential_values(self): -249 """Returns an array of grouped `QExp` objects with the same `QSys.potential_values`.""" -250 print('Grouping Experiment by potential_values...') -251 grouped_data = [] -252 for system in self.systems: -253 data = QExp() -254 data.comment = self.comment -255 data.systems.append(system) -256 new_group = True -257 for data_i in grouped_data: -258 if np.array_equal(system.potential_values, data_i.systems[0].potential_values): -259 data_i.systems.append(system) -260 new_group = False -261 break -262 if new_group: -263 print('New potential_values found') -264 grouped_data.append(data) -265 return grouped_data -266 -267 def sort_by_gridsize(self): -268 """Returns the same `QExp`, sorted by `QSys.gridsize`.""" -269 self.systems = sorted(self.systems, key=lambda sys: sys.gridsize) -270 return self -271 -272 def get_ideal_E(self, E_level): -273 """Calculates the ideal energy for a specified `E_level` for a convergence test. Only for 'zero' potential.""" -274 real_E_level = None -275 if self.systems[0].potential_name == 'zero': -276 if E_level % 2 == 0: -277 real_E_level = E_level / 2 -278 else: -279 real_E_level = (E_level + 1) / 2 -280 ideal_E = int(real_E_level ** 2) -281 return ideal_E -282 else: -283 print("WARNING: get_ideal_E() only valid for potential_name='zero'") -284 return -285 -286 def discard_shit(self): -287 """Discard data that takes too much space, like eigenvectors, potential values and grids.""" -288 for dataset in self.systems: -289 dataset.eigenvectors = None -290 dataset.potential_values = None -291 dataset.grid = None -292 return self +@@ -1362,21 +1377,21 @@172class QExp: +173 def __init__(self, +174 comment: str = None, +175 systems: list = [], +176 plotting: Plotting = None, +177 ): +178 self.version = __version__ +179 """Version of the package used to generate the data.""" +180 self.comment: str = comment +181 """Custom comment for the dataset.""" +182 if isinstance(systems, QSys): +183 systems = [systems] +184 self.systems = systems +185 """List containing the calculated `QSys` objects.""" +186 self.plotting: Plotting = plotting +187 """`aton.spx.classes.Plotting` object (not implemented).""" +188 +189 def add(self, *args): +190 """Adds more systems to `self.systems` from the introduced `QSys` or `QExp` objects.""" +191 for value in args: +192 if isinstance(value, QExp): +193 self.systems.extend(value.systems) +194 self.version = value.version if len(self.systems) == 0 else self.version +195 self.comment = value.comment if self.comment is None else self.comment +196 self.plotting = value.plotting if self.plotting is None else self.plotting +197 elif isinstance(value, QSys): +198 self.systems.append(value) +199 else: +200 raise TypeError(f'QExp.add() can only add QExp and/or QSys objects, not {type(value)}.') +201 +202 def get_energies(self): +203 """Returns a list with all `QSys.eigenvalues` values.""" +204 energies = [] +205 for i in self.systems: +206 if all(i.eigenvalues): +207 energies.append(i.eigenvalues) +208 else: +209 energies.append(None) +210 return energies +211 +212 def get_gridsizes(self): +213 """Returns a list with all `QSys.gridsize` values.""" +214 gridsizes = [] +215 for i in self.systems: +216 if i.gridsize: +217 gridsizes.append(i.gridsize) +218 else: +219 gridsizes.append(None) +220 return gridsizes +221 +222 def get_runtimes(self): +223 """Returns a list with all `QSys.runtime` values.""" +224 runtimes = [] +225 for i in self.systems: +226 if i.runtime: +227 runtimes.append(i.runtime) +228 else: +229 runtimes.append(None) +230 return runtimes +231 +232 def get_gropus(self): +233 """Returns a list with all `QSys.group` values.""" +234 groups = [] +235 for i in self.systems: +236 if i.group not in groups: +237 groups.append(i.group) +238 return groups +239 +240 def sort_by_potential_values(self): +241 """Returns the `QExp` object, sorted by `QSys.potential_values`.""" +242 grouped_data = self.group_by_potential_values() +243 data = QExp( +244 version = self.version, +245 comment = self.comment, +246 plotting = self.plotting, +247 ) +248 for dataset in grouped_data: +249 data.add(dataset) +250 return data +251 +252 def group_by_potential_values(self): +253 """Returns an array of grouped `QExp` objects with the same `QSys.potential_values`.""" +254 print('Grouping Experiment by potential_values...') +255 grouped_data = [] +256 for system in self.systems: +257 data = QExp() +258 data.comment = self.comment +259 data.systems.append(system) +260 new_group = True +261 for data_i in grouped_data: +262 if np.array_equal(system.potential_values, data_i.systems[0].potential_values): +263 data_i.systems.append(system) +264 new_group = False +265 break +266 if new_group: +267 print('New potential_values found') +268 grouped_data.append(data) +269 return grouped_data +270 +271 def sort_by_gridsize(self): +272 """Returns the same `QExp`, sorted by `QSys.gridsize`.""" +273 self.systems = sorted(self.systems, key=lambda sys: sys.gridsize) +274 return self +275 +276 def get_ideal_E(self, E_level): +277 """Calculates the ideal energy for a specified `E_level` for a convergence test. Only for 'zero' potential.""" +278 real_E_level = None +279 if self.systems[0].potential_name == 'zero': +280 if E_level % 2 == 0: +281 real_E_level = E_level / 2 +282 else: +283 real_E_level = (E_level + 1) / 2 +284 ideal_E = int(real_E_level ** 2) +285 return ideal_E +286 else: +287 print("WARNING: get_ideal_E() only valid for potential_name='zero'") +288 return +289 +290 def discard_shit(self): +291 """Discard data that takes too much space, like eigenvectors, potential values and grids.""" +292 for dataset in self.systems: +293 dataset.eigenvectors = None +294 dataset.potential_values = None +295 dataset.grid = None +296 return selfIndex
169 def __init__(self, -170 comment: str = None, -171 systems: list = [], -172 plotting: Plotting = None, -173 ): -174 self.version = __version__ -175 """Version of the package used to generate the data.""" -176 self.comment: str = comment -177 """Custom comment for the dataset.""" -178 if isinstance(systems, QSys): -179 systems = [systems] -180 self.systems = systems -181 """List containing the calculated `QSys` objects.""" -182 self.plotting: Plotting = plotting -183 """`aton.spx.classes.Plotting` object (not implemented).""" +@@ -1446,18 +1461,18 @@173 def __init__(self, +174 comment: str = None, +175 systems: list = [], +176 plotting: Plotting = None, +177 ): +178 self.version = __version__ +179 """Version of the package used to generate the data.""" +180 self.comment: str = comment +181 """Custom comment for the dataset.""" +182 if isinstance(systems, QSys): +183 systems = [systems] +184 self.systems = systems +185 """List containing the calculated `QSys` objects.""" +186 self.plotting: Plotting = plotting +187 """`aton.spx.classes.Plotting` object (not implemented)."""Index
185 def add(self, *args): -186 """Adds more systems to `self.systems` from the introduced `QSys` or `QExp` objects.""" -187 for value in args: -188 if isinstance(value, QExp): -189 self.systems.extend(value.systems) -190 self.version = value.version if len(self.systems) == 0 else self.version -191 self.comment = value.comment if self.comment is None else self.comment -192 self.plotting = value.plotting if self.plotting is None else self.plotting -193 elif isinstance(value, QSys): -194 self.systems.append(value) -195 else: -196 raise TypeError(f'QExp.add() can only add QExp and/or QSys objects, not {type(value)}.') +@@ -1477,15 +1492,15 @@189 def add(self, *args): +190 """Adds more systems to `self.systems` from the introduced `QSys` or `QExp` objects.""" +191 for value in args: +192 if isinstance(value, QExp): +193 self.systems.extend(value.systems) +194 self.version = value.version if len(self.systems) == 0 else self.version +195 self.comment = value.comment if self.comment is None else self.comment +196 self.plotting = value.plotting if self.plotting is None else self.plotting +197 elif isinstance(value, QSys): +198 self.systems.append(value) +199 else: +200 raise TypeError(f'QExp.add() can only add QExp and/or QSys objects, not {type(value)}.')Index
198 def get_energies(self): -199 """Returns a list with all `QSys.eigenvalues` values.""" -200 energies = [] -201 for i in self.systems: -202 if all(i.eigenvalues): -203 energies.append(i.eigenvalues) -204 else: -205 energies.append(None) -206 return energies +@@ -1505,15 +1520,15 @@202 def get_energies(self): +203 """Returns a list with all `QSys.eigenvalues` values.""" +204 energies = [] +205 for i in self.systems: +206 if all(i.eigenvalues): +207 energies.append(i.eigenvalues) +208 else: +209 energies.append(None) +210 return energiesIndex
208 def get_gridsizes(self): -209 """Returns a list with all `QSys.gridsize` values.""" -210 gridsizes = [] -211 for i in self.systems: -212 if i.gridsize: -213 gridsizes.append(i.gridsize) -214 else: -215 gridsizes.append(None) -216 return gridsizes +@@ -1533,15 +1548,15 @@212 def get_gridsizes(self): +213 """Returns a list with all `QSys.gridsize` values.""" +214 gridsizes = [] +215 for i in self.systems: +216 if i.gridsize: +217 gridsizes.append(i.gridsize) +218 else: +219 gridsizes.append(None) +220 return gridsizesIndex
218 def get_runtimes(self): -219 """Returns a list with all `QSys.runtime` values.""" -220 runtimes = [] -221 for i in self.systems: -222 if i.runtime: -223 runtimes.append(i.runtime) -224 else: -225 runtimes.append(None) -226 return runtimes +@@ -1561,13 +1576,13 @@222 def get_runtimes(self): +223 """Returns a list with all `QSys.runtime` values.""" +224 runtimes = [] +225 for i in self.systems: +226 if i.runtime: +227 runtimes.append(i.runtime) +228 else: +229 runtimes.append(None) +230 return runtimesIndex
228 def get_gropus(self): -229 """Returns a list with all `QSys.group` values.""" -230 groups = [] -231 for i in self.systems: -232 if i.group not in groups: -233 groups.append(i.group) -234 return groups +@@ -1587,17 +1602,17 @@232 def get_gropus(self): +233 """Returns a list with all `QSys.group` values.""" +234 groups = [] +235 for i in self.systems: +236 if i.group not in groups: +237 groups.append(i.group) +238 return groupsIndex
236 def sort_by_potential_values(self): -237 """Returns the `QExp` object, sorted by `QSys.potential_values`.""" -238 grouped_data = self.group_by_potential_values() -239 data = QExp( -240 version = self.version, -241 comment = self.comment, -242 plotting = self.plotting, -243 ) -244 for dataset in grouped_data: -245 data.add(dataset) -246 return data +@@ -1617,24 +1632,24 @@240 def sort_by_potential_values(self): +241 """Returns the `QExp` object, sorted by `QSys.potential_values`.""" +242 grouped_data = self.group_by_potential_values() +243 data = QExp( +244 version = self.version, +245 comment = self.comment, +246 plotting = self.plotting, +247 ) +248 for dataset in grouped_data: +249 data.add(dataset) +250 return dataIndex
248 def group_by_potential_values(self): -249 """Returns an array of grouped `QExp` objects with the same `QSys.potential_values`.""" -250 print('Grouping Experiment by potential_values...') -251 grouped_data = [] -252 for system in self.systems: -253 data = QExp() -254 data.comment = self.comment -255 data.systems.append(system) -256 new_group = True -257 for data_i in grouped_data: -258 if np.array_equal(system.potential_values, data_i.systems[0].potential_values): -259 data_i.systems.append(system) -260 new_group = False -261 break -262 if new_group: -263 print('New potential_values found') -264 grouped_data.append(data) -265 return grouped_data +@@ -1654,10 +1669,10 @@252 def group_by_potential_values(self): +253 """Returns an array of grouped `QExp` objects with the same `QSys.potential_values`.""" +254 print('Grouping Experiment by potential_values...') +255 grouped_data = [] +256 for system in self.systems: +257 data = QExp() +258 data.comment = self.comment +259 data.systems.append(system) +260 new_group = True +261 for data_i in grouped_data: +262 if np.array_equal(system.potential_values, data_i.systems[0].potential_values): +263 data_i.systems.append(system) +264 new_group = False +265 break +266 if new_group: +267 print('New potential_values found') +268 grouped_data.append(data) +269 return grouped_dataIndex
267 def sort_by_gridsize(self): -268 """Returns the same `QExp`, sorted by `QSys.gridsize`.""" -269 self.systems = sorted(self.systems, key=lambda sys: sys.gridsize) -270 return self +@@ -1677,19 +1692,19 @@271 def sort_by_gridsize(self): +272 """Returns the same `QExp`, sorted by `QSys.gridsize`.""" +273 self.systems = sorted(self.systems, key=lambda sys: sys.gridsize) +274 return selfIndex
272 def get_ideal_E(self, E_level): -273 """Calculates the ideal energy for a specified `E_level` for a convergence test. Only for 'zero' potential.""" -274 real_E_level = None -275 if self.systems[0].potential_name == 'zero': -276 if E_level % 2 == 0: -277 real_E_level = E_level / 2 -278 else: -279 real_E_level = (E_level + 1) / 2 -280 ideal_E = int(real_E_level ** 2) -281 return ideal_E -282 else: -283 print("WARNING: get_ideal_E() only valid for potential_name='zero'") -284 return +@@ -1709,13 +1724,13 @@276 def get_ideal_E(self, E_level): +277 """Calculates the ideal energy for a specified `E_level` for a convergence test. Only for 'zero' potential.""" +278 real_E_level = None +279 if self.systems[0].potential_name == 'zero': +280 if E_level % 2 == 0: +281 real_E_level = E_level / 2 +282 else: +283 real_E_level = (E_level + 1) / 2 +284 ideal_E = int(real_E_level ** 2) +285 return ideal_E +286 else: +287 print("WARNING: get_ideal_E() only valid for potential_name='zero'") +288 returnIndex
286 def discard_shit(self): -287 """Discard data that takes too much space, like eigenvectors, potential values and grids.""" -288 for dataset in self.systems: -289 dataset.eigenvectors = None -290 dataset.potential_values = None -291 dataset.grid = None -292 return self +diff --git a/docs/aton/qrotor/constants.html b/docs/aton/qrotor/constants.html index 766d0cb..40555e5 100644 --- a/docs/aton/qrotor/constants.html +++ b/docs/aton/qrotor/constants.html @@ -130,7 +130,7 @@290 def discard_shit(self): +291 """Discard data that takes too much space, like eigenvectors, potential values and grids.""" +292 for dataset in self.systems: +293 dataset.eigenvectors = None +294 dataset.potential_values = None +295 dataset.grid = None +296 return selfAPI Documentation
- + built with pdoc37"""Rotation radius of the amine group, in meters.""" 38 39# Inertia, SI units -40I_CH = 3 * (phys.atoms['H'].mass * r_CH**2) +40I_CH = 3 * (phys.atoms['H'].mass * phys.amu_to_kg * r_CH**2) 41"""Inertia of CH3, in uma·m^2.""" -42I_CD = 3 * (phys.atoms['H'].isotope[2].mass * r_CH**2) +42I_CD = 3 * (phys.atoms['H'].isotope[2].mass * phys.amu_to_kg * r_CH**2) 43"""Inertia of CD3, in uma·m^2.""" -44I_NH = 3 * (phys.atoms['H'].mass * r_NH**2) +44I_NH = 3 * (phys.atoms['H'].mass * phys.amu_to_kg * r_NH**2) 45"""Inertia of NH3, in uma·m^2.""" -46I_ND = 3 * (phys.atoms['H'].isotope[2].mass * r_NH**2) +46I_ND = 3 * (phys.atoms['H'].isotope[2].mass * phys.amu_to_kg * r_NH**2) 47"""Inertia of ND3, in uma·m^2.""" 48 49# Rotational energy. -50B_CH = ((phys.hbar_eV**2) / (2 * I_CH)) * phys.J_to_eV +50B_CH = ((phys.hbar**2) / (2 * I_CH)) * phys.J_to_eV 51"""Rotational energy of CH3, in eV·s/uma·m^2.""" 52B_CD = ((phys.hbar**2) / (2 * I_CD)) * phys.J_to_eV 53"""Rotational energy of CD3, in eV·s/uma·m^2.""" @@ -348,7 +348,7 @@
35def load( 36 filepath:str='potential.dat', 37 system:QSys=None, - 38 angle:str='deg', - 39 energy:str='eV', + 38 angle_unit:str='deg', + 39 energy_unit:str='eV', 40 ) -> QSys: 41 """Read a potential rotational energy dataset. 42 - 43 The file in `filepath` should contain two columns with `angle` and `potential` values. - 44 Degrees and eV are assumed as default units unless stated in `angle` and `energy`. + 43 The file in `filepath` should contain two columns with angle and potential energy values. + 44 Degrees and eV are assumed as default units unless stated in `angle_unit` and `energy_unit`. 45 Units will be converted automatically to radians and eV. 46 """ 47 file_path = file.get(filepath) @@ -223,21 +223,21 @@
I_CH = -np.float64(3.239331176354078e-20) +np.float64(5.37903596799128e-47)@@ -362,7 +362,7 @@
I_CD = -np.float64(6.47294747852218e-20) +np.float64(1.0748582164136045e-46)@@ -376,7 +376,7 @@
I_NH = -np.float64(2.8408244456194727e-20) +np.float64(4.717299973303422e-47)@@ -390,7 +390,7 @@
I_ND = -np.float64(5.676637068301648e-20) +np.float64(9.426277618824576e-47)@@ -404,7 +404,7 @@
B_CH = -np.float64(41738399.7746217) +np.float64(0.0006452195002679675)@@ -418,7 +418,7 @@
B_CD = -np.float64(5.3617906073032625e-31) +np.float64(0.0003228945777398468)@@ -432,7 +432,7 @@
B_NH = -np.float64(1.2217083334883588e-30) +np.float64(0.0007357299554474443)@@ -446,7 +446,7 @@
B_ND = -np.float64(6.1139348128682075e-31) +np.float64(0.0003681897605328047)diff --git a/docs/aton/qrotor/plot.html b/docs/aton/qrotor/plot.html index df0f67a..ba90eac 100644 --- a/docs/aton/qrotor/plot.html +++ b/docs/aton/qrotor/plot.html @@ -95,7 +95,7 @@API Documentation
- + built with pdocAPI Documentation - + built with pdoc
Index
Index
57 positions.append(float(position.strip())) 58 potentials.append(float(potential.strip())) 59 # Save angles to numpy arrays - 60 if angle.lower() in alias.units['deg']: + 60 if angle_unit.lower() in alias.units['deg']: 61 positions = np.radians(positions) - 62 elif angle.lower() in alias.units['rad']: + 62 elif angle_unit.lower() in alias.units['rad']: 63 positions = np.array(positions) 64 else: - 65 raise ValueError(f"Angle unit '{angle}' not recognized.") + 65 raise ValueError(f"Angle unit '{angle_unit}' not recognized.") 66 # Save energies to numpy arrays - 67 if energy.lower() in alias.units['meV']: + 67 if energy_unit.lower() in alias.units['meV']: 68 potentials = np.array(potentials) * 1000 - 69 elif energy.lower() in alias.units['eV']: + 69 elif energy_unit.lower() in alias.units['eV']: 70 potentials = np.array(potentials) - 71 elif energy.lower() in alias.units['Ry']: + 71 elif energy_unit.lower() in alias.units['Ry']: 72 potentials = np.array(potentials) * phys.Ry_to_eV 73 else: - 74 raise ValueError(f"Energy unit '{energy}' not recognized.") + 74 raise ValueError(f"Energy unit '{energy_unit}' not recognized.") 75 # Set the system 76 system.grid = np.array(positions) 77 system.gridsize = len(positions) @@ -247,126 +247,137 @@Index
81 82def from_qe( 83 folder=None, - 84 filters:str=None, - 85 output:str='potential.dat', - 86 ) -> None: - 87 """Creates a potential data file from Quantum ESPRESSO outputs. - 88 - 89 The angle in degrees is extracted from the output filenames, - 90 which must follow `whatever_ANGLE.out`. - 91 - 92 Outputs from SCF calculations must be located in the provided `folder` (CWD if None), - 93 and can be filtered with `filters`. - 94 The `output` name is `potential.dat` by default. - 95 """ - 96 folder = file.get_dir(folder) - 97 files = file.get_list(folder=folder, filters=filters, abspath=True) - 98 potential_data = '# Angle/deg Potential/eV\n' - 99 potential_data_list = [] -100 print('Extracting the potential as a function of the angle...') -101 for filepath in files: -102 filename = os.path.basename(filepath) -103 filepath = file.get(filepath=filepath, filters='.out', return_anyway=True) -104 if not filepath: # Not an output file, skip it -105 continue -106 content = qe.read_out(filepath) -107 if not content['Success']: # Ignore unsuccessful calculations -108 print(f'{filename} was unsuccessful :(') -109 continue -110 energy = content['Energy'] * phys.Ry_to_eV -111 splits = filename.split('_') -112 angle = splits[-1].replace('.out', '') -113 angle = float(angle) -114 potential_data_list.append((angle, energy)) -115 print(f'{filename} added') -116 # Sort by angle -117 potential_data_list_sorted = sorted(potential_data_list, key=lambda x: x[0]) -118 # Append the sorted values as a string -119 for angle, energy in potential_data_list_sorted: -120 potential_data += f'{angle} {energy}\n' -121 with open(output, 'w') as f: -122 f.write(potential_data) -123 print(f'Saved angles and potential values at {output}') -124 return None -125 -126 -127def interpolate(system:QSys) -> QSys: -128 """Interpolates the current `aton.qrotor.classes.QSys.potential_values` to a new grid of size `aton.qrotor.classes.QSys.gridsize`.""" -129 V = system.potential_values -130 grid = system.grid -131 gridsize = system.gridsize -132 new_grid = np.linspace(0, 2*np.pi, gridsize) -133 cubic_spline = CubicSpline(grid, V) -134 new_V = cubic_spline(new_grid) -135 system.grid = new_grid -136 system.potential_values = new_V -137 print(f"Interpolated potential to a grid of size {gridsize}") -138 return system -139 -140 -141# Redirect to the desired potential energy function -142def solve(system:QSys): -143 """Solves `aton.qrotor.classes.QSys.potential_values`, -144 according to the `aton.qrotor.classes.QSys.potential_name`. -145 Returns the new `potential_values`. -146 -147 If `QSys.potential_name` is not present or not recognised, -148 the current `QSys.potential_values` are used. -149 -150 If a bigger `QSys.gridsize` is provided, -151 the potential is also interpolated to the new gridsize. -152 """ -153 data = deepcopy(system) -154 # Is there a potential_name? -155 if not data.potential_name: -156 if not data.potential_values.any(): -157 raise ValueError(f'No potential_name and no potential_values found in the system!') -158 elif data.potential_name.lower() == 'titov2023': -159 data.potential_values = titov2023(data) -160 elif data.potential_name.lower() == 'zero': -161 data.potential_values = zero(data) -162 elif data.potential_name.lower() == 'sine': -163 data.potential_values = sine(data) -164 # At least there should be potential_values -165 elif not data.potential_values.any(): -166 raise ValueError("Unrecognised potential_name '{data.potential_name}' and no potential_values found") -167 return data.potential_values -168 -169 -170def zero(system:QSys): -171 """Zero potential.""" -172 x = system.grid -173 return 0 * x -174 -175 -176def sine(system:QSys): -177 """Sine potential. -178 -179 If potential_constants are provided, returns: -180 $C_0 + C_1 sin(3x + C_2)$. -181 """ -182 x = system.grid -183 C = system.potential_constants -184 C0 = 0 -185 C1 = 1 -186 C2 = 0 -187 if C: -188 if len(C) > 0: -189 C0 = C[0] -190 if len(C) > 1: -191 C1 = C[1] -192 if len(C) > 2: -193 C2 = C[2] -194 return C0 + C1 * np.sin(3*x + C2) -195 -196 -197def titov2023(system:QSys): -198 """Potential energy function of the hindered methyl rotor, from titov2023.""" -199 x = system.grid -200 C = system.potential_constants -201 if C is None: -202 C = constants.constants_titov2023[0] -203 return C[0] + C[1] * np.sin(3*x) + C[2] * np.cos(3*x) + C[3] * np.sin(6*x) + C[4] * np.cos(6*x) + 84 output:str='potential.dat', + 85 include:list=['.out'], + 86 ignore:list=['slurm-'], + 87 ) -> None: + 88 """Creates a potential data file from Quantum ESPRESSO outputs. + 89 + 90 The angle in degrees is extracted from the output filenames, + 91 which must follow `whatever_ANGLE.out`. + 92 + 93 Outputs from SCF calculations must be located in the provided `folder` (CWD if None). + 94 Files can be filtered by those containing the specified `filters`, + 95 excluding those containing any string from the `ignore` list. + 96 The `output` name is `potential.dat` by default. + 97 """ + 98 folder = file.get_dir(folder) + 99 files = file.get_list(folder=folder, include=include, ignore=ignore, abspath=True) +100 potential_data = '# Angle/deg Potential/eV\n' +101 potential_data_list = [] +102 print('Extracting the potential as a function of the angle...') +103 print('----------------------------------') +104 counter_success = 0 +105 counter_errors = 0 +106 for filepath in files: +107 filename = os.path.basename(filepath) +108 filepath = file.get(filepath=filepath, filters='.out', return_anyway=True) +109 if not filepath: # Not an output file, skip it +110 continue +111 content = qe.read_out(filepath) +112 if not content['Success']: # Ignore unsuccessful calculations +113 print(f'x {filename}') +114 counter_errors += 1 +115 continue +116 energy = content['Energy'] * phys.Ry_to_eV +117 splits = filename.split('_') +118 angle = splits[-1].replace('.out', '') +119 angle = float(angle) +120 potential_data_list.append((angle, energy)) +121 print(f'OK {filename}') +122 counter_success += 1 +123 # Sort by angle +124 potential_data_list_sorted = sorted(potential_data_list, key=lambda x: x[0]) +125 # Append the sorted values as a string +126 for angle, energy in potential_data_list_sorted: +127 potential_data += f'{angle} {energy}\n' +128 with open(output, 'w') as f: +129 f.write(potential_data) +130 print('----------------------------------') +131 print(f'Succesful calculations (OK): {counter_success}') +132 print(f'Faulty calculations (x): {counter_errors}') +133 print('----------------------------------') +134 print(f'Saved angles and potential values at {output}') +135 return None +136 +137 +138def interpolate(system:QSys) -> QSys: +139 """Interpolates the current `aton.qrotor.classes.QSys.potential_values` to a new grid of size `aton.qrotor.classes.QSys.gridsize`.""" +140 V = system.potential_values +141 grid = system.grid +142 gridsize = system.gridsize +143 new_grid = np.linspace(0, 2*np.pi, gridsize) +144 cubic_spline = CubicSpline(grid, V) +145 new_V = cubic_spline(new_grid) +146 system.grid = new_grid +147 system.potential_values = new_V +148 print(f"Interpolated potential to a grid of size {gridsize}") +149 return system +150 +151 +152# Redirect to the desired potential energy function +153def solve(system:QSys): +154 """Solves `aton.qrotor.classes.QSys.potential_values`, +155 according to the `aton.qrotor.classes.QSys.potential_name`. +156 Returns the new `potential_values`. +157 +158 If `QSys.potential_name` is not present or not recognised, +159 the current `QSys.potential_values` are used. +160 +161 If a bigger `QSys.gridsize` is provided, +162 the potential is also interpolated to the new gridsize. +163 """ +164 data = deepcopy(system) +165 # Is there a potential_name? +166 if not data.potential_name: +167 if not any(data.potential_values): +168 raise ValueError(f'No potential_name and no potential_values found in the system!') +169 elif data.potential_name.lower() == 'titov2023': +170 data.potential_values = titov2023(data) +171 elif data.potential_name.lower() == 'zero': +172 data.potential_values = zero(data) +173 elif data.potential_name.lower() == 'sine': +174 data.potential_values = sine(data) +175 # At least there should be potential_values +176 elif not any(data.potential_values): +177 raise ValueError("Unrecognised potential_name '{data.potential_name}' and no potential_values found") +178 return data.potential_values +179 +180 +181def zero(system:QSys): +182 """Zero potential.""" +183 x = system.grid +184 return 0 * x +185 +186 +187def sine(system:QSys): +188 """Sine potential. +189 +190 If potential_constants are provided, returns: +191 $C_0 + C_1 sin(3x + C_2)$. +192 """ +193 x = system.grid +194 C = system.potential_constants +195 C0 = 0 +196 C1 = 1 +197 C2 = 0 +198 if C: +199 if len(C) > 0: +200 C0 = C[0] +201 if len(C) > 1: +202 C1 = C[1] +203 if len(C) > 2: +204 C2 = C[2] +205 return C0 + C1 * np.sin(3*x + C2) +206 +207 +208def titov2023(system:QSys): +209 """Potential energy function of the hindered methyl rotor, from titov2023.""" +210 x = system.grid +211 C = system.potential_constants +212 if C is None: +213 C = constants.constants_titov2023[0] +214 return C[0] + C[1] * np.sin(3*x) + C[2] * np.cos(3*x) + C[3] * np.sin(6*x) + C[4] * np.cos(6*x)
36def load( 37 filepath:str='potential.dat', 38 system:QSys=None, -39 angle:str='deg', -40 energy:str='eV', +39 angle_unit:str='deg', +40 energy_unit:str='eV', 41 ) -> QSys: 42 """Read a potential rotational energy dataset. 43 -44 The file in `filepath` should contain two columns with `angle` and `potential` values. -45 Degrees and eV are assumed as default units unless stated in `angle` and `energy`. +44 The file in `filepath` should contain two columns with angle and potential energy values. +45 Degrees and eV are assumed as default units unless stated in `angle_unit` and `energy_unit`. 46 Units will be converted automatically to radians and eV. 47 """ 48 file_path = file.get(filepath) @@ -407,21 +418,21 @@Index
58 positions.append(float(position.strip())) 59 potentials.append(float(potential.strip())) 60 # Save angles to numpy arrays -61 if angle.lower() in alias.units['deg']: +61 if angle_unit.lower() in alias.units['deg']: 62 positions = np.radians(positions) -63 elif angle.lower() in alias.units['rad']: +63 elif angle_unit.lower() in alias.units['rad']: 64 positions = np.array(positions) 65 else: -66 raise ValueError(f"Angle unit '{angle}' not recognized.") +66 raise ValueError(f"Angle unit '{angle_unit}' not recognized.") 67 # Save energies to numpy arrays -68 if energy.lower() in alias.units['meV']: +68 if energy_unit.lower() in alias.units['meV']: 69 potentials = np.array(potentials) * 1000 -70 elif energy.lower() in alias.units['eV']: +70 elif energy_unit.lower() in alias.units['eV']: 71 potentials = np.array(potentials) -72 elif energy.lower() in alias.units['Ry']: +72 elif energy_unit.lower() in alias.units['Ry']: 73 potentials = np.array(potentials) * phys.Ry_to_eV 74 else: -75 raise ValueError(f"Energy unit '{energy}' not recognized.") +75 raise ValueError(f"Energy unit '{energy_unit}' not recognized.") 76 # Set the system 77 system.grid = np.array(positions) 78 system.gridsize = len(positions) @@ -432,8 +443,8 @@Index
@@ -444,7 +455,7 @@Read a potential rotational energy dataset.
-The file in
filepath
should contain two columns withangle
andpotential
values. -Degrees and eV are assumed as default units unless stated inangle
andenergy
. +The file in
filepath
should contain two columns with angle and potential energy values. +Degrees and eV are assumed as default units unless stated inangle_unit
andenergy_unit
. Units will be converted automatically to radians and eV.Index
def - from_qe(folder=None, filters: str = None, output: str = 'potential.dat') -> None: + from_qe( folder=None, output: str = 'potential.dat', include: list = ['.out'], ignore: list = ['slurm-']) -> None: @@ -452,47 +463,58 @@@@ -519,18 +542,18 @@Index
@@ -501,8 +523,9 @@83def from_qe( 84 folder=None, - 85 filters:str=None, - 86 output:str='potential.dat', - 87 ) -> None: - 88 """Creates a potential data file from Quantum ESPRESSO outputs. - 89 - 90 The angle in degrees is extracted from the output filenames, - 91 which must follow `whatever_ANGLE.out`. - 92 - 93 Outputs from SCF calculations must be located in the provided `folder` (CWD if None), - 94 and can be filtered with `filters`. - 95 The `output` name is `potential.dat` by default. - 96 """ - 97 folder = file.get_dir(folder) - 98 files = file.get_list(folder=folder, filters=filters, abspath=True) - 99 potential_data = '# Angle/deg Potential/eV\n' -100 potential_data_list = [] -101 print('Extracting the potential as a function of the angle...') -102 for filepath in files: -103 filename = os.path.basename(filepath) -104 filepath = file.get(filepath=filepath, filters='.out', return_anyway=True) -105 if not filepath: # Not an output file, skip it -106 continue -107 content = qe.read_out(filepath) -108 if not content['Success']: # Ignore unsuccessful calculations -109 print(f'{filename} was unsuccessful :(') -110 continue -111 energy = content['Energy'] * phys.Ry_to_eV -112 splits = filename.split('_') -113 angle = splits[-1].replace('.out', '') -114 angle = float(angle) -115 potential_data_list.append((angle, energy)) -116 print(f'{filename} added') -117 # Sort by angle -118 potential_data_list_sorted = sorted(potential_data_list, key=lambda x: x[0]) -119 # Append the sorted values as a string -120 for angle, energy in potential_data_list_sorted: -121 potential_data += f'{angle} {energy}\n' -122 with open(output, 'w') as f: -123 f.write(potential_data) -124 print(f'Saved angles and potential values at {output}') -125 return None + 85 output:str='potential.dat', + 86 include:list=['.out'], + 87 ignore:list=['slurm-'], + 88 ) -> None: + 89 """Creates a potential data file from Quantum ESPRESSO outputs. + 90 + 91 The angle in degrees is extracted from the output filenames, + 92 which must follow `whatever_ANGLE.out`. + 93 + 94 Outputs from SCF calculations must be located in the provided `folder` (CWD if None). + 95 Files can be filtered by those containing the specified `filters`, + 96 excluding those containing any string from the `ignore` list. + 97 The `output` name is `potential.dat` by default. + 98 """ + 99 folder = file.get_dir(folder) +100 files = file.get_list(folder=folder, include=include, ignore=ignore, abspath=True) +101 potential_data = '# Angle/deg Potential/eV\n' +102 potential_data_list = [] +103 print('Extracting the potential as a function of the angle...') +104 print('----------------------------------') +105 counter_success = 0 +106 counter_errors = 0 +107 for filepath in files: +108 filename = os.path.basename(filepath) +109 filepath = file.get(filepath=filepath, filters='.out', return_anyway=True) +110 if not filepath: # Not an output file, skip it +111 continue +112 content = qe.read_out(filepath) +113 if not content['Success']: # Ignore unsuccessful calculations +114 print(f'x {filename}') +115 counter_errors += 1 +116 continue +117 energy = content['Energy'] * phys.Ry_to_eV +118 splits = filename.split('_') +119 angle = splits[-1].replace('.out', '') +120 angle = float(angle) +121 potential_data_list.append((angle, energy)) +122 print(f'OK {filename}') +123 counter_success += 1 +124 # Sort by angle +125 potential_data_list_sorted = sorted(potential_data_list, key=lambda x: x[0]) +126 # Append the sorted values as a string +127 for angle, energy in potential_data_list_sorted: +128 potential_data += f'{angle} {energy}\n' +129 with open(output, 'w') as f: +130 f.write(potential_data) +131 print('----------------------------------') +132 print(f'Succesful calculations (OK): {counter_success}') +133 print(f'Faulty calculations (x): {counter_errors}') +134 print('----------------------------------') +135 print(f'Saved angles and potential values at {output}') +136 return NoneIndex
The angle in degrees is extracted from the output filenames, which must follow
-whatever_ANGLE.out
.Outputs from SCF calculations must be located in the provided
folder
(CWD if None), -and can be filtered withfilters
. +Outputs from SCF calculations must be located in the provided
folder
(CWD if None). +Files can be filtered by those containing the specifiedfilters
, +excluding those containing any string from theignore
list. Theoutput
name ispotential.dat
by default.Index
128def interpolate(system:QSys) -> QSys: -129 """Interpolates the current `aton.qrotor.classes.QSys.potential_values` to a new grid of size `aton.qrotor.classes.QSys.gridsize`.""" -130 V = system.potential_values -131 grid = system.grid -132 gridsize = system.gridsize -133 new_grid = np.linspace(0, 2*np.pi, gridsize) -134 cubic_spline = CubicSpline(grid, V) -135 new_V = cubic_spline(new_grid) -136 system.grid = new_grid -137 system.potential_values = new_V -138 print(f"Interpolated potential to a grid of size {gridsize}") -139 return system +@@ -550,32 +573,32 @@139def interpolate(system:QSys) -> QSys: +140 """Interpolates the current `aton.qrotor.classes.QSys.potential_values` to a new grid of size `aton.qrotor.classes.QSys.gridsize`.""" +141 V = system.potential_values +142 grid = system.grid +143 gridsize = system.gridsize +144 new_grid = np.linspace(0, 2*np.pi, gridsize) +145 cubic_spline = CubicSpline(grid, V) +146 new_V = cubic_spline(new_grid) +147 system.grid = new_grid +148 system.potential_values = new_V +149 print(f"Interpolated potential to a grid of size {gridsize}") +150 return systemIndex
143def solve(system:QSys): -144 """Solves `aton.qrotor.classes.QSys.potential_values`, -145 according to the `aton.qrotor.classes.QSys.potential_name`. -146 Returns the new `potential_values`. -147 -148 If `QSys.potential_name` is not present or not recognised, -149 the current `QSys.potential_values` are used. -150 -151 If a bigger `QSys.gridsize` is provided, -152 the potential is also interpolated to the new gridsize. -153 """ -154 data = deepcopy(system) -155 # Is there a potential_name? -156 if not data.potential_name: -157 if not data.potential_values.any(): -158 raise ValueError(f'No potential_name and no potential_values found in the system!') -159 elif data.potential_name.lower() == 'titov2023': -160 data.potential_values = titov2023(data) -161 elif data.potential_name.lower() == 'zero': -162 data.potential_values = zero(data) -163 elif data.potential_name.lower() == 'sine': -164 data.potential_values = sine(data) -165 # At least there should be potential_values -166 elif not data.potential_values.any(): -167 raise ValueError("Unrecognised potential_name '{data.potential_name}' and no potential_values found") -168 return data.potential_values +@@ -603,10 +626,10 @@154def solve(system:QSys): +155 """Solves `aton.qrotor.classes.QSys.potential_values`, +156 according to the `aton.qrotor.classes.QSys.potential_name`. +157 Returns the new `potential_values`. +158 +159 If `QSys.potential_name` is not present or not recognised, +160 the current `QSys.potential_values` are used. +161 +162 If a bigger `QSys.gridsize` is provided, +163 the potential is also interpolated to the new gridsize. +164 """ +165 data = deepcopy(system) +166 # Is there a potential_name? +167 if not data.potential_name: +168 if not any(data.potential_values): +169 raise ValueError(f'No potential_name and no potential_values found in the system!') +170 elif data.potential_name.lower() == 'titov2023': +171 data.potential_values = titov2023(data) +172 elif data.potential_name.lower() == 'zero': +173 data.potential_values = zero(data) +174 elif data.potential_name.lower() == 'sine': +175 data.potential_values = sine(data) +176 # At least there should be potential_values +177 elif not any(data.potential_values): +178 raise ValueError("Unrecognised potential_name '{data.potential_name}' and no potential_values found") +179 return data.potential_valuesIndex
171def zero(system:QSys): -172 """Zero potential.""" -173 x = system.grid -174 return 0 * x + @@ -626,25 +649,25 @@Index
177def sine(system:QSys): -178 """Sine potential. -179 -180 If potential_constants are provided, returns: -181 $C_0 + C_1 sin(3x + C_2)$. -182 """ -183 x = system.grid -184 C = system.potential_constants -185 C0 = 0 -186 C1 = 1 -187 C2 = 0 -188 if C: -189 if len(C) > 0: -190 C0 = C[0] -191 if len(C) > 1: -192 C1 = C[1] -193 if len(C) > 2: -194 C2 = C[2] -195 return C0 + C1 * np.sin(3*x + C2) +@@ -667,13 +690,13 @@188def sine(system:QSys): +189 """Sine potential. +190 +191 If potential_constants are provided, returns: +192 $C_0 + C_1 sin(3x + C_2)$. +193 """ +194 x = system.grid +195 C = system.potential_constants +196 C0 = 0 +197 C1 = 1 +198 C2 = 0 +199 if C: +200 if len(C) > 0: +201 C0 = C[0] +202 if len(C) > 1: +203 C1 = C[1] +204 if len(C) > 2: +205 C2 = C[2] +206 return C0 + C1 * np.sin(3*x + C2)Index
198def titov2023(system:QSys): -199 """Potential energy function of the hindered methyl rotor, from titov2023.""" -200 x = system.grid -201 C = system.potential_constants -202 if C is None: -203 C = constants.constants_titov2023[0] -204 return C[0] + C[1] * np.sin(3*x) + C[2] * np.cos(3*x) + C[3] * np.sin(6*x) + C[4] * np.cos(6*x) +diff --git a/docs/aton/qrotor/rotate.html b/docs/aton/qrotor/rotate.html index ad414ed..192841d 100644 --- a/docs/aton/qrotor/rotate.html +++ b/docs/aton/qrotor/rotate.html @@ -83,7 +83,7 @@209def titov2023(system:QSys): +210 """Potential energy function of the hindered methyl rotor, from titov2023.""" +211 x = system.grid +212 C = system.potential_constants +213 if C is None: +214 C = constants.constants_titov2023[0] +215 return C[0] + C[1] * np.sin(3*x) + C[2] * np.cos(3*x) + C[3] * np.sin(6*x) + C[4] * np.cos(6*x)API Documentation
- + built with pdocContents
API Documentation
- + built with pdoc
- - laplacian_matrix -
-- - hamiltonian_matrix + energies
- potential @@ -87,12 +84,15 @@
API Documentation
schrodinger- - energies + hamiltonian_matrix +
+- + laplacian_matrix
Index
- -- laplacian_matrix()
Calculate the second derivative matrix for a given grid -- - hamiltonian_matrix()
Calculate the hamiltonian matrix of the system ++ energies()
Solve the system(s) for the QSys
orQExp
object@@ -138,8 +134,12 @@ potential()
Index
Solve the Schrödiger equation for the system - +- energies()
Solve the system(s) for the +QSys
orQExp
object+ hamiltonian_matrix()
Calculate the hamiltonian matrix of the system ++ @@ -162,11 +162,11 @@+ laplacian_matrix()
Calculate the second derivative matrix for a given grid Index
9 10| | | 11| --- | --- | - 12| `laplacian_matrix()` | Calculate the second derivative matrix for a given grid | - 13| `hamiltonian_matrix()` | Calculate the hamiltonian matrix of the system | - 14| `potential()` | Solve the potential values of the system | - 15| `schrodinger()` | Solve the Schrödiger equation for the system | - 16| `energies()` | Solve the system(s) for the `QSys` or `QExp` object | + 12| `energies()` | Solve the system(s) for the `QSys` or `QExp` object | + 13| `potential()` | Solve the potential values of the system | + 14| `schrodinger()` | Solve the Schrödiger equation for the system | + 15| `hamiltonian_matrix()` | Calculate the hamiltonian matrix of the system | + 16| `laplacian_matrix()` | Calculate the second derivative matrix for a given grid | 17 18--- 19""" @@ -182,146 +182,123 @@Index
29import aton 30 31 - 32def laplacian_matrix(grid): - 33 """Calculates the Laplacian (second derivative) matrix for a given `grid`.""" - 34 x = grid - 35 diagonals = [-2*np.ones(len(x)), np.ones(len(x)), np.ones(len(x))] - 36 laplacian_matrix = sparse.spdiags(diagonals, [0, -1, 1], format='lil') - 37 # Periodic boundary conditions - 38 laplacian_matrix[0, -1] = 1 - 39 laplacian_matrix[-1, 0] = 1 - 40 dx = x[1] - x[0] - 41 laplacian_matrix /= dx**2 - 42 return laplacian_matrix - 43 - 44 - 45def hamiltonian_matrix(system:QSys): - 46 """Calculates the Hamiltonian matrix for a given `aton.qrotor.classes.QSys` object.""" - 47 V = system.potential_values.tolist() - 48 potential = sparse.diags(V, format='lil') - 49 B = system.B - 50 x = system.grid - 51 H = -B * laplacian_matrix(x) + potential - 52 return H - 53 - 54 - 55def potential(system:QSys) -> QSys: - 56 """Solves the potential_values of the system. - 57 - 58 It uses the potential name, by calling `aton.qrotor.potential.solve`. - 59 Then it applies extra operations, such as removing the potential offset - 60 if `aton.qrotor.classes.QSys.correct_potential_offset = True`. - 61 """ - 62 if system.gridsize > len(system.grid): - 63 system = interpolate(system) - 64 V = solve_potential(system) - 65 if system.correct_potential_offset is True: - 66 offset = min(V) - 67 V = V - offset - 68 system.corrected_potential_offset = offset - 69 system.potential_values = V - 70 return system - 71 - 72 - 73def schrodinger(system:QSys) -> QSys: - 74 """Solves the Schrödinger equation for a given `aton.qrotor.classes.QSys` object. - 75 - 76 Uses ARPACK in shift-inverse mode to solve the hamiltonian sparse matrix. - 77 """ - 78 time_start = time.time() - 79 V = system.potential_values - 80 H = hamiltonian_matrix(system) - 81 print(f'Solving Hamiltonian matrix of size {system.gridsize}...') - 82 # Solve eigenvalues with ARPACK in shift-inverse mode, with a sparse matrix - 83 eigenvalues, eigenvectors = sparse.linalg.eigsh(H, system.E_levels, which='LM', sigma=0, maxiter=10000) - 84 if any(eigenvalues) is None: - 85 print('WARNING: Not all eigenvalues were found.\n') - 86 else: print('Done.\n') - 87 system.runtime = time.time() - time_start - 88 system.eigenvalues = eigenvalues - 89 system.potential_max = max(V) - 90 system.potential_min = min(V) - 91 system.energy_barrier = max(V) - min(eigenvalues) - 92 system.first_transition = eigenvalues[1] - eigenvalues[0] - 93 if system.save_eigenvectors == True: - 94 system.eigenvectors = eigenvectors - 95 system.eigenvalues_B = eigenvalues / system.B - 96 system.potential_max_B = system.potential_max / system.B - 97 return system - 98 - 99 -100def energies(var, filename:str=None) -> QExp: -101 """Solves the Schrödinger equation for a given `aton.qrotor.classes.QSys` or `aton.qrotor.classes.QExp` object.""" -102 if isinstance(var, QSys): -103 data = QExp() -104 data.systems = [deepcopy(var)] -105 elif isinstance(var, QExp): -106 data = deepcopy(var) -107 else: -108 raise TypeError('Input must be a QSys or QExp object.') -109 for system in data.systems: -110 system = potential(system) -111 system = schrodinger(system) -112 if filename: -113 aton.st.file.save(data, filename) -114 return data + 32def energies(var, filename:str=None) -> QExp: + 33 """Solves the Schrödinger equation for a given `aton.qrotor.classes.QSys` or `aton.qrotor.classes.QExp` object.""" + 34 if isinstance(var, QSys): + 35 data = QExp() + 36 data.systems = [deepcopy(var)] + 37 elif isinstance(var, QExp): + 38 data = deepcopy(var) + 39 else: + 40 raise TypeError('Input must be a QSys or QExp object.') + 41 for system in data.systems: + 42 system = potential(system) + 43 system = schrodinger(system) + 44 if filename: + 45 aton.st.file.save(data, filename) + 46 return data + 47 + 48 + 49def potential(system:QSys) -> QSys: + 50 """Solves the potential_values of the system. + 51 + 52 It uses the potential name, by calling `aton.qrotor.potential.solve`. + 53 Then it applies extra operations, such as removing the potential offset + 54 if `aton.qrotor.classes.QSys.correct_potential_offset = True`. + 55 """ + 56 if system.gridsize > len(system.grid): + 57 system = interpolate(system) + 58 V = solve_potential(system) + 59 if system.correct_potential_offset is True: + 60 offset = min(V) + 61 V = V - offset + 62 system.corrected_potential_offset = offset + 63 system.potential_values = V + 64 return system + 65 + 66 + 67def schrodinger(system:QSys) -> QSys: + 68 """Solves the Schrödinger equation for a given `aton.qrotor.classes.QSys` object. + 69 + 70 Uses ARPACK in shift-inverse mode to solve the hamiltonian sparse matrix. + 71 """ + 72 time_start = time.time() + 73 V = system.potential_values + 74 H = hamiltonian_matrix(system) + 75 print(f'Solving Hamiltonian matrix of size {system.gridsize}...') + 76 # Solve eigenvalues with ARPACK in shift-inverse mode, with a sparse matrix + 77 eigenvalues, eigenvectors = sparse.linalg.eigsh(H, system.E_levels, which='LM', sigma=0, maxiter=10000) + 78 if any(eigenvalues) is None: + 79 print('WARNING: Not all eigenvalues were found.\n') + 80 else: print('Done.\n') + 81 system.runtime = time.time() - time_start + 82 system.eigenvalues = eigenvalues + 83 system.potential_max = max(V) + 84 system.potential_min = min(V) + 85 system.energy_barrier = max(V) - min(eigenvalues) + 86 system.first_transition = eigenvalues[1] - eigenvalues[0] + 87 if system.save_eigenvectors == True: + 88 system.eigenvectors = eigenvectors + 89 system.eigenvalues_B = eigenvalues / system.B + 90 system.potential_max_B = system.potential_max / system.B + 91 return system + 92 + 93 + 94def hamiltonian_matrix(system:QSys): + 95 """Calculates the Hamiltonian matrix for a given `aton.qrotor.classes.QSys` object.""" + 96 V = system.potential_values.tolist() + 97 potential = sparse.diags(V, format='lil') + 98 B = system.B + 99 x = system.grid +100 H = -B * laplacian_matrix(x) + potential +101 return H +102 +103 +104def laplacian_matrix(grid): +105 """Calculates the Laplacian (second derivative) matrix for a given `grid`.""" +106 x = grid +107 diagonals = [-2*np.ones(len(x)), np.ones(len(x)), np.ones(len(x))] +108 laplacian_matrix = sparse.spdiags(diagonals, [0, -1, 1], format='lil') +109 # Periodic boundary conditions +110 laplacian_matrix[0, -1] = 1 +111 laplacian_matrix[-1, 0] = 1 +112 dx = x[1] - x[0] +113 laplacian_matrix /= dx**2 +114 return laplacian_matrix
33def laplacian_matrix(grid): -34 """Calculates the Laplacian (second derivative) matrix for a given `grid`.""" -35 x = grid -36 diagonals = [-2*np.ones(len(x)), np.ones(len(x)), np.ones(len(x))] -37 laplacian_matrix = sparse.spdiags(diagonals, [0, -1, 1], format='lil') -38 # Periodic boundary conditions -39 laplacian_matrix[0, -1] = 1 -40 laplacian_matrix[-1, 0] = 1 -41 dx = x[1] - x[0] -42 laplacian_matrix /= dx**2 -43 return laplacian_matrix -
Calculates the Laplacian (second derivative) matrix for a given grid
.
46def hamiltonian_matrix(system:QSys): -47 """Calculates the Hamiltonian matrix for a given `aton.qrotor.classes.QSys` object.""" -48 V = system.potential_values.tolist() -49 potential = sparse.diags(V, format='lil') -50 B = system.B -51 x = system.grid -52 H = -B * laplacian_matrix(x) + potential -53 return H + +-33def energies(var, filename:str=None) -> QExp: +34 """Solves the Schrödinger equation for a given `aton.qrotor.classes.QSys` or `aton.qrotor.classes.QExp` object.""" +35 if isinstance(var, QSys): +36 data = QExp() +37 data.systems = [deepcopy(var)] +38 elif isinstance(var, QExp): +39 data = deepcopy(var) +40 else: +41 raise TypeError('Input must be a QSys or QExp object.') +42 for system in data.systems: +43 system = potential(system) +44 system = schrodinger(system) +45 if filename: +46 aton.st.file.save(data, filename) +47 return data-Calculates the Hamiltonian matrix for a given
+aton.qrotor.classes.QSys
object.@@ -337,22 +314,22 @@Solves the Schrödinger equation for a given
aton.qrotor.classes.QSys
oraton.qrotor.classes.QExp
object.Index
-56def potential(system:QSys) -> QSys: -57 """Solves the potential_values of the system. -58 -59 It uses the potential name, by calling `aton.qrotor.potential.solve`. -60 Then it applies extra operations, such as removing the potential offset -61 if `aton.qrotor.classes.QSys.correct_potential_offset = True`. -62 """ -63 if system.gridsize > len(system.grid): -64 system = interpolate(system) -65 V = solve_potential(system) -66 if system.correct_potential_offset is True: -67 offset = min(V) -68 V = V - offset -69 system.corrected_potential_offset = offset -70 system.potential_values = V -71 return system +@@ -376,31 +353,31 @@50def potential(system:QSys) -> QSys: +51 """Solves the potential_values of the system. +52 +53 It uses the potential name, by calling `aton.qrotor.potential.solve`. +54 Then it applies extra operations, such as removing the potential offset +55 if `aton.qrotor.classes.QSys.correct_potential_offset = True`. +56 """ +57 if system.gridsize > len(system.grid): +58 system = interpolate(system) +59 V = solve_potential(system) +60 if system.correct_potential_offset is True: +61 offset = min(V) +62 V = V - offset +63 system.corrected_potential_offset = offset +64 system.potential_values = V +65 return systemIndex
74def schrodinger(system:QSys) -> QSys: -75 """Solves the Schrödinger equation for a given `aton.qrotor.classes.QSys` object. -76 -77 Uses ARPACK in shift-inverse mode to solve the hamiltonian sparse matrix. -78 """ -79 time_start = time.time() -80 V = system.potential_values -81 H = hamiltonian_matrix(system) -82 print(f'Solving Hamiltonian matrix of size {system.gridsize}...') -83 # Solve eigenvalues with ARPACK in shift-inverse mode, with a sparse matrix -84 eigenvalues, eigenvectors = sparse.linalg.eigsh(H, system.E_levels, which='LM', sigma=0, maxiter=10000) -85 if any(eigenvalues) is None: -86 print('WARNING: Not all eigenvalues were found.\n') -87 else: print('Done.\n') -88 system.runtime = time.time() - time_start -89 system.eigenvalues = eigenvalues -90 system.potential_max = max(V) -91 system.potential_min = min(V) -92 system.energy_barrier = max(V) - min(eigenvalues) -93 system.first_transition = eigenvalues[1] - eigenvalues[0] -94 if system.save_eigenvectors == True: -95 system.eigenvectors = eigenvectors -96 system.eigenvalues_B = eigenvalues / system.B -97 system.potential_max_B = system.potential_max / system.B -98 return system +@@ -411,36 +388,59 @@68def schrodinger(system:QSys) -> QSys: +69 """Solves the Schrödinger equation for a given `aton.qrotor.classes.QSys` object. +70 +71 Uses ARPACK in shift-inverse mode to solve the hamiltonian sparse matrix. +72 """ +73 time_start = time.time() +74 V = system.potential_values +75 H = hamiltonian_matrix(system) +76 print(f'Solving Hamiltonian matrix of size {system.gridsize}...') +77 # Solve eigenvalues with ARPACK in shift-inverse mode, with a sparse matrix +78 eigenvalues, eigenvectors = sparse.linalg.eigsh(H, system.E_levels, which='LM', sigma=0, maxiter=10000) +79 if any(eigenvalues) is None: +80 print('WARNING: Not all eigenvalues were found.\n') +81 else: print('Done.\n') +82 system.runtime = time.time() - time_start +83 system.eigenvalues = eigenvalues +84 system.potential_max = max(V) +85 system.potential_min = min(V) +86 system.energy_barrier = max(V) - min(eigenvalues) +87 system.first_transition = eigenvalues[1] - eigenvalues[0] +88 if system.save_eigenvectors == True: +89 system.eigenvectors = eigenvectors +90 system.eigenvalues_B = eigenvalues / system.B +91 system.potential_max_B = system.potential_max / system.B +92 return systemIndex
-- + + def - energies(var, filename: str = None) -> aton.qrotor.classes.QExp: + hamiltonian_matrix(system: aton.qrotor.classes.QSys): - +- -101def energies(var, filename:str=None) -> QExp: -102 """Solves the Schrödinger equation for a given `aton.qrotor.classes.QSys` or `aton.qrotor.classes.QExp` object.""" -103 if isinstance(var, QSys): -104 data = QExp() -105 data.systems = [deepcopy(var)] -106 elif isinstance(var, QExp): -107 data = deepcopy(var) -108 else: -109 raise TypeError('Input must be a QSys or QExp object.') -110 for system in data.systems: -111 system = potential(system) -112 system = schrodinger(system) -113 if filename: -114 aton.st.file.save(data, filename) -115 return data + +-95def hamiltonian_matrix(system:QSys): + 96 """Calculates the Hamiltonian matrix for a given `aton.qrotor.classes.QSys` object.""" + 97 V = system.potential_values.tolist() + 98 potential = sparse.diags(V, format='lil') + 99 B = system.B +100 x = system.grid +101 H = -B * laplacian_matrix(x) + potential +102 return H@@ -485,7 +504,7 @@Solves the Schrödinger equation for a given
+aton.qrotor.classes.QSys
oraton.qrotor.classes.QExp
object.+ + + +Calculates the Hamiltonian matrix for a given
+aton.qrotor.classes.QSys
object.+ + + + def + laplacian_matrix(grid): + + + ++ ++ + +105def laplacian_matrix(grid): +106 """Calculates the Laplacian (second derivative) matrix for a given `grid`.""" +107 x = grid +108 diagonals = [-2*np.ones(len(x)), np.ones(len(x)), np.ones(len(x))] +109 laplacian_matrix = sparse.spdiags(diagonals, [0, -1, 1], format='lil') +110 # Periodic boundary conditions +111 laplacian_matrix[0, -1] = 1 +112 laplacian_matrix[-1, 0] = 1 +113 dx = x[1] - x[0] +114 laplacian_matrix /= dx**2 +115 return laplacian_matrix +diff --git a/docs/aton/spx.html b/docs/aton/spx.html index 19c13b5..0240a12 100644 --- a/docs/aton/spx.html +++ b/docs/aton/spx.html @@ -83,7 +83,7 @@Calculates the Laplacian (second derivative) matrix for a given
grid
.Submodules
- + built with pdocAPI Documentation - + built with pdoc
API Documentation - + built with pdoc
API Documentation - + built with pdoc
API Documentation - + built with pdoc
API Documentation - + built with pdoc
API Documentation - + built with pdoc
Submodules - + built with pdoc
API Documentation - + built with pdoc
API Documentation - + built with pdoc
API Documentation - + built with pdoc
Index 49 if os.path.isfile(filepath): 50 return os.path.abspath(filepath) 51 elif os.path.isdir(filepath): - 52 files = get_list(filepath, filters, abspath=True) + 52 files = get_list(folder=filepath, include=filters, abspath=True) 53 elif return_anyway: 54 return None 55 else: @@ -260,197 +260,216 @@
Index
66 67 68def get_list( - 69 folder:str, - 70 filters=None, - 71 abspath:bool=True - 72 ) -> list: - 73 """Return the files inside a `folder`, applying optional `filters`. - 74 - 75 The full paths are returned by default; to get only the base names, set `abspath = False`. - 76 """ - 77 if os.path.isfile(folder): - 78 folder = os.path.dirname(folder) - 79 if not os.path.isdir(folder): - 80 raise FileNotFoundError('Directory not found: ' + folder) - 81 folder = os.path.abspath(folder) - 82 files = os.listdir(folder) - 83 # Apply filters or not - 84 if filters is not None: - 85 target_files = [] - 86 if not isinstance(filters, list): - 87 filters = [str(filters)] - 88 for filter_i in filters: - 89 filter_i = os.path.basename(filter_i) - 90 for f in files: - 91 if filter_i in f: - 92 target_files.append(f) - 93 files = target_files - 94 if abspath: - 95 filepaths = [] - 96 for f in files: - 97 filepaths.append(os.path.join(folder, f)) - 98 files = filepaths - 99 return files -100 -101 -102def get_dir(folder=None) -> str: -103 """Returns the full path of `folder` or the parent folder if it's a file. If none is provided, the current working directory is returned.""" -104 if folder == None: -105 path = os.getcwd() -106 elif os.path.isdir(folder): -107 path = os.path.realpath(folder) -108 elif not os.path.isdir(folder): -109 if os.path.isfile: -110 path = os.path.dirname(folder) -111 path = os.path.realpath(path) -112 else: -113 raise FileNotFoundError(f'Missing folder at {folder}') -114 return path -115 -116 -117def copy( -118 old:str, -119 new:str -120 ) -> None: -121 """Copies `old` file to `new` file""" -122 # Yes, I know, why use ATON for this right? copy() and move() functions are here just for consistancy. -123 file = shutil.copy(old, new) -124 return None -125 -126 -127def move( -128 old:str, -129 new:str -130 ) -> None: -131 """Moves `old` file to `new` file.""" -132 file = shutil.move(old, new) -133 return None + 69 folder:str=None, + 70 include=None, + 71 ignore=None, + 72 abspath:bool=True, + 73 also_folders:bool=False, + 74 ) -> list: + 75 """Return the files inside a `folder`, applying optional filters. + 76 + 77 Only filenames containing all strings in the `include` list will be returned. + 78 Filenames containing any string from the `ignore` list will be ignored. + 79 + 80 The full paths are returned by default; to get only the base names, set `abspath = False`. + 81 The CWD folder is used by default if no `folder` is provided. + 82 It also returns folders if `also_folders = True`. + 83 """ + 84 if not folder: + 85 folder = os.getcwd() + 86 if os.path.isfile(folder): + 87 folder = os.path.dirname(folder) + 88 if not os.path.isdir(folder): + 89 raise FileNotFoundError('Directory not found: ' + folder) + 90 folder = os.path.abspath(folder) + 91 files = os.listdir(folder) + 92 if not files: + 93 return [] + 94 # Absolute paths? + 95 if abspath: + 96 files = [os.path.join(folder, f) for f in files] + 97 # Should we keep only files? + 98 if not also_folders: + 99 files = [f for f in files if not os.path.isdir(f if abspath else os.path.join(folder, f))] +100 # Apply filters if provided +101 if include is not None: +102 # Ensure include filters is always a list +103 if not isinstance(include, list): +104 include = [str(include)] +105 # Normalize filter names +106 include = [os.path.basename(i) for i in include] +107 # Only keep files that contain all filters +108 files = [f for f in files if all(filter_str in os.path.basename(f) for filter_str in include)] +109 # Remove files containing any string from the ignore list +110 if ignore is not None: +111 # Ensure ignore filters is always a list +112 if not isinstance(ignore, list): +113 ignore = [str(ignore)] +114 # Normalize ignoring filter names +115 ignore = [os.path.basename(i) for i in ignore] +116 # Exclude the corresponding files +117 files = [f for f in files if not any(filter_str in os.path.basename(f) for filter_str in ignore)] +118 return files +119 +120 +121def get_dir(folder=None) -> str: +122 """Returns the full path of `folder` or the parent folder if it's a file. If none is provided, the current working directory is returned.""" +123 if folder == None: +124 path = os.getcwd() +125 elif os.path.isdir(folder): +126 path = os.path.realpath(folder) +127 elif not os.path.isdir(folder): +128 if os.path.isfile: +129 path = os.path.dirname(folder) +130 path = os.path.realpath(path) +131 else: +132 raise FileNotFoundError(f'Missing folder at {folder}') +133 return path 134 135 -136def remove(filepath:str) -> None: -137 """Removes the given file or folder at `filepath`. -138 -139 > WARNING: Removing stuff is always dangerous, be careful! -140 """ -141 if filepath is None: -142 return None # It did not exist in the first place -143 elif os.path.isfile(filepath): -144 os.remove(filepath) -145 elif os.path.isdir(filepath): -146 shutil.rmtree(filepath) -147 else: -148 return None # It did not exist in the first place -149 return None -150 -151 -152def rename_on_folder( -153 old:str, -154 new:str, -155 folder=None, -156 ) -> None: -157 """Batch renames files in the given `folder`. -158 -159 Replaces the `old` string by `new` string. -160 If no folder is provided, the current working directory is used. -161 """ -162 if folder is None: -163 files = os.listdir('.') -164 elif os.path.isdir(folder): -165 file_list = os.listdir(folder) -166 files = [] -167 for file in file_list: -168 file_path = os.path.join(folder, file) -169 files.append(file_path) -170 elif os.path.isdir(os.path.join(os.getcwd(), folder)): -171 folder_path = os.path.join(os.getcwd(), folder) -172 file_list = os.listdir(folder_path) -173 files = [] -174 for file in file_list: -175 file_path = os.path.join(folder_path, file) -176 files.append(file_path) -177 else: -178 raise FileNotFoundError('Missing folder at ' + folder + ' or in the CWD ' + os.getcwd()) -179 for f in files: -180 if old in f: -181 os.rename(f, f.replace(old, new)) -182 return None -183 -184 -185def rename_on_folders( -186 old:str, -187 new:str, -188 folder=None, -189 ) -> None: -190 """Renames the files inside the subfolders in the parent `folder`. -191 -192 Renames from an `old` string to the `new` string. -193 If no `folder` is provided, the current working directory is used. -194 """ -195 if folder is None: -196 things = os.listdir('.') -197 elif os.path.isdir(folder): -198 things = os.listdir(folder) -199 elif os.path.isdir(os.path.join(os.getcwd(), folder)): -200 things = os.listdir(os.path.join(os.getcwd(), folder)) -201 else: -202 raise FileNotFoundError('Missing folder at ' + folder + ' or in the CWD ' + os.getcwd()) -203 for d in things: -204 if os.path.isdir(d): -205 for f in os.listdir(d): -206 if old in f: -207 old_file = os.path.join(d, f) -208 new_file = os.path.join(d, f.replace(old, new)) -209 os.rename(old_file, new_file) -210 return None -211 -212 -213def copy_to_folders( -214 folder=None, -215 extension:str=None, -216 strings_to_delete:list=[], -217 ) -> None: -218 """Copies the files from the parent `folder` with the given `extension` to individual subfolders. -219 -220 The subfolders are named as the original files, -221 removing the strings from the `strings_to_delete` list. -222 If no `folder` is provided, it runs in the current working directory. -223 """ -224 if folder is None: -225 folder = os.getcwd() -226 old_files = get_list(folder, extension) -227 if old_files is None: -228 raise ValueError('No ' + extension + ' files found in path!') -229 for old_file in old_files: -230 new_file = old_file -231 for string in strings_to_delete: -232 new_file = new_file.replace(string, '') -233 path = new_file.replace(extension, '') -234 os.makedirs(path, exist_ok=True) -235 new_file_path = os.path.join(path, new_file) -236 copy(old_file, new_file_path) -237 return None +136def copy( +137 old:str, +138 new:str +139 ) -> None: +140 """Copies `old` file to `new` file""" +141 # Yes, I know, why use ATON for this right? copy() and move() functions are here just for consistancy. +142 file = shutil.copy(old, new) +143 return None +144 +145 +146def move( +147 old:str, +148 new:str +149 ) -> None: +150 """Moves `old` file to `new` file.""" +151 file = shutil.move(old, new) +152 return None +153 +154 +155def remove(filepath:str) -> None: +156 """Removes the given file or folder at `filepath`. +157 +158 > WARNING: Removing stuff is always dangerous, be careful! +159 """ +160 if filepath is None: +161 return None # It did not exist in the first place +162 elif os.path.isfile(filepath): +163 os.remove(filepath) +164 elif os.path.isdir(filepath): +165 shutil.rmtree(filepath) +166 else: +167 return None # It did not exist in the first place +168 return None +169 +170 +171def rename_on_folder( +172 old:str, +173 new:str, +174 folder=None, +175 ) -> None: +176 """Batch renames files in the given `folder`. +177 +178 Replaces the `old` string by `new` string. +179 If no folder is provided, the current working directory is used. +180 """ +181 if folder is None: +182 files = os.listdir('.') +183 elif os.path.isdir(folder): +184 file_list = os.listdir(folder) +185 files = [] +186 for file in file_list: +187 file_path = os.path.join(folder, file) +188 files.append(file_path) +189 elif os.path.isdir(os.path.join(os.getcwd(), folder)): +190 folder_path = os.path.join(os.getcwd(), folder) +191 file_list = os.listdir(folder_path) +192 files = [] +193 for file in file_list: +194 file_path = os.path.join(folder_path, file) +195 files.append(file_path) +196 else: +197 raise FileNotFoundError('Missing folder at ' + folder + ' or in the CWD ' + os.getcwd()) +198 for f in files: +199 if old in f: +200 os.rename(f, f.replace(old, new)) +201 return None +202 +203 +204def rename_on_folders( +205 old:str, +206 new:str, +207 folder=None, +208 ) -> None: +209 """Renames the files inside the subfolders in the parent `folder`. +210 +211 Renames from an `old` string to the `new` string. +212 If no `folder` is provided, the current working directory is used. +213 """ +214 if folder is None: +215 things = os.listdir('.') +216 elif os.path.isdir(folder): +217 things = os.listdir(folder) +218 elif os.path.isdir(os.path.join(os.getcwd(), folder)): +219 things = os.listdir(os.path.join(os.getcwd(), folder)) +220 else: +221 raise FileNotFoundError('Missing folder at ' + folder + ' or in the CWD ' + os.getcwd()) +222 for d in things: +223 if os.path.isdir(d): +224 for f in os.listdir(d): +225 if old in f: +226 old_file = os.path.join(d, f) +227 new_file = os.path.join(d, f.replace(old, new)) +228 os.rename(old_file, new_file) +229 return None +230 +231 +232def copy_to_folders( +233 folder=None, +234 extension:str=None, +235 strings_to_delete:list=[], +236 ) -> None: +237 """Copies the files from the parent `folder` with the given `extension` to individual subfolders. 238 -239 -240def save(object, filename:str=None): -241 """Save a Python object in the current working directory as a binary `*.aton` file.""" -242 filename = 'data' if filename is None else filename -243 if not filename.endswith('.aton'): -244 filename += '.aton' -245 file = os.path.join(os.getcwd(), filename) -246 with gzip.open(file, 'wb') as f: -247 pickle.dump(object, f) -248 print(f"Data saved and compressed to {file}") -249 -250 -251def load(filepath:str='data.aton'): -252 """Load a Python object from a binary `*.aton` file. -253 -254 Use only if you trust the person who sent you the file! -255 """ -256 file_path = get(filepath) -257 with gzip.open(file_path, 'rb') as f: -258 data = pickle.load(f) -259 return data +239 The subfolders are named as the original files, +240 removing the strings from the `strings_to_delete` list. +241 If no `folder` is provided, it runs in the current working directory. +242 """ +243 if folder is None: +244 folder = os.getcwd() +245 old_files = get_list(folder=folder, include=extension) +246 if old_files is None: +247 raise ValueError('No ' + extension + ' files found in path!') +248 for old_file in old_files: +249 new_file = old_file +250 for string in strings_to_delete: +251 new_file = new_file.replace(string, '') +252 path = new_file.replace(extension, '') +253 os.makedirs(path, exist_ok=True) +254 new_file_path = os.path.join(path, new_file) +255 copy(old_file, new_file_path) +256 return None +257 +258 +259def save(object, filename:str=None): +260 """Save a Python object in the current working directory as a binary `*.aton` file.""" +261 filename = 'data' if filename is None else filename +262 if not filename.endswith('.aton'): +263 filename += '.aton' +264 file = os.path.join(os.getcwd(), filename) +265 with gzip.open(file, 'wb') as f: +266 pickle.dump(object, f) +267 print(f"Data saved and compressed to {file}") +268 +269 +270def load(filepath:str='data.aton'): +271 """Load a Python object from a binary `*.aton` file. +272 +273 Use only if you trust the person who sent you the file! +274 """ +275 file_path = get(filepath) +276 with gzip.open(file_path, 'rb') as f: +277 data = pickle.load(f) +278 return dataIndex
50 if os.path.isfile(filepath): 51 return os.path.abspath(filepath) 52 elif os.path.isdir(filepath): -53 files = get_list(filepath, filters, abspath=True) +53 files = get_list(folder=filepath, include=filters, abspath=True) 54 elif return_anyway: 55 return None 56 else: @@ -521,50 +540,74 @@Index
def - get_list(folder: str, filters=None, abspath: bool = True) -> list: + get_list( folder: str = None, include=None, ignore=None, abspath: bool = True, also_folders: bool = False) -> list:-69def get_list( - 70 folder:str, - 71 filters=None, - 72 abspath:bool=True - 73 ) -> list: - 74 """Return the files inside a `folder`, applying optional `filters`. - 75 - 76 The full paths are returned by default; to get only the base names, set `abspath = False`. - 77 """ - 78 if os.path.isfile(folder): - 79 folder = os.path.dirname(folder) - 80 if not os.path.isdir(folder): - 81 raise FileNotFoundError('Directory not found: ' + folder) - 82 folder = os.path.abspath(folder) - 83 files = os.listdir(folder) - 84 # Apply filters or not - 85 if filters is not None: - 86 target_files = [] - 87 if not isinstance(filters, list): - 88 filters = [str(filters)] - 89 for filter_i in filters: - 90 filter_i = os.path.basename(filter_i) - 91 for f in files: - 92 if filter_i in f: - 93 target_files.append(f) - 94 files = target_files - 95 if abspath: - 96 filepaths = [] - 97 for f in files: - 98 filepaths.append(os.path.join(folder, f)) - 99 files = filepaths -100 return files + 70 folder:str=None, + 71 include=None, + 72 ignore=None, + 73 abspath:bool=True, + 74 also_folders:bool=False, + 75 ) -> list: + 76 """Return the files inside a `folder`, applying optional filters. + 77 + 78 Only filenames containing all strings in the `include` list will be returned. + 79 Filenames containing any string from the `ignore` list will be ignored. + 80 + 81 The full paths are returned by default; to get only the base names, set `abspath = False`. + 82 The CWD folder is used by default if no `folder` is provided. + 83 It also returns folders if `also_folders = True`. + 84 """ + 85 if not folder: + 86 folder = os.getcwd() + 87 if os.path.isfile(folder): + 88 folder = os.path.dirname(folder) + 89 if not os.path.isdir(folder): + 90 raise FileNotFoundError('Directory not found: ' + folder) + 91 folder = os.path.abspath(folder) + 92 files = os.listdir(folder) + 93 if not files: + 94 return [] + 95 # Absolute paths? + 96 if abspath: + 97 files = [os.path.join(folder, f) for f in files] + 98 # Should we keep only files? + 99 if not also_folders: +100 files = [f for f in files if not os.path.isdir(f if abspath else os.path.join(folder, f))] +101 # Apply filters if provided +102 if include is not None: +103 # Ensure include filters is always a list +104 if not isinstance(include, list): +105 include = [str(include)] +106 # Normalize filter names +107 include = [os.path.basename(i) for i in include] +108 # Only keep files that contain all filters +109 files = [f for f in files if all(filter_str in os.path.basename(f) for filter_str in include)] +110 # Remove files containing any string from the ignore list +111 if ignore is not None: +112 # Ensure ignore filters is always a list +113 if not isinstance(ignore, list): +114 ignore = [str(ignore)] +115 # Normalize ignoring filter names +116 ignore = [os.path.basename(i) for i in ignore] +117 # Exclude the corresponding files +118 files = [f for f in files if not any(filter_str in os.path.basename(f) for filter_str in ignore)] +119 return files-Return the files inside a
+folder
, applying optionalfilters
.@@ -580,19 +623,19 @@Return the files inside a
-folder
, applying optional filters.The full paths are returned by default; to get only the base names, set
+abspath = False
.Only filenames containing all strings in the
+ +include
list will be returned. +Filenames containing any string from theignore
list will be ignored.The full paths are returned by default; to get only the base names, set
abspath = False
. +The CWD folder is used by default if nofolder
is provided. +It also returns folders ifalso_folders = True
.Index
-103def get_dir(folder=None) -> str: -104 """Returns the full path of `folder` or the parent folder if it's a file. If none is provided, the current working directory is returned.""" -105 if folder == None: -106 path = os.getcwd() -107 elif os.path.isdir(folder): -108 path = os.path.realpath(folder) -109 elif not os.path.isdir(folder): -110 if os.path.isfile: -111 path = os.path.dirname(folder) -112 path = os.path.realpath(path) -113 else: -114 raise FileNotFoundError(f'Missing folder at {folder}') -115 return path +@@ -612,14 +655,14 @@122def get_dir(folder=None) -> str: +123 """Returns the full path of `folder` or the parent folder if it's a file. If none is provided, the current working directory is returned.""" +124 if folder == None: +125 path = os.getcwd() +126 elif os.path.isdir(folder): +127 path = os.path.realpath(folder) +128 elif not os.path.isdir(folder): +129 if os.path.isfile: +130 path = os.path.dirname(folder) +131 path = os.path.realpath(path) +132 else: +133 raise FileNotFoundError(f'Missing folder at {folder}') +134 return pathIndex
-118def copy( -119 old:str, -120 new:str -121 ) -> None: -122 """Copies `old` file to `new` file""" -123 # Yes, I know, why use ATON for this right? copy() and move() functions are here just for consistancy. -124 file = shutil.copy(old, new) -125 return None +@@ -639,13 +682,13 @@137def copy( +138 old:str, +139 new:str +140 ) -> None: +141 """Copies `old` file to `new` file""" +142 # Yes, I know, why use ATON for this right? copy() and move() functions are here just for consistancy. +143 file = shutil.copy(old, new) +144 return NoneIndex
-128def move( -129 old:str, -130 new:str -131 ) -> None: -132 """Moves `old` file to `new` file.""" -133 file = shutil.move(old, new) -134 return None +@@ -665,20 +708,20 @@147def move( +148 old:str, +149 new:str +150 ) -> None: +151 """Moves `old` file to `new` file.""" +152 file = shutil.move(old, new) +153 return NoneIndex
-137def remove(filepath:str) -> None: -138 """Removes the given file or folder at `filepath`. -139 -140 > WARNING: Removing stuff is always dangerous, be careful! -141 """ -142 if filepath is None: -143 return None # It did not exist in the first place -144 elif os.path.isfile(filepath): -145 os.remove(filepath) -146 elif os.path.isdir(filepath): -147 shutil.rmtree(filepath) -148 else: -149 return None # It did not exist in the first place -150 return None +@@ -702,37 +745,37 @@156def remove(filepath:str) -> None: +157 """Removes the given file or folder at `filepath`. +158 +159 > WARNING: Removing stuff is always dangerous, be careful! +160 """ +161 if filepath is None: +162 return None # It did not exist in the first place +163 elif os.path.isfile(filepath): +164 os.remove(filepath) +165 elif os.path.isdir(filepath): +166 shutil.rmtree(filepath) +167 else: +168 return None # It did not exist in the first place +169 return NoneIndex
-153def rename_on_folder( -154 old:str, -155 new:str, -156 folder=None, -157 ) -> None: -158 """Batch renames files in the given `folder`. -159 -160 Replaces the `old` string by `new` string. -161 If no folder is provided, the current working directory is used. -162 """ -163 if folder is None: -164 files = os.listdir('.') -165 elif os.path.isdir(folder): -166 file_list = os.listdir(folder) -167 files = [] -168 for file in file_list: -169 file_path = os.path.join(folder, file) -170 files.append(file_path) -171 elif os.path.isdir(os.path.join(os.getcwd(), folder)): -172 folder_path = os.path.join(os.getcwd(), folder) -173 file_list = os.listdir(folder_path) -174 files = [] -175 for file in file_list: -176 file_path = os.path.join(folder_path, file) -177 files.append(file_path) -178 else: -179 raise FileNotFoundError('Missing folder at ' + folder + ' or in the CWD ' + os.getcwd()) -180 for f in files: -181 if old in f: -182 os.rename(f, f.replace(old, new)) -183 return None +@@ -755,32 +798,32 @@172def rename_on_folder( +173 old:str, +174 new:str, +175 folder=None, +176 ) -> None: +177 """Batch renames files in the given `folder`. +178 +179 Replaces the `old` string by `new` string. +180 If no folder is provided, the current working directory is used. +181 """ +182 if folder is None: +183 files = os.listdir('.') +184 elif os.path.isdir(folder): +185 file_list = os.listdir(folder) +186 files = [] +187 for file in file_list: +188 file_path = os.path.join(folder, file) +189 files.append(file_path) +190 elif os.path.isdir(os.path.join(os.getcwd(), folder)): +191 folder_path = os.path.join(os.getcwd(), folder) +192 file_list = os.listdir(folder_path) +193 files = [] +194 for file in file_list: +195 file_path = os.path.join(folder_path, file) +196 files.append(file_path) +197 else: +198 raise FileNotFoundError('Missing folder at ' + folder + ' or in the CWD ' + os.getcwd()) +199 for f in files: +200 if old in f: +201 os.rename(f, f.replace(old, new)) +202 return NoneIndex
-186def rename_on_folders( -187 old:str, -188 new:str, -189 folder=None, -190 ) -> None: -191 """Renames the files inside the subfolders in the parent `folder`. -192 -193 Renames from an `old` string to the `new` string. -194 If no `folder` is provided, the current working directory is used. -195 """ -196 if folder is None: -197 things = os.listdir('.') -198 elif os.path.isdir(folder): -199 things = os.listdir(folder) -200 elif os.path.isdir(os.path.join(os.getcwd(), folder)): -201 things = os.listdir(os.path.join(os.getcwd(), folder)) -202 else: -203 raise FileNotFoundError('Missing folder at ' + folder + ' or in the CWD ' + os.getcwd()) -204 for d in things: -205 if os.path.isdir(d): -206 for f in os.listdir(d): -207 if old in f: -208 old_file = os.path.join(d, f) -209 new_file = os.path.join(d, f.replace(old, new)) -210 os.rename(old_file, new_file) -211 return None +@@ -803,31 +846,31 @@205def rename_on_folders( +206 old:str, +207 new:str, +208 folder=None, +209 ) -> None: +210 """Renames the files inside the subfolders in the parent `folder`. +211 +212 Renames from an `old` string to the `new` string. +213 If no `folder` is provided, the current working directory is used. +214 """ +215 if folder is None: +216 things = os.listdir('.') +217 elif os.path.isdir(folder): +218 things = os.listdir(folder) +219 elif os.path.isdir(os.path.join(os.getcwd(), folder)): +220 things = os.listdir(os.path.join(os.getcwd(), folder)) +221 else: +222 raise FileNotFoundError('Missing folder at ' + folder + ' or in the CWD ' + os.getcwd()) +223 for d in things: +224 if os.path.isdir(d): +225 for f in os.listdir(d): +226 if old in f: +227 old_file = os.path.join(d, f) +228 new_file = os.path.join(d, f.replace(old, new)) +229 os.rename(old_file, new_file) +230 return NoneIndex
-214def copy_to_folders( -215 folder=None, -216 extension:str=None, -217 strings_to_delete:list=[], -218 ) -> None: -219 """Copies the files from the parent `folder` with the given `extension` to individual subfolders. -220 -221 The subfolders are named as the original files, -222 removing the strings from the `strings_to_delete` list. -223 If no `folder` is provided, it runs in the current working directory. -224 """ -225 if folder is None: -226 folder = os.getcwd() -227 old_files = get_list(folder, extension) -228 if old_files is None: -229 raise ValueError('No ' + extension + ' files found in path!') -230 for old_file in old_files: -231 new_file = old_file -232 for string in strings_to_delete: -233 new_file = new_file.replace(string, '') -234 path = new_file.replace(extension, '') -235 os.makedirs(path, exist_ok=True) -236 new_file_path = os.path.join(path, new_file) -237 copy(old_file, new_file_path) -238 return None +@@ -851,15 +894,15 @@233def copy_to_folders( +234 folder=None, +235 extension:str=None, +236 strings_to_delete:list=[], +237 ) -> None: +238 """Copies the files from the parent `folder` with the given `extension` to individual subfolders. +239 +240 The subfolders are named as the original files, +241 removing the strings from the `strings_to_delete` list. +242 If no `folder` is provided, it runs in the current working directory. +243 """ +244 if folder is None: +245 folder = os.getcwd() +246 old_files = get_list(folder=folder, include=extension) +247 if old_files is None: +248 raise ValueError('No ' + extension + ' files found in path!') +249 for old_file in old_files: +250 new_file = old_file +251 for string in strings_to_delete: +252 new_file = new_file.replace(string, '') +253 path = new_file.replace(extension, '') +254 os.makedirs(path, exist_ok=True) +255 new_file_path = os.path.join(path, new_file) +256 copy(old_file, new_file_path) +257 return NoneIndex
-241def save(object, filename:str=None): -242 """Save a Python object in the current working directory as a binary `*.aton` file.""" -243 filename = 'data' if filename is None else filename -244 if not filename.endswith('.aton'): -245 filename += '.aton' -246 file = os.path.join(os.getcwd(), filename) -247 with gzip.open(file, 'wb') as f: -248 pickle.dump(object, f) -249 print(f"Data saved and compressed to {file}") +@@ -879,15 +922,15 @@260def save(object, filename:str=None): +261 """Save a Python object in the current working directory as a binary `*.aton` file.""" +262 filename = 'data' if filename is None else filename +263 if not filename.endswith('.aton'): +264 filename += '.aton' +265 file = os.path.join(os.getcwd(), filename) +266 with gzip.open(file, 'wb') as f: +267 pickle.dump(object, f) +268 print(f"Data saved and compressed to {file}")Index
252def load(filepath:str='data.aton'): -253 """Load a Python object from a binary `*.aton` file. -254 -255 Use only if you trust the person who sent you the file! -256 """ -257 file_path = get(filepath) -258 with gzip.open(file_path, 'rb') as f: -259 data = pickle.load(f) -260 return data +diff --git a/docs/aton/txt.html b/docs/aton/txt.html index 461d7fc..781c2fa 100644 --- a/docs/aton/txt.html +++ b/docs/aton/txt.html @@ -80,7 +80,7 @@271def load(filepath:str='data.aton'): +272 """Load a Python object from a binary `*.aton` file. +273 +274 Use only if you trust the person who sent you the file! +275 """ +276 file_path = get(filepath) +277 with gzip.open(file_path, 'rb') as f: +278 data = pickle.load(f) +279 return dataSubmodules
- + built with pdocAPI Documentation - + built with pdoc
API Documentation - + built with pdoc
API Documentation - + built with pdoc
o;o++){for(var r=e[o],s=0;i>s&&(r=this._queue[s](r,o,e),void 0!==r&&null!==r);s++);void 0!==r&&null!==r&&t.push(r)}return t},t.Pipeline.prototype.reset=function(){this._queue=[]},t.Pipeline.prototype.get=function(){return this._queue},t.Pipeline.prototype.toJSON=function(){return this._queue.map(function(e){return t.Pipeline.warnIfFunctionNotRegistered(e),e.label})},t.Index=function(){this._fields=[],this._ref="id",this.pipeline=new t.Pipeline,this.documentStore=new t.DocumentStore,this.index={},this.eventEmitter=new t.EventEmitter,this._idfCache={},this.on("add","remove","update",function(){this._idfCache={}}.bind(this))},t.Index.prototype.on=function(){var e=Array.prototype.slice.call(arguments);return this.eventEmitter.addListener.apply(this.eventEmitter,e)},t.Index.prototype.off=function(e,t){return this.eventEmitter.removeListener(e,t)},t.Index.load=function(e){e.version!==t.version&&t.utils.warn("version mismatch: current "+t.version+" importing "+e.version);var n=new this;n._fields=e.fields,n._ref=e.ref,n.documentStore=t.DocumentStore.load(e.documentStore),n.pipeline=t.Pipeline.load(e.pipeline),n.index={};for(var i in e.index)n.index[i]=t.InvertedIndex.load(e.index[i]);return n},t.Index.prototype.addField=function(e){return this._fields.push(e),this.index[e]=new t.InvertedIndex,this},t.Index.prototype.setRef=function(e){return this._ref=e,this},t.Index.prototype.saveDocument=function(e){return this.documentStore=new t.DocumentStore(e),this},t.Index.prototype.addDoc=function(e,n){if(e){var n=void 0===n?!0:n,i=e[this._ref];this.documentStore.addDoc(i,e),this._fields.forEach(function(n){var o=this.pipeline.run(t.tokenizer(e[n]));this.documentStore.addFieldLength(i,n,o.length);var r={};o.forEach(function(e){e in r?r[e]+=1:r[e]=1},this);for(var s in r){var u=r[s];u=Math.sqrt(u),this.index[n].addToken(s,{ref:i,tf:u})}},this),n&&this.eventEmitter.emit("add",e,this)}},t.Index.prototype.removeDocByRef=function(e){if(e&&this.documentStore.isDocStored()!==!1&&this.documentStore.hasDoc(e)){var t=this.documentStore.getDoc(e);this.removeDoc(t,!1)}},t.Index.prototype.removeDoc=function(e,n){if(e){var n=void 0===n?!0:n,i=e[this._ref];this.documentStore.hasDoc(i)&&(this.documentStore.removeDoc(i),this._fields.forEach(function(n){var o=this.pipeline.run(t.tokenizer(e[n]));o.forEach(function(e){this.index[n].removeToken(e,i)},this)},this),n&&this.eventEmitter.emit("remove",e,this))}},t.Index.prototype.updateDoc=function(e,t){var t=void 0===t?!0:t;this.removeDocByRef(e[this._ref],!1),this.addDoc(e,!1),t&&this.eventEmitter.emit("update",e,this)},t.Index.prototype.idf=function(e,t){var n="@"+t+"/"+e;if(Object.prototype.hasOwnProperty.call(this._idfCache,n))return this._idfCache[n];var i=this.index[t].getDocFreq(e),o=1+Math.log(this.documentStore.length/(i+1));return this._idfCache[n]=o,o},t.Index.prototype.getFields=function(){return this._fields.slice()},t.Index.prototype.search=function(e,n){if(!e)return[];e="string"==typeof e?{any:e}:JSON.parse(JSON.stringify(e));var i=null;null!=n&&(i=JSON.stringify(n));for(var o=new t.Configuration(i,this.getFields()).get(),r={},s=Object.keys(e),u=0;u
0&&t.push(e);for(var i in n)"docs"!==i&&"df"!==i&&this.expandToken(e+i,t,n[i]);return t},t.InvertedIndex.prototype.toJSON=function(){return{root:this.root}},t.Configuration=function(e,n){var e=e||"";if(void 0==n||null==n)throw new Error("fields should not be null");this.config={};var i;try{i=JSON.parse(e),this.buildUserConfig(i,n)}catch(o){t.utils.warn("user configuration parse failed, will use default configuration"),this.buildDefaultConfig(n)}},t.Configuration.prototype.buildDefaultConfig=function(e){this.reset(),e.forEach(function(e){this.config[e]={boost:1,bool:"OR",expand:!1}},this)},t.Configuration.prototype.buildUserConfig=function(e,n){var i="OR",o=!1;if(this.reset(),"bool"in e&&(i=e.bool||i),"expand"in e&&(o=e.expand||o),"fields"in e)for(var r in e.fields)if(n.indexOf(r)>-1){var s=e.fields[r],u=o;void 0!=s.expand&&(u=s.expand),this.config[r]={boost:s.boost||0===s.boost?s.boost:1,bool:s.bool||i,expand:u}}else t.utils.warn("field name in user configuration not found in index instance fields");else this.addAllFields2UserConfig(i,o,n)},t.Configuration.prototype.addAllFields2UserConfig=function(e,t,n){n.forEach(function(n){this.config[n]={boost:1,bool:e,expand:t}},this)},t.Configuration.prototype.get=function(){return this.config},t.Configuration.prototype.reset=function(){this.config={}},lunr.SortedSet=function(){this.length=0,this.elements=[]},lunr.SortedSet.load=function(e){var t=new this;return t.elements=e,t.length=e.length,t},lunr.SortedSet.prototype.add=function(){var e,t;for(e=0;e 1;){if(r===e)return o;e>r&&(t=o),r>e&&(n=o),i=n-t,o=t+Math.floor(i/2),r=this.elements[o]}return r===e?o:-1},lunr.SortedSet.prototype.locationFor=function(e){for(var t=0,n=this.elements.length,i=n-t,o=t+Math.floor(i/2),r=this.elements[o];i>1;)e>r&&(t=o),r>e&&(n=o),i=n-t,o=t+Math.floor(i/2),r=this.elements[o];return r>e?o:e>r?o+1:void 0},lunr.SortedSet.prototype.intersect=function(e){for(var t=new lunr.SortedSet,n=0,i=0,o=this.length,r=e.length,s=this.elements,u=e.elements;;){if(n>o-1||i>r-1)break;s[n]!==u[i]?s[n]u[i]&&i++:(t.add(s[n]),n++,i++)}return t},lunr.SortedSet.prototype.clone=function(){var e=new lunr.SortedSet;return e.elements=this.toArray(),e.length=e.elements.length,e},lunr.SortedSet.prototype.union=function(e){var t,n,i;this.length>=e.length?(t=this,n=e):(t=e,n=this),i=t.clone();for(var o=0,r=n.toArray();o \n\n
Welcome to ATON
\n\nThe Ab-iniTiO & Neutron research toolbox,\nor ATON,\nprovides powerful and comprehensive tools\nfor cutting-edge materials research,\nfocused on (but not limited to) neutron science.
\n\nJust like its ancient Egyptian deity counterpart,\nthis all-in-one Python package contains a range of tools from spectra normalisation to deuteration estimations.\nA set of physico-chemical constants and definitions is also included.\nATON also allows you to easily create, edit and analyse all kinds of text files,\nwith a special focus on ab-initio calculation files.\nIn particular, it contains interfaces for Quantum ESPRESSO,\nPhonopy and CASTEP.
\n\nThe source code is available on GitHub.
\n\n
\n\nInstallation
\n\nAs always, it is recommended to install your packages in a virtual environment:
\n\n\n\n\n\npython3 -m venv .venv\nsource .venv/bin/activate\n
With pip
\n\nThe fastest way to install ATON is through pip:
\n\n\n\n\n\npip install aton\n
To upgrade to a newer version,
\n\n\n\n\n\npip install aton -U\n
From source
\n\nOptionally, you can install ATON from the GitHub repository.
\n\nFirst install the dependencies:
\n\n\n\n\n\npip install pandas numpy scipy matplotlib\n
Then clone the repository or download the latest stable release as a ZIP, unzip it, and run inside the
\n\nAton/
directory:\n\n\n\npip install .\n
\n\nDocumentation
\n\nThe full ATON documentation is available online.
\n\n
\nAn offline version of the documentation is found atdocs/aton.html
.
\nCode examples are included in theATON/examples/
folder.Interfaces for ab-initio codes
\n\nThe interface module contains interfaces for several ab-initio codes.\nThese are powered by the aton.txt module and can be easily extended.
\n\n\n\n
aton.interface
\n\n
\n\n\n \n\n\n\n \n \n \n\n aton.interface.qe
Interface for Quantum ESPRESSO's pw.x module \n\n \n\n aton.interface.phonopy
Interface for Phonopy calculations \n\n \n\n aton.interface.castep
Interface for CASTEP calculations \n\n \n\n\n aton.interface.slurm
Batch jobs via Slurm \nPhysico-chemical constants
\n\nThe phys module contains physico-chemical definitions.\nValues are accessed directly as
\n\nphys.value
orphys.function()
.\n\n
aton.phys
\n\n
\n\n\n \n\n\n\n \n \n \n\n aton.phys.units
Physical constants and conversion factors \n\n \n\n aton.phys.atoms
Megadictionary with data for all chemical elements \n\n \n\n\n aton.phys.functions
Functions to sort and analyse element data, and to update the atoms dictionary \nQuantum rotations
\n\nThe QRotor module is used to study the energy levels of quantum rotations,\nsuch as methyl and amine groups.
\n\n\n\n
aton.qrotor
\n\n
\n\n\n \n\n\n\n \n \n \n\n aton.qrotor.classes
Definition of the \nQSys
andQExp
classes\n \n\n aton.qrotor.constants
Bond lengths and inertias \n\n \n\n aton.qrotor.rotate
Rotate specific atoms from structural files \n\n \n\n aton.qrotor.potential
Potential definitions and loading functions \n\n \n\n aton.qrotor.solve
Solve rotation eigenvalues and eigenvectors \n\n \n\n\n aton.qrotor.plot
Plotting functions \nSpectra analysis
\n\nThe spx module includes tools for spectral analysis from\nInelastic Neutron Scattering, Raman, Infrared, etc.
\n\n\n\n
aton.spx
\n\n
\n\n\n \n\n\n\n \n \n \n\n aton.spx.classes
Class definitions for the spectra module \n\n \n\n aton.spx.fit
Spectra fitting functions \n\n \n\n aton.spx.normalize
Spectra normalization \n\n \n\n aton.spx.plot
Plotting \n\n \n\n aton.spx.deuterium
Deuteration estimations via INS \n\n \n\n\n aton.spx.samples
Sample materials for testing \nGeneral text edition
\n\nThe text module handles text files.\nIt powers more complex subpackages,\nsuch as aton.interface.
\n\n\n\n
aton.txt
\n\n
\n\n\n \n\n\n\n \n \n \n\n aton.txt.find
Search for specific content in text files \n\n \n\n aton.txt.edit
Manipulate text files \n\n \n\n\n aton.txt.extract
Extract data from raw text strings \nSystem tools
\n\nThe st module contains System Tools for common system tasks across subpackages.
\n\n\n\n
aton.st
\n\n
\n\n\n \n\n\n\n \n \n \n\n aton.st.file
File manipulation \n\n \n\n aton.st.call
Run bash scripts and related \n\n \n\n\n aton.st.alias
Useful dictionaries for user input correction \n
\n\nContributing
\n\nIf you are interested in opening an issue or a pull request, please feel free to do so on GitHub.
\n\n
\nFor major changes, please get in touch first to discuss the details.Code style
\n\nPlease try to follow some general guidelines:
\n\n\n
\n\n- Use a code style consistent with the rest of the project.
\n- Include docstrings to document new additions.
\n- Include automated tests for new features or modifications, see automated testing.
\n- Arrange function arguments by order of relevance. Most implemented functions follow something similar to
\nfunction(file, key/s, value/s, optional)
.Automated testing
\n\nIf you are modifying the source code, you should run the automated tests of the
\n\nATON/tests/
folder to check that everything works as intended.\nTo do so, first install PyTest in your environment,\n\n\n\npip install pytest\n
And then run PyTest inside the
\n\nATON/
directory,\n\n\n\npytest -vv\n
Compiling the documentation
\n\nThe documentation can be compiled automatically to
\n\ndocs/aton.html
with Pdoc and ATON itself, by running:\n\n\n\npython3 makedocs.py\n
This runs Pdoc, updating links and pictures, and using the custom theme CSS template from the
\n\ncss/
folder.
\n\nCitation
\n\nATON development started for the following paper, please cite if you use ATON in your work:
\n\n
\nCryst. Growth Des. 2024, 24, 391\u2212404License
\n\nCopyright (C) 2025 Pablo Gila-Herranz
\n"}, {"fullname": "aton.interface", "modulename": "aton.interface", "kind": "module", "doc": "
\nThis program is free software: you can redistribute it and/or modify\nit under the terms of the GNU Affero General Public License as published\nby the Free Software Foundation, either version 3 of the License, or\n(at your option) any later version.
\nThis program is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
\nSee the attached GNU Affero General Public License for more details.Ab-initio interfaces
\n\nThis module contains interfaces for several ab-initio calculation softwares.\nThese interfaces can be easily expanded with the
\n\naton.txt
module.Index
\n\n\n\n
\n\n\n \n\n\n\n \n \n \n\n aton.interface.qe
Interface for Quantum ESPRESSO's pw.x module \n\n \n\n aton.interface.phonopy
Interface for Phonopy calculations \n\n \n\n aton.interface.castep
Interface for CASTEP calculations \n\n \n\n\n aton.interface.slurm
Batch jobs via Slurm \nExamples
\n\nQuantum ESPRESSO
\n\nTo read the output from a Quantum ESPRESSO pw.x calculation,
\n\n\n\n\n\nfrom aton.interface import qe\n# Read to a dictionary\ncalculation = qe.read_out('relax.out')\ncalculation.keys() # See the available values\n# Final energy from the calculation\nenergy = calculation['Energy']\n
To modify values from an input file,
\n\n\n\n\n\nfrom aton.interface import qe\n# Add a hydrogen atom to a specific position\nqe.add_atom('H 0.10 0.20 0.30')\n# Set the input ecutwfc value\nqe.set_value('relax.in', 'ecutwfc', 60.0)\n
Check the full
\n\naton.interface.qe
API reference for more details.Phonopy
\n\nTo perform a phonon calculation from a relaxed structure via Quantum ESPRESSO,
\n\n\n\n\n\nfrom aton import interface\n# Create the supercell inputs\ninterface.phonopy.make_supercells(dimension='2 2 2')\n# Sbatch to a cluster\ninterface.slurm.sbatch('supercell-', 'template.slurm')\n
Check the full
\n\naton.interface.phonopy
API reference for more details.CASTEP
\n\nTo read output values from a CASTEP calculation,
\n\n\n\n\n\nfrom aton.interface import castep\n# Read the output\noutput = castep.read_castep('calculation.castep')\n# Get the final energy\nenergy = output['Energy']\n
Check the full
\n"}, {"fullname": "aton.interface.castep", "modulename": "aton.interface.castep", "kind": "module", "doc": "aton.interface.castep
API reference for more details.Description
\n\nFunctions to work with CASTEP calculation files.
\n\nIndex
\n\n\n\n
\n\n\n \n\n\n\n \n \n \n\n\n read_castep()
Output reading \n
\n"}, {"fullname": "aton.interface.castep.read_castep", "modulename": "aton.interface.castep", "qualname": "read_castep", "kind": "function", "doc": "Reads a CASTEP output file, specified in
\n\nfilename
.\nReturns a dictionary with the following keys:\n'Enthalpy'
(LBFGS: Final Enthalpy, in kJ/mol),\n'Energy'
(Total energy corrected for finite basis set, in eV),\n'Space group'
,'Volume'
(Angstrom^3),'Density'
(amu/Angstrom^3),'Density_g'
(g/cm^3),\n'A'
,'B'
,'C'
(Angstroms),'Alpha'
,'Beta'
,'Gamma'
(Degrees).Note that these output keys start with a Capital letter.
\n", "signature": "(filename) -> dict:", "funcdef": "def"}, {"fullname": "aton.interface.phonopy", "modulename": "aton.interface.phonopy", "kind": "module", "doc": "Description
\n\nFunctions to work with Phonopy calculations,\nalong with Quantum ESPRESSO.
\n\nIndex
\n\n\n\n
\n\n\n \n\n\n\n \n \n \n\n\n make_supercells()
Build supercell SCF inputs for phonon calculations \nExamples
\n\nTo create the supercells and run the phonon calculations\nfrom a folder with
\n\nrelax.in
andrelax.out
files,\nusing atemplate.slurm
file,\n\n\n\nfrom aton import interface\ninterface.phonopy.make_supercells()\ninterface.slurm.sbatch('supercell-', 'scf.slurm')\n
\n"}, {"fullname": "aton.interface.phonopy.make_supercells", "modulename": "aton.interface.phonopy", "qualname": "make_supercells", "kind": "function", "doc": "Creates the supercell inputs of a given
\n\ndimension
('2 2 2' by default),\nfrom therelax_in
andrelax_out
files in thefolder
\n('relax.in', 'relax.out' and CWD by default, respectively),\nneeded for the Phonopy calculations with Quantum ESPRESSO.If
\n", "signature": "(\tdimension: str = '2 2 2',\trelax_in: str = 'relax.in',\trelax_out: str = 'relax.out',\tfolder: str = None,\tslurm_template: str = None) -> None:", "funcdef": "def"}, {"fullname": "aton.interface.qe", "modulename": "aton.interface.qe", "kind": "module", "doc": "slurm_template
is present,\nit checks it withaton.interface.slurm.check_template()
.Description
\n\nTools to work with the pw.x module from Quantum ESPRESSO.
\n\nIndex
\n\nInput and output reading
\n\n
\nread_in()
\nread_out()
\nread_dir()
\nread_dirs()
Input file manipulation
\n\n
\nset_value()
\nadd_atom()
\nscf_from_relax()
Data extraction
\n\n
\nget_atom()
\ncount_elements()
\nnormalize_card()
\nto_cartesian()
\nfrom_cartesian()
Dicts with input file description
\n\n
\npw_namelists
\npw_cards
\n"}, {"fullname": "aton.interface.qe.read_in", "modulename": "aton.interface.qe", "qualname": "read_in", "kind": "function", "doc": "Reads a Quantum ESPRESSO input
\n\nfilepath
and returns the values as a dict.Dict keys are named after the corresponding variable.\nCARDS are returned as lists, and contain the\ntitle card + parameters in the first item.
\n", "signature": "(filepath) -> dict:", "funcdef": "def"}, {"fullname": "aton.interface.qe.read_out", "modulename": "aton.interface.qe", "qualname": "read_out", "kind": "function", "doc": "Reads a Quantum ESPRESSO output
\n\nfilepath
, returns a dict with the output keys.The output keys are:\n
\n\n'Energy'
(Ry),'Total force'
(float),'Total SCF correction'
(float),\n'Runtime'
(str),'JOB DONE'
(bool),'BFGS converged'
(bool),'BFGS failed'
(bool),\n'Maxiter reached'
(bool),'Error'
(str),'Success'
(bool),'CELL_PARAMETERS_out'
(list of str),'ATOMIC_POSITIONS_out'
(list of str),'Alat'
(bohr),'Volume'
(a.u.^3),'Density'
(g/cm^3).Note that these output keys start with a Capital letter.
\n", "signature": "(filepath) -> dict:", "funcdef": "def"}, {"fullname": "aton.interface.qe.read_dir", "modulename": "aton.interface.qe", "qualname": "read_dir", "kind": "function", "doc": "Takes a
\n\nfolder
from a QE calculation, returns a dict with input and output values.Input and output files are determined automatically,\nbut must be specified with
\n", "signature": "(folder, in_str: str = '.in', out_str: str = '.out') -> dict:", "funcdef": "def"}, {"fullname": "aton.interface.qe.read_dirs", "modulename": "aton.interface.qe", "qualname": "read_dirs", "kind": "function", "doc": "in_str
andout_str
\nif more than one file ends with.in
or.out
.Reads recursively QE calculations from all the subfolders inside the given
\n\ndirectory
.Results are saved to CSV files inside the current directory.\nInput and output files are determined automatically, but must be specified with\n
\n\nin_str
andout_str
if more than one file ends with.in
or.out
.To properly group the calculations per type, saving separated CSVs for each calculation type,\nyou can modify
\n\ncalc_splitter
('_' by default),calc_type_index
(0) andcalc_id_index
(1).\nWith these default values, a subfolder named './CalculationType_CalculationID_AdditionalText/'\nwill be interpreted as follows:\n
\n\n- Calculation type: 'CalculationType' (The output CSV will be named after this)
\n- CalculationID: 'CalculationID' (Stored in the 'ID' column of the resulting dataframe)
\nIf everything fails, the subfolder name will be used for the CSV file.
\n", "signature": "(\tdirectory,\tin_str: str = '.in',\tout_str: str = '.out',\tcalc_splitter='_',\tcalc_type_index=0,\tcalc_id_index=1) -> None:", "funcdef": "def"}, {"fullname": "aton.interface.qe.set_value", "modulename": "aton.interface.qe", "qualname": "set_value", "kind": "function", "doc": "Replace the
\n\nvalue
of akey
parameter in an inputfilepath
.Delete parameters with
\n\nvalue=''
.\nRemember to include the single quotes'
on values that use them.Updating 'ATOMIC_POSITIONS' updates 'nat' automatically,\nand updating 'ATOMIC_SPECIES' updates 'ntyp'.
\n\nOptionally change indentation with
\n", "signature": "(filepath, key: str, value, indent: str = ' ') -> None:", "funcdef": "def"}, {"fullname": "aton.interface.qe.add_atom", "modulename": "aton.interface.qe", "qualname": "add_atom", "kind": "function", "doc": "indent
, 2 spaces by default.Adds an atom in a given
\n\nfilepath
at a specifiedposition
.Position must be a string or a list, as follows:\n
\n\n\"specie:str float float float\"
or[specie:str, float, float, float]
.This method updates automatically other related values,\nsuch as 'ntyp' when updating ATOMIC_SPECIES, etc.
\n\nOptionally change indentation with
\n", "signature": "(filepath, position, indent=' ') -> None:", "funcdef": "def"}, {"fullname": "aton.interface.qe.get_atom", "modulename": "aton.interface.qe", "qualname": "get_atom", "kind": "function", "doc": "indent
, 2 spaces by default.Takes the approximate
\n\nposition
of an atom, and returns the full line from thefilepath
.It compares the atomic positions rounded up to the specified
\n", "signature": "(\tfilepath: str,\tposition: list,\tprecision: int = 3,\treturn_anyway: bool = False) -> str:", "funcdef": "def"}, {"fullname": "aton.interface.qe.normalize_card", "modulename": "aton.interface.qe", "qualname": "normalize_card", "kind": "function", "doc": "precision
decimals.\nIfreturn_anyway = True
, ignores errors and returns an empty string.Take a matched card, and return it in a normalised format.
\n\nOptionally change indentation with
\n", "signature": "(card: list, indent='') -> list:", "funcdef": "def"}, {"fullname": "aton.interface.qe.count_elements", "modulename": "aton.interface.qe", "qualname": "count_elements", "kind": "function", "doc": "indent
, 0 spaces by default.Takes ATOMIC_POSITIONS, returns a dict as
\n", "signature": "(atomic_positions) -> dict:", "funcdef": "def"}, {"fullname": "aton.interface.qe.scf_from_relax", "modulename": "aton.interface.qe", "qualname": "scf_from_relax", "kind": "function", "doc": "{element : number of atoms}
Create a Quantum ESPRESSO
\n\nscf.in
file from a previous relax calculation.If no
\n", "signature": "(\tfolder: str = None,\trelax_in: str = 'relax.in',\trelax_out: str = 'relax.out') -> None:", "funcdef": "def"}, {"fullname": "aton.interface.qe.to_cartesian", "modulename": "aton.interface.qe", "qualname": "to_cartesian", "kind": "function", "doc": "folder
is provided, the current working directory is used.\nTherelax_in
andrelax_out
files by default arerelax.in
andrelax.out
,\nupdate the names if necessary.Converts a given
\n\ncordinates
from crystal lattice vectors to cartesian.Only for
\n", "signature": "(filepath, coordinates) -> str:", "funcdef": "def"}, {"fullname": "aton.interface.qe.from_cartesian", "modulename": "aton.interface.qe", "qualname": "from_cartesian", "kind": "function", "doc": "ibrav=0
. Uses the cell parameters.\nNote that the result is not multiplied byA
norcelldm(1)
.Converts a given
\n\ncordinates
from cartesian to the base of lattice vectors.Only for
\n", "signature": "(filepath, coordinates: list) -> str:", "funcdef": "def"}, {"fullname": "aton.interface.qe.pw_namelists", "modulename": "aton.interface.qe", "qualname": "pw_namelists", "kind": "variable", "doc": "ibrav=0
. Uses the cell parameters.\nNote that the result is not divided byA
norcelldm(1)
.Dictionary with all possible NAMELISTs as keys, and the corresponding variables as values.
\n", "default_value": "{'&CONTROL': ['calculation', 'title', 'verbosity', 'restart_mode', 'wf_collect', 'nstep', 'iprint', 'tstress', 'tprnfor', 'dt', 'outdir', 'wfcdir', 'prefix', 'lkpoint_dir', 'max_seconds', 'etot_conv_thr', 'forc_conv_thr', 'disk_io', 'pseudo_dir', 'tefield', 'dipfield', 'lelfield', 'nberrycyc', 'lorbm', 'lberry', 'gdir', 'nppstr', 'gate', 'twochem', 'lfcp', 'trism'], '&SYSTEM': ['ibrav', 'celldm(1)', 'celldm(2)', 'celldm(3)', 'celldm(4)', 'celldm(5)', 'celldm(6)', 'A', 'B', 'C', 'cosAB', 'cosAC', 'cosBC', 'nat', 'ntyp', 'nbnd', 'nbnd_cond', 'tot_charge', 'starting_charge', 'tot_magnetization', 'starting_magnetization', 'ecutwfc', 'ecutrho', 'ecutfock', 'nr1', 'nr2', 'nr3', 'nr1s', 'nr2s', 'nr3s', 'nosym', 'nosym_evc', 'noinv', 'no_t_rev', 'force_symmorphic', 'use_all_frac', 'occupations', 'one_atom_occupations', 'starting_spin_angle', 'degauss_cond', 'nelec_cond', 'degauss', 'smearing', 'nspin', 'sic_gamma', 'pol_type', 'sic_energy', 'sci_vb', 'sci_cb', 'noncolin', 'ecfixed', 'qcutz', 'q2sigma', 'input_dft', 'ace', 'exx_fraction', 'screening_parameter', 'exxdiv_treatment', 'x_gamma_extrapolation', 'ecutvcutnqx1', 'nqx2', 'nqx3', 'localization_thr', 'Hubbard_occ', 'Hubbard_alpha', 'Hubbard_beta', 'starting_ns_eigenvalue', 'dmft', 'dmft_prefix', 'ensemble_energies', 'edir', 'emaxpos', 'eopreg', 'eamp', 'angle1', 'angle2', 'lforcet', 'constrained_magnetization', 'fixed_magnetization', 'lambda', 'report', 'lspinorb', 'assume_isolated', 'esm_bc', 'esm_w', 'esm_efield', 'esm_nfit', 'lgcscf', 'gcscf_mu', 'gcscf_conv_thr', 'gcscf_beta', 'vdw_corr', 'london', 'london_s6', 'london_c6', 'london_rvdw', 'london_rcut', 'dftd3_version', 'dftd3_threebody', 'ts_vdw_econv_thr', 'ts_vdw_isolated', 'xdm', 'xdm_a1', 'xdm_a2', 'space_group', 'uniqueb', 'origin_choice', 'rhombohedral', 'zgate', 'relaxz', 'block', 'block_1', 'block_2', 'block_height', 'nextffield'], '&ELECTRONS': ['electron_maxstep', 'exx_maxstep', 'scf_must_converge', 'conv_thr', 'adaptive_thr', 'conv_thr_init', 'conv_thr_multi', 'mixing_mode', 'mixing_beta', 'mixing_ndim', 'mixing_fixed_ns', 'diagonalization', 'diago_thr_init', 'diago_cg_maxiter', 'diago_ppcg_maxiter', 'diago_david_ndim', 'diago_rmm_ndim', 'diago_rmm_conv', 'diago_gs_nblock', 'diago_full_acc', 'efield', 'efield_cart', 'efield_phase', 'startingpot', 'startingwfc', 'tqr', 'real_space'], '&IONS': ['ion_positions', 'ion_velocities', 'ion_dynamics', 'pot_extrapolation', 'wfc_extrapolation', 'remove_rigid_rot', 'ion_temperature', 'tempw', 'tolp', 'delta_t', 'nraise', 'refold_pos', 'upscale', 'bfgs_ndim', 'trust_radius_max', 'trust_radius_min', 'trust_radius_ini', 'w_1', 'w_2', 'fire_alpha_init', 'fire_falpha', 'fire_nmin', 'fire_f_inc', 'fire_f_dec', 'fire_dtmax'], '&CELL': ['cell_dynamics', 'press', 'wmass', 'cell_factor', 'press_conv_thrcell_dofree'], '&FCP': ['fcp_mu', 'fcp_dynamics', 'fcp_conv_thr', 'fcp_ndiis', 'fcp_mass', 'fcp_velocity', 'fcp_temperature', 'fcp_tempw', 'fcp_tolp ', 'fcp_delta_t', 'fcp_nraise', 'freeze_all_atoms'], '&RISM': ['nsolv', 'closure', 'tempv', 'ecutsolv', 'solute_lj', 'solute_epsilon', 'solute_sigma', 'starting1d', 'starting3d', 'smear1d', 'smear3d', 'rism1d_maxstep', 'rism3d_maxstep', 'rism1d_conv_thr', 'rism3d_conv_thr', 'mdiis1d_size', 'mdiis3d_size', 'mdiis1d_step', 'mdiis3d_step', 'rism1d_bond_width', 'rism1d_dielectric', 'rism1d_molesize', 'rism1d_nproc', 'rism3d_conv_level', 'rism3d_planar_average', 'laue_nfit', 'laue_expand_right', 'laue_expand_left', 'laue_starting_right', 'laue_starting_left', 'laue_buffer_right', 'laue_buffer_left', 'laue_both_hands', 'laue_wall', 'laue_wall_z', 'laue_wall_rho', 'laue_wall_epsilon', 'laue_wall_sigma', 'laue_wall_lj6']}"}, {"fullname": "aton.interface.qe.pw_cards", "modulename": "aton.interface.qe", "qualname": "pw_cards", "kind": "variable", "doc": "Dictionary with every possible CARDs as keys, and the corresponding variables as values.
\n", "default_value": "{'ATOMIC_SPECIES': ['X', 'Mass_X', 'PseudoPot_X'], 'ATOMIC_POSITIONS': ['X', 'x', 'y', 'z', 'if_pos(1)', 'if_pos(2)', 'if_pos(3)'], 'K_POINTS': ['nks', 'xk_x', 'xk_y', 'xk_z', 'wk', 'nk1', 'nk2', 'nk3', 'sk1', 'sk2', 'sk3'], 'ADDITIONAL_K_POINTS': ['nks_add', 'k_x', 'k_y', 'k_z', 'wk_'], 'CELL_PARAMETERS': ['v1', 'v2', 'v3'], 'CONSTRAINTS': ['nconstr', 'constr_tol', 'constr_type', 'constr(1)', 'constr(2)', 'constr(3)', 'constr(4)', 'constr_target'], 'OCCUPATIONS': ['f_inp1', 'f_inp2'], 'ATOMIC_VELOCITIES': ['V', 'vx', 'vy', 'vz'], 'ATOMIC_FORCES': ['X', 'fx', 'fy', 'fz'], 'SOLVENTS': ['X', 'Density', 'Molecule', 'X', 'Density_Left', 'Density_Right', 'Molecule'], 'HUBBARD': ['label(1)-manifold(1)', 'u_val(1)', 'label(1)-manifold(1)', 'j0_val(1)', 'paramType(1)', 'label(1)-manifold(1)', 'paramValue(1)', 'label(I)-manifold(I)', 'u_val(I)', 'label(I)-manifold(I)', 'j0_val(I)', 'label(I)-manifold(I)', 'label(J)-manifold(J)', 'I', 'J', 'v_val(I,J)'], 'CELL_PARAMETERS_out': ['v1', 'v2', 'v3'], 'ATOMIC_POSITIONS_out': ['X', 'x', 'y', 'z', 'if_pos(1)', 'if_pos(2)', 'if_pos(3)']}"}, {"fullname": "aton.interface.slurm", "modulename": "aton.interface.slurm", "kind": "module", "doc": "Description
\n\nFunctions to handle Slurm calls, to run calculations in clusters.
\n\nIndex
\n\n\n\n
\n\n\n \n\n\n\n \n \n \n\n sbatch()
Sbatch all calculations \n\n \n\n squeue()
Get a Pandas DataFrame with info about the submitted calculations \n\n \n\n scancel()
Scancel all calculations, or applying some filters \n\n \n\n scancel_here()
Scancel all calculations running from a specific folder \n\n \n\n\n check_template()
Checks that the slurm template is OK, and provides an example if not \n
\n"}, {"fullname": "aton.interface.slurm.sbatch", "modulename": "aton.interface.slurm", "qualname": "sbatch", "kind": "function", "doc": "Sbatch all the calculations at once.
\n\nCalculation names should follow
\n\nprefix_ID.ext
,\nwithprefix
as the common name across calculations,\nfollowed by the calculation ID, used as JOB_NAME.\nThe extensions fromin_ext
andout_ext
('.in' and '.out' by default)\nwill be used for the INPUT_FILE and OUTPUT_FILE of the slurm template.The slurm template,
\n\ntemplate.slurm
by default,\nmust contain the keywords JOB_ID, INPUT_FILE and OUTPUT_FILE:\n\n#SBATCH --job-name=JOB_NAME\nmpirun pw.x -inp INPUT_FILE > OUTPUT_FILE\n
Runs from the specified
\n\nfolder
, current working directory if empty.If more control is required, a custom list of
\n\nfiles
can be specified for sbatching.If
\n", "signature": "(\tprefix: str = '',\ttemplate: str = 'template.slurm',\tin_ext: str = '.in',\tout_ext: str = '.out',\tfolder=None,\tfiles: list = [],\ttesting: bool = False) -> None:", "funcdef": "def"}, {"fullname": "aton.interface.slurm.squeue", "modulename": "aton.interface.slurm", "qualname": "squeue", "kind": "function", "doc": "\n", "signature": "(user) -> pandas.core.frame.DataFrame:", "funcdef": "def"}, {"fullname": "aton.interface.slurm.scancel", "modulename": "aton.interface.slurm", "qualname": "scancel", "kind": "function", "doc": "testing = True
it skips the final sbatching,\njust printing the commands on the screen.Cancel all
\n\nuser
jobs.If a particular
\n\nstatus
string is provided,\nonly the calculations with said status will be cancelled.If a particular
\n\ntext
string is provided,\nonly the calculations containing said text in the name will be deleted.If
\n\ntesting = True
, it shows the calculations that would be deleted.if the slurm squeue titles are different in your cluster,\nyou can specify them with
\n", "signature": "(\tuser: str,\tstatus: str = '',\ttext: str = '',\ttesting: bool = False,\tkey_jobid: str = 'JOBID',\tkey_name: str = 'NAME',\tkey_status: str = 'ST') -> None:", "funcdef": "def"}, {"fullname": "aton.interface.slurm.scancel_here", "modulename": "aton.interface.slurm", "qualname": "scancel_here", "kind": "function", "doc": "key_jobid
,key_status
andkey_name
.Cancel all running
\n\njobs
in a givenfolder
.If no job is provided, all jobs detected in the current folder will be cancelled.\nThe jobs will be detected from the
\n", "signature": "(\tjobs=None,\tfolder=None,\tprefix: str = 'slurm-',\tsufix: str = '.out') -> None:", "funcdef": "def"}, {"fullname": "aton.interface.slurm.check_template", "modulename": "aton.interface.slurm", "qualname": "check_template", "kind": "function", "doc": "<prefix>JOBID<sufix>
files,slurm-JOBID.out
by default.Check the slurm
\n\ntemplate
insidefolder
.The current working directory is used if
\n", "signature": "(template: str = 'template.slurm', folder=None) -> str:", "funcdef": "def"}, {"fullname": "aton.phys", "modulename": "aton.phys", "kind": "module", "doc": "folder
is not provided.\nIf the file does not exist or is invalid, creates atemplate_EXAMPLE.slurm
file for reference.Physico-chemical constants
\n\nThis subpackage contains universal physical constants,\nas well as chemical data from all known elements.\nIt also includes functions to manage this data.
\n\nIndex
\n\n\n\n
\n\n\n \n\n\n\n \n \n \n\n aton.phys.units
Universal constants and conversion factors \n\n \n\n aton.phys.atoms
Data from all chemical elements \n\n \n\n\n aton.phys.functions
Functions to manage data from the \naton.phys.atoms
dictExamples
\n\nAll values and functions from phys submodules can be\nloaded directly as
\n\nphys.value
orphys.function()
,\nas in the example below.\n\n\n\nfrom aton import phys\nphys.eV_to_J # 1.602176634e-19\nphys.atoms['H'].isotope[2].mass # 2.0141017779\nphys.split_isotope('He4') # ('He', 4)\n
See the API reference of the specific modules for more information.
\n\nReferences
\n\n\n\n
aton.phys.units
Constant values come from the 2022 CODATA Internationally\nrecommended 2022 values of the Fundamental Physical Constants.
\n\n\n\n
aton.phys.atoms
Atomic
\n\nmass
are in atomic mass units (amu), and come from:\nPure Appl. Chem., Vol. 78, No. 11, pp. 2051-2066, 2006.\nThe following masses are obtained from Wikipedia:\nAc: 227, Np: 237, Pm: 145, Tc: 98.Isotope
\n\nmass
,mass_number
andabundance
come from:\nJ. R. de Laeter, J. K. B\u00f6hlke, P. De Bi\u00e8vre, H. Hidaka, H. S. Peiser, K. J. R. Rosman\nand P. D. P. Taylor (2003). \"Atomic weights of the elements. Review 2000 (IUPAC Technical Report)\".Total bound scattering
\n"}, {"fullname": "aton.phys.atoms", "modulename": "aton.phys.atoms", "kind": "module", "doc": "cross_section
$\\sigma_s$ are in barns (1 b = 100 fm$^2$).\nFrom Felix Fernandez-Alonso, \"Neutron Scattering Fundamentals\", 2013.Description
\n\nThis module contains the
\n\natoms
megadictionary,\nwhich contains the properties of all elements.\nIt is managed and updated automatically withaton.phys.functions
.The
\n\natoms
dictionary can be loaded directly asaton.phys.atoms
.Index
\n\n\n\n
\n\n\n \n\n\n\n \n \n \n\n Element
Used as values in the \natoms
dict, stores element properties\n \n\n Isotope
Used as values in \nElement.isotope
, contains isotope properties\n \n\n\n atoms
The dict with data from all elements \nExamples
\n\n\n\n\n\nfrom aton import phys\naluminium_cross_section = phys.atoms['Al'].cross_section # 1.503\nHe4_mass = phys.atoms['H'].isotope[4].mass # 4.0026032497\n
\n"}, {"fullname": "aton.phys.atoms.Element", "modulename": "aton.phys.atoms", "qualname": "Element", "kind": "class", "doc": "Used in the
\n"}, {"fullname": "aton.phys.atoms.Element.__init__", "modulename": "aton.phys.atoms", "qualname": "Element.__init__", "kind": "function", "doc": "\n", "signature": "(\tZ: int = None,\tsymbol: str = None,\tname: str = None,\tmass: float = None,\tcross_section: float = None,\tisotope: dict = None)"}, {"fullname": "aton.phys.atoms.Element.Z", "modulename": "aton.phys.atoms", "qualname": "Element.Z", "kind": "variable", "doc": "aton.atoms
megadictionary to store element data.Atomic number (Z). Corresponds to the number of protons / electrons.
\n", "annotation": ": int"}, {"fullname": "aton.phys.atoms.Element.symbol", "modulename": "aton.phys.atoms", "qualname": "Element.symbol", "kind": "variable", "doc": "Standard symbol of the element.
\n", "annotation": ": str"}, {"fullname": "aton.phys.atoms.Element.name", "modulename": "aton.phys.atoms", "qualname": "Element.name", "kind": "variable", "doc": "Full name.
\n", "annotation": ": str"}, {"fullname": "aton.phys.atoms.Element.mass", "modulename": "aton.phys.atoms", "qualname": "Element.mass", "kind": "variable", "doc": "Atomic mass, in atomic mass units (amu).
\n", "annotation": ": float"}, {"fullname": "aton.phys.atoms.Element.cross_section", "modulename": "aton.phys.atoms", "qualname": "Element.cross_section", "kind": "variable", "doc": "Total bound scattering cross section.
\n", "annotation": ": float"}, {"fullname": "aton.phys.atoms.Element.isotope", "modulename": "aton.phys.atoms", "qualname": "Element.isotope", "kind": "variable", "doc": "Dictionary containing the different
\n", "annotation": ": dict"}, {"fullname": "aton.phys.atoms.Isotope", "modulename": "aton.phys.atoms", "qualname": "Isotope", "kind": "class", "doc": "Isotope
of the element.\nThe keys are the mass number (A).Used in the
\n"}, {"fullname": "aton.phys.atoms.Isotope.__init__", "modulename": "aton.phys.atoms", "qualname": "Isotope.__init__", "kind": "function", "doc": "\n", "signature": "(\tA: int = None,\tmass: float = None,\tabundance: float = None,\tcross_section: float = None)"}, {"fullname": "aton.phys.atoms.Isotope.A", "modulename": "aton.phys.atoms", "qualname": "Isotope.A", "kind": "variable", "doc": "aton.atoms
megadictionary to store isotope data.Mass number (A) of the isotope.\nCorresponds to the total number of protons + neutrons in the core.
\n", "annotation": ": int"}, {"fullname": "aton.phys.atoms.Isotope.mass", "modulename": "aton.phys.atoms", "qualname": "Isotope.mass", "kind": "variable", "doc": "Atomic mass of the isotope, in atomic mass units (amu).
\n", "annotation": ": float"}, {"fullname": "aton.phys.atoms.Isotope.abundance", "modulename": "aton.phys.atoms", "qualname": "Isotope.abundance", "kind": "variable", "doc": "Relative abundance of the isotope.
\n", "annotation": ": float"}, {"fullname": "aton.phys.atoms.Isotope.cross_section", "modulename": "aton.phys.atoms", "qualname": "Isotope.cross_section", "kind": "variable", "doc": "Total bound scattering cross section of the isotope.
\n", "annotation": ": float"}, {"fullname": "aton.phys.atoms.atoms", "modulename": "aton.phys.atoms", "qualname": "atoms", "kind": "variable", "doc": "\n", "default_value": "{'H': <aton.phys.atoms.Element object>, 'He': <aton.phys.atoms.Element object>, 'Li': <aton.phys.atoms.Element object>, 'Be': <aton.phys.atoms.Element object>, 'B': <aton.phys.atoms.Element object>, 'C': <aton.phys.atoms.Element object>, 'N': <aton.phys.atoms.Element object>, 'O': <aton.phys.atoms.Element object>, 'F': <aton.phys.atoms.Element object>, 'Ne': <aton.phys.atoms.Element object>, 'Na': <aton.phys.atoms.Element object>, 'Mg': <aton.phys.atoms.Element object>, 'Al': <aton.phys.atoms.Element object>, 'Si': <aton.phys.atoms.Element object>, 'P': <aton.phys.atoms.Element object>, 'S': <aton.phys.atoms.Element object>, 'Cl': <aton.phys.atoms.Element object>, 'Ar': <aton.phys.atoms.Element object>, 'K': <aton.phys.atoms.Element object>, 'Ca': <aton.phys.atoms.Element object>, 'Sc': <aton.phys.atoms.Element object>, 'Ti': <aton.phys.atoms.Element object>, 'V': <aton.phys.atoms.Element object>, 'Cr': <aton.phys.atoms.Element object>, 'Mn': <aton.phys.atoms.Element object>, 'Fe': <aton.phys.atoms.Element object>, 'Co': <aton.phys.atoms.Element object>, 'Ni': <aton.phys.atoms.Element object>, 'Cu': <aton.phys.atoms.Element object>, 'Zn': <aton.phys.atoms.Element object>, 'Ga': <aton.phys.atoms.Element object>, 'Ge': <aton.phys.atoms.Element object>, 'As': <aton.phys.atoms.Element object>, 'Se': <aton.phys.atoms.Element object>, 'Br': <aton.phys.atoms.Element object>, 'Kr': <aton.phys.atoms.Element object>, 'Rb': <aton.phys.atoms.Element object>, 'Sr': <aton.phys.atoms.Element object>, 'Y': <aton.phys.atoms.Element object>, 'Zr': <aton.phys.atoms.Element object>, 'Nb': <aton.phys.atoms.Element object>, 'Mo': <aton.phys.atoms.Element object>, 'Tc': <aton.phys.atoms.Element object>, 'Ru': <aton.phys.atoms.Element object>, 'Rh': <aton.phys.atoms.Element object>, 'Pd': <aton.phys.atoms.Element object>, 'Ag': <aton.phys.atoms.Element object>, 'Cd': <aton.phys.atoms.Element object>, 'In': <aton.phys.atoms.Element object>, 'Sn': <aton.phys.atoms.Element object>, 'Sb': <aton.phys.atoms.Element object>, 'Te': <aton.phys.atoms.Element object>, 'I': <aton.phys.atoms.Element object>, 'Xe': <aton.phys.atoms.Element object>, 'Cs': <aton.phys.atoms.Element object>, 'Ba': <aton.phys.atoms.Element object>, 'La': <aton.phys.atoms.Element object>, 'Ce': <aton.phys.atoms.Element object>, 'Pr': <aton.phys.atoms.Element object>, 'Nd': <aton.phys.atoms.Element object>, 'Pm': <aton.phys.atoms.Element object>, 'Sm': <aton.phys.atoms.Element object>, 'Eu': <aton.phys.atoms.Element object>, 'Gd': <aton.phys.atoms.Element object>, 'Tb': <aton.phys.atoms.Element object>, 'Dy': <aton.phys.atoms.Element object>, 'Ho': <aton.phys.atoms.Element object>, 'Er': <aton.phys.atoms.Element object>, 'Tm': <aton.phys.atoms.Element object>, 'Yb': <aton.phys.atoms.Element object>, 'Lu': <aton.phys.atoms.Element object>, 'Hf': <aton.phys.atoms.Element object>, 'Ta': <aton.phys.atoms.Element object>, 'W': <aton.phys.atoms.Element object>, 'Re': <aton.phys.atoms.Element object>, 'Os': <aton.phys.atoms.Element object>, 'Ir': <aton.phys.atoms.Element object>, 'Pt': <aton.phys.atoms.Element object>, 'Au': <aton.phys.atoms.Element object>, 'Hg': <aton.phys.atoms.Element object>, 'Tl': <aton.phys.atoms.Element object>, 'Pb': <aton.phys.atoms.Element object>, 'Bi': <aton.phys.atoms.Element object>, 'Po': <aton.phys.atoms.Element object>, 'At': <aton.phys.atoms.Element object>, 'Rn': <aton.phys.atoms.Element object>, 'Fr': <aton.phys.atoms.Element object>, 'Ra': <aton.phys.atoms.Element object>, 'Ac': <aton.phys.atoms.Element object>, 'Th': <aton.phys.atoms.Element object>, 'Pa': <aton.phys.atoms.Element object>, 'U': <aton.phys.atoms.Element object>, 'Np': <aton.phys.atoms.Element object>, 'Pu': <aton.phys.atoms.Element object>, 'Am': <aton.phys.atoms.Element object>, 'Cm': <aton.phys.atoms.Element object>, 'Bk': <aton.phys.atoms.Element object>, 'Cf': <aton.phys.atoms.Element object>, 'Es': <aton.phys.atoms.Element object>, 'Fm': <aton.phys.atoms.Element object>, 'Md': <aton.phys.atoms.Element object>, 'No': <aton.phys.atoms.Element object>, 'Lr': <aton.phys.atoms.Element object>, 'Rf': <aton.phys.atoms.Element object>, 'Db': <aton.phys.atoms.Element object>, 'Sg': <aton.phys.atoms.Element object>, 'Bh': <aton.phys.atoms.Element object>, 'Hs': <aton.phys.atoms.Element object>, 'Mt': <aton.phys.atoms.Element object>, 'Ds': <aton.phys.atoms.Element object>, 'Rg': <aton.phys.atoms.Element object>, 'Cn': <aton.phys.atoms.Element object>, 'Uut': <aton.phys.atoms.Element object>, 'Uuq': <aton.phys.atoms.Element object>, 'Uup': <aton.phys.atoms.Element object>, 'Uuh': <aton.phys.atoms.Element object>, 'Uus': <aton.phys.atoms.Element object>, 'Uuo': <aton.phys.atoms.Element object>}"}, {"fullname": "aton.phys.functions", "modulename": "aton.phys.functions", "kind": "module", "doc": "Description
\n\nThis module contains functions to sort and analyse\nchemical data using the
\n\naton.phys.atoms
megadictionary,\nwhich contains the properties of all elements.\nIt also contains the tools needed to\nautomatically update said megadictionary.Index
\n\n\n\n
\n\n\n \n\n\n\n \n \n \n\n export_atoms()
Used to update and export the \naton.phys.atoms
dict\n \n\n split_isotope()
Splits element name and mass number \n\n \n\n\n allowed_isotopes()
Returns the available mass numbers for a given element \nExamples
\n\nAll functions can be called from the phys subpackage directly, as:
\n\n\n\n\n\nfrom aton import phys\nphys.split_isotope('He4') # (He, 4)\nphys.allowed_isotopes('Li') # (6, 7)\n
\n"}, {"fullname": "aton.phys.functions.export_atoms", "modulename": "aton.phys.functions", "qualname": "export_atoms", "kind": "function", "doc": "Export a dictionary of chemical elements to a python file.
\n\nThis is used to build and update the
\n", "signature": "(\tatoms: dict = {'H': <aton.phys.atoms.Element object>, 'He': <aton.phys.atoms.Element object>, 'Li': <aton.phys.atoms.Element object>, 'Be': <aton.phys.atoms.Element object>, 'B': <aton.phys.atoms.Element object>, 'C': <aton.phys.atoms.Element object>, 'N': <aton.phys.atoms.Element object>, 'O': <aton.phys.atoms.Element object>, 'F': <aton.phys.atoms.Element object>, 'Ne': <aton.phys.atoms.Element object>, 'Na': <aton.phys.atoms.Element object>, 'Mg': <aton.phys.atoms.Element object>, 'Al': <aton.phys.atoms.Element object>, 'Si': <aton.phys.atoms.Element object>, 'P': <aton.phys.atoms.Element object>, 'S': <aton.phys.atoms.Element object>, 'Cl': <aton.phys.atoms.Element object>, 'Ar': <aton.phys.atoms.Element object>, 'K': <aton.phys.atoms.Element object>, 'Ca': <aton.phys.atoms.Element object>, 'Sc': <aton.phys.atoms.Element object>, 'Ti': <aton.phys.atoms.Element object>, 'V': <aton.phys.atoms.Element object>, 'Cr': <aton.phys.atoms.Element object>, 'Mn': <aton.phys.atoms.Element object>, 'Fe': <aton.phys.atoms.Element object>, 'Co': <aton.phys.atoms.Element object>, 'Ni': <aton.phys.atoms.Element object>, 'Cu': <aton.phys.atoms.Element object>, 'Zn': <aton.phys.atoms.Element object>, 'Ga': <aton.phys.atoms.Element object>, 'Ge': <aton.phys.atoms.Element object>, 'As': <aton.phys.atoms.Element object>, 'Se': <aton.phys.atoms.Element object>, 'Br': <aton.phys.atoms.Element object>, 'Kr': <aton.phys.atoms.Element object>, 'Rb': <aton.phys.atoms.Element object>, 'Sr': <aton.phys.atoms.Element object>, 'Y': <aton.phys.atoms.Element object>, 'Zr': <aton.phys.atoms.Element object>, 'Nb': <aton.phys.atoms.Element object>, 'Mo': <aton.phys.atoms.Element object>, 'Tc': <aton.phys.atoms.Element object>, 'Ru': <aton.phys.atoms.Element object>, 'Rh': <aton.phys.atoms.Element object>, 'Pd': <aton.phys.atoms.Element object>, 'Ag': <aton.phys.atoms.Element object>, 'Cd': <aton.phys.atoms.Element object>, 'In': <aton.phys.atoms.Element object>, 'Sn': <aton.phys.atoms.Element object>, 'Sb': <aton.phys.atoms.Element object>, 'Te': <aton.phys.atoms.Element object>, 'I': <aton.phys.atoms.Element object>, 'Xe': <aton.phys.atoms.Element object>, 'Cs': <aton.phys.atoms.Element object>, 'Ba': <aton.phys.atoms.Element object>, 'La': <aton.phys.atoms.Element object>, 'Ce': <aton.phys.atoms.Element object>, 'Pr': <aton.phys.atoms.Element object>, 'Nd': <aton.phys.atoms.Element object>, 'Pm': <aton.phys.atoms.Element object>, 'Sm': <aton.phys.atoms.Element object>, 'Eu': <aton.phys.atoms.Element object>, 'Gd': <aton.phys.atoms.Element object>, 'Tb': <aton.phys.atoms.Element object>, 'Dy': <aton.phys.atoms.Element object>, 'Ho': <aton.phys.atoms.Element object>, 'Er': <aton.phys.atoms.Element object>, 'Tm': <aton.phys.atoms.Element object>, 'Yb': <aton.phys.atoms.Element object>, 'Lu': <aton.phys.atoms.Element object>, 'Hf': <aton.phys.atoms.Element object>, 'Ta': <aton.phys.atoms.Element object>, 'W': <aton.phys.atoms.Element object>, 'Re': <aton.phys.atoms.Element object>, 'Os': <aton.phys.atoms.Element object>, 'Ir': <aton.phys.atoms.Element object>, 'Pt': <aton.phys.atoms.Element object>, 'Au': <aton.phys.atoms.Element object>, 'Hg': <aton.phys.atoms.Element object>, 'Tl': <aton.phys.atoms.Element object>, 'Pb': <aton.phys.atoms.Element object>, 'Bi': <aton.phys.atoms.Element object>, 'Po': <aton.phys.atoms.Element object>, 'At': <aton.phys.atoms.Element object>, 'Rn': <aton.phys.atoms.Element object>, 'Fr': <aton.phys.atoms.Element object>, 'Ra': <aton.phys.atoms.Element object>, 'Ac': <aton.phys.atoms.Element object>, 'Th': <aton.phys.atoms.Element object>, 'Pa': <aton.phys.atoms.Element object>, 'U': <aton.phys.atoms.Element object>, 'Np': <aton.phys.atoms.Element object>, 'Pu': <aton.phys.atoms.Element object>, 'Am': <aton.phys.atoms.Element object>, 'Cm': <aton.phys.atoms.Element object>, 'Bk': <aton.phys.atoms.Element object>, 'Cf': <aton.phys.atoms.Element object>, 'Es': <aton.phys.atoms.Element object>, 'Fm': <aton.phys.atoms.Element object>, 'Md': <aton.phys.atoms.Element object>, 'No': <aton.phys.atoms.Element object>, 'Lr': <aton.phys.atoms.Element object>, 'Rf': <aton.phys.atoms.Element object>, 'Db': <aton.phys.atoms.Element object>, 'Sg': <aton.phys.atoms.Element object>, 'Bh': <aton.phys.atoms.Element object>, 'Hs': <aton.phys.atoms.Element object>, 'Mt': <aton.phys.atoms.Element object>, 'Ds': <aton.phys.atoms.Element object>, 'Rg': <aton.phys.atoms.Element object>, 'Cn': <aton.phys.atoms.Element object>, 'Uut': <aton.phys.atoms.Element object>, 'Uuq': <aton.phys.atoms.Element object>, 'Uup': <aton.phys.atoms.Element object>, 'Uuh': <aton.phys.atoms.Element object>, 'Uus': <aton.phys.atoms.Element object>, 'Uuo': <aton.phys.atoms.Element object>},\tfilename='exported_atoms.py') -> None:", "funcdef": "def"}, {"fullname": "aton.phys.functions.split_isotope", "modulename": "aton.phys.functions", "qualname": "split_isotope", "kind": "function", "doc": "aton.atoms
megadictionary, that contains\nall the element data, such as masses, cross-sections, etc.\nTheatoms.py
file must be modified here.Split the
\n\nname
of an isotope into the element and the mass number, eg. He4 -> He, 4.If the isotope is not found in the
\n", "signature": "(name: str) -> tuple:", "funcdef": "def"}, {"fullname": "aton.phys.functions.allowed_isotopes", "modulename": "aton.phys.functions", "qualname": "allowed_isotopes", "kind": "function", "doc": "aton.atoms
megadictionary it raises an error,\ninforming of the allowed mass numbers (A) values for the given element.Return a list with the allowed mass numbers (A) of a given
\n\nelement
.These mass numbers are used as isotope keys in the
\n", "signature": "(element) -> list:", "funcdef": "def"}, {"fullname": "aton.phys.units", "modulename": "aton.phys.units", "kind": "module", "doc": "aton.atoms
megadictionary.Description
\n\nThis module contains useful constants and conversion factors.
\n\nIndex
\n\nEnergy conversion factors
\n\n
\nDistance conversion factors
\nMass conversion factors
\nPressure conversion factors
\nTime conversion factors
\nUniversal constantsExamples
\n\n\n\n\n\nfrom aton import phys\nenergy_in_cm1 = 1000 * phys.meV_to_cm1 # 8065.5\nlength_in_angstroms = 10.0 * phys.bohr_to_A # 5.29177210544\nphys.hbar # 1.0545718176461565e-34\n
\n\nEnergy conversion factors
\n\nNote that
\n"}, {"fullname": "aton.phys.units.eV_to_meV", "modulename": "aton.phys.units", "qualname": "eV_to_meV", "kind": "variable", "doc": "\n", "default_value": "1000.0"}, {"fullname": "aton.phys.units.meV_to_eV", "modulename": "aton.phys.units", "qualname": "meV_to_eV", "kind": "variable", "doc": "\n", "default_value": "0.001"}, {"fullname": "aton.phys.units.meV_to_cm1", "modulename": "aton.phys.units", "qualname": "meV_to_cm1", "kind": "variable", "doc": "\n", "default_value": "8.0655"}, {"fullname": "aton.phys.units.cm1_to_meV", "modulename": "aton.phys.units", "qualname": "cm1_to_meV", "kind": "variable", "doc": "\n", "default_value": "0.12398487384539086"}, {"fullname": "aton.phys.units.eV_to_J", "modulename": "aton.phys.units", "qualname": "eV_to_J", "kind": "variable", "doc": "\n", "default_value": "1.602176634e-19"}, {"fullname": "aton.phys.units.J_to_eV", "modulename": "aton.phys.units", "qualname": "J_to_eV", "kind": "variable", "doc": "\n", "default_value": "6.241509074460763e+18"}, {"fullname": "aton.phys.units.meV_to_J", "modulename": "aton.phys.units", "qualname": "meV_to_J", "kind": "variable", "doc": "\n", "default_value": "1.6021766339999998e-22"}, {"fullname": "aton.phys.units.J_to_meV", "modulename": "aton.phys.units", "qualname": "J_to_meV", "kind": "variable", "doc": "\n", "default_value": "6.241509074460763e+21"}, {"fullname": "aton.phys.units.Ry_to_eV", "modulename": "aton.phys.units", "qualname": "Ry_to_eV", "kind": "variable", "doc": "\n", "default_value": "13.60569312299"}, {"fullname": "aton.phys.units.eV_to_Ry", "modulename": "aton.phys.units", "qualname": "eV_to_Ry", "kind": "variable", "doc": "\n", "default_value": "0.07349864435133158"}, {"fullname": "aton.phys.units.Ry_to_J", "modulename": "aton.phys.units", "qualname": "Ry_to_J", "kind": "variable", "doc": "\n", "default_value": "2.179872361103e-18"}, {"fullname": "aton.phys.units.J_to_Ry", "modulename": "aton.phys.units", "qualname": "J_to_Ry", "kind": "variable", "doc": "\n", "default_value": "4.5874245567938074e+17"}, {"fullname": "aton.phys.units.cal_to_J", "modulename": "aton.phys.units", "qualname": "cal_to_J", "kind": "variable", "doc": "\n", "default_value": "4.184"}, {"fullname": "aton.phys.units.J_to_cal", "modulename": "aton.phys.units", "qualname": "J_to_cal", "kind": "variable", "doc": "\n", "default_value": "0.2390057361376673"}, {"fullname": "aton.phys.units.kcal_to_J", "modulename": "aton.phys.units", "qualname": "kcal_to_J", "kind": "variable", "doc": "\n", "default_value": "4184.0"}, {"fullname": "aton.phys.units.J_to_kcal", "modulename": "aton.phys.units", "qualname": "J_to_kcal", "kind": "variable", "doc": "cm
refers to cm$^{-1}$.
\n\nDistance conversion factors
\n\nNote that
\n", "default_value": "0.0002390057361376673"}, {"fullname": "aton.phys.units.A_to_m", "modulename": "aton.phys.units", "qualname": "A_to_m", "kind": "variable", "doc": "\n", "default_value": "1e-10"}, {"fullname": "aton.phys.units.m_to_A", "modulename": "aton.phys.units", "qualname": "m_to_A", "kind": "variable", "doc": "\n", "default_value": "10000000000.0"}, {"fullname": "aton.phys.units.bohr_to_m", "modulename": "aton.phys.units", "qualname": "bohr_to_m", "kind": "variable", "doc": "\n", "default_value": "5.29177210544e-11"}, {"fullname": "aton.phys.units.m_to_bohr", "modulename": "aton.phys.units", "qualname": "m_to_bohr", "kind": "variable", "doc": "\n", "default_value": "18897261259.077824"}, {"fullname": "aton.phys.units.A_to_bohr", "modulename": "aton.phys.units", "qualname": "A_to_bohr", "kind": "variable", "doc": "\n", "default_value": "1.8897261259077824"}, {"fullname": "aton.phys.units.bohr_to_A", "modulename": "aton.phys.units", "qualname": "bohr_to_A", "kind": "variable", "doc": "A
refers to Angstroms.
\n\nMass conversion factors
\n", "default_value": "0.529177210544"}, {"fullname": "aton.phys.units.amu_to_kg", "modulename": "aton.phys.units", "qualname": "amu_to_kg", "kind": "variable", "doc": "\n", "default_value": "1.6605390666e-27"}, {"fullname": "aton.phys.units.kg_to_amu", "modulename": "aton.phys.units", "qualname": "kg_to_amu", "kind": "variable", "doc": "\n", "default_value": "6.022140762081123e+26"}, {"fullname": "aton.phys.units.kg_to_g", "modulename": "aton.phys.units", "qualname": "kg_to_g", "kind": "variable", "doc": "\n", "default_value": "1000.0"}, {"fullname": "aton.phys.units.g_to_kg", "modulename": "aton.phys.units", "qualname": "g_to_kg", "kind": "variable", "doc": "
\n\nPressure conversion factors
\n", "default_value": "0.001"}, {"fullname": "aton.phys.units.GPa_to_Pa", "modulename": "aton.phys.units", "qualname": "GPa_to_Pa", "kind": "variable", "doc": "\n", "default_value": "1000000000.0"}, {"fullname": "aton.phys.units.Pa_to_GPa", "modulename": "aton.phys.units", "qualname": "Pa_to_GPa", "kind": "variable", "doc": "\n", "default_value": "1e-09"}, {"fullname": "aton.phys.units.kbar_to_bar", "modulename": "aton.phys.units", "qualname": "kbar_to_bar", "kind": "variable", "doc": "\n", "default_value": "1000.0"}, {"fullname": "aton.phys.units.bar_to_kbar", "modulename": "aton.phys.units", "qualname": "bar_to_kbar", "kind": "variable", "doc": "\n", "default_value": "0.001"}, {"fullname": "aton.phys.units.Pa_to_bar", "modulename": "aton.phys.units", "qualname": "Pa_to_bar", "kind": "variable", "doc": "\n", "default_value": "1e-05"}, {"fullname": "aton.phys.units.bar_to_Pa", "modulename": "aton.phys.units", "qualname": "bar_to_Pa", "kind": "variable", "doc": "\n", "default_value": "99999.99999999999"}, {"fullname": "aton.phys.units.GPa_to_kbar", "modulename": "aton.phys.units", "qualname": "GPa_to_kbar", "kind": "variable", "doc": "\n", "default_value": "10.0"}, {"fullname": "aton.phys.units.kbar_to_GPa", "modulename": "aton.phys.units", "qualname": "kbar_to_GPa", "kind": "variable", "doc": "
\n\nTime conversion factors
\n\nNote that
\n", "default_value": "0.1"}, {"fullname": "aton.phys.units.H_to_s", "modulename": "aton.phys.units", "qualname": "H_to_s", "kind": "variable", "doc": "\n", "default_value": "3600.0"}, {"fullname": "aton.phys.units.s_to_H", "modulename": "aton.phys.units", "qualname": "s_to_H", "kind": "variable", "doc": "H
refers to hours.
\n\nUniversal constants
\n\nGiven in SI units unless stated otherwise.
\n", "default_value": "0.0002777777777777778"}, {"fullname": "aton.phys.units.h", "modulename": "aton.phys.units", "qualname": "h", "kind": "variable", "doc": "Planck constant, in J\u00b7s.
\n", "default_value": "6.62607015e-34"}, {"fullname": "aton.phys.units.h_eV", "modulename": "aton.phys.units", "qualname": "h_eV", "kind": "variable", "doc": "Planck constant, in eV\u00b7s.
\n", "default_value": "4.135667696923859e-15"}, {"fullname": "aton.phys.units.hbar", "modulename": "aton.phys.units", "qualname": "hbar", "kind": "variable", "doc": "Reduced Planck constant, in J\u00b7s.
\n", "default_value": "1.0545718176461565e-34"}, {"fullname": "aton.phys.units.hbar_eV", "modulename": "aton.phys.units", "qualname": "hbar_eV", "kind": "variable", "doc": "Reduced Planck constant, in eV\u00b7s.
\n", "default_value": "6.582119569509066e-16"}, {"fullname": "aton.qrotor", "modulename": "aton.qrotor", "kind": "module", "doc": "QRotor
\n\nThe QRotor module is used to study the energy levels of quantum rotations, such as methyl and amine groups.
\n\nIndex
\n\n\n\n
\n"}, {"fullname": "aton.qrotor.classes", "modulename": "aton.qrotor.classes", "kind": "module", "doc": "\n \n\n\n\n \n \n \n\n aton.qrotor.classes
Definition of the \nQSys
andQExp
classes\n \n\n aton.qrotor.constants
Bond lengths and inertias \n\n \n\n aton.qrotor.rotate
Rotate specific atoms from structural files \n\n \n\n aton.qrotor.potential
Potential definitions and loading functions \n\n \n\n aton.qrotor.solve
Solve rotation eigenvalues and eigenvectors \n\n \n\n\n aton.qrotor.plot
Plotting functions \nDescription
\n\nThis module contains common classes for QRotor calculations.\nThese classes can be loaded directly as
\n\naton.qrotor.Class()
.Index
\n\n\n\n
\n\n\n \n\n\n\n \n \n \n\n QSys
Quantum system, with all the data for a single calculation \n\n \n\n\n QExp
Quantum experiment, contains several \nQSys
objects
\n"}, {"fullname": "aton.qrotor.classes.QSys", "modulename": "aton.qrotor.classes", "qualname": "QSys", "kind": "class", "doc": "Quantum system, contains all the data for a single calculation, with both inputs and outputs.
\n"}, {"fullname": "aton.qrotor.classes.QSys.__init__", "modulename": "aton.qrotor.classes", "qualname": "QSys.__init__", "kind": "function", "doc": "\n", "signature": "(\tcomment: str = None,\tgroup: str = 'CH3',\tE_levels: int = 5,\tunits=None,\tcorrect_potential_offset: bool = True,\tsave_eigenvectors: bool = False,\tgridsize: int = None,\tgrid=None,\tB: float = None,\tpotential_name: str = '',\tpotential_constants: list = None,\tpotential_values=None)"}, {"fullname": "aton.qrotor.classes.QSys.comment", "modulename": "aton.qrotor.classes", "qualname": "QSys.comment", "kind": "variable", "doc": "Custom comment for the dataset.
\n", "annotation": ": str"}, {"fullname": "aton.qrotor.classes.QSys.group", "modulename": "aton.qrotor.classes", "qualname": "QSys.group", "kind": "variable", "doc": "Chemical group, methyl or amine:
\n", "annotation": ": str"}, {"fullname": "aton.qrotor.classes.QSys.E_levels", "modulename": "aton.qrotor.classes", "qualname": "QSys.E_levels", "kind": "variable", "doc": "'CH3'
,'CD3'
,'NH3'
,'ND3'
.Number of energy levels to be studied.
\n", "annotation": ": int"}, {"fullname": "aton.qrotor.classes.QSys.units", "modulename": "aton.qrotor.classes", "qualname": "QSys.units", "kind": "variable", "doc": "List containing the energy units in use, e.g. ['meV'].
\n"}, {"fullname": "aton.qrotor.classes.QSys.correct_potential_offset", "modulename": "aton.qrotor.classes", "qualname": "QSys.correct_potential_offset", "kind": "variable", "doc": "Correct the potential offset as
\n", "annotation": ": bool"}, {"fullname": "aton.qrotor.classes.QSys.save_eigenvectors", "modulename": "aton.qrotor.classes", "qualname": "QSys.save_eigenvectors", "kind": "variable", "doc": "V - min(V)
or not.Save or not the eigenvectors. Final file size will be bigger.
\n", "annotation": ": bool"}, {"fullname": "aton.qrotor.classes.QSys.gridsize", "modulename": "aton.qrotor.classes", "qualname": "QSys.gridsize", "kind": "variable", "doc": "Number of points in the grid.
\n", "annotation": ": int"}, {"fullname": "aton.qrotor.classes.QSys.grid", "modulename": "aton.qrotor.classes", "qualname": "QSys.grid", "kind": "variable", "doc": "The grid with the points to be used in the calculation.
\n\nCan be set automatically over $2 \\Pi$ with
\n"}, {"fullname": "aton.qrotor.classes.QSys.B", "modulename": "aton.qrotor.classes", "qualname": "QSys.B", "kind": "variable", "doc": "QSys.set_grid()
.\nUnits should be in radians.Rotational inertia, as in $B=\\frac{\\hbar^2}{2I}.
\n", "annotation": ": float"}, {"fullname": "aton.qrotor.classes.QSys.potential_name", "modulename": "aton.qrotor.classes", "qualname": "QSys.potential_name", "kind": "variable", "doc": "Name of the desired potential:
\n", "annotation": ": str"}, {"fullname": "aton.qrotor.classes.QSys.potential_constants", "modulename": "aton.qrotor.classes", "qualname": "QSys.potential_constants", "kind": "variable", "doc": "'zero'
,'titov2023'
,'test'
...\nIf empty or unrecognised, the custom potential values insideQSys.potential_values
will be used.List of constants to be used in the calculation of the potential energy, in the
\n", "annotation": ": list"}, {"fullname": "aton.qrotor.classes.QSys.potential_values", "modulename": "aton.qrotor.classes", "qualname": "QSys.potential_values", "kind": "variable", "doc": "aton.qrotor.potential
module.Numpy array with the potential values for each point in the grid.
\n\nCan be calculated with a function available in the
\n"}, {"fullname": "aton.qrotor.classes.QSys.potential_offset", "modulename": "aton.qrotor.classes", "qualname": "QSys.potential_offset", "kind": "variable", "doc": "qrotor.potential
module,\nor loaded externally with theqrotor.potential.load()
function.\nUnits should be in eV.\n", "annotation": ": float"}, {"fullname": "aton.qrotor.classes.QSys.potential_min", "modulename": "aton.qrotor.classes", "qualname": "QSys.potential_min", "kind": "variable", "doc": "
min(V)
before offset correction whenQSys.correct_potential_offset = True
\n", "annotation": ": float"}, {"fullname": "aton.qrotor.classes.QSys.potential_max", "modulename": "aton.qrotor.classes", "qualname": "QSys.potential_max", "kind": "variable", "doc": "
min(V)
\n", "annotation": ": float"}, {"fullname": "aton.qrotor.classes.QSys.potential_max_B", "modulename": "aton.qrotor.classes", "qualname": "QSys.potential_max_B", "kind": "variable", "doc": "
max(V)
Reduced
\n", "annotation": ": float"}, {"fullname": "aton.qrotor.classes.QSys.eigenvalues", "modulename": "aton.qrotor.classes", "qualname": "QSys.eigenvalues", "kind": "variable", "doc": "potential_max
, in units of B.Calculated eigenvalues of the system.
\n"}, {"fullname": "aton.qrotor.classes.QSys.eigenvalues_B", "modulename": "aton.qrotor.classes", "qualname": "QSys.eigenvalues_B", "kind": "variable", "doc": "Reduced
\n"}, {"fullname": "aton.qrotor.classes.QSys.eigenvectors", "modulename": "aton.qrotor.classes", "qualname": "QSys.eigenvectors", "kind": "variable", "doc": "eigenvalues
, in units of B.Eigenvectors, if
\n"}, {"fullname": "aton.qrotor.classes.QSys.energy_barrier", "modulename": "aton.qrotor.classes", "qualname": "QSys.energy_barrier", "kind": "variable", "doc": "save_eigenvectors
is True. Beware of the file size.\n", "annotation": ": float"}, {"fullname": "aton.qrotor.classes.QSys.first_transition", "modulename": "aton.qrotor.classes", "qualname": "QSys.first_transition", "kind": "variable", "doc": "
max(V) - min(eigenvalues)
eigenvalues[1] - eigenvalues[0]
\n", "annotation": ": float"}, {"fullname": "aton.qrotor.classes.QSys.runtime", "modulename": "aton.qrotor.classes", "qualname": "QSys.runtime", "kind": "variable", "doc": "Time taken to solve the eigenvalues.
\n", "annotation": ": float"}, {"fullname": "aton.qrotor.classes.QSys.summary", "modulename": "aton.qrotor.classes", "qualname": "QSys.summary", "kind": "function", "doc": "\n", "signature": "(self):", "funcdef": "def"}, {"fullname": "aton.qrotor.classes.QSys.set_grid", "modulename": "aton.qrotor.classes", "qualname": "QSys.set_grid", "kind": "function", "doc": "Sets the
\n", "signature": "(self, gridsize: int = None):", "funcdef": "def"}, {"fullname": "aton.qrotor.classes.QSys.set_group", "modulename": "aton.qrotor.classes", "qualname": "QSys.set_group", "kind": "function", "doc": "QSys.grid
to the specifiedgridsize
.Normalise
\n", "signature": "(self, group: str = None, B: float = None):", "funcdef": "def"}, {"fullname": "aton.qrotor.classes.QExp", "modulename": "aton.qrotor.classes", "qualname": "QExp", "kind": "class", "doc": "\n"}, {"fullname": "aton.qrotor.classes.QExp.__init__", "modulename": "aton.qrotor.classes", "qualname": "QExp.__init__", "kind": "function", "doc": "\n", "signature": "(\tcomment: str = None,\tsystems: list = [],\tplotting: aton.spx.classes.Plotting = None)"}, {"fullname": "aton.qrotor.classes.QExp.version", "modulename": "aton.qrotor.classes", "qualname": "QExp.version", "kind": "variable", "doc": "QSys.group
name, and setQSys.B
based on it.Version of the package used to generate the data.
\n"}, {"fullname": "aton.qrotor.classes.QExp.comment", "modulename": "aton.qrotor.classes", "qualname": "QExp.comment", "kind": "variable", "doc": "Custom comment for the dataset.
\n", "annotation": ": str"}, {"fullname": "aton.qrotor.classes.QExp.systems", "modulename": "aton.qrotor.classes", "qualname": "QExp.systems", "kind": "variable", "doc": "List containing the calculated
\n"}, {"fullname": "aton.qrotor.classes.QExp.plotting", "modulename": "aton.qrotor.classes", "qualname": "QExp.plotting", "kind": "variable", "doc": "QSys
objects.\n", "annotation": ": aton.spx.classes.Plotting"}, {"fullname": "aton.qrotor.classes.QExp.add", "modulename": "aton.qrotor.classes", "qualname": "QExp.add", "kind": "function", "doc": "
aton.spx.classes.Plotting
object (not implemented).Adds more systems to
\n", "signature": "(self, *args):", "funcdef": "def"}, {"fullname": "aton.qrotor.classes.QExp.get_energies", "modulename": "aton.qrotor.classes", "qualname": "QExp.get_energies", "kind": "function", "doc": "self.systems
from the introducedQSys
orQExp
objects.Returns a list with all
\n", "signature": "(self):", "funcdef": "def"}, {"fullname": "aton.qrotor.classes.QExp.get_gridsizes", "modulename": "aton.qrotor.classes", "qualname": "QExp.get_gridsizes", "kind": "function", "doc": "QSys.eigenvalues
values.Returns a list with all
\n", "signature": "(self):", "funcdef": "def"}, {"fullname": "aton.qrotor.classes.QExp.get_runtimes", "modulename": "aton.qrotor.classes", "qualname": "QExp.get_runtimes", "kind": "function", "doc": "QSys.gridsize
values.Returns a list with all
\n", "signature": "(self):", "funcdef": "def"}, {"fullname": "aton.qrotor.classes.QExp.get_gropus", "modulename": "aton.qrotor.classes", "qualname": "QExp.get_gropus", "kind": "function", "doc": "QSys.runtime
values.Returns a list with all
\n", "signature": "(self):", "funcdef": "def"}, {"fullname": "aton.qrotor.classes.QExp.sort_by_potential_values", "modulename": "aton.qrotor.classes", "qualname": "QExp.sort_by_potential_values", "kind": "function", "doc": "QSys.group
values.Returns the
\n", "signature": "(self):", "funcdef": "def"}, {"fullname": "aton.qrotor.classes.QExp.group_by_potential_values", "modulename": "aton.qrotor.classes", "qualname": "QExp.group_by_potential_values", "kind": "function", "doc": "QExp
object, sorted byQSys.potential_values
.Returns an array of grouped
\n", "signature": "(self):", "funcdef": "def"}, {"fullname": "aton.qrotor.classes.QExp.sort_by_gridsize", "modulename": "aton.qrotor.classes", "qualname": "QExp.sort_by_gridsize", "kind": "function", "doc": "QExp
objects with the sameQSys.potential_values
.Returns the same
\n", "signature": "(self):", "funcdef": "def"}, {"fullname": "aton.qrotor.classes.QExp.get_ideal_E", "modulename": "aton.qrotor.classes", "qualname": "QExp.get_ideal_E", "kind": "function", "doc": "QExp
, sorted byQSys.gridsize
.Calculates the ideal energy for a specified
\n", "signature": "(self, E_level):", "funcdef": "def"}, {"fullname": "aton.qrotor.classes.QExp.discard_shit", "modulename": "aton.qrotor.classes", "qualname": "QExp.discard_shit", "kind": "function", "doc": "E_level
for a convergence test. Only for 'zero' potential.Discard data that takes too much space, like eigenvectors, potential values and grids.
\n", "signature": "(self):", "funcdef": "def"}, {"fullname": "aton.qrotor.constants", "modulename": "aton.qrotor.constants", "kind": "module", "doc": "Description
\n\nCommon constants and default values used in the QRotor subpackage.
\n\nBond lengths and angles were obtained from MAPbI3,\nsee Cryst. Growth Des. 2024, 24, 391\u2212404.
\n\n
\n"}, {"fullname": "aton.qrotor.constants.distance_CH", "modulename": "aton.qrotor.constants", "qualname": "distance_CH", "kind": "variable", "doc": "Distance of the C-H bond, in Angstroms.
\n", "default_value": "1.09285"}, {"fullname": "aton.qrotor.constants.distance_NH", "modulename": "aton.qrotor.constants", "qualname": "distance_NH", "kind": "variable", "doc": "Distance of the N-H bond, in Angstroms.
\n", "default_value": "1.040263"}, {"fullname": "aton.qrotor.constants.angle_CH_external", "modulename": "aton.qrotor.constants", "qualname": "angle_CH_external", "kind": "variable", "doc": "External angle of the X-C-H bond, in degrees.
\n", "default_value": "108.7223"}, {"fullname": "aton.qrotor.constants.angle_NH_external", "modulename": "aton.qrotor.constants", "qualname": "angle_NH_external", "kind": "variable", "doc": "External angle of the X-N-H bond, in degrees.
\n", "default_value": "111.29016"}, {"fullname": "aton.qrotor.constants.angle_CH", "modulename": "aton.qrotor.constants", "qualname": "angle_CH", "kind": "variable", "doc": "Internal angle of the X-C-H bond, in degrees.
\n", "default_value": "71.2777"}, {"fullname": "aton.qrotor.constants.angle_NH", "modulename": "aton.qrotor.constants", "qualname": "angle_NH", "kind": "variable", "doc": "Internal angle of the X-N-H bond, in degrees.
\n", "default_value": "68.70984"}, {"fullname": "aton.qrotor.constants.r_CH", "modulename": "aton.qrotor.constants", "qualname": "r_CH", "kind": "variable", "doc": "Rotation radius of the methyl group, in meters.
\n", "default_value": "np.float64(1.0350223020441665e-10)"}, {"fullname": "aton.qrotor.constants.r_NH", "modulename": "aton.qrotor.constants", "qualname": "r_NH", "kind": "variable", "doc": "Rotation radius of the amine group, in meters.
\n", "default_value": "np.float64(9.69268793902999e-11)"}, {"fullname": "aton.qrotor.constants.I_CH", "modulename": "aton.qrotor.constants", "qualname": "I_CH", "kind": "variable", "doc": "Inertia of CH3, in uma\u00b7m^2.
\n", "default_value": "np.float64(3.239331176354078e-20)"}, {"fullname": "aton.qrotor.constants.I_CD", "modulename": "aton.qrotor.constants", "qualname": "I_CD", "kind": "variable", "doc": "Inertia of CD3, in uma\u00b7m^2.
\n", "default_value": "np.float64(6.47294747852218e-20)"}, {"fullname": "aton.qrotor.constants.I_NH", "modulename": "aton.qrotor.constants", "qualname": "I_NH", "kind": "variable", "doc": "Inertia of NH3, in uma\u00b7m^2.
\n", "default_value": "np.float64(2.8408244456194727e-20)"}, {"fullname": "aton.qrotor.constants.I_ND", "modulename": "aton.qrotor.constants", "qualname": "I_ND", "kind": "variable", "doc": "Inertia of ND3, in uma\u00b7m^2.
\n", "default_value": "np.float64(5.676637068301648e-20)"}, {"fullname": "aton.qrotor.constants.B_CH", "modulename": "aton.qrotor.constants", "qualname": "B_CH", "kind": "variable", "doc": "Rotational energy of CH3, in eV\u00b7s/uma\u00b7m^2.
\n", "default_value": "np.float64(41738399.7746217)"}, {"fullname": "aton.qrotor.constants.B_CD", "modulename": "aton.qrotor.constants", "qualname": "B_CD", "kind": "variable", "doc": "Rotational energy of CD3, in eV\u00b7s/uma\u00b7m^2.
\n", "default_value": "np.float64(5.3617906073032625e-31)"}, {"fullname": "aton.qrotor.constants.B_NH", "modulename": "aton.qrotor.constants", "qualname": "B_NH", "kind": "variable", "doc": "Rotational energy of NH3, in eV\u00b7s/uma\u00b7m^2.
\n", "default_value": "np.float64(1.2217083334883588e-30)"}, {"fullname": "aton.qrotor.constants.B_ND", "modulename": "aton.qrotor.constants", "qualname": "B_ND", "kind": "variable", "doc": "Rotational energy of ND3, in eV\u00b7s/uma\u00b7m^2.
\n", "default_value": "np.float64(6.1139348128682075e-31)"}, {"fullname": "aton.qrotor.constants.constants_titov2023", "modulename": "aton.qrotor.constants", "qualname": "constants_titov2023", "kind": "variable", "doc": "Potential constants from titov2023.
\n", "default_value": "[[2.786, 0.013, -1.5284, -0.0037, -1.2791], [2.6507, 0.0158, -1.4111, -0.0007, -1.2547], [2.1852, 0.0164, -1.0017, 0.0003, -1.2061], [5.9109, 0.0258, -7.0152, -0.0168, 1.0213], [1.4526, 0.0134, -0.3196, 0.0005, -1.1461]]"}, {"fullname": "aton.qrotor.constants.constants_titov2023_zero", "modulename": "aton.qrotor.constants", "qualname": "constants_titov2023_zero", "kind": "variable", "doc": "Zero potential constants.
\n", "default_value": "[[0, 0, 0, 0, 0]]"}, {"fullname": "aton.qrotor.plot", "modulename": "aton.qrotor.plot", "kind": "module", "doc": "Description
\n\nThis module provides straightforward functions to plot QRotor data.
\n\nIndex
\n\n\n\n
\n\n\n \n\n\n\n \n \n \n\n reduced_energies()
Reduced energies E/B as a function of the reduced potential V/B \n\n \n\n potential()
Potential values as a function of the angle \n\n \n\n energies_DEV()
NOT IMPLEMENTED \n\n \n\n energy_DEV()
NOT IMPLEMENTED \n\n \n\n convergence_DEV()
NOT IMPLEMENTED \n\n \n\n\n eigenvectors_DEV()
NOT IMPLEMENTED \n
\n"}, {"fullname": "aton.qrotor.plot.reduced_energies", "modulename": "aton.qrotor.plot", "qualname": "reduced_energies", "kind": "function", "doc": "Plots the reduced energy of the system, E/B, vs the reduced potential energy, V/B
\n", "signature": "(data: aton.qrotor.classes.QExp):", "funcdef": "def"}, {"fullname": "aton.qrotor.plot.potential", "modulename": "aton.qrotor.plot", "qualname": "potential", "kind": "function", "doc": "Plot the potential values of the system.
\n\nInput
\n", "signature": "(data):", "funcdef": "def"}, {"fullname": "aton.qrotor.plot.energies_DEV", "modulename": "aton.qrotor.plot", "qualname": "energies_DEV", "kind": "function", "doc": "data
can be aQSys
orQExp
object.Plots the energy in separated plots. NOT YET IMPLEMENTED
\n", "signature": "(data: aton.qrotor.classes.QExp):", "funcdef": "def"}, {"fullname": "aton.qrotor.plot.energy_DEV", "modulename": "aton.qrotor.plot", "qualname": "energy_DEV", "kind": "function", "doc": "Plots the energy of the system. NOT YET IMPLEMENTED
\n", "signature": "(data: aton.qrotor.classes.QExp):", "funcdef": "def"}, {"fullname": "aton.qrotor.plot.convergence_DEV", "modulename": "aton.qrotor.plot", "qualname": "convergence_DEV", "kind": "function", "doc": "Plots the energy convergence of the system. NOT YET IMPLEMENTED
\n", "signature": "(data: aton.qrotor.classes.QExp):", "funcdef": "def"}, {"fullname": "aton.qrotor.plot.eigenvectors_DEV", "modulename": "aton.qrotor.plot", "qualname": "eigenvectors_DEV", "kind": "function", "doc": "\n", "signature": "(\tdata: aton.qrotor.classes.QExp,\tlevels=None,\tsquared=False,\tscaling_factor=1):", "funcdef": "def"}, {"fullname": "aton.qrotor.potential", "modulename": "aton.qrotor.potential", "kind": "module", "doc": "Description
\n\nThis module contains functions to calculate the actual
\n\npotential_values
of the system.Index
\n\n\n\n
\n\n\n \n\n\n\n \n \n \n\n load()
Load a system with a custom potential from a potential file \n\n \n\n from_qe()
Creates a potential data file from Quantum ESPRESSO outputs \n\n \n\n interpolate()
Interpolates the current \nQSys.potential_values
to a newQSys.gridsize
\n \n\n solve()
Solve the potential values based on the potential name \n\n \n\n zero()
Zero potential \n\n \n\n sine()
Sine potential \n\n \n\n\n titov2023()
Potential of the hidered methyl rotor, as in titov2023. \n
\n"}, {"fullname": "aton.qrotor.potential.load", "modulename": "aton.qrotor.potential", "qualname": "load", "kind": "function", "doc": "Read a potential rotational energy dataset.
\n\nThe file in
\n", "signature": "(\tfilepath: str = 'potential.dat',\tsystem: aton.qrotor.classes.QSys = None,\tangle: str = 'deg',\tenergy: str = 'eV') -> aton.qrotor.classes.QSys:", "funcdef": "def"}, {"fullname": "aton.qrotor.potential.from_qe", "modulename": "aton.qrotor.potential", "qualname": "from_qe", "kind": "function", "doc": "filepath
should contain two columns withangle
andpotential
values.\nDegrees and eV are assumed as default units unless stated inangle
andenergy
.\nUnits will be converted automatically to radians and eV.Creates a potential data file from Quantum ESPRESSO outputs.
\n\nThe angle in degrees is extracted from the output filenames,\nwhich must follow
\n\nwhatever_ANGLE.out
.Outputs from SCF calculations must be located in the provided
\n", "signature": "(folder=None, filters: str = None, output: str = 'potential.dat') -> None:", "funcdef": "def"}, {"fullname": "aton.qrotor.potential.interpolate", "modulename": "aton.qrotor.potential", "qualname": "interpolate", "kind": "function", "doc": "folder
(CWD if None),\nand can be filtered withfilters
.\nTheoutput
name ispotential.dat
by default.Interpolates the current
\n", "signature": "(system: aton.qrotor.classes.QSys) -> aton.qrotor.classes.QSys:", "funcdef": "def"}, {"fullname": "aton.qrotor.potential.solve", "modulename": "aton.qrotor.potential", "qualname": "solve", "kind": "function", "doc": "aton.qrotor.classes.QSys.potential_values
to a new grid of sizeaton.qrotor.classes.QSys.gridsize
.Solves
\n\naton.qrotor.classes.QSys.potential_values
,\naccording to theaton.qrotor.classes.QSys.potential_name
.\nReturns the newpotential_values
.If
\n\nQSys.potential_name
is not present or not recognised,\nthe currentQSys.potential_values
are used.If a bigger
\n", "signature": "(system: aton.qrotor.classes.QSys):", "funcdef": "def"}, {"fullname": "aton.qrotor.potential.zero", "modulename": "aton.qrotor.potential", "qualname": "zero", "kind": "function", "doc": "QSys.gridsize
is provided,\nthe potential is also interpolated to the new gridsize.Zero potential.
\n", "signature": "(system: aton.qrotor.classes.QSys):", "funcdef": "def"}, {"fullname": "aton.qrotor.potential.sine", "modulename": "aton.qrotor.potential", "qualname": "sine", "kind": "function", "doc": "Sine potential.
\n\nIf potential_constants are provided, returns:\n$C_0 + C_1 sin(3x + C_2)$.
\n", "signature": "(system: aton.qrotor.classes.QSys):", "funcdef": "def"}, {"fullname": "aton.qrotor.potential.titov2023", "modulename": "aton.qrotor.potential", "qualname": "titov2023", "kind": "function", "doc": "Potential energy function of the hindered methyl rotor, from titov2023.
\n", "signature": "(system: aton.qrotor.classes.QSys):", "funcdef": "def"}, {"fullname": "aton.qrotor.rotate", "modulename": "aton.qrotor.rotate", "kind": "module", "doc": "Description
\n\nThis submodule contains tools to rotate molecular structures.\nWorks with Quantum ESPRESSO input files.
\n\nIndex
\n\n\n\n
\n\n\n \n\n\n\n \n \n \n\n qe()
Rotate specific atoms from a Quantum ESPRESSO input file \n\n \n\n\n rotate_coords()
Rotate a specific list of coordinates \n
\n"}, {"fullname": "aton.qrotor.rotate.qe", "modulename": "aton.qrotor.rotate", "qualname": "qe", "kind": "function", "doc": "Rotates atoms from a Quantum ESPRESSO input file.
\n\nTakes a
\n\nfilepath
with a molecular structure, and three or more atomicpositions
(list).\nThese input positions can be approximate, and are used to identify the target atoms.\nThe decimal precision in the search for these positions is controlled byprecision
.It rotates the atoms by the geometrical center of the first 3 atoms by a specific
\n\nangle
.\nAdditionally, ifrepeat = True
it repeats the same rotation over the whole circunference.\nFinally, it writes the rotated structure(s) to a new structural file(s).\nReturns a list with the output filename(s).To debug,
\n", "signature": "(\tfilepath: str,\tpositions: list,\tangle: float,\trepeat: bool = False,\tprecision: int = 3,\tshow_axis: bool = False) -> list:", "funcdef": "def"}, {"fullname": "aton.qrotor.rotate.rotate_coords", "modulename": "aton.qrotor.rotate", "qualname": "rotate_coords", "kind": "function", "doc": "show_axis = True
adds two additional helium atoms as the rotation vector.Rotates geometrical coordinates.
\n\nTakes a list of atomic
\n\npositions
in cartesian coordinates, as\n[[x1,y1,z1], [x2,y2,z2], [x3,y3,z3]], [etc]
.\nThen rotates said coordinates by a givenangle
(degrees),\ntaking the perpendicular axis that passes through the\ngeometrical center of the first three points as the axis of rotation.\nAny additional coordinates are rotated with the same rotation matrix.\nReturns a list with the updated positions.If
\n", "signature": "(positions: list, angle: float, show_axis: bool = False) -> list:", "funcdef": "def"}, {"fullname": "aton.qrotor.solve", "modulename": "aton.qrotor.solve", "kind": "module", "doc": "show_axis = True
it returns two additional coordinates at the end of the list,\nwith the centroid and the rotation vector.Description
\n\nThis module is used to solve the hamiltonian eigenvalues and eigenvectors for a given quantum system.\nSparse matrices are used to achieve optimal performance.
\n\nIndex
\n\n\n\n
\n\n\n \n\n\n\n \n \n \n\n laplacian_matrix()
Calculate the second derivative matrix for a given grid \n\n \n\n hamiltonian_matrix()
Calculate the hamiltonian matrix of the system \n\n \n\n potential()
Solve the potential values of the system \n\n \n\n schrodinger()
Solve the Schr\u00f6diger equation for the system \n\n \n\n\n energies()
Solve the system(s) for the \nQSys
orQExp
object
\n"}, {"fullname": "aton.qrotor.solve.laplacian_matrix", "modulename": "aton.qrotor.solve", "qualname": "laplacian_matrix", "kind": "function", "doc": "Calculates the Laplacian (second derivative) matrix for a given
\n", "signature": "(grid):", "funcdef": "def"}, {"fullname": "aton.qrotor.solve.hamiltonian_matrix", "modulename": "aton.qrotor.solve", "qualname": "hamiltonian_matrix", "kind": "function", "doc": "grid
.Calculates the Hamiltonian matrix for a given
\n", "signature": "(system: aton.qrotor.classes.QSys):", "funcdef": "def"}, {"fullname": "aton.qrotor.solve.potential", "modulename": "aton.qrotor.solve", "qualname": "potential", "kind": "function", "doc": "aton.qrotor.classes.QSys
object.Solves the potential_values of the system.
\n\nIt uses the potential name, by calling
\n", "signature": "(system: aton.qrotor.classes.QSys) -> aton.qrotor.classes.QSys:", "funcdef": "def"}, {"fullname": "aton.qrotor.solve.schrodinger", "modulename": "aton.qrotor.solve", "qualname": "schrodinger", "kind": "function", "doc": "aton.qrotor.potential.solve
.\nThen it applies extra operations, such as removing the potential offset\nifaton.qrotor.classes.QSys.correct_potential_offset = True
.Solves the Schr\u00f6dinger equation for a given
\n\naton.qrotor.classes.QSys
object.Uses ARPACK in shift-inverse mode to solve the hamiltonian sparse matrix.
\n", "signature": "(system: aton.qrotor.classes.QSys) -> aton.qrotor.classes.QSys:", "funcdef": "def"}, {"fullname": "aton.qrotor.solve.energies", "modulename": "aton.qrotor.solve", "qualname": "energies", "kind": "function", "doc": "Solves the Schr\u00f6dinger equation for a given
\n", "signature": "(var, filename: str = None) -> aton.qrotor.classes.QExp:", "funcdef": "def"}, {"fullname": "aton.spx", "modulename": "aton.spx", "kind": "module", "doc": "aton.qrotor.classes.QSys
oraton.qrotor.classes.QExp
object.Spectra analysis
\n\nThis module contains spectral analysis tools.
\n\nIndex
\n\n\n\n
\n\n\n \n\n\n\n \n \n \n\n aton.spx.classes
Definition of the \nSpectra
,Plotting
andMaterial
classes, instantiated asaton.spx.Class()
\n \n\n aton.spx.fit
Spectral fitting functions \n\n \n\n aton.spx.normalize
Spectra normalisation \n\n \n\n aton.spx.deuterium
Deuteration estimation functions \n\n \n\n aton.spx.samples
Material definition examples \n\n \n\n\n aton.spx.plot
Spectra plotting, as \naton.spx.plot(Spectra)
Examples
\n\nTo load two INS spectra CSV files with cm$^{-1}$ as input units,\nand plot them in meV units, normalizing their heights over the range from 20 to 50 meV:
\n\n\n\n\n\nfrom aton import spx\n# Set plotting parameters\nplotting_options = spx.Plotting(\n title = 'Calculated INS',\n )\n# Load the spectral data\nins = spx.Spectra(\n type = 'INS',\n files = ['example_1.csv', 'example_2.csv'],\n units_in = 'cm-1',\n units = 'meV',\n plotting = plotting_options,\n )\n# Normalize the spectra\nspx.height(spectra=ins, range=[20, 50])\n# Plot the spectra\nspx.plot(ins)\n
More examples in the
\n"}, {"fullname": "aton.spx.classes", "modulename": "aton.spx.classes", "kind": "module", "doc": "Aton/examples/
folder.Description
\n\nThis module contains common classes used to load and manipulate spectral data.\nAny class can be instantiated directly from the
\n\naton.spx
module,\nasaton.spx.Class()
.Index
\n\n\n\n
\n\n\n \n\n\n\n \n \n \n\n Spectra
Used to load and process spectral data \n\n \n\n Plotting
Stores plotting options, used in \nSpectra.plotting
\n \n\n\n Material
Used to store and calculate material parameters, such as molar masses and neutron cross sections \nExamples
\n\nTo load two INS spectra CSV files with cm$^{-1}$ as input units,\nconverting them to meV units, and finally plotting them:
\n\n\n\n\n\nfrom aton import spx\nins = spx.Spectra(\n type = 'ins',\n files = ['example_1.csv', 'example_2.csv'],\n units_in = 'cm-1',\n units = 'meV',\n )\nspx.plot(ins)\n
Check more use examples in the
\n\nATON/examples/
folder.
\n"}, {"fullname": "aton.spx.classes.Plotting", "modulename": "aton.spx.classes", "qualname": "Plotting", "kind": "class", "doc": "Stores plotting options, read by
\n"}, {"fullname": "aton.spx.classes.Plotting.__init__", "modulename": "aton.spx.classes", "qualname": "Plotting.__init__", "kind": "function", "doc": "aton.spx.plot
Default values can be overwritten when initializing the Plotting object.
\n", "signature": "(\ttitle: str = None,\txlim=None,\tylim=None,\tmargins: list = [0, 0],\toffset=True,\tscaling: float = 1.0,\tvline: list = None,\tvline_error: list = None,\tfigsize: tuple = None,\tlog_xscale: bool = False,\tshow_yticks: bool = False,\txlabel: str = None,\tylabel: str = None,\tlegend=None,\tlegend_title: str = None,\tlegend_size='medium',\tlegend_loc='best',\tsave_as: str = None)"}, {"fullname": "aton.spx.classes.Plotting.title", "modulename": "aton.spx.classes", "qualname": "Plotting.title", "kind": "variable", "doc": "Title of the plot. Set it to an empty string to remove the title.
\n"}, {"fullname": "aton.spx.classes.Plotting.xlim", "modulename": "aton.spx.classes", "qualname": "Plotting.xlim", "kind": "variable", "doc": "List with the x-limits of the plot, as in
\n"}, {"fullname": "aton.spx.classes.Plotting.ylim", "modulename": "aton.spx.classes", "qualname": "Plotting.ylim", "kind": "variable", "doc": "[xlim_low, xlim_top]
.List with the y-limits of the plot, as in
\n"}, {"fullname": "aton.spx.classes.Plotting.margins", "modulename": "aton.spx.classes", "qualname": "Plotting.margins", "kind": "variable", "doc": "[ylim_low, ylim_top]
.List with additional margins at the bottom and top of the plot, as in
\n"}, {"fullname": "aton.spx.classes.Plotting.offset", "modulename": "aton.spx.classes", "qualname": "Plotting.offset", "kind": "variable", "doc": "[low_margin, top_margin]
.If
\n\nTrue
, the plots will be separated automatically.It can be set to a float, to equally offset the plots by a given value.
\n"}, {"fullname": "aton.spx.classes.Plotting.scaling", "modulename": "aton.spx.classes", "qualname": "Plotting.scaling", "kind": "variable", "doc": "Scaling factor
\n"}, {"fullname": "aton.spx.classes.Plotting.vline", "modulename": "aton.spx.classes", "qualname": "Plotting.vline", "kind": "variable", "doc": "Vertical line/s to plot. Can be an int or float with the x-position, or a list with several ones.
\n"}, {"fullname": "aton.spx.classes.Plotting.vline_error", "modulename": "aton.spx.classes", "qualname": "Plotting.vline_error", "kind": "variable", "doc": "Plot a shaded area of the specified width around the vertical lines specified at
\n\nvline
.It can be an array of the same length as
\n"}, {"fullname": "aton.spx.classes.Plotting.figsize", "modulename": "aton.spx.classes", "qualname": "Plotting.figsize", "kind": "variable", "doc": "vline
, or a single value to be applied to all.Tuple with the figure size, as in matplotlib.
\n"}, {"fullname": "aton.spx.classes.Plotting.log_xscale", "modulename": "aton.spx.classes", "qualname": "Plotting.log_xscale", "kind": "variable", "doc": "If true, plot the x-axis in logarithmic scale.
\n"}, {"fullname": "aton.spx.classes.Plotting.show_yticks", "modulename": "aton.spx.classes", "qualname": "Plotting.show_yticks", "kind": "variable", "doc": "Show or not the yticks on the plot.
\n"}, {"fullname": "aton.spx.classes.Plotting.xlabel", "modulename": "aton.spx.classes", "qualname": "Plotting.xlabel", "kind": "variable", "doc": "Custom label of the x-axis.
\n\nIf
\n"}, {"fullname": "aton.spx.classes.Plotting.ylabel", "modulename": "aton.spx.classes", "qualname": "Plotting.ylabel", "kind": "variable", "doc": "None
, the default label will be used.\nSet to''
to remove the label of the horizontal axis.Custom label of the y-axis.
\n\nIf
\n"}, {"fullname": "aton.spx.classes.Plotting.legend", "modulename": "aton.spx.classes", "qualname": "Plotting.legend", "kind": "variable", "doc": "None
, the default label will be used.\nSet to''
to remove the label of the vertical axis.Legend of the plot.
\n\nIf
\n"}, {"fullname": "aton.spx.classes.Plotting.legend_title", "modulename": "aton.spx.classes", "qualname": "Plotting.legend_title", "kind": "variable", "doc": "None
, the filenames will be used as legend.\nCan be a bool to show or hide the plot legend.\nIt can also be an array containing the strings to display;\nin that case, elements set toFalse
will not be displayed.Title of the legend, defaults to
\n"}, {"fullname": "aton.spx.classes.Plotting.legend_size", "modulename": "aton.spx.classes", "qualname": "Plotting.legend_size", "kind": "variable", "doc": "None
.Size of the legend, as in matplotlib. Defaults to
\n"}, {"fullname": "aton.spx.classes.Plotting.legend_loc", "modulename": "aton.spx.classes", "qualname": "Plotting.legend_loc", "kind": "variable", "doc": "'medium'
.Location of the legend, as in matplotlib. Defaults to
\n"}, {"fullname": "aton.spx.classes.Plotting.save_as", "modulename": "aton.spx.classes", "qualname": "Plotting.save_as", "kind": "variable", "doc": "'best'
.Filename to save the plot. None by default.
\n"}, {"fullname": "aton.spx.classes.Spectra", "modulename": "aton.spx.classes", "qualname": "Spectra", "kind": "class", "doc": "Spectra object. Used to load and process spectral data.
\n\nMost functions in the
\n"}, {"fullname": "aton.spx.classes.Spectra.__init__", "modulename": "aton.spx.classes", "qualname": "Spectra.__init__", "kind": "function", "doc": "aton.spx
module receive this object as input.All values can be set when initializing the Spectra object.
\n", "signature": "(\ttype: str = None,\tcomment: str = None,\tfiles=None,\tdfs=None,\tunits=None,\tunits_in=None,\tplotting: aton.spx.classes.Plotting = <aton.spx.classes.Plotting object>)"}, {"fullname": "aton.spx.classes.Spectra.type", "modulename": "aton.spx.classes", "qualname": "Spectra.type", "kind": "variable", "doc": "Type of the spectra:
\n"}, {"fullname": "aton.spx.classes.Spectra.comment", "modulename": "aton.spx.classes", "qualname": "Spectra.comment", "kind": "variable", "doc": "'INS'
,'ATR'
, or'RAMAN'
.Custom comment. If
\n"}, {"fullname": "aton.spx.classes.Spectra.files", "modulename": "aton.spx.classes", "qualname": "Spectra.files", "kind": "variable", "doc": "Plotting.title
is None, it will be the title of the plot.List containing the files with the spectral data.
\n\nLoaded automatically to
\n"}, {"fullname": "aton.spx.classes.Spectra.dfs", "modulename": "aton.spx.classes", "qualname": "Spectra.dfs", "kind": "variable", "doc": "dfs
with Pandas at initialization.\nIn order for Pandas to read the files properly, note that the column lines must start by#
.\nAny additional line that is not data must be removed or commented with#
.\nCSV files must be formatted with the first column as the energy or energy transfer,\nand the second column with the intensity or absorbance, depending on the case.\nAn additional third'Error'
column can be used.List containing the pandas dataframes with the spectral data.
\n\nLoaded automatically from
\n"}, {"fullname": "aton.spx.classes.Spectra.units", "modulename": "aton.spx.classes", "qualname": "Spectra.units", "kind": "variable", "doc": "files
at initialization.Target units of the spectral data.
\n\nCan be
\n"}, {"fullname": "aton.spx.classes.Spectra.units_in", "modulename": "aton.spx.classes", "qualname": "Spectra.units_in", "kind": "variable", "doc": "'meV'
or'cm-1'
.Input units of the spectral data, used in the input CSV files.
\n\nCan be
\n"}, {"fullname": "aton.spx.classes.Spectra.plotting", "modulename": "aton.spx.classes", "qualname": "Spectra.plotting", "kind": "variable", "doc": "'meV'
or'cm-1'
.\nIf the input CSV files have different units,\nit can also be set as a list of the same length of the number of input files,\neg.['meV', 'cm-1', 'cm-1']
.\n"}, {"fullname": "aton.spx.classes.Spectra.set_units", "modulename": "aton.spx.classes", "qualname": "Spectra.set_units", "kind": "function", "doc": "
Plotting
object, used to set the plotting options.Method to change between spectral units. ALWAYS use this method to do that.
\n\nFor example, to change to meV from cm-1:
\n\n\n\n", "signature": "(self, units, units_in=None, default_unit='cm-1'):", "funcdef": "def"}, {"fullname": "aton.spx.classes.Material", "modulename": "aton.spx.classes", "qualname": "Material", "kind": "class", "doc": "\nSpectra.set_units('meV', 'cm-1')\n
Material class.
\n\nUsed to calculate molar masses and cross sections,\nand to pass data to different analysis functions\nsuch as
\n"}, {"fullname": "aton.spx.classes.Material.__init__", "modulename": "aton.spx.classes", "qualname": "Material.__init__", "kind": "function", "doc": "aton.spectra.deuterium.impulse_approx().
All values can be set when initializing the Material object.\nHowever, it is recommended to only set the elements and the grams,\nand optionally the name, and calculate the rest with
\n", "signature": "(\telements: dict,\tname: str = None,\tgrams: float = None,\tgrams_error: float = None,\tmols: float = None,\tmols_error: float = None,\tmolar_mass: float = None,\tcross_section: float = None,\tpeaks: dict = None)"}, {"fullname": "aton.spx.classes.Material.elements", "modulename": "aton.spx.classes", "qualname": "Material.elements", "kind": "variable", "doc": "Material.set()
.Dict of atoms in the material, as in
\n\n{'H': 6, 'C':1, 'N':1}
.Isotopes can be expressed as 'H2', 'He4', etc. with the atom symbol + isotope mass number.
\n"}, {"fullname": "aton.spx.classes.Material.name", "modulename": "aton.spx.classes", "qualname": "Material.name", "kind": "variable", "doc": "String with the name of the material.
\n"}, {"fullname": "aton.spx.classes.Material.grams", "modulename": "aton.spx.classes", "qualname": "Material.grams", "kind": "variable", "doc": "Mass, in grams.
\n"}, {"fullname": "aton.spx.classes.Material.grams_error", "modulename": "aton.spx.classes", "qualname": "Material.grams_error", "kind": "variable", "doc": "Error of the measured mass in grams.
\n\nSet automatically with
\n"}, {"fullname": "aton.spx.classes.Material.mols", "modulename": "aton.spx.classes", "qualname": "Material.mols", "kind": "variable", "doc": "Material.set()
.Number of moles.
\n\nSet automatically with
\n"}, {"fullname": "aton.spx.classes.Material.mols_error", "modulename": "aton.spx.classes", "qualname": "Material.mols_error", "kind": "variable", "doc": "Material.set()
.Error of the number of moles.
\n\nSet automatically with
\n"}, {"fullname": "aton.spx.classes.Material.molar_mass", "modulename": "aton.spx.classes", "qualname": "Material.molar_mass", "kind": "variable", "doc": "Material.set()
.Molar mass of the material, in mol/g.
\n\nCalculated automatically with
\n"}, {"fullname": "aton.spx.classes.Material.cross_section", "modulename": "aton.spx.classes", "qualname": "Material.cross_section", "kind": "variable", "doc": "Material.set()
.Neutron total bound scattering cross section, in barns.
\n\nCalculated automatically with
\n"}, {"fullname": "aton.spx.classes.Material.peaks", "modulename": "aton.spx.classes", "qualname": "Material.peaks", "kind": "variable", "doc": "Material.set()
.Dict with interesting peaks that you might want to store for later use.
\n"}, {"fullname": "aton.spx.classes.Material.set", "modulename": "aton.spx.classes", "qualname": "Material.set", "kind": "function", "doc": "Set the molar mass, cross section and errors of the material.
\n", "signature": "(self):", "funcdef": "def"}, {"fullname": "aton.spx.classes.Material.print", "modulename": "aton.spx.classes", "qualname": "Material.print", "kind": "function", "doc": "Print a summary with the material information.
\n", "signature": "(self):", "funcdef": "def"}, {"fullname": "aton.spx.deuterium", "modulename": "aton.spx.deuterium", "kind": "module", "doc": "Description
\n\nThis module contains methods to calculate deuteration levels from different spectra.
\n\nIndex
\n\n\n\n
\n\n\n \n\n\n\n \n \n \n\n impulse_approx()
Calculate the deuteration levels from INS spectra with the Impulse Approximation \n\n \n\n\n peaks_mapbi3()
Estimates CH$_3$NH$_3$PbI$_3$ deuteration by integrating the INS disrotatory peaks \n
\n"}, {"fullname": "aton.spx.deuterium.impulse_approx", "modulename": "aton.spx.deuterium", "qualname": "impulse_approx", "kind": "function", "doc": "Calculate the deuteration levels from INS spectra\nwith the Impulse Approximation, see\nhttps://www.tandfonline.com/doi/full/10.1080/00018732.2017.1317963.
\n\nProtonated and deuterated materials must be specified\nas
\n\naton.spectra.classes.Material
objects.\nNote that this approximation is very sensitive to the mass sample.\nThe threshold controls the start of the plateau (in meV)\nto start considering Deep Inelastic Neutron Scattering (DINS).\nThe protonated and deuterated dataframe indexes are specified\nbyH_df_index
andD_df_index
, respectively.In this approximation, the ideal ratio between\nthe cross-sections and the experimental ratio between\nthe pleteaus at high energies should be the same:\n$$\n\\frac{\\text{plateau_D}}{\\text{plateau_H}} \\approx \\frac{\\text{cross_section_D}}{\\text{cross_section_H}}\n$$\nTaking this into account, the deuteration is estimated as:\n$$\n\\text{Deuteration} = \\frac{1-\\text{real_ratio}}{1-\\text{ideal_ratio}}\n$$
\n", "signature": "(\tins: aton.spx.classes.Spectra,\tmaterial_H: aton.spx.classes.Material,\tmaterial_D: aton.spx.classes.Material,\tthreshold: float = 600,\tH_df_index: int = 0,\tD_df_index: int = 1) -> tuple:", "funcdef": "def"}, {"fullname": "aton.spx.deuterium.peaks_mapbi3", "modulename": "aton.spx.deuterium", "qualname": "peaks_mapbi3", "kind": "function", "doc": "Estimates CH$_3$NH$_3$PbI$_3$ deuteration by integrating the INS disrotatory peaks.
\n\nThe INS disrotatory peaks of CH3NH3 appear at ~38 meV for the fully protonated sample.\nNote that
\n\npeaks
must be a dictionary with the peak limits\nand the baseline, as in the example below:\n\n\n\npeaks = {\n 'baseline' : None,\n 'baseline_error' : None,\n 'h6d0' : [41, 43],\n 'h5d1' : [41, 43],\n 'h4d2' : [41, 43],\n 'h3d3' : [34.7, 37.3],\n 'h2d4' : [31.0, 33.0],\n 'h1d5' : [28.0, 30.5],\n 'h0d6' : [26.5, 28.0],\n }\n
Peak keywords required for selective deuteration (only C or only N):\n
\n\nh6d0
,h5d1
,h4d2
,h3d3
.Additional peak keywords required for total deuteration:\n
\n\nh2d4
,h1d5
,h0d6
.If some peak is not present in your sample,\njust set the limits to a small baseline plateau.
\n", "signature": "(ins: aton.spx.classes.Spectra, peaks: dict, df_index: int = 0) -> str:", "funcdef": "def"}, {"fullname": "aton.spx.fit", "modulename": "aton.spx.fit", "kind": "module", "doc": "Description
\n\nThis module contains functions for fitting and analyzing spectral data.
\n\nIndex
\n\n\n\n
\n\n\n \n\n\n\n \n \n \n\n plateau()
Fit the mean value and the error of a plateau \n\n \n\n area_under_peak()
Calculate the area under a given peak \n\n \n\n ratio_areas()
Check the ratio between two areas \n\n \n\n\n mean()
Get the mean and standard deviation of a list of values \n
\n"}, {"fullname": "aton.spx.fit.plateau", "modulename": "aton.spx.fit", "qualname": "plateau", "kind": "function", "doc": "Fit the mean value and the error of a plateau in a
\n\naton.spectra.Spectra
object.Use as
\n\naton.spx.fit.plateau(spectra, cuts=[low_cut, high_cut], df_index=0)
.If
\n\naton.spx.classes.Spectra.dfs[df_index]
has an 'Error' column, those errors are also taken into account\nalong with the standard deviation of the mean, else only the standard deviation is considered.\nThis is the case if your dataset had a third column with the errors\nwhen you imported theaton.spx.classes.Spectra
object.Note that
\n", "signature": "(spectra: aton.spx.classes.Spectra, cuts=None, df_index: int = 0) -> tuple:", "funcdef": "def"}, {"fullname": "aton.spx.fit.area_under_peak", "modulename": "aton.spx.fit", "qualname": "area_under_peak", "kind": "function", "doc": "cuts
,low_cut
and/ortop_cut
can be set to None.Calculate the area under a given peak.
\n\nPeaks must be defined as
\n", "signature": "(\tspectra: aton.spx.classes.Spectra,\tpeak: list,\tdf_index: int = 0,\terrors_as_in_baseline: bool = True,\tmin_as_baseline: bool = False) -> tuple:", "funcdef": "def"}, {"fullname": "aton.spx.fit.ratio_areas", "modulename": "aton.spx.fit", "qualname": "ratio_areas", "kind": "function", "doc": "peak:list=[xmin, xmax, baseline=0, baseline_error=0]
.\nIf the dataset has noError
column, the error for each point is assumed to be the same\nas the baseline error iferrors_as_in_baseline=True
, otherwise it is assumed to be zero.\nIfmin_as_baseline=True
andbaseline=0
, the baseline is assumed to be the minimum value.\nAlso, ifmin_as_baseline=True
and there are negative areas even after applying the baseline,\nthe baseline will be corrected to the minimum value.Check the ratio between two areas, e.g. to estimate deuteration levels from ATR data.
\n\nThe ratio is calculated as
\n", "signature": "(\tarea: float,\tarea_total: float,\tarea_error: float = 0.0,\tarea_total_error: float = 0.0,\tinverse_ratio: bool = False) -> tuple:", "funcdef": "def"}, {"fullname": "aton.spx.fit.mean", "modulename": "aton.spx.fit", "qualname": "mean", "kind": "function", "doc": "area / area_total
. This behavior is modified ifinverse_ratio = True
,\nso that the ratio is calculated as(area_total - area) / area_total
.\nNote that changing the ratio calculation also affects the error propagation.Takes an
\n\narray
of numerical values and returns the mean and standard deviation.It is calculated with numpy as:
\n\n$\\sigma_{x}=\\sqrt{\\frac{\\sum{(x_{i}-{\\overline{x}})^2}}{N-\\text{ddof}}}$
\n\nwhere ddof are the delta
\n\ndegrees_of_freedom
, zero by default.\nSet it to1
for a corrected sample standard deviation (low N cases),\nsee more details here.The mean is rounded up to the order of the error by default. To override this behaviour, set
\n", "signature": "(array: list, rounded: bool = True, degrees_of_freedom=0) -> tuple:", "funcdef": "def"}, {"fullname": "aton.spx.normalize", "modulename": "aton.spx.normalize", "kind": "module", "doc": "rounded=False
.Description
\n\nThis module contains functions to normalize data and other variables.
\n\nIndex
\n\n\n\n
\n\n\n \n\n\n\n \n \n \n\n height()
Normalize a \nspectra
by height\n \n\n area()
Normalize a \nspectra
by the area under the datasets\n \n\n\n unit_str()
Normalize a \nunit
string from user input
\n"}, {"fullname": "aton.spx.normalize.height", "modulename": "aton.spx.normalize", "qualname": "height", "kind": "function", "doc": "Normalize a set of
\n\nspectra
by height.By default it normalises the spectra over the entire range.\nThis can be modified by setting a specific range,\nas in
\n\nrange = [x_min, x_max]
withaxis = 'x'
.\nIt can also normalise over manual y-positions,\nfor example for peaks with different baselines.\nThis can be done by settingchaxis='y'
, and\nrange = [[y_min_1, y_max_1], ..., [y_min_N, y_max_N]]
.Heights are normalised with respect to the\nreference dataframe
\n", "signature": "(\tspectra: aton.spx.classes.Spectra,\trange: list = None,\taxis: str = 'x',\tdf_index: int = 0) -> aton.spx.classes.Spectra:", "funcdef": "def"}, {"fullname": "aton.spx.normalize.area", "modulename": "aton.spx.normalize", "qualname": "area", "kind": "function", "doc": "df_index
, the first one by default.Normalize
\n", "signature": "(\tspectra: aton.spx.classes.Spectra,\trange: list = None,\tdf_index: int = 0) -> aton.spx.classes.Spectra:", "funcdef": "def"}, {"fullname": "aton.spx.normalize.unit_str", "modulename": "aton.spx.normalize", "qualname": "unit_str", "kind": "function", "doc": "spectra
by the area under the datasets.Normalize
\n", "signature": "(unit: str):", "funcdef": "def"}, {"fullname": "aton.spx.plot", "modulename": "aton.spx.plot", "kind": "module", "doc": "unit
string from user input.Description
\n\nThis module contains the
\n\nplot()
function,\nused to plotaton.spx.classes.Spectra
data,\ncontaining optionalaton.spx.classes.Plotting
parameters.It is used as
\n\naton.spx.plot(Spectra)
\n"}, {"fullname": "aton.spx.plot.plot", "modulename": "aton.spx.plot", "qualname": "plot", "kind": "function", "doc": "Plots a
\n\nspectra
.Optional
\n", "signature": "(spectra: aton.spx.classes.Spectra):", "funcdef": "def"}, {"fullname": "aton.spx.samples", "modulename": "aton.spx.samples", "kind": "module", "doc": "aton.spectra.classes.Plotting
attributes can be used.Description
\n\nThis module contains premade examples of material compositions, for testing purposes.\nThe
\n\naton.spx.classes.Material.grams
is yet to be provided,\nbefore setting the material asaton.spx.Material.set()
.
\n"}, {"fullname": "aton.spx.samples.CH3NH3PbI3", "modulename": "aton.spx.samples", "qualname": "CH3NH3PbI3", "kind": "variable", "doc": "CH$_3$NH$_3$PbI$_3$
\n", "default_value": "<aton.spx.classes.Material object>"}, {"fullname": "aton.spx.samples.CD3ND3PbI3", "modulename": "aton.spx.samples", "qualname": "CD3ND3PbI3", "kind": "variable", "doc": "CD$_3$ND$_3$PbI$_3$.
\n\nWith experimental values of the partially-deuterated amine peaks\nfor the disrotatory mode of MAPbI3's methylammonium.\nMeasured at TOSCA, ISIS RAL, UK, May 2024.
\n", "default_value": "<aton.spx.classes.Material object>"}, {"fullname": "aton.spx.samples.CH3ND3PbI3", "modulename": "aton.spx.samples", "qualname": "CH3ND3PbI3", "kind": "variable", "doc": "CH$_3$ND$_3$PbI$_3$.
\n\nWith experimental values of the partially-deuterated amine peaks\nfor the disrotatory mode of MAPbI3's methylammonium.\nMeasured at TOSCA, ISIS RAL, UK, May 2024.
\n", "default_value": "<aton.spx.classes.Material object>"}, {"fullname": "aton.spx.samples.CD3NH3PbI3", "modulename": "aton.spx.samples", "qualname": "CD3NH3PbI3", "kind": "variable", "doc": "CD$_3$NH$_3$PbI$_3$
\n", "default_value": "<aton.spx.classes.Material object>"}, {"fullname": "aton.spx.samples.CH3NH3I", "modulename": "aton.spx.samples", "qualname": "CH3NH3I", "kind": "variable", "doc": "CH$_3$NH$_3$I
\n", "default_value": "<aton.spx.classes.Material object>"}, {"fullname": "aton.spx.samples.CH3ND3I", "modulename": "aton.spx.samples", "qualname": "CH3ND3I", "kind": "variable", "doc": "CH$_3$ND$_3$I
\n", "default_value": "<aton.spx.classes.Material object>"}, {"fullname": "aton.st", "modulename": "aton.st", "kind": "module", "doc": "System Tools
\n\nCommon system tools across all ATON subpackages.
\n\nIndex
\n\n\n\n
\n"}, {"fullname": "aton.st.alias", "modulename": "aton.st.alias", "kind": "module", "doc": "\n \n\n\n\n \n \n \n\n aton.st.file
File manipulation \n\n \n\n aton.st.call
Run bash scripts and related \n\n \n\n\n aton.st.alias
Useful dictionaries for user input correction \nDescription
\n\nThis module contains common dictionaries to normalise and correct user inputs.\nAll values can be found in lowercase, to allow comparison with the
\n\nstring.lower()
method.Index
\n\n\n\n
units
\nspatial
\nexperiments
\nfiles
\nboolean
Examples
\n\n\n\n\n\nunit = 'Electronvolts'\nif unit.lower() in aton.alias.units['eV']:\n ... do stuff ...\n
\n"}, {"fullname": "aton.st.alias.units", "modulename": "aton.st.alias", "qualname": "units", "kind": "variable", "doc": "Dict with unit names.
\n", "annotation": ": dict", "default_value": "{'mol': ['mol', 'mols', 'mole', 'moles'], 'g': ['g', 'gram', 'grams'], 'kg': ['kg', 'kilogram', 'kilograms'], 'amu': ['amu', 'atomicmassunit', 'atomicmassunits'], 'eV': ['eV', 'ev', 'electronvolt', 'electronvolts'], 'meV': ['meV', 'mev', 'millielectronvolt', 'millielectronvolts'], 'J': ['J', 'j', 'joule', 'joules'], 'cal': ['cal', 'calorie', 'calories'], 'kcal': ['kcal', 'kilocalorie', 'kilocalories'], 'Ry': ['Ry', 'ry', 'rydberg', 'rydbergs'], 'cm-1': ['cm^{-1}', 'cm1', 'cm-1', 'cm^-1'], 'cm': ['cm', 'centimeter', 'centimeters'], 'A': ['A', 'a', 'aa', 'angstrom', 'angstroms', 'armstrong', 'armstrongs'], 'bohr': ['bohr', 'bohrs', 'bohrradii'], 'm': ['m', 'meter', 'meters'], 'deg': ['deg', 'degree', 'degrees'], 'rad': ['rad', 'radian', 'radians'], 'bar': ['bar', 'bars'], 'kbar': ['kbar', 'kilobar', 'kilobars'], 'Pa': ['Pa', 'pa', 'pascal', 'pascals'], 'GPa': ['GPa', 'gpa', 'gigapascal', 'gigapascals'], 's': ['s', 'second', 'seconds'], 'H': ['H', 'h', 'hour', 'hours']}"}, {"fullname": "aton.st.alias.spatial", "modulename": "aton.st.alias", "qualname": "spatial", "kind": "variable", "doc": "Dict with different spatial parameters. Values must be compared to
\n", "annotation": ": dict", "default_value": "{'height': ['height', 'h'], 'area': ['area', 'a'], 'volume': ['volume', 'vol'], 'x': ['x', 'horizontal', 'h'], 'y': ['y', 'vertical', 'v'], 'z': ['z']}"}, {"fullname": "aton.st.alias.chemical", "modulename": "aton.st.alias", "qualname": "chemical", "kind": "variable", "doc": "string.lower()
.Dict with chemical groups.
\n", "annotation": ": dict", "default_value": "{'CH3': ['ch', 'CH', 'ch3', 'CH3', 'methyl'], 'NH3': ['nh', 'NH', 'nh3', 'NH3', 'amine'], 'CD3': ['cd', 'CD', 'cd3', 'CD3', 'deuterated methyl'], 'ND3': ['nd', 'ND', 'nd3', 'ND3', 'deuterated amine']}"}, {"fullname": "aton.st.alias.experiments", "modulename": "aton.st.alias", "qualname": "experiments", "kind": "variable", "doc": "Dictionary with the available experiment types. Values must be compared to
\n", "annotation": ": dict", "default_value": "{'ins': ['ins', 'inelasticneutronscattering', 'inelastic neutron scattering'], 'atr': ['atr', 'ftir', 'attenuatedtotalreflection', 'attenuated total reflection'], 'raman': ['raman'], 'qens': ['qens', 'quasielasticneutronscattering', 'quasielastic neutron scattering', 'quasi elastic neutron scattering']}"}, {"fullname": "aton.st.alias.files", "modulename": "aton.st.alias", "qualname": "files", "kind": "variable", "doc": "string.lower()
.Strings related to files. Values must be compared to
\n", "annotation": ": dict", "default_value": "{'file': ['file', 'files', 'f', 'filepath', 'file path', 'filename', 'file name'], 'dir': ['dir', 'directory', 'd', 'folder'], 'error': ['error', 'errors', 'e', 'err']}"}, {"fullname": "aton.st.alias.boolean", "modulename": "aton.st.alias", "qualname": "boolean", "kind": "variable", "doc": "string.lower()
.Strings with booleans such as 'yes' / 'no'.
\n", "annotation": ": dict", "default_value": "{True: ['yes', 'YES', 'Yes', 'Y', 'y', 'T', 'True', 'TRUE', 't', 'true', True, 'Si', 'SI', 'si', 'S', 's'], False: ['no', 'NO', 'No', 'N', 'n', 'F', 'False', 'FALSE', 'f', 'false', False]}"}, {"fullname": "aton.st.call", "modulename": "aton.st.call", "kind": "module", "doc": "Description
\n\nFunctions to handle bash calls and related operations on Linux systems.
\n\nIndex
\n\n\n\n
\n\n\n \n\n\n\n \n \n \n\n bash()
Run a bash shell commands \n\n \n\n git()
Automatically update a Git repository \n\n \n\n\n here()
Runs the rest of the script inside a given folder \n
\n"}, {"fullname": "aton.st.call.bash", "modulename": "aton.st.call", "qualname": "bash", "kind": "function", "doc": "Run a bash shell commands.
\n\nA given
\n", "signature": "(\tcommand: str,\tcwd=None,\tverbose: bool = True,\treturn_anyway: bool = False):", "funcdef": "def"}, {"fullname": "aton.st.call.git", "modulename": "aton.st.call", "qualname": "git", "kind": "function", "doc": "command
will be executed inside an optionalcwd
directory.\nIf empty, the current working directory will be used.\nPrints the running command and outputs by default, override this withverbose=False
.\nReturns the result of the command used, except for when\nerrors are raised automatically; setreturn_anyway=True
to override this.Automatically update a Git repository
\n", "signature": "(path=None, verbose=True, message=None, tag=None) -> None:", "funcdef": "def"}, {"fullname": "aton.st.call.here", "modulename": "aton.st.call", "qualname": "here", "kind": "function", "doc": "Runs the rest of the script inside the specified
\n\nfolder
.If none is provided, it runs from the same directory where the current script lies.\nThis is really useful to run scripts from the VSCode terminal, etc.\nReturns the path of the used
\n\nfolder
, or the path of the script if folder is not provided.Note that this changes not only the working directory of your script,\nbut also of other scripts that import and run your script.
\n", "signature": "(folder=None) -> str:", "funcdef": "def"}, {"fullname": "aton.st.file", "modulename": "aton.st.file", "kind": "module", "doc": "Description
\n\nFunctions to move files around.
\n\nIndex
\n\n\n\n
\n\n\n \n\n\n\n \n \n \n\n get()
Check that a file exists, and return the full path \n\n \n\n get_list()
Get a list of the files inside a folder, applying optional filters \n\n \n\n get_dir()
Get the full path of a folder or the cwd \n\n \n\n copy()
Copy file \n\n \n\n move()
Move file \n\n \n\n remove()
Remove file or folder \n\n \n\n rename_on_folder()
Batch rename files from a folder \n\n \n\n rename_on_folders()
Barch rename files from subfolders \n\n \n\n copy_to_folders()
Copy files to individual subfolders \n\n \n\n save()
Save a Python object to a binary file, as \n.aton
\n \n\n\n load()
Load a Python object from a binary file, as \n.aton
\n"}, {"fullname": "aton.st.file.get", "modulename": "aton.st.file", "qualname": "get", "kind": "function", "doc": "Check if
\n\nfilepath
exists, and returns its full path.Raises an error if the file is not found,\nunless
\n\nreturn_anyway = True
, in which case it returns None.\nThis can be used to personalize errors.If the provided string is a directory, it checks the files inside it.\nif there is only one file inside, it returns said file;\nif there are more files, it tries to filter them with the
\n", "signature": "(filepath, filters=None, return_anyway: bool = False) -> str:", "funcdef": "def"}, {"fullname": "aton.st.file.get_list", "modulename": "aton.st.file", "qualname": "get_list", "kind": "function", "doc": "filters
keyword(s) to return a single file.\nIf this fails, try using more strict filers to return a single file.Return the files inside a
\n\nfolder
, applying optionalfilters
.The full paths are returned by default; to get only the base names, set
\n", "signature": "(folder: str, filters=None, abspath: bool = True) -> list:", "funcdef": "def"}, {"fullname": "aton.st.file.get_dir", "modulename": "aton.st.file", "qualname": "get_dir", "kind": "function", "doc": "abspath = False
.Returns the full path of
\n", "signature": "(folder=None) -> str:", "funcdef": "def"}, {"fullname": "aton.st.file.copy", "modulename": "aton.st.file", "qualname": "copy", "kind": "function", "doc": "folder
or the parent folder if it's a file. If none is provided, the current working directory is returned.Copies
\n", "signature": "(old: str, new: str) -> None:", "funcdef": "def"}, {"fullname": "aton.st.file.move", "modulename": "aton.st.file", "qualname": "move", "kind": "function", "doc": "old
file tonew
fileMoves
\n", "signature": "(old: str, new: str) -> None:", "funcdef": "def"}, {"fullname": "aton.st.file.remove", "modulename": "aton.st.file", "qualname": "remove", "kind": "function", "doc": "old
file tonew
file.Removes the given file or folder at
\n\nfilepath
.\n\n", "signature": "(filepath: str) -> None:", "funcdef": "def"}, {"fullname": "aton.st.file.rename_on_folder", "modulename": "aton.st.file", "qualname": "rename_on_folder", "kind": "function", "doc": "WARNING: Removing stuff is always dangerous, be careful!
\nBatch renames files in the given
\n\nfolder
.Replaces the
\n", "signature": "(old: str, new: str, folder=None) -> None:", "funcdef": "def"}, {"fullname": "aton.st.file.rename_on_folders", "modulename": "aton.st.file", "qualname": "rename_on_folders", "kind": "function", "doc": "old
string bynew
string.\nIf no folder is provided, the current working directory is used.Renames the files inside the subfolders in the parent
\n\nfolder
.Renames from an
\n", "signature": "(old: str, new: str, folder=None) -> None:", "funcdef": "def"}, {"fullname": "aton.st.file.copy_to_folders", "modulename": "aton.st.file", "qualname": "copy_to_folders", "kind": "function", "doc": "old
string to thenew
string.\nIf nofolder
is provided, the current working directory is used.Copies the files from the parent
\n\nfolder
with the givenextension
to individual subfolders.The subfolders are named as the original files,\nremoving the strings from the
\n", "signature": "(folder=None, extension: str = None, strings_to_delete: list = []) -> None:", "funcdef": "def"}, {"fullname": "aton.st.file.save", "modulename": "aton.st.file", "qualname": "save", "kind": "function", "doc": "strings_to_delete
list.\nIf nofolder
is provided, it runs in the current working directory.Save a Python object in the current working directory as a binary
\n", "signature": "(object, filename: str = None):", "funcdef": "def"}, {"fullname": "aton.st.file.load", "modulename": "aton.st.file", "qualname": "load", "kind": "function", "doc": "*.aton
file.Load a Python object from a binary
\n\n*.aton
file.Use only if you trust the person who sent you the file!
\n", "signature": "(filepath: str = 'data.aton'):", "funcdef": "def"}, {"fullname": "aton.txt", "modulename": "aton.txt", "kind": "module", "doc": "General text operations
\n\nThis subpackage contains tools for general text operations.\nIt provides the basic functionality that powers more complex subpackages,\nsuch as
\n\naton.interface
.Index
\n\n\n\n
\n\n\n \n\n\n\n \n \n \n\n aton.txt.find
Search for specific content from a text file \n\n \n\n aton.txt.edit
Edit specific content from a text file \n\n \n\n\n aton.txt.extract
Extract data from raw text strings \nExamples
\n\nThe following example shows how to find a value in a text file, extract it and paste it into another file using the txt subpackage:
\n\n\n\n\n\nfrom aton import txt\n# Get an array with all matches\nalat_lines = txt.find.lines('relax.out', 'Lattice parameter =')\n# Extract the numerical value of the last match\nalat = txt.extract.number(alat_lines[-1], 'Lattice parameter')\n# Paste it into another file\ntxt.edit.replace_line('scf.in', 'Lattice parameter =', f'Lattice parameter ='{alat})\n
Advanced usage such as regular expression matching or\nadditional line extraction is detailed in the API documentation.
\n"}, {"fullname": "aton.txt.edit", "modulename": "aton.txt.edit", "kind": "module", "doc": "Description
\n\nFunctions to manipulate the content of text files.
\n\nIndex
\n\n\n\n
insert_at()
\ninsert_under()
\nreplace()
\nreplace_line()
\nreplace_between()
\ndelete_under()
\ncorrect_with_dict()
\nfrom_template()
\n"}, {"fullname": "aton.txt.edit.insert_at", "modulename": "aton.txt.edit", "qualname": "insert_at", "kind": "function", "doc": "Inserts a
\n\ntext
in the line withposition
index of a givenfilepath
.If
\n", "signature": "(filepath, text: str, position: int) -> None:", "funcdef": "def"}, {"fullname": "aton.txt.edit.insert_under", "modulename": "aton.txt.edit", "qualname": "insert_under", "kind": "function", "doc": "position
is negative, starts from the end of the file.Inserts a
\n\ntext
under the line(s) containing thekey
infilepath
.The keyword can be at any position within the line.\nRegular expressions can be used by setting
\n\nregex=True
.By default all matches are inserted with
\n\ninsertions=0
,\nbut it can insert only a specific number of matches\nwith positive numbers (1, 2...), or starting from the bottom with negative numbers.The text can be introduced after a specific number of lines after the match,\nchanging the value
\n", "signature": "(\tfilepath,\tkey: str,\ttext: str,\tinsertions: int = 0,\tskips: int = 0,\tregex: bool = False) -> None:", "funcdef": "def"}, {"fullname": "aton.txt.edit.replace", "modulename": "aton.txt.edit", "qualname": "replace", "kind": "function", "doc": "skips
. Negative integers introduce the text in the previous lines.Replaces the
\n\nkey
withtext
infilepath
.It can also be used to delete the keyword with
\n\ntext=''
.\nTo search with regular expressions, setregex=True
.The value
\n\nreplacements
specifies the number of replacements to perform:\n1 to replace only the first keyword found, 2, 3...\nUse negative values to replace from the end of the file,\neg. to replace the last found key, usereplacements=-1
.\nTo replace all values, setreplacements = 0
, which is the value by default.\n", "signature": "(\tfilepath: str,\tkey: str,\ttext: str,\treplacements: int = 0,\tregex: bool = False) -> None:", "funcdef": "def"}, {"fullname": "aton.txt.edit.replace_line", "modulename": "aton.txt.edit", "qualname": "replace_line", "kind": "function", "doc": "line... key ...line -> line... text ...line\n
Replaces the entire line(s) containing the
\n\nkey
with thetext
infilepath
.It can be used to delete line(s) by setting
\n\ntext=''
.\nRegular expressions can be used withregex=True
.The value
\n\nreplacements
specifies the number of lines to replace:\n1 to replace only the first line with the keyword, 2, 3...\nUse negative values to replace from the end of the file,\ne.g., to replace only the last line containing the keyword, usereplacements = -1
.\nTo replace all lines, setreplacements = 0
, which is the value by default.The default line to replace is the matching line,\nbut it can be any other specific line after or before the matching line;\nthis is indicated with
\n\nskips
as a positive or negative integer.More lines can be replaced with
\n", "signature": "(\tfilepath: str,\tkey: str,\ttext: str,\treplacements: int = 0,\tskips: int = 0,\tadditional: int = 0,\tregex: bool = False,\traise_errors: bool = False) -> None:", "funcdef": "def"}, {"fullname": "aton.txt.edit.replace_between", "modulename": "aton.txt.edit", "qualname": "replace_between", "kind": "function", "doc": "additional
lines (int).\nNote that the matched line plus the additional lines\nwill be replaced, this is, additional lines +1.Replace with
\n\ntext
between keywordskey1
andkey2
infilepath
.It can be used to delete the text between the keys by setting
\n\ntext=''
.\nRegular expressions can be used by settingregex=True
.Key lines are also deleted if
\n\ndelete_keys=True
.Only the first matches of the keywords are used by default;\nyou can use the last ones with
\n\nfrom_end = True
.\n", "signature": "(\tfilepath: str,\tkey1: str,\tkey2: str,\ttext: str,\tdelete_keys: bool = False,\tfrom_end: bool = False,\tregex: bool = False) -> None:", "funcdef": "def"}, {"fullname": "aton.txt.edit.delete_under", "modulename": "aton.txt.edit", "qualname": "delete_under", "kind": "function", "doc": "lines...\nkey1\ntext\nkey2\nlines...\n
Deletes all the content under the line containing the
\n\nkey
infilepath
.The keyword can be at any position within the line.\nRegular expressions can be used by setting
\n\nregex=True
.By default the first
\n\nmatch
is used; it can be any positive integer (0 is treated as 1!),\nincluding negative integers to select a match starting from the end of the file.The content can be deleted after a specific number of lines after the match,\nchanging the value
\n", "signature": "(\tfilepath,\tkey: str,\tmatch: int = 1,\tskips: int = 0,\tregex: bool = False) -> None:", "funcdef": "def"}, {"fullname": "aton.txt.edit.correct_with_dict", "modulename": "aton.txt.edit", "qualname": "correct_with_dict", "kind": "function", "doc": "skips
, that skips the specified number of lines.\nNegative integers start deleting the content from the previous lines.Corrects the given text file
\n", "signature": "(filepath: str, correct: dict) -> None:", "funcdef": "def"}, {"fullname": "aton.txt.edit.from_template", "modulename": "aton.txt.edit", "qualname": "from_template", "kind": "function", "doc": "filepath
using acorrect
dictionary.Creates
\n", "signature": "(old: str, new: str, correct: dict = None, comment: str = None) -> None:", "funcdef": "def"}, {"fullname": "aton.txt.extract", "modulename": "aton.txt.extract", "kind": "module", "doc": "new
file fromold
, replacing values from acorrect
dict, inserting acomment
on top.Description
\n\nFunctions to extract data from raw text strings.
\n\nIndex
\n\n\n\n
number()
\nstring()
\ncolumn()
\ncoords()
\nelement()
Examples
\n\nTo extract a float value from a string,
\n\n\n\n\n\nfrom aton import txt\nline = 'energy = 500.0 Ry'\ntxt.extract.number(line, 'energy')\n# 500.0 (float output)\n
To extract a text value, after and before specific strings,
\n\n\n\n\n\nline = 'energy = 500.0 Ry were calculated'\ntxt.extract.string(line, 'energy', 'were')\n# '500.0 Ry' (String output)\n
To extract a value from a specific column,
\n\n\n\n\n\n# Name, Energy, Force, Error\nline = 'Testing 1.1 1.2 0.3'\nenergy = txt.extract.column(line, 1)\n# '1.1' (String output)\n
To extract coordinates,
\n\n\n\n\n\nline = ' He 0.10 0.20 0.30 '\ntxt.extract.coords(line)\n# [0.1, 0.2, 0.3] (List of floats)\n
To extract chemical elements,
\n\n\n\n\n\nline = ' He4 0.10 Ag 0.20 Pb 0.30 '\nfirst_element = txt.extract.element(line, 0)\n# 'He4'\nthird_element = txt.extract.element(line, 2)\n# 'Pb'\n
\n"}, {"fullname": "aton.txt.extract.number", "modulename": "aton.txt.extract", "qualname": "number", "kind": "function", "doc": "Extracts the float value of a given
\n", "signature": "(text: str, name: str = '') -> float:", "funcdef": "def"}, {"fullname": "aton.txt.extract.string", "modulename": "aton.txt.extract", "qualname": "string", "kind": "function", "doc": "name
variable from a rawtext
.Extracts the
\n\ntext
value of a givenname
variable from a raw string. Stops before an optionalstop
string.Removes leading and trailing commas by default, change this with
\n", "signature": "(text: str, name: str = '', stop: str = '', strip: bool = True) -> str:", "funcdef": "def"}, {"fullname": "aton.txt.extract.column", "modulename": "aton.txt.extract", "qualname": "column", "kind": "function", "doc": "strip = False
.Extracts the desired
\n", "signature": "(text: str, column: int = 0) -> str:", "funcdef": "def"}, {"fullname": "aton.txt.extract.coords", "modulename": "aton.txt.extract", "qualname": "coords", "kind": "function", "doc": "column
index of a givenstring
(0 by default).Returns a list with the float coordinates expressed in a given
\n", "signature": "(text: str) -> list:", "funcdef": "def"}, {"fullname": "aton.txt.extract.element", "modulename": "aton.txt.extract", "qualname": "element", "kind": "function", "doc": "text
string.Extract a chemical element from a raw
\n\ntext
string.If there are several elements, you can return a specific
\n", "signature": "(text: str, index: int = 0) -> str:", "funcdef": "def"}, {"fullname": "aton.txt.find", "modulename": "aton.txt.find", "kind": "module", "doc": "index
match (positive, 0 by default).\nAllows for standard elements (H, He, Na...) and isotopes (H2, He4...).Description
\n\nFunctions to search for specific content inside text files.
\n\nIndex
\n\nFind and return specific text strings from a file
\n\n
\nlines()
\nbetween()
Find the
\n\n(start, end)
position of specific strings in a file
\npos()
\npos_regex()
\nnext_pos()
\nnext_pos_regex()
\nline_pos()
\nbetween_pos()
Examples
\n\nTo find the lines containing the word 'key', plus an additional line below,
\n\n\n\n\n\nfrom aton import txt\n# with split = False\ntxt.find.lines(filepath=file, key='key', additional=1)\n # ['line with key 1\\nline below first match',\n # 'line with key 2\\nline below second match]\n# with split = True\ntxt.find.lines(filepath=file, key='key', additional=1, split=True)\n # ['line with key 1',\n # 'line below first match',\n # 'line with key 2',\n # 'line below second match]\n
To find the text between the lines containing the words 'first' and 'second',
\n\n\n\n\n\nfrom aton import txt\ntxt.find.between(filepath=file, key1='first', key2='second')\n # 'first line\\nadditional\\nlines\\nin\\nbetween\\nsecond line'\n
\n"}, {"fullname": "aton.txt.find.lines", "modulename": "aton.txt.find", "qualname": "lines", "kind": "function", "doc": "Returns a list with the matches containing the
\n\nkey
string infilepath
.If no match is found, returns an empty list.
\n\nTo use regular expressions in the search, set
\n\nregex=True
\n(deactivated by default).The value
\n\nmatches
specifies the max number of matches to be returned.\nDefaults to 0 to return all possible matches. Set it to 1 to return only one match,\nor to negative integers to start the search from the end of the file upwards.The value
\n", "signature": "(\tfilepath: str,\tkey: str,\tmatches: int = 0,\tadditional: int = 0,\tsplit: bool = False,\tregex: bool = False) -> list:", "funcdef": "def"}, {"fullname": "aton.txt.find.between", "modulename": "aton.txt.find", "qualname": "between", "kind": "function", "doc": "additional
specifies the number of additional lines\nbelow the target line that are also returned;\n2 to return the found line plus two additional lines below, etc.\nNegative values return the specified number of lines before the target line.\nThe original ordering from the file is preserved.\nDefaults toadditional=0
, only returning the target line.\nBy default, the additional lines are returned\nin the same list item as the match separated by a\\n
,\nunlesssplit=True
, in which case these additional lines\nare splitted and added as additional items in the list.Returns the content between the lines with
\n\nkey1
andkey2
infilepath
.Keywords can be at any position within the line.\nRegular expressions can be used by setting
\n\nregex=True
.Key lines are omited by default, but can be returned with
\n\ninclude_keys=True
.If there is more than one match, only the first one is considered by default;\nset
\n\nmatch
(int) to specify a particular match (1, 2... 0 is considered as 1!).\nUse negative numbers to start from the end of the file.If no match is found, returns an empty string.
\n\nIf
\n", "signature": "(\tfilepath: str,\tkey1: str,\tkey2: str,\tinclude_keys: bool = True,\tmatch: int = 1,\tregex: bool = False) -> str:", "funcdef": "def"}, {"fullname": "aton.txt.find.pos", "modulename": "aton.txt.find", "qualname": "pos", "kind": "function", "doc": "key2
is not found, it returns all the text fromkey1
to the end of the file.Returns a list with the positions of the
\n\nkey
infilepath
.If no match is found, returns an empty list.
\n\nThe
\n\nfilepath
can be a file or a memory mapped file.The value
\n\nmatches
specifies the max number of matches to return.\nDefaults to 0 to return all possible matches.\nSet it to 1 to return only one match,\n2 to get the first two matches, etc.\nYou can also set it to negative integers to start\nsearching from the end of the file upwards.This method is faster than
\n", "signature": "(filepath, key: str, matches: int = 0) -> list:", "funcdef": "def"}, {"fullname": "aton.txt.find.pos_regex", "modulename": "aton.txt.find", "qualname": "pos_regex", "kind": "function", "doc": "pos_regex()
,\nbut does not search for regular expressions.Returns a list of the positions of a
\n\nkey
in a givenfilepath
(actual file, not mmapped!).The value
\n\nmatches
specifies the max number of matches to return.\nDefaults to 0 to return all possible matches. Set it to 1 to return only one match,\nor to negative integers to start searching from the end of the file upwards.For big files, this method is slower than
\n", "signature": "(filepath, key: str, matches: int = 0) -> list:", "funcdef": "def"}, {"fullname": "aton.txt.find.next_pos", "modulename": "aton.txt.find", "qualname": "next_pos", "kind": "function", "doc": "pos()
, but it can search for regular expressions.Get the next position of the
\n\nkey
in thefilepath
(file or mmapped file), starting from an initialposition
tuple.The
\n\nmatch
number specifies the nonzero index of the next match to return (1, 2... 0 is considered as 1!).\nIt can be negative to search backwards from the initial position.\nThe last known positions will be returned if no more matches are found.This method is specific for normal strings.\nTo use regular expressions, check
\n", "signature": "(filepath, position: tuple, key: str, match: int = 1) -> tuple:", "funcdef": "def"}, {"fullname": "aton.txt.find.next_pos_regex", "modulename": "aton.txt.find", "qualname": "next_pos_regex", "kind": "function", "doc": "next_pos_regex()
.Get the next position of the
\n\nkey
in thefilepath
(actual file, not mmapped!), starting from an initialposition
tuple.The
\n\nmatch
number specifies the next match to return (1, 2... 0 is considered as 1!).\nIt can be negative to search backwards from the initial position.\nThis method is specific for regular expressions.For normal strings, check the faster
\n", "signature": "(filepath, position: tuple, key: str, match: int = 0) -> tuple:", "funcdef": "def"}, {"fullname": "aton.txt.find.line_pos", "modulename": "aton.txt.find", "qualname": "line_pos", "kind": "function", "doc": "next_pos()
method.Get the position of the full line containing the
\n\nposition
tuple infilepath
(whether file or memory mapped file).A specific line below can be returned with
\n", "signature": "(filepath, position: tuple, skips: int = 0) -> tuple:", "funcdef": "def"}, {"fullname": "aton.txt.find.between_pos", "modulename": "aton.txt.find", "qualname": "between_pos", "kind": "function", "doc": "skips
being a natural int,\nor previous lines with negative values.Returns the positions of the content between the lines containing
\n\nkey1
andkey2
in thefilepath
.Keywords can be at any position within the line.\nRegular expressions can be used by setting
\n\nregex=True
.Key lines are omited by default, but can be returned with
\n\ninclude_keys=True
.If there is more than one match, only the first one is considered by default;\nset
\n\nmatch
number to specify a particular match (1, 2... 0 is considered as 1!).\nUse negative numbers to start from the end of the file.If
\n", "signature": "(\tfilepath,\tkey1: str,\tkey2: str,\tinclude_keys: bool = True,\tmatch: int = 1,\tregex: bool = False) -> tuple:", "funcdef": "def"}]; + /** pdoc search index */const docs = [{"fullname": "aton", "modulename": "aton", "kind": "module", "doc": "key2
is not found, it returns the text position fromkey1
to the end of the file.\n\n
Welcome to ATON
\n\nThe Ab-iniTiO & Neutron research toolbox,\nor ATON,\nprovides powerful and comprehensive tools\nfor cutting-edge materials research,\nfocused on (but not limited to) neutron science.
\n\nJust like its ancient Egyptian deity counterpart,\nthis all-in-one Python package contains a range of tools from spectra normalisation to deuteration estimations.\nA set of physico-chemical constants and definitions is also included.\nATON also allows you to easily create, edit and analyse all kinds of text files,\nwith a special focus on ab-initio calculation files.\nIn particular, it contains interfaces for Quantum ESPRESSO,\nPhonopy and CASTEP.
\n\nThe source code is available on GitHub.
\n\n
\n\nInstallation
\n\nAs always, it is recommended to install your packages in a virtual environment:
\n\n\n\n\n\npython3 -m venv .venv\nsource .venv/bin/activate\n
With pip
\n\nThe fastest way to install ATON is through pip:
\n\n\n\n\n\npip install aton\n
To upgrade to a newer version,
\n\n\n\n\n\npip install aton -U\n
From source
\n\nOptionally, you can install ATON from the GitHub repository.
\n\nFirst install the dependencies:
\n\n\n\n\n\npip install pandas numpy scipy matplotlib\n
Then clone the repository or download the latest stable release as a ZIP, unzip it, and run inside the
\n\nAton/
directory:\n\n\n\npip install .\n
\n\nDocumentation
\n\nThe full ATON documentation is available online.
\n\n
\nAn offline version of the documentation is found atdocs/aton.html
.
\nCode examples are included in theATON/examples/
folder.Interfaces for ab-initio codes
\n\nThe interface module contains interfaces for several ab-initio codes.\nThese are powered by the aton.txt module and can be easily extended.
\n\n\n\n
aton.interface
\n\n
\n\n\n \n\n\n\n \n \n \n\n aton.interface.qe
Interface for Quantum ESPRESSO's pw.x module \n\n \n\n aton.interface.phonopy
Interface for Phonopy calculations \n\n \n\n aton.interface.castep
Interface for CASTEP calculations \n\n \n\n\n aton.interface.slurm
Batch jobs via Slurm \nPhysico-chemical constants
\n\nThe phys module contains physico-chemical definitions.\nValues are accessed directly as
\n\nphys.value
orphys.function()
.\n\n
aton.phys
\n\n
\n\n\n \n\n\n\n \n \n \n\n aton.phys.units
Physical constants and conversion factors \n\n \n\n aton.phys.atoms
Megadictionary with data for all chemical elements \n\n \n\n\n aton.phys.functions
Functions to sort and analyse element data, and to update the atoms dictionary \nQuantum rotations
\n\nThe QRotor module is used to study the energy levels of quantum rotations,\nsuch as methyl and amine groups.
\n\n\n\n
aton.qrotor
\n\n
\n\n\n \n\n\n\n \n \n \n\n aton.qrotor.classes
Definition of the \nQSys
andQExp
classes\n \n\n aton.qrotor.constants
Bond lengths and inertias \n\n \n\n aton.qrotor.rotate
Rotate specific atoms from structural files \n\n \n\n aton.qrotor.potential
Potential definitions and loading functions \n\n \n\n aton.qrotor.solve
Solve rotation eigenvalues and eigenvectors \n\n \n\n\n aton.qrotor.plot
Plotting functions \nSpectra analysis
\n\nThe spx module includes tools for spectral analysis from\nInelastic Neutron Scattering, Raman, Infrared, etc.
\n\n\n\n
aton.spx
\n\n
\n\n\n \n\n\n\n \n \n \n\n aton.spx.classes
Class definitions for the spectra module \n\n \n\n aton.spx.fit
Spectra fitting functions \n\n \n\n aton.spx.normalize
Spectra normalization \n\n \n\n aton.spx.plot
Plotting \n\n \n\n aton.spx.deuterium
Deuteration estimations via INS \n\n \n\n\n aton.spx.samples
Sample materials for testing \nGeneral text edition
\n\nThe text module handles text files.\nIt powers more complex subpackages,\nsuch as aton.interface.
\n\n\n\n
aton.txt
\n\n
\n\n\n \n\n\n\n \n \n \n\n aton.txt.find
Search for specific content in text files \n\n \n\n aton.txt.edit
Manipulate text files \n\n \n\n\n aton.txt.extract
Extract data from raw text strings \nSystem tools
\n\nThe st module contains System Tools for common system tasks across subpackages.
\n\n\n\n
aton.st
\n\n
\n\n\n \n\n\n\n \n \n \n\n aton.st.file
File manipulation \n\n \n\n aton.st.call
Run bash scripts and related \n\n \n\n\n aton.st.alias
Useful dictionaries for user input correction \n
\n\nContributing
\n\nIf you are interested in opening an issue or a pull request, please feel free to do so on GitHub.
\n\n
\nFor major changes, please get in touch first to discuss the details.Code style
\n\nPlease try to follow some general guidelines:
\n\n\n
\n\n- Use a code style consistent with the rest of the project.
\n- Include docstrings to document new additions.
\n- Include automated tests for new features or modifications, see automated testing.
\n- Arrange function arguments by order of relevance. Most implemented functions follow something similar to
\nfunction(file, key/s, value/s, optional)
.Automated testing
\n\nIf you are modifying the source code, you should run the automated tests of the
\n\nATON/tests/
folder to check that everything works as intended.\nTo do so, first install PyTest in your environment,\n\n\n\npip install pytest\n
And then run PyTest inside the
\n\nATON/
directory,\n\n\n\npytest -vv\n
Compiling the documentation
\n\nThe documentation can be compiled automatically to
\n\ndocs/aton.html
with Pdoc and ATON itself, by running:\n\n\n\npython3 makedocs.py\n
This runs Pdoc, updating links and pictures, and using the custom theme CSS template from the
\n\ncss/
folder.
\n\nCitation
\n\nATON development started for the following paper, please cite if you use ATON in your work:
\n\n
\nCryst. Growth Des. 2024, 24, 391\u2212404License
\n\nCopyright (C) 2025 Pablo Gila-Herranz
\n"}, {"fullname": "aton.interface", "modulename": "aton.interface", "kind": "module", "doc": "
\nThis program is free software: you can redistribute it and/or modify\nit under the terms of the GNU Affero General Public License as published\nby the Free Software Foundation, either version 3 of the License, or\n(at your option) any later version.
\nThis program is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
\nSee the attached GNU Affero General Public License for more details.Ab-initio interfaces
\n\nThis module contains interfaces for several ab-initio calculation softwares.\nThese interfaces can be easily expanded with the
\n\naton.txt
module.Index
\n\n\n\n
\n\n\n \n\n\n\n \n \n \n\n aton.interface.qe
Interface for Quantum ESPRESSO's pw.x module \n\n \n\n aton.interface.phonopy
Interface for Phonopy calculations \n\n \n\n aton.interface.castep
Interface for CASTEP calculations \n\n \n\n\n aton.interface.slurm
Batch jobs via Slurm \nExamples
\n\nQuantum ESPRESSO
\n\nTo read the output from a Quantum ESPRESSO pw.x calculation,
\n\n\n\n\n\nfrom aton.interface import qe\n# Read to a dictionary\ncalculation = qe.read_out('relax.out')\ncalculation.keys() # See the available values\n# Final energy from the calculation\nenergy = calculation['Energy']\n
To modify values from an input file,
\n\n\n\n\n\nfrom aton.interface import qe\n# Add a hydrogen atom to a specific position\nqe.add_atom('H 0.10 0.20 0.30')\n# Set the input ecutwfc value\nqe.set_value('relax.in', 'ecutwfc', 60.0)\n
Check the full
\n\naton.interface.qe
API reference for more details.Phonopy
\n\nTo perform a phonon calculation from a relaxed structure via Quantum ESPRESSO,
\n\n\n\n\n\nfrom aton import interface\n# Create the supercell inputs\ninterface.phonopy.make_supercells(dimension='2 2 2')\n# Sbatch to a cluster\ninterface.slurm.sbatch('supercell-', 'template.slurm')\n
Check the full
\n\naton.interface.phonopy
API reference for more details.CASTEP
\n\nTo read output values from a CASTEP calculation,
\n\n\n\n\n\nfrom aton.interface import castep\n# Read the output\noutput = castep.read_castep('calculation.castep')\n# Get the final energy\nenergy = output['Energy']\n
Check the full
\n"}, {"fullname": "aton.interface.castep", "modulename": "aton.interface.castep", "kind": "module", "doc": "aton.interface.castep
API reference for more details.Description
\n\nFunctions to work with CASTEP calculation files.
\n\nIndex
\n\n\n\n
\n\n\n \n\n\n\n \n \n \n\n\n read_castep()
Output reading \n
\n"}, {"fullname": "aton.interface.castep.read_castep", "modulename": "aton.interface.castep", "qualname": "read_castep", "kind": "function", "doc": "Reads a CASTEP output file, specified in
\n\nfilename
.\nReturns a dictionary with the following keys:\n'Enthalpy'
(LBFGS: Final Enthalpy, in kJ/mol),\n'Energy'
(Total energy corrected for finite basis set, in eV),\n'Space group'
,'Volume'
(Angstrom^3),'Density'
(amu/Angstrom^3),'Density_g'
(g/cm^3),\n'A'
,'B'
,'C'
(Angstroms),'Alpha'
,'Beta'
,'Gamma'
(Degrees).Note that these output keys start with a Capital letter.
\n", "signature": "(filename) -> dict:", "funcdef": "def"}, {"fullname": "aton.interface.phonopy", "modulename": "aton.interface.phonopy", "kind": "module", "doc": "Description
\n\nFunctions to work with Phonopy calculations,\nalong with Quantum ESPRESSO.
\n\nIndex
\n\n\n\n
\n\n\n \n\n\n\n \n \n \n\n\n make_supercells()
Build supercell SCF inputs for phonon calculations \nExamples
\n\nTo create the supercells and run the phonon calculations\nfrom a folder with
\n\nrelax.in
andrelax.out
files,\nusing atemplate.slurm
file,\n\n\n\nfrom aton import interface\ninterface.phonopy.make_supercells()\ninterface.slurm.sbatch('supercell-', 'scf.slurm')\n
\n"}, {"fullname": "aton.interface.phonopy.make_supercells", "modulename": "aton.interface.phonopy", "qualname": "make_supercells", "kind": "function", "doc": "Creates the supercell inputs of a given
\n\ndimension
('2 2 2' by default),\nfrom therelax_in
andrelax_out
files in thefolder
\n('relax.in', 'relax.out' and CWD by default, respectively),\nneeded for the Phonopy calculations with Quantum ESPRESSO.If
\n", "signature": "(\tdimension: str = '2 2 2',\trelax_in: str = 'relax.in',\trelax_out: str = 'relax.out',\tfolder: str = None,\tslurm_template: str = None) -> None:", "funcdef": "def"}, {"fullname": "aton.interface.qe", "modulename": "aton.interface.qe", "kind": "module", "doc": "slurm_template
is present,\nit checks it withaton.interface.slurm.check_template()
.Description
\n\nTools to work with the pw.x module from Quantum ESPRESSO.
\n\nIndex
\n\nInput and output reading
\n\n
\nread_in()
\nread_out()
\nread_dir()
\nread_dirs()
Input file manipulation
\n\n
\nset_value()
\nadd_atom()
\nscf_from_relax()
Data extraction
\n\n
\nget_atom()
\ncount_elements()
\nnormalize_card()
\nto_cartesian()
\nfrom_cartesian()
Dicts with input file description
\n\n
\npw_namelists
\npw_cards
\n"}, {"fullname": "aton.interface.qe.read_in", "modulename": "aton.interface.qe", "qualname": "read_in", "kind": "function", "doc": "Reads a Quantum ESPRESSO input
\n\nfilepath
and returns the values as a dict.Dict keys are named after the corresponding variable.\nCARDS are returned as lists, and contain the\ntitle card + parameters in the first item.
\n", "signature": "(filepath) -> dict:", "funcdef": "def"}, {"fullname": "aton.interface.qe.read_out", "modulename": "aton.interface.qe", "qualname": "read_out", "kind": "function", "doc": "Reads a Quantum ESPRESSO output
\n\nfilepath
, returns a dict with the output keys.The output keys are:\n
\n\n'Energy'
(Ry),'Total force'
(float),'Total SCF correction'
(float),\n'Runtime'
(str),'JOB DONE'
(bool),'BFGS converged'
(bool),'BFGS failed'
(bool),\n'Maxiter reached'
(bool),'Error'
(str),'Success'
(bool),'CELL_PARAMETERS_out'
(list of str),'ATOMIC_POSITIONS_out'
(list of str),'Alat'
(bohr),'Volume'
(a.u.^3),'Density'
(g/cm^3).Note that these output keys start with a Capital letter.
\n", "signature": "(filepath) -> dict:", "funcdef": "def"}, {"fullname": "aton.interface.qe.read_dir", "modulename": "aton.interface.qe", "qualname": "read_dir", "kind": "function", "doc": "Takes a
\n\nfolder
from a QE calculation, returns a dict with input and output values.Input and output files are determined automatically,\nbut must be specified with
\n", "signature": "(folder, in_str: str = '.in', out_str: str = '.out') -> dict:", "funcdef": "def"}, {"fullname": "aton.interface.qe.read_dirs", "modulename": "aton.interface.qe", "qualname": "read_dirs", "kind": "function", "doc": "in_str
andout_str
\nif more than one file ends with.in
or.out
.Reads recursively QE calculations from all the subfolders inside the given
\n\ndirectory
.Results are saved to CSV files inside the current directory.\nInput and output files are determined automatically, but must be specified with\n
\n\nin_str
andout_str
if more than one file ends with.in
or.out
.To properly group the calculations per type, saving separated CSVs for each calculation type,\nyou can modify
\n\ncalc_splitter
('_' by default),calc_type_index
(0) andcalc_id_index
(1).\nWith these default values, a subfolder named './CalculationType_CalculationID_AdditionalText/'\nwill be interpreted as follows:\n
\n\n- Calculation type: 'CalculationType' (The output CSV will be named after this)
\n- CalculationID: 'CalculationID' (Stored in the 'ID' column of the resulting dataframe)
\nIf everything fails, the subfolder name will be used for the CSV file.
\n", "signature": "(\tdirectory,\tin_str: str = '.in',\tout_str: str = '.out',\tcalc_splitter='_',\tcalc_type_index=0,\tcalc_id_index=1) -> None:", "funcdef": "def"}, {"fullname": "aton.interface.qe.set_value", "modulename": "aton.interface.qe", "qualname": "set_value", "kind": "function", "doc": "Replace the
\n\nvalue
of akey
parameter in an inputfilepath
.Delete parameters with
\n\nvalue=''
.\nRemember to include the single quotes'
on values that use them.Updating 'ATOMIC_POSITIONS' updates 'nat' automatically,\nand updating 'ATOMIC_SPECIES' updates 'ntyp'.
\n\nOptionally change indentation with
\n", "signature": "(filepath, key: str, value, indent: str = ' ') -> None:", "funcdef": "def"}, {"fullname": "aton.interface.qe.add_atom", "modulename": "aton.interface.qe", "qualname": "add_atom", "kind": "function", "doc": "indent
, 2 spaces by default.Adds an atom in a given
\n\nfilepath
at a specifiedposition
.Position must be a string or a list, as follows:\n
\n\n\"specie:str float float float\"
or[specie:str, float, float, float]
.This method updates automatically other related values,\nsuch as 'ntyp' when updating ATOMIC_SPECIES, etc.
\n\nOptionally change indentation with
\n", "signature": "(filepath, position, indent=' ') -> None:", "funcdef": "def"}, {"fullname": "aton.interface.qe.get_atom", "modulename": "aton.interface.qe", "qualname": "get_atom", "kind": "function", "doc": "indent
, 2 spaces by default.Takes the approximate
\n\nposition
of an atom, and returns the full line from thefilepath
.It compares the atomic positions rounded up to the specified
\n", "signature": "(\tfilepath: str,\tposition: list,\tprecision: int = 3,\treturn_anyway: bool = False) -> str:", "funcdef": "def"}, {"fullname": "aton.interface.qe.normalize_card", "modulename": "aton.interface.qe", "qualname": "normalize_card", "kind": "function", "doc": "precision
decimals.\nIfreturn_anyway = True
, ignores errors and returns an empty string.Take a matched card, and return it in a normalised format.
\n\nOptionally change indentation with
\n", "signature": "(card: list, indent='') -> list:", "funcdef": "def"}, {"fullname": "aton.interface.qe.count_elements", "modulename": "aton.interface.qe", "qualname": "count_elements", "kind": "function", "doc": "indent
, 0 spaces by default.Takes ATOMIC_POSITIONS, returns a dict as
\n", "signature": "(atomic_positions) -> dict:", "funcdef": "def"}, {"fullname": "aton.interface.qe.scf_from_relax", "modulename": "aton.interface.qe", "qualname": "scf_from_relax", "kind": "function", "doc": "{element : number of atoms}
Create a Quantum ESPRESSO
\n\nscf.in
file from a previous relax calculation.If no
\n", "signature": "(\tfolder: str = None,\trelax_in: str = 'relax.in',\trelax_out: str = 'relax.out') -> None:", "funcdef": "def"}, {"fullname": "aton.interface.qe.to_cartesian", "modulename": "aton.interface.qe", "qualname": "to_cartesian", "kind": "function", "doc": "folder
is provided, the current working directory is used.\nTherelax_in
andrelax_out
files by default arerelax.in
andrelax.out
,\nupdate the names if necessary.Converts a given
\n\ncordinates
from crystal lattice vectors to cartesian.Only for
\n", "signature": "(filepath, coordinates) -> str:", "funcdef": "def"}, {"fullname": "aton.interface.qe.from_cartesian", "modulename": "aton.interface.qe", "qualname": "from_cartesian", "kind": "function", "doc": "ibrav=0
. Uses the cell parameters.\nNote that the result is not multiplied byA
norcelldm(1)
.Converts a given
\n\ncordinates
from cartesian to the base of lattice vectors.Only for
\n", "signature": "(filepath, coordinates: list) -> str:", "funcdef": "def"}, {"fullname": "aton.interface.qe.pw_namelists", "modulename": "aton.interface.qe", "qualname": "pw_namelists", "kind": "variable", "doc": "ibrav=0
. Uses the cell parameters.\nNote that the result is not divided byA
norcelldm(1)
.Dictionary with all possible NAMELISTs as keys, and the corresponding variables as values.
\n", "default_value": "{'&CONTROL': ['calculation', 'title', 'verbosity', 'restart_mode', 'wf_collect', 'nstep', 'iprint', 'tstress', 'tprnfor', 'dt', 'outdir', 'wfcdir', 'prefix', 'lkpoint_dir', 'max_seconds', 'etot_conv_thr', 'forc_conv_thr', 'disk_io', 'pseudo_dir', 'tefield', 'dipfield', 'lelfield', 'nberrycyc', 'lorbm', 'lberry', 'gdir', 'nppstr', 'gate', 'twochem', 'lfcp', 'trism'], '&SYSTEM': ['ibrav', 'celldm(1)', 'celldm(2)', 'celldm(3)', 'celldm(4)', 'celldm(5)', 'celldm(6)', 'A', 'B', 'C', 'cosAB', 'cosAC', 'cosBC', 'nat', 'ntyp', 'nbnd', 'nbnd_cond', 'tot_charge', 'starting_charge', 'tot_magnetization', 'starting_magnetization', 'ecutwfc', 'ecutrho', 'ecutfock', 'nr1', 'nr2', 'nr3', 'nr1s', 'nr2s', 'nr3s', 'nosym', 'nosym_evc', 'noinv', 'no_t_rev', 'force_symmorphic', 'use_all_frac', 'occupations', 'one_atom_occupations', 'starting_spin_angle', 'degauss_cond', 'nelec_cond', 'degauss', 'smearing', 'nspin', 'sic_gamma', 'pol_type', 'sic_energy', 'sci_vb', 'sci_cb', 'noncolin', 'ecfixed', 'qcutz', 'q2sigma', 'input_dft', 'ace', 'exx_fraction', 'screening_parameter', 'exxdiv_treatment', 'x_gamma_extrapolation', 'ecutvcutnqx1', 'nqx2', 'nqx3', 'localization_thr', 'Hubbard_occ', 'Hubbard_alpha', 'Hubbard_beta', 'starting_ns_eigenvalue', 'dmft', 'dmft_prefix', 'ensemble_energies', 'edir', 'emaxpos', 'eopreg', 'eamp', 'angle1', 'angle2', 'lforcet', 'constrained_magnetization', 'fixed_magnetization', 'lambda', 'report', 'lspinorb', 'assume_isolated', 'esm_bc', 'esm_w', 'esm_efield', 'esm_nfit', 'lgcscf', 'gcscf_mu', 'gcscf_conv_thr', 'gcscf_beta', 'vdw_corr', 'london', 'london_s6', 'london_c6', 'london_rvdw', 'london_rcut', 'dftd3_version', 'dftd3_threebody', 'ts_vdw_econv_thr', 'ts_vdw_isolated', 'xdm', 'xdm_a1', 'xdm_a2', 'space_group', 'uniqueb', 'origin_choice', 'rhombohedral', 'zgate', 'relaxz', 'block', 'block_1', 'block_2', 'block_height', 'nextffield'], '&ELECTRONS': ['electron_maxstep', 'exx_maxstep', 'scf_must_converge', 'conv_thr', 'adaptive_thr', 'conv_thr_init', 'conv_thr_multi', 'mixing_mode', 'mixing_beta', 'mixing_ndim', 'mixing_fixed_ns', 'diagonalization', 'diago_thr_init', 'diago_cg_maxiter', 'diago_ppcg_maxiter', 'diago_david_ndim', 'diago_rmm_ndim', 'diago_rmm_conv', 'diago_gs_nblock', 'diago_full_acc', 'efield', 'efield_cart', 'efield_phase', 'startingpot', 'startingwfc', 'tqr', 'real_space'], '&IONS': ['ion_positions', 'ion_velocities', 'ion_dynamics', 'pot_extrapolation', 'wfc_extrapolation', 'remove_rigid_rot', 'ion_temperature', 'tempw', 'tolp', 'delta_t', 'nraise', 'refold_pos', 'upscale', 'bfgs_ndim', 'trust_radius_max', 'trust_radius_min', 'trust_radius_ini', 'w_1', 'w_2', 'fire_alpha_init', 'fire_falpha', 'fire_nmin', 'fire_f_inc', 'fire_f_dec', 'fire_dtmax'], '&CELL': ['cell_dynamics', 'press', 'wmass', 'cell_factor', 'press_conv_thrcell_dofree'], '&FCP': ['fcp_mu', 'fcp_dynamics', 'fcp_conv_thr', 'fcp_ndiis', 'fcp_mass', 'fcp_velocity', 'fcp_temperature', 'fcp_tempw', 'fcp_tolp ', 'fcp_delta_t', 'fcp_nraise', 'freeze_all_atoms'], '&RISM': ['nsolv', 'closure', 'tempv', 'ecutsolv', 'solute_lj', 'solute_epsilon', 'solute_sigma', 'starting1d', 'starting3d', 'smear1d', 'smear3d', 'rism1d_maxstep', 'rism3d_maxstep', 'rism1d_conv_thr', 'rism3d_conv_thr', 'mdiis1d_size', 'mdiis3d_size', 'mdiis1d_step', 'mdiis3d_step', 'rism1d_bond_width', 'rism1d_dielectric', 'rism1d_molesize', 'rism1d_nproc', 'rism3d_conv_level', 'rism3d_planar_average', 'laue_nfit', 'laue_expand_right', 'laue_expand_left', 'laue_starting_right', 'laue_starting_left', 'laue_buffer_right', 'laue_buffer_left', 'laue_both_hands', 'laue_wall', 'laue_wall_z', 'laue_wall_rho', 'laue_wall_epsilon', 'laue_wall_sigma', 'laue_wall_lj6']}"}, {"fullname": "aton.interface.qe.pw_cards", "modulename": "aton.interface.qe", "qualname": "pw_cards", "kind": "variable", "doc": "Dictionary with every possible CARDs as keys, and the corresponding variables as values.
\n", "default_value": "{'ATOMIC_SPECIES': ['X', 'Mass_X', 'PseudoPot_X'], 'ATOMIC_POSITIONS': ['X', 'x', 'y', 'z', 'if_pos(1)', 'if_pos(2)', 'if_pos(3)'], 'K_POINTS': ['nks', 'xk_x', 'xk_y', 'xk_z', 'wk', 'nk1', 'nk2', 'nk3', 'sk1', 'sk2', 'sk3'], 'ADDITIONAL_K_POINTS': ['nks_add', 'k_x', 'k_y', 'k_z', 'wk_'], 'CELL_PARAMETERS': ['v1', 'v2', 'v3'], 'CONSTRAINTS': ['nconstr', 'constr_tol', 'constr_type', 'constr(1)', 'constr(2)', 'constr(3)', 'constr(4)', 'constr_target'], 'OCCUPATIONS': ['f_inp1', 'f_inp2'], 'ATOMIC_VELOCITIES': ['V', 'vx', 'vy', 'vz'], 'ATOMIC_FORCES': ['X', 'fx', 'fy', 'fz'], 'SOLVENTS': ['X', 'Density', 'Molecule', 'X', 'Density_Left', 'Density_Right', 'Molecule'], 'HUBBARD': ['label(1)-manifold(1)', 'u_val(1)', 'label(1)-manifold(1)', 'j0_val(1)', 'paramType(1)', 'label(1)-manifold(1)', 'paramValue(1)', 'label(I)-manifold(I)', 'u_val(I)', 'label(I)-manifold(I)', 'j0_val(I)', 'label(I)-manifold(I)', 'label(J)-manifold(J)', 'I', 'J', 'v_val(I,J)'], 'CELL_PARAMETERS_out': ['v1', 'v2', 'v3'], 'ATOMIC_POSITIONS_out': ['X', 'x', 'y', 'z', 'if_pos(1)', 'if_pos(2)', 'if_pos(3)']}"}, {"fullname": "aton.interface.slurm", "modulename": "aton.interface.slurm", "kind": "module", "doc": "Description
\n\nFunctions to handle Slurm calls, to run calculations in clusters.
\n\nIndex
\n\n\n\n
\n\n\n \n\n\n\n \n \n \n\n sbatch()
Sbatch all calculations \n\n \n\n squeue()
Get a Pandas DataFrame with info about the submitted calculations \n\n \n\n scancel()
Scancel all calculations, or applying some filters \n\n \n\n scancel_here()
Scancel all calculations running from a specific folder \n\n \n\n\n check_template()
Checks that the slurm template is OK, and provides an example if not \n
\n"}, {"fullname": "aton.interface.slurm.sbatch", "modulename": "aton.interface.slurm", "qualname": "sbatch", "kind": "function", "doc": "Sbatch all the calculations at once.
\n\nCalculation names should follow
\n\nprefix_ID.ext
,\nwithprefix
as the common name across calculations,\nfollowed by the calculation ID, used as JOB_NAME.\nThe extensions fromin_ext
andout_ext
('.in' and '.out' by default)\nwill be used for the INPUT_FILE and OUTPUT_FILE of the slurm template.The slurm template,
\n\ntemplate.slurm
by default,\nmust contain the keywords JOB_ID, INPUT_FILE and OUTPUT_FILE:\n\n#SBATCH --job-name=JOB_NAME\nmpirun pw.x -inp INPUT_FILE > OUTPUT_FILE\n
Runs from the specified
\n\nfolder
, current working directory if empty.If more control is required, a custom list of
\n\nfiles
can be specified for sbatching.If
\n", "signature": "(\tprefix: str = '',\ttemplate: str = 'template.slurm',\tin_ext: str = '.in',\tout_ext: str = '.out',\tfolder=None,\tfiles: list = [],\ttesting: bool = False) -> None:", "funcdef": "def"}, {"fullname": "aton.interface.slurm.squeue", "modulename": "aton.interface.slurm", "qualname": "squeue", "kind": "function", "doc": "\n", "signature": "(user) -> pandas.core.frame.DataFrame:", "funcdef": "def"}, {"fullname": "aton.interface.slurm.scancel", "modulename": "aton.interface.slurm", "qualname": "scancel", "kind": "function", "doc": "testing = True
it skips the final sbatching,\njust printing the commands on the screen.Cancel all
\n\nuser
jobs.If a particular
\n\nstatus
string is provided,\nonly the calculations with said status will be cancelled.If a particular
\n\ntext
string is provided,\nonly the calculations containing said text in the name will be deleted.If
\n\ntesting = True
, it shows the calculations that would be deleted.if the slurm squeue titles are different in your cluster,\nyou can specify them with
\n", "signature": "(\tuser: str,\tstatus: str = '',\ttext: str = '',\ttesting: bool = False,\tkey_jobid: str = 'JOBID',\tkey_name: str = 'NAME',\tkey_status: str = 'ST') -> None:", "funcdef": "def"}, {"fullname": "aton.interface.slurm.scancel_here", "modulename": "aton.interface.slurm", "qualname": "scancel_here", "kind": "function", "doc": "key_jobid
,key_status
andkey_name
.Cancel all running
\n\njobs
in a givenfolder
.If no job is provided, all jobs detected in the current folder will be cancelled.\nThe jobs will be detected from the
\n", "signature": "(\tjobs=None,\tfolder=None,\tprefix: str = 'slurm-',\tsufix: str = '.out') -> None:", "funcdef": "def"}, {"fullname": "aton.interface.slurm.check_template", "modulename": "aton.interface.slurm", "qualname": "check_template", "kind": "function", "doc": "<prefix>JOBID<sufix>
files,slurm-JOBID.out
by default.Check the slurm
\n\ntemplate
insidefolder
.The current working directory is used if
\n", "signature": "(template: str = 'template.slurm', folder=None) -> str:", "funcdef": "def"}, {"fullname": "aton.phys", "modulename": "aton.phys", "kind": "module", "doc": "folder
is not provided.\nIf the file does not exist or is invalid, creates atemplate_EXAMPLE.slurm
file for reference.Physico-chemical constants
\n\nThis subpackage contains universal physical constants,\nas well as chemical data from all known elements.\nIt also includes functions to manage this data.
\n\nIndex
\n\n\n\n
\n\n\n \n\n\n\n \n \n \n\n aton.phys.units
Universal constants and conversion factors \n\n \n\n aton.phys.atoms
Data from all chemical elements \n\n \n\n\n aton.phys.functions
Functions to manage data from the \naton.phys.atoms
dictExamples
\n\nAll values and functions from phys submodules can be\nloaded directly as
\n\nphys.value
orphys.function()
,\nas in the example below.\n\n\n\nfrom aton import phys\nphys.eV_to_J # 1.602176634e-19\nphys.atoms['H'].isotope[2].mass # 2.0141017779\nphys.split_isotope('He4') # ('He', 4)\n
See the API reference of the specific modules for more information.
\n\nReferences
\n\n\n\n
aton.phys.units
Constant values come from the 2022 CODATA Internationally\nrecommended 2022 values of the Fundamental Physical Constants.
\n\n\n\n
aton.phys.atoms
Atomic
\n\nmass
are in atomic mass units (amu), and come from:\nPure Appl. Chem., Vol. 78, No. 11, pp. 2051-2066, 2006.\nThe following masses are obtained from Wikipedia:\nAc: 227, Np: 237, Pm: 145, Tc: 98.Isotope
\n\nmass
,mass_number
andabundance
come from:\nJ. R. de Laeter, J. K. B\u00f6hlke, P. De Bi\u00e8vre, H. Hidaka, H. S. Peiser, K. J. R. Rosman\nand P. D. P. Taylor (2003). \"Atomic weights of the elements. Review 2000 (IUPAC Technical Report)\".Total bound scattering
\n"}, {"fullname": "aton.phys.atoms", "modulename": "aton.phys.atoms", "kind": "module", "doc": "cross_section
$\\sigma_s$ are in barns (1 b = 100 fm$^2$).\nFrom Felix Fernandez-Alonso, \"Neutron Scattering Fundamentals\", 2013.Description
\n\nThis module contains the
\n\natoms
megadictionary,\nwhich contains the properties of all elements.\nIt is managed and updated automatically withaton.phys.functions
.The
\n\natoms
dictionary can be loaded directly asaton.phys.atoms
.Index
\n\n\n\n
\n\n\n \n\n\n\n \n \n \n\n Element
Used as values in the \natoms
dict, stores element properties\n \n\n Isotope
Used as values in \nElement.isotope
, contains isotope properties\n \n\n\n atoms
The dict with data from all elements \nExamples
\n\n\n\n\n\nfrom aton import phys\naluminium_cross_section = phys.atoms['Al'].cross_section # 1.503\nHe4_mass = phys.atoms['H'].isotope[4].mass # 4.0026032497\n
\n"}, {"fullname": "aton.phys.atoms.Element", "modulename": "aton.phys.atoms", "qualname": "Element", "kind": "class", "doc": "Used in the
\n"}, {"fullname": "aton.phys.atoms.Element.__init__", "modulename": "aton.phys.atoms", "qualname": "Element.__init__", "kind": "function", "doc": "\n", "signature": "(\tZ: int = None,\tsymbol: str = None,\tname: str = None,\tmass: float = None,\tcross_section: float = None,\tisotope: dict = None)"}, {"fullname": "aton.phys.atoms.Element.Z", "modulename": "aton.phys.atoms", "qualname": "Element.Z", "kind": "variable", "doc": "aton.atoms
megadictionary to store element data.Atomic number (Z). Corresponds to the number of protons / electrons.
\n", "annotation": ": int"}, {"fullname": "aton.phys.atoms.Element.symbol", "modulename": "aton.phys.atoms", "qualname": "Element.symbol", "kind": "variable", "doc": "Standard symbol of the element.
\n", "annotation": ": str"}, {"fullname": "aton.phys.atoms.Element.name", "modulename": "aton.phys.atoms", "qualname": "Element.name", "kind": "variable", "doc": "Full name.
\n", "annotation": ": str"}, {"fullname": "aton.phys.atoms.Element.mass", "modulename": "aton.phys.atoms", "qualname": "Element.mass", "kind": "variable", "doc": "Atomic mass, in atomic mass units (amu).
\n", "annotation": ": float"}, {"fullname": "aton.phys.atoms.Element.cross_section", "modulename": "aton.phys.atoms", "qualname": "Element.cross_section", "kind": "variable", "doc": "Total bound scattering cross section.
\n", "annotation": ": float"}, {"fullname": "aton.phys.atoms.Element.isotope", "modulename": "aton.phys.atoms", "qualname": "Element.isotope", "kind": "variable", "doc": "Dictionary containing the different
\n", "annotation": ": dict"}, {"fullname": "aton.phys.atoms.Isotope", "modulename": "aton.phys.atoms", "qualname": "Isotope", "kind": "class", "doc": "Isotope
of the element.\nThe keys are the mass number (A).Used in the
\n"}, {"fullname": "aton.phys.atoms.Isotope.__init__", "modulename": "aton.phys.atoms", "qualname": "Isotope.__init__", "kind": "function", "doc": "\n", "signature": "(\tA: int = None,\tmass: float = None,\tabundance: float = None,\tcross_section: float = None)"}, {"fullname": "aton.phys.atoms.Isotope.A", "modulename": "aton.phys.atoms", "qualname": "Isotope.A", "kind": "variable", "doc": "aton.atoms
megadictionary to store isotope data.Mass number (A) of the isotope.\nCorresponds to the total number of protons + neutrons in the core.
\n", "annotation": ": int"}, {"fullname": "aton.phys.atoms.Isotope.mass", "modulename": "aton.phys.atoms", "qualname": "Isotope.mass", "kind": "variable", "doc": "Atomic mass of the isotope, in atomic mass units (amu).
\n", "annotation": ": float"}, {"fullname": "aton.phys.atoms.Isotope.abundance", "modulename": "aton.phys.atoms", "qualname": "Isotope.abundance", "kind": "variable", "doc": "Relative abundance of the isotope.
\n", "annotation": ": float"}, {"fullname": "aton.phys.atoms.Isotope.cross_section", "modulename": "aton.phys.atoms", "qualname": "Isotope.cross_section", "kind": "variable", "doc": "Total bound scattering cross section of the isotope.
\n", "annotation": ": float"}, {"fullname": "aton.phys.atoms.atoms", "modulename": "aton.phys.atoms", "qualname": "atoms", "kind": "variable", "doc": "\n", "default_value": "{'H': <aton.phys.atoms.Element object>, 'He': <aton.phys.atoms.Element object>, 'Li': <aton.phys.atoms.Element object>, 'Be': <aton.phys.atoms.Element object>, 'B': <aton.phys.atoms.Element object>, 'C': <aton.phys.atoms.Element object>, 'N': <aton.phys.atoms.Element object>, 'O': <aton.phys.atoms.Element object>, 'F': <aton.phys.atoms.Element object>, 'Ne': <aton.phys.atoms.Element object>, 'Na': <aton.phys.atoms.Element object>, 'Mg': <aton.phys.atoms.Element object>, 'Al': <aton.phys.atoms.Element object>, 'Si': <aton.phys.atoms.Element object>, 'P': <aton.phys.atoms.Element object>, 'S': <aton.phys.atoms.Element object>, 'Cl': <aton.phys.atoms.Element object>, 'Ar': <aton.phys.atoms.Element object>, 'K': <aton.phys.atoms.Element object>, 'Ca': <aton.phys.atoms.Element object>, 'Sc': <aton.phys.atoms.Element object>, 'Ti': <aton.phys.atoms.Element object>, 'V': <aton.phys.atoms.Element object>, 'Cr': <aton.phys.atoms.Element object>, 'Mn': <aton.phys.atoms.Element object>, 'Fe': <aton.phys.atoms.Element object>, 'Co': <aton.phys.atoms.Element object>, 'Ni': <aton.phys.atoms.Element object>, 'Cu': <aton.phys.atoms.Element object>, 'Zn': <aton.phys.atoms.Element object>, 'Ga': <aton.phys.atoms.Element object>, 'Ge': <aton.phys.atoms.Element object>, 'As': <aton.phys.atoms.Element object>, 'Se': <aton.phys.atoms.Element object>, 'Br': <aton.phys.atoms.Element object>, 'Kr': <aton.phys.atoms.Element object>, 'Rb': <aton.phys.atoms.Element object>, 'Sr': <aton.phys.atoms.Element object>, 'Y': <aton.phys.atoms.Element object>, 'Zr': <aton.phys.atoms.Element object>, 'Nb': <aton.phys.atoms.Element object>, 'Mo': <aton.phys.atoms.Element object>, 'Tc': <aton.phys.atoms.Element object>, 'Ru': <aton.phys.atoms.Element object>, 'Rh': <aton.phys.atoms.Element object>, 'Pd': <aton.phys.atoms.Element object>, 'Ag': <aton.phys.atoms.Element object>, 'Cd': <aton.phys.atoms.Element object>, 'In': <aton.phys.atoms.Element object>, 'Sn': <aton.phys.atoms.Element object>, 'Sb': <aton.phys.atoms.Element object>, 'Te': <aton.phys.atoms.Element object>, 'I': <aton.phys.atoms.Element object>, 'Xe': <aton.phys.atoms.Element object>, 'Cs': <aton.phys.atoms.Element object>, 'Ba': <aton.phys.atoms.Element object>, 'La': <aton.phys.atoms.Element object>, 'Ce': <aton.phys.atoms.Element object>, 'Pr': <aton.phys.atoms.Element object>, 'Nd': <aton.phys.atoms.Element object>, 'Pm': <aton.phys.atoms.Element object>, 'Sm': <aton.phys.atoms.Element object>, 'Eu': <aton.phys.atoms.Element object>, 'Gd': <aton.phys.atoms.Element object>, 'Tb': <aton.phys.atoms.Element object>, 'Dy': <aton.phys.atoms.Element object>, 'Ho': <aton.phys.atoms.Element object>, 'Er': <aton.phys.atoms.Element object>, 'Tm': <aton.phys.atoms.Element object>, 'Yb': <aton.phys.atoms.Element object>, 'Lu': <aton.phys.atoms.Element object>, 'Hf': <aton.phys.atoms.Element object>, 'Ta': <aton.phys.atoms.Element object>, 'W': <aton.phys.atoms.Element object>, 'Re': <aton.phys.atoms.Element object>, 'Os': <aton.phys.atoms.Element object>, 'Ir': <aton.phys.atoms.Element object>, 'Pt': <aton.phys.atoms.Element object>, 'Au': <aton.phys.atoms.Element object>, 'Hg': <aton.phys.atoms.Element object>, 'Tl': <aton.phys.atoms.Element object>, 'Pb': <aton.phys.atoms.Element object>, 'Bi': <aton.phys.atoms.Element object>, 'Po': <aton.phys.atoms.Element object>, 'At': <aton.phys.atoms.Element object>, 'Rn': <aton.phys.atoms.Element object>, 'Fr': <aton.phys.atoms.Element object>, 'Ra': <aton.phys.atoms.Element object>, 'Ac': <aton.phys.atoms.Element object>, 'Th': <aton.phys.atoms.Element object>, 'Pa': <aton.phys.atoms.Element object>, 'U': <aton.phys.atoms.Element object>, 'Np': <aton.phys.atoms.Element object>, 'Pu': <aton.phys.atoms.Element object>, 'Am': <aton.phys.atoms.Element object>, 'Cm': <aton.phys.atoms.Element object>, 'Bk': <aton.phys.atoms.Element object>, 'Cf': <aton.phys.atoms.Element object>, 'Es': <aton.phys.atoms.Element object>, 'Fm': <aton.phys.atoms.Element object>, 'Md': <aton.phys.atoms.Element object>, 'No': <aton.phys.atoms.Element object>, 'Lr': <aton.phys.atoms.Element object>, 'Rf': <aton.phys.atoms.Element object>, 'Db': <aton.phys.atoms.Element object>, 'Sg': <aton.phys.atoms.Element object>, 'Bh': <aton.phys.atoms.Element object>, 'Hs': <aton.phys.atoms.Element object>, 'Mt': <aton.phys.atoms.Element object>, 'Ds': <aton.phys.atoms.Element object>, 'Rg': <aton.phys.atoms.Element object>, 'Cn': <aton.phys.atoms.Element object>, 'Uut': <aton.phys.atoms.Element object>, 'Uuq': <aton.phys.atoms.Element object>, 'Uup': <aton.phys.atoms.Element object>, 'Uuh': <aton.phys.atoms.Element object>, 'Uus': <aton.phys.atoms.Element object>, 'Uuo': <aton.phys.atoms.Element object>}"}, {"fullname": "aton.phys.functions", "modulename": "aton.phys.functions", "kind": "module", "doc": "Description
\n\nThis module contains functions to sort and analyse\nchemical data using the
\n\naton.phys.atoms
megadictionary,\nwhich contains the properties of all elements.\nIt also contains the tools needed to\nautomatically update said megadictionary.Index
\n\n\n\n
\n\n\n \n\n\n\n \n \n \n\n export_atoms()
Used to update and export the \naton.phys.atoms
dict\n \n\n split_isotope()
Splits element name and mass number \n\n \n\n\n allowed_isotopes()
Returns the available mass numbers for a given element \nExamples
\n\nAll functions can be called from the phys subpackage directly, as:
\n\n\n\n\n\nfrom aton import phys\nphys.split_isotope('He4') # (He, 4)\nphys.allowed_isotopes('Li') # (6, 7)\n
\n"}, {"fullname": "aton.phys.functions.export_atoms", "modulename": "aton.phys.functions", "qualname": "export_atoms", "kind": "function", "doc": "Export a dictionary of chemical elements to a python file.
\n\nThis is used to build and update the
\n", "signature": "(\tatoms: dict = {'H': <aton.phys.atoms.Element object>, 'He': <aton.phys.atoms.Element object>, 'Li': <aton.phys.atoms.Element object>, 'Be': <aton.phys.atoms.Element object>, 'B': <aton.phys.atoms.Element object>, 'C': <aton.phys.atoms.Element object>, 'N': <aton.phys.atoms.Element object>, 'O': <aton.phys.atoms.Element object>, 'F': <aton.phys.atoms.Element object>, 'Ne': <aton.phys.atoms.Element object>, 'Na': <aton.phys.atoms.Element object>, 'Mg': <aton.phys.atoms.Element object>, 'Al': <aton.phys.atoms.Element object>, 'Si': <aton.phys.atoms.Element object>, 'P': <aton.phys.atoms.Element object>, 'S': <aton.phys.atoms.Element object>, 'Cl': <aton.phys.atoms.Element object>, 'Ar': <aton.phys.atoms.Element object>, 'K': <aton.phys.atoms.Element object>, 'Ca': <aton.phys.atoms.Element object>, 'Sc': <aton.phys.atoms.Element object>, 'Ti': <aton.phys.atoms.Element object>, 'V': <aton.phys.atoms.Element object>, 'Cr': <aton.phys.atoms.Element object>, 'Mn': <aton.phys.atoms.Element object>, 'Fe': <aton.phys.atoms.Element object>, 'Co': <aton.phys.atoms.Element object>, 'Ni': <aton.phys.atoms.Element object>, 'Cu': <aton.phys.atoms.Element object>, 'Zn': <aton.phys.atoms.Element object>, 'Ga': <aton.phys.atoms.Element object>, 'Ge': <aton.phys.atoms.Element object>, 'As': <aton.phys.atoms.Element object>, 'Se': <aton.phys.atoms.Element object>, 'Br': <aton.phys.atoms.Element object>, 'Kr': <aton.phys.atoms.Element object>, 'Rb': <aton.phys.atoms.Element object>, 'Sr': <aton.phys.atoms.Element object>, 'Y': <aton.phys.atoms.Element object>, 'Zr': <aton.phys.atoms.Element object>, 'Nb': <aton.phys.atoms.Element object>, 'Mo': <aton.phys.atoms.Element object>, 'Tc': <aton.phys.atoms.Element object>, 'Ru': <aton.phys.atoms.Element object>, 'Rh': <aton.phys.atoms.Element object>, 'Pd': <aton.phys.atoms.Element object>, 'Ag': <aton.phys.atoms.Element object>, 'Cd': <aton.phys.atoms.Element object>, 'In': <aton.phys.atoms.Element object>, 'Sn': <aton.phys.atoms.Element object>, 'Sb': <aton.phys.atoms.Element object>, 'Te': <aton.phys.atoms.Element object>, 'I': <aton.phys.atoms.Element object>, 'Xe': <aton.phys.atoms.Element object>, 'Cs': <aton.phys.atoms.Element object>, 'Ba': <aton.phys.atoms.Element object>, 'La': <aton.phys.atoms.Element object>, 'Ce': <aton.phys.atoms.Element object>, 'Pr': <aton.phys.atoms.Element object>, 'Nd': <aton.phys.atoms.Element object>, 'Pm': <aton.phys.atoms.Element object>, 'Sm': <aton.phys.atoms.Element object>, 'Eu': <aton.phys.atoms.Element object>, 'Gd': <aton.phys.atoms.Element object>, 'Tb': <aton.phys.atoms.Element object>, 'Dy': <aton.phys.atoms.Element object>, 'Ho': <aton.phys.atoms.Element object>, 'Er': <aton.phys.atoms.Element object>, 'Tm': <aton.phys.atoms.Element object>, 'Yb': <aton.phys.atoms.Element object>, 'Lu': <aton.phys.atoms.Element object>, 'Hf': <aton.phys.atoms.Element object>, 'Ta': <aton.phys.atoms.Element object>, 'W': <aton.phys.atoms.Element object>, 'Re': <aton.phys.atoms.Element object>, 'Os': <aton.phys.atoms.Element object>, 'Ir': <aton.phys.atoms.Element object>, 'Pt': <aton.phys.atoms.Element object>, 'Au': <aton.phys.atoms.Element object>, 'Hg': <aton.phys.atoms.Element object>, 'Tl': <aton.phys.atoms.Element object>, 'Pb': <aton.phys.atoms.Element object>, 'Bi': <aton.phys.atoms.Element object>, 'Po': <aton.phys.atoms.Element object>, 'At': <aton.phys.atoms.Element object>, 'Rn': <aton.phys.atoms.Element object>, 'Fr': <aton.phys.atoms.Element object>, 'Ra': <aton.phys.atoms.Element object>, 'Ac': <aton.phys.atoms.Element object>, 'Th': <aton.phys.atoms.Element object>, 'Pa': <aton.phys.atoms.Element object>, 'U': <aton.phys.atoms.Element object>, 'Np': <aton.phys.atoms.Element object>, 'Pu': <aton.phys.atoms.Element object>, 'Am': <aton.phys.atoms.Element object>, 'Cm': <aton.phys.atoms.Element object>, 'Bk': <aton.phys.atoms.Element object>, 'Cf': <aton.phys.atoms.Element object>, 'Es': <aton.phys.atoms.Element object>, 'Fm': <aton.phys.atoms.Element object>, 'Md': <aton.phys.atoms.Element object>, 'No': <aton.phys.atoms.Element object>, 'Lr': <aton.phys.atoms.Element object>, 'Rf': <aton.phys.atoms.Element object>, 'Db': <aton.phys.atoms.Element object>, 'Sg': <aton.phys.atoms.Element object>, 'Bh': <aton.phys.atoms.Element object>, 'Hs': <aton.phys.atoms.Element object>, 'Mt': <aton.phys.atoms.Element object>, 'Ds': <aton.phys.atoms.Element object>, 'Rg': <aton.phys.atoms.Element object>, 'Cn': <aton.phys.atoms.Element object>, 'Uut': <aton.phys.atoms.Element object>, 'Uuq': <aton.phys.atoms.Element object>, 'Uup': <aton.phys.atoms.Element object>, 'Uuh': <aton.phys.atoms.Element object>, 'Uus': <aton.phys.atoms.Element object>, 'Uuo': <aton.phys.atoms.Element object>},\tfilename='exported_atoms.py') -> None:", "funcdef": "def"}, {"fullname": "aton.phys.functions.split_isotope", "modulename": "aton.phys.functions", "qualname": "split_isotope", "kind": "function", "doc": "aton.atoms
megadictionary, that contains\nall the element data, such as masses, cross-sections, etc.\nTheatoms.py
file must be modified here.Split the
\n\nname
of an isotope into the element and the mass number, eg. He4 -> He, 4.If the isotope is not found in the
\n", "signature": "(name: str) -> tuple:", "funcdef": "def"}, {"fullname": "aton.phys.functions.allowed_isotopes", "modulename": "aton.phys.functions", "qualname": "allowed_isotopes", "kind": "function", "doc": "aton.atoms
megadictionary it raises an error,\ninforming of the allowed mass numbers (A) values for the given element.Return a list with the allowed mass numbers (A) of a given
\n\nelement
.These mass numbers are used as isotope keys in the
\n", "signature": "(element) -> list:", "funcdef": "def"}, {"fullname": "aton.phys.units", "modulename": "aton.phys.units", "kind": "module", "doc": "aton.atoms
megadictionary.Description
\n\nThis module contains useful constants and conversion factors.
\n\nIndex
\n\nEnergy conversion factors
\n\n
\nDistance conversion factors
\nMass conversion factors
\nPressure conversion factors
\nTime conversion factors
\nUniversal constantsExamples
\n\n\n\n\n\nfrom aton import phys\nenergy_in_cm1 = 1000 * phys.meV_to_cm1 # 8065.5\nlength_in_angstroms = 10.0 * phys.bohr_to_A # 5.29177210544\nphys.hbar # 1.0545718176461565e-34\n
\n\nEnergy conversion factors
\n\nNote that
\n"}, {"fullname": "aton.phys.units.eV_to_meV", "modulename": "aton.phys.units", "qualname": "eV_to_meV", "kind": "variable", "doc": "\n", "default_value": "1000.0"}, {"fullname": "aton.phys.units.meV_to_eV", "modulename": "aton.phys.units", "qualname": "meV_to_eV", "kind": "variable", "doc": "\n", "default_value": "0.001"}, {"fullname": "aton.phys.units.meV_to_cm1", "modulename": "aton.phys.units", "qualname": "meV_to_cm1", "kind": "variable", "doc": "\n", "default_value": "8.0655"}, {"fullname": "aton.phys.units.cm1_to_meV", "modulename": "aton.phys.units", "qualname": "cm1_to_meV", "kind": "variable", "doc": "\n", "default_value": "0.12398487384539086"}, {"fullname": "aton.phys.units.eV_to_J", "modulename": "aton.phys.units", "qualname": "eV_to_J", "kind": "variable", "doc": "\n", "default_value": "1.602176634e-19"}, {"fullname": "aton.phys.units.J_to_eV", "modulename": "aton.phys.units", "qualname": "J_to_eV", "kind": "variable", "doc": "\n", "default_value": "6.241509074460763e+18"}, {"fullname": "aton.phys.units.meV_to_J", "modulename": "aton.phys.units", "qualname": "meV_to_J", "kind": "variable", "doc": "\n", "default_value": "1.6021766339999998e-22"}, {"fullname": "aton.phys.units.J_to_meV", "modulename": "aton.phys.units", "qualname": "J_to_meV", "kind": "variable", "doc": "\n", "default_value": "6.241509074460763e+21"}, {"fullname": "aton.phys.units.Ry_to_eV", "modulename": "aton.phys.units", "qualname": "Ry_to_eV", "kind": "variable", "doc": "\n", "default_value": "13.60569312299"}, {"fullname": "aton.phys.units.eV_to_Ry", "modulename": "aton.phys.units", "qualname": "eV_to_Ry", "kind": "variable", "doc": "\n", "default_value": "0.07349864435133158"}, {"fullname": "aton.phys.units.Ry_to_J", "modulename": "aton.phys.units", "qualname": "Ry_to_J", "kind": "variable", "doc": "\n", "default_value": "2.179872361103e-18"}, {"fullname": "aton.phys.units.J_to_Ry", "modulename": "aton.phys.units", "qualname": "J_to_Ry", "kind": "variable", "doc": "\n", "default_value": "4.5874245567938074e+17"}, {"fullname": "aton.phys.units.cal_to_J", "modulename": "aton.phys.units", "qualname": "cal_to_J", "kind": "variable", "doc": "\n", "default_value": "4.184"}, {"fullname": "aton.phys.units.J_to_cal", "modulename": "aton.phys.units", "qualname": "J_to_cal", "kind": "variable", "doc": "\n", "default_value": "0.2390057361376673"}, {"fullname": "aton.phys.units.kcal_to_J", "modulename": "aton.phys.units", "qualname": "kcal_to_J", "kind": "variable", "doc": "\n", "default_value": "4184.0"}, {"fullname": "aton.phys.units.J_to_kcal", "modulename": "aton.phys.units", "qualname": "J_to_kcal", "kind": "variable", "doc": "cm
refers to cm$^{-1}$.
\n\nDistance conversion factors
\n\nNote that
\n", "default_value": "0.0002390057361376673"}, {"fullname": "aton.phys.units.A_to_m", "modulename": "aton.phys.units", "qualname": "A_to_m", "kind": "variable", "doc": "\n", "default_value": "1e-10"}, {"fullname": "aton.phys.units.m_to_A", "modulename": "aton.phys.units", "qualname": "m_to_A", "kind": "variable", "doc": "\n", "default_value": "10000000000.0"}, {"fullname": "aton.phys.units.bohr_to_m", "modulename": "aton.phys.units", "qualname": "bohr_to_m", "kind": "variable", "doc": "\n", "default_value": "5.29177210544e-11"}, {"fullname": "aton.phys.units.m_to_bohr", "modulename": "aton.phys.units", "qualname": "m_to_bohr", "kind": "variable", "doc": "\n", "default_value": "18897261259.077824"}, {"fullname": "aton.phys.units.A_to_bohr", "modulename": "aton.phys.units", "qualname": "A_to_bohr", "kind": "variable", "doc": "\n", "default_value": "1.8897261259077824"}, {"fullname": "aton.phys.units.bohr_to_A", "modulename": "aton.phys.units", "qualname": "bohr_to_A", "kind": "variable", "doc": "A
refers to Angstroms.
\n\nMass conversion factors
\n", "default_value": "0.529177210544"}, {"fullname": "aton.phys.units.amu_to_kg", "modulename": "aton.phys.units", "qualname": "amu_to_kg", "kind": "variable", "doc": "\n", "default_value": "1.6605390666e-27"}, {"fullname": "aton.phys.units.kg_to_amu", "modulename": "aton.phys.units", "qualname": "kg_to_amu", "kind": "variable", "doc": "\n", "default_value": "6.022140762081123e+26"}, {"fullname": "aton.phys.units.kg_to_g", "modulename": "aton.phys.units", "qualname": "kg_to_g", "kind": "variable", "doc": "\n", "default_value": "1000.0"}, {"fullname": "aton.phys.units.g_to_kg", "modulename": "aton.phys.units", "qualname": "g_to_kg", "kind": "variable", "doc": "
\n\nPressure conversion factors
\n", "default_value": "0.001"}, {"fullname": "aton.phys.units.GPa_to_Pa", "modulename": "aton.phys.units", "qualname": "GPa_to_Pa", "kind": "variable", "doc": "\n", "default_value": "1000000000.0"}, {"fullname": "aton.phys.units.Pa_to_GPa", "modulename": "aton.phys.units", "qualname": "Pa_to_GPa", "kind": "variable", "doc": "\n", "default_value": "1e-09"}, {"fullname": "aton.phys.units.kbar_to_bar", "modulename": "aton.phys.units", "qualname": "kbar_to_bar", "kind": "variable", "doc": "\n", "default_value": "1000.0"}, {"fullname": "aton.phys.units.bar_to_kbar", "modulename": "aton.phys.units", "qualname": "bar_to_kbar", "kind": "variable", "doc": "\n", "default_value": "0.001"}, {"fullname": "aton.phys.units.Pa_to_bar", "modulename": "aton.phys.units", "qualname": "Pa_to_bar", "kind": "variable", "doc": "\n", "default_value": "1e-05"}, {"fullname": "aton.phys.units.bar_to_Pa", "modulename": "aton.phys.units", "qualname": "bar_to_Pa", "kind": "variable", "doc": "\n", "default_value": "99999.99999999999"}, {"fullname": "aton.phys.units.GPa_to_kbar", "modulename": "aton.phys.units", "qualname": "GPa_to_kbar", "kind": "variable", "doc": "\n", "default_value": "10.0"}, {"fullname": "aton.phys.units.kbar_to_GPa", "modulename": "aton.phys.units", "qualname": "kbar_to_GPa", "kind": "variable", "doc": "
\n\nTime conversion factors
\n\nNote that
\n", "default_value": "0.1"}, {"fullname": "aton.phys.units.H_to_s", "modulename": "aton.phys.units", "qualname": "H_to_s", "kind": "variable", "doc": "\n", "default_value": "3600.0"}, {"fullname": "aton.phys.units.s_to_H", "modulename": "aton.phys.units", "qualname": "s_to_H", "kind": "variable", "doc": "H
refers to hours.
\n\nUniversal constants
\n\nGiven in SI units unless stated otherwise.
\n", "default_value": "0.0002777777777777778"}, {"fullname": "aton.phys.units.h", "modulename": "aton.phys.units", "qualname": "h", "kind": "variable", "doc": "Planck constant, in J\u00b7s.
\n", "default_value": "6.62607015e-34"}, {"fullname": "aton.phys.units.h_eV", "modulename": "aton.phys.units", "qualname": "h_eV", "kind": "variable", "doc": "Planck constant, in eV\u00b7s.
\n", "default_value": "4.135667696923859e-15"}, {"fullname": "aton.phys.units.hbar", "modulename": "aton.phys.units", "qualname": "hbar", "kind": "variable", "doc": "Reduced Planck constant, in J\u00b7s.
\n", "default_value": "1.0545718176461565e-34"}, {"fullname": "aton.phys.units.hbar_eV", "modulename": "aton.phys.units", "qualname": "hbar_eV", "kind": "variable", "doc": "Reduced Planck constant, in eV\u00b7s.
\n", "default_value": "6.582119569509066e-16"}, {"fullname": "aton.qrotor", "modulename": "aton.qrotor", "kind": "module", "doc": "QRotor
\n\nThe QRotor module is used to study the energy levels of quantum rotations, such as methyl and amine groups.
\n\nIndex
\n\n\n\n
\n"}, {"fullname": "aton.qrotor.classes", "modulename": "aton.qrotor.classes", "kind": "module", "doc": "\n \n\n\n\n \n \n \n\n aton.qrotor.classes
Definition of the \nQSys
andQExp
classes\n \n\n aton.qrotor.constants
Bond lengths and inertias \n\n \n\n aton.qrotor.rotate
Rotate specific atoms from structural files \n\n \n\n aton.qrotor.potential
Potential definitions and loading functions \n\n \n\n aton.qrotor.solve
Solve rotation eigenvalues and eigenvectors \n\n \n\n\n aton.qrotor.plot
Plotting functions \nDescription
\n\nThis module contains common classes for QRotor calculations.\nThese classes can be loaded directly as
\n\naton.qrotor.Class()
.Index
\n\n\n\n
\n\n\n \n\n\n\n \n \n \n\n QSys
Quantum system, with all the data for a single calculation \n\n \n\n\n QExp
Quantum experiment, contains several \nQSys
objects
\n"}, {"fullname": "aton.qrotor.classes.QSys", "modulename": "aton.qrotor.classes", "qualname": "QSys", "kind": "class", "doc": "Quantum system, contains all the data for a single calculation, with both inputs and outputs.
\n"}, {"fullname": "aton.qrotor.classes.QSys.__init__", "modulename": "aton.qrotor.classes", "qualname": "QSys.__init__", "kind": "function", "doc": "\n", "signature": "(\tcomment: str = None,\tgroup: str = 'CH3',\tE_levels: int = 5,\tunits=None,\tcorrect_potential_offset: bool = True,\tsave_eigenvectors: bool = False,\tgridsize: int = None,\tgrid=None,\tB: float = None,\tpotential_name: str = '',\tpotential_constants: list = None,\tpotential_values=None)"}, {"fullname": "aton.qrotor.classes.QSys.comment", "modulename": "aton.qrotor.classes", "qualname": "QSys.comment", "kind": "variable", "doc": "Custom comment for the dataset.
\n", "annotation": ": str"}, {"fullname": "aton.qrotor.classes.QSys.group", "modulename": "aton.qrotor.classes", "qualname": "QSys.group", "kind": "variable", "doc": "Chemical group, methyl or amine:
\n", "annotation": ": str"}, {"fullname": "aton.qrotor.classes.QSys.E_levels", "modulename": "aton.qrotor.classes", "qualname": "QSys.E_levels", "kind": "variable", "doc": "'CH3'
,'CD3'
,'NH3'
,'ND3'
.Number of energy levels to be studied.
\n", "annotation": ": int"}, {"fullname": "aton.qrotor.classes.QSys.units", "modulename": "aton.qrotor.classes", "qualname": "QSys.units", "kind": "variable", "doc": "List containing the energy units in use, e.g. ['meV'].
\n"}, {"fullname": "aton.qrotor.classes.QSys.correct_potential_offset", "modulename": "aton.qrotor.classes", "qualname": "QSys.correct_potential_offset", "kind": "variable", "doc": "Correct the potential offset as
\n", "annotation": ": bool"}, {"fullname": "aton.qrotor.classes.QSys.save_eigenvectors", "modulename": "aton.qrotor.classes", "qualname": "QSys.save_eigenvectors", "kind": "variable", "doc": "V - min(V)
or not.Save or not the eigenvectors. Final file size will be bigger.
\n", "annotation": ": bool"}, {"fullname": "aton.qrotor.classes.QSys.gridsize", "modulename": "aton.qrotor.classes", "qualname": "QSys.gridsize", "kind": "variable", "doc": "Number of points in the grid.
\n", "annotation": ": int"}, {"fullname": "aton.qrotor.classes.QSys.grid", "modulename": "aton.qrotor.classes", "qualname": "QSys.grid", "kind": "variable", "doc": "The grid with the points to be used in the calculation.
\n\nCan be set automatically over $2 \\Pi$ with
\n"}, {"fullname": "aton.qrotor.classes.QSys.B", "modulename": "aton.qrotor.classes", "qualname": "QSys.B", "kind": "variable", "doc": "QSys.set_grid()
.\nUnits should be in radians.Rotational inertia, as in $B=\\frac{\\hbar^2}{2I}.
\n", "annotation": ": float"}, {"fullname": "aton.qrotor.classes.QSys.potential_name", "modulename": "aton.qrotor.classes", "qualname": "QSys.potential_name", "kind": "variable", "doc": "Name of the desired potential:
\n", "annotation": ": str"}, {"fullname": "aton.qrotor.classes.QSys.potential_constants", "modulename": "aton.qrotor.classes", "qualname": "QSys.potential_constants", "kind": "variable", "doc": "'zero'
,'titov2023'
,'test'
...\nIf empty or unrecognised, the custom potential values insideQSys.potential_values
will be used.List of constants to be used in the calculation of the potential energy, in the
\n", "annotation": ": list"}, {"fullname": "aton.qrotor.classes.QSys.potential_values", "modulename": "aton.qrotor.classes", "qualname": "QSys.potential_values", "kind": "variable", "doc": "aton.qrotor.potential
module.Numpy array with the potential values for each point in the grid.
\n\nCan be calculated with a function available in the
\n"}, {"fullname": "aton.qrotor.classes.QSys.potential_offset", "modulename": "aton.qrotor.classes", "qualname": "QSys.potential_offset", "kind": "variable", "doc": "qrotor.potential
module,\nor loaded externally with theqrotor.potential.load()
function.\nUnits should be in eV.\n", "annotation": ": float"}, {"fullname": "aton.qrotor.classes.QSys.potential_min", "modulename": "aton.qrotor.classes", "qualname": "QSys.potential_min", "kind": "variable", "doc": "
min(V)
before offset correction whenQSys.correct_potential_offset = True
\n", "annotation": ": float"}, {"fullname": "aton.qrotor.classes.QSys.potential_max", "modulename": "aton.qrotor.classes", "qualname": "QSys.potential_max", "kind": "variable", "doc": "
min(V)
\n", "annotation": ": float"}, {"fullname": "aton.qrotor.classes.QSys.potential_max_B", "modulename": "aton.qrotor.classes", "qualname": "QSys.potential_max_B", "kind": "variable", "doc": "
max(V)
Reduced
\n", "annotation": ": float"}, {"fullname": "aton.qrotor.classes.QSys.eigenvalues", "modulename": "aton.qrotor.classes", "qualname": "QSys.eigenvalues", "kind": "variable", "doc": "potential_max
, in units of B.Calculated eigenvalues of the system.
\n"}, {"fullname": "aton.qrotor.classes.QSys.eigenvalues_B", "modulename": "aton.qrotor.classes", "qualname": "QSys.eigenvalues_B", "kind": "variable", "doc": "Reduced
\n"}, {"fullname": "aton.qrotor.classes.QSys.eigenvectors", "modulename": "aton.qrotor.classes", "qualname": "QSys.eigenvectors", "kind": "variable", "doc": "eigenvalues
, in units of B.Eigenvectors, if
\n"}, {"fullname": "aton.qrotor.classes.QSys.energy_barrier", "modulename": "aton.qrotor.classes", "qualname": "QSys.energy_barrier", "kind": "variable", "doc": "save_eigenvectors
is True. Beware of the file size.\n", "annotation": ": float"}, {"fullname": "aton.qrotor.classes.QSys.first_transition", "modulename": "aton.qrotor.classes", "qualname": "QSys.first_transition", "kind": "variable", "doc": "
max(V) - min(eigenvalues)
eigenvalues[1] - eigenvalues[0]
\n", "annotation": ": float"}, {"fullname": "aton.qrotor.classes.QSys.runtime", "modulename": "aton.qrotor.classes", "qualname": "QSys.runtime", "kind": "variable", "doc": "Time taken to solve the eigenvalues.
\n", "annotation": ": float"}, {"fullname": "aton.qrotor.classes.QSys.summary", "modulename": "aton.qrotor.classes", "qualname": "QSys.summary", "kind": "function", "doc": "\n", "signature": "(self):", "funcdef": "def"}, {"fullname": "aton.qrotor.classes.QSys.set_grid", "modulename": "aton.qrotor.classes", "qualname": "QSys.set_grid", "kind": "function", "doc": "Sets the
\n\nQSys.grid
to the specifiedgridsize
.It removes the previous grid,\ndo not use this method if the potential was loaded externally!
\n", "signature": "(self, gridsize: int = None):", "funcdef": "def"}, {"fullname": "aton.qrotor.classes.QSys.set_group", "modulename": "aton.qrotor.classes", "qualname": "QSys.set_group", "kind": "function", "doc": "Normalise
\n", "signature": "(self, group: str = None, B: float = None):", "funcdef": "def"}, {"fullname": "aton.qrotor.classes.QExp", "modulename": "aton.qrotor.classes", "qualname": "QExp", "kind": "class", "doc": "\n"}, {"fullname": "aton.qrotor.classes.QExp.__init__", "modulename": "aton.qrotor.classes", "qualname": "QExp.__init__", "kind": "function", "doc": "\n", "signature": "(\tcomment: str = None,\tsystems: list = [],\tplotting: aton.spx.classes.Plotting = None)"}, {"fullname": "aton.qrotor.classes.QExp.version", "modulename": "aton.qrotor.classes", "qualname": "QExp.version", "kind": "variable", "doc": "QSys.group
name, and setQSys.B
based on it.Version of the package used to generate the data.
\n"}, {"fullname": "aton.qrotor.classes.QExp.comment", "modulename": "aton.qrotor.classes", "qualname": "QExp.comment", "kind": "variable", "doc": "Custom comment for the dataset.
\n", "annotation": ": str"}, {"fullname": "aton.qrotor.classes.QExp.systems", "modulename": "aton.qrotor.classes", "qualname": "QExp.systems", "kind": "variable", "doc": "List containing the calculated
\n"}, {"fullname": "aton.qrotor.classes.QExp.plotting", "modulename": "aton.qrotor.classes", "qualname": "QExp.plotting", "kind": "variable", "doc": "QSys
objects.\n", "annotation": ": aton.spx.classes.Plotting"}, {"fullname": "aton.qrotor.classes.QExp.add", "modulename": "aton.qrotor.classes", "qualname": "QExp.add", "kind": "function", "doc": "
aton.spx.classes.Plotting
object (not implemented).Adds more systems to
\n", "signature": "(self, *args):", "funcdef": "def"}, {"fullname": "aton.qrotor.classes.QExp.get_energies", "modulename": "aton.qrotor.classes", "qualname": "QExp.get_energies", "kind": "function", "doc": "self.systems
from the introducedQSys
orQExp
objects.Returns a list with all
\n", "signature": "(self):", "funcdef": "def"}, {"fullname": "aton.qrotor.classes.QExp.get_gridsizes", "modulename": "aton.qrotor.classes", "qualname": "QExp.get_gridsizes", "kind": "function", "doc": "QSys.eigenvalues
values.Returns a list with all
\n", "signature": "(self):", "funcdef": "def"}, {"fullname": "aton.qrotor.classes.QExp.get_runtimes", "modulename": "aton.qrotor.classes", "qualname": "QExp.get_runtimes", "kind": "function", "doc": "QSys.gridsize
values.Returns a list with all
\n", "signature": "(self):", "funcdef": "def"}, {"fullname": "aton.qrotor.classes.QExp.get_gropus", "modulename": "aton.qrotor.classes", "qualname": "QExp.get_gropus", "kind": "function", "doc": "QSys.runtime
values.Returns a list with all
\n", "signature": "(self):", "funcdef": "def"}, {"fullname": "aton.qrotor.classes.QExp.sort_by_potential_values", "modulename": "aton.qrotor.classes", "qualname": "QExp.sort_by_potential_values", "kind": "function", "doc": "QSys.group
values.Returns the
\n", "signature": "(self):", "funcdef": "def"}, {"fullname": "aton.qrotor.classes.QExp.group_by_potential_values", "modulename": "aton.qrotor.classes", "qualname": "QExp.group_by_potential_values", "kind": "function", "doc": "QExp
object, sorted byQSys.potential_values
.Returns an array of grouped
\n", "signature": "(self):", "funcdef": "def"}, {"fullname": "aton.qrotor.classes.QExp.sort_by_gridsize", "modulename": "aton.qrotor.classes", "qualname": "QExp.sort_by_gridsize", "kind": "function", "doc": "QExp
objects with the sameQSys.potential_values
.Returns the same
\n", "signature": "(self):", "funcdef": "def"}, {"fullname": "aton.qrotor.classes.QExp.get_ideal_E", "modulename": "aton.qrotor.classes", "qualname": "QExp.get_ideal_E", "kind": "function", "doc": "QExp
, sorted byQSys.gridsize
.Calculates the ideal energy for a specified
\n", "signature": "(self, E_level):", "funcdef": "def"}, {"fullname": "aton.qrotor.classes.QExp.discard_shit", "modulename": "aton.qrotor.classes", "qualname": "QExp.discard_shit", "kind": "function", "doc": "E_level
for a convergence test. Only for 'zero' potential.Discard data that takes too much space, like eigenvectors, potential values and grids.
\n", "signature": "(self):", "funcdef": "def"}, {"fullname": "aton.qrotor.constants", "modulename": "aton.qrotor.constants", "kind": "module", "doc": "Description
\n\nCommon constants and default values used in the QRotor subpackage.
\n\nBond lengths and angles were obtained from MAPbI3,\nsee Cryst. Growth Des. 2024, 24, 391\u2212404.
\n\n
\n"}, {"fullname": "aton.qrotor.constants.distance_CH", "modulename": "aton.qrotor.constants", "qualname": "distance_CH", "kind": "variable", "doc": "Distance of the C-H bond, in Angstroms.
\n", "default_value": "1.09285"}, {"fullname": "aton.qrotor.constants.distance_NH", "modulename": "aton.qrotor.constants", "qualname": "distance_NH", "kind": "variable", "doc": "Distance of the N-H bond, in Angstroms.
\n", "default_value": "1.040263"}, {"fullname": "aton.qrotor.constants.angle_CH_external", "modulename": "aton.qrotor.constants", "qualname": "angle_CH_external", "kind": "variable", "doc": "External angle of the X-C-H bond, in degrees.
\n", "default_value": "108.7223"}, {"fullname": "aton.qrotor.constants.angle_NH_external", "modulename": "aton.qrotor.constants", "qualname": "angle_NH_external", "kind": "variable", "doc": "External angle of the X-N-H bond, in degrees.
\n", "default_value": "111.29016"}, {"fullname": "aton.qrotor.constants.angle_CH", "modulename": "aton.qrotor.constants", "qualname": "angle_CH", "kind": "variable", "doc": "Internal angle of the X-C-H bond, in degrees.
\n", "default_value": "71.2777"}, {"fullname": "aton.qrotor.constants.angle_NH", "modulename": "aton.qrotor.constants", "qualname": "angle_NH", "kind": "variable", "doc": "Internal angle of the X-N-H bond, in degrees.
\n", "default_value": "68.70984"}, {"fullname": "aton.qrotor.constants.r_CH", "modulename": "aton.qrotor.constants", "qualname": "r_CH", "kind": "variable", "doc": "Rotation radius of the methyl group, in meters.
\n", "default_value": "np.float64(1.0350223020441665e-10)"}, {"fullname": "aton.qrotor.constants.r_NH", "modulename": "aton.qrotor.constants", "qualname": "r_NH", "kind": "variable", "doc": "Rotation radius of the amine group, in meters.
\n", "default_value": "np.float64(9.69268793902999e-11)"}, {"fullname": "aton.qrotor.constants.I_CH", "modulename": "aton.qrotor.constants", "qualname": "I_CH", "kind": "variable", "doc": "Inertia of CH3, in uma\u00b7m^2.
\n", "default_value": "np.float64(5.37903596799128e-47)"}, {"fullname": "aton.qrotor.constants.I_CD", "modulename": "aton.qrotor.constants", "qualname": "I_CD", "kind": "variable", "doc": "Inertia of CD3, in uma\u00b7m^2.
\n", "default_value": "np.float64(1.0748582164136045e-46)"}, {"fullname": "aton.qrotor.constants.I_NH", "modulename": "aton.qrotor.constants", "qualname": "I_NH", "kind": "variable", "doc": "Inertia of NH3, in uma\u00b7m^2.
\n", "default_value": "np.float64(4.717299973303422e-47)"}, {"fullname": "aton.qrotor.constants.I_ND", "modulename": "aton.qrotor.constants", "qualname": "I_ND", "kind": "variable", "doc": "Inertia of ND3, in uma\u00b7m^2.
\n", "default_value": "np.float64(9.426277618824576e-47)"}, {"fullname": "aton.qrotor.constants.B_CH", "modulename": "aton.qrotor.constants", "qualname": "B_CH", "kind": "variable", "doc": "Rotational energy of CH3, in eV\u00b7s/uma\u00b7m^2.
\n", "default_value": "np.float64(0.0006452195002679675)"}, {"fullname": "aton.qrotor.constants.B_CD", "modulename": "aton.qrotor.constants", "qualname": "B_CD", "kind": "variable", "doc": "Rotational energy of CD3, in eV\u00b7s/uma\u00b7m^2.
\n", "default_value": "np.float64(0.0003228945777398468)"}, {"fullname": "aton.qrotor.constants.B_NH", "modulename": "aton.qrotor.constants", "qualname": "B_NH", "kind": "variable", "doc": "Rotational energy of NH3, in eV\u00b7s/uma\u00b7m^2.
\n", "default_value": "np.float64(0.0007357299554474443)"}, {"fullname": "aton.qrotor.constants.B_ND", "modulename": "aton.qrotor.constants", "qualname": "B_ND", "kind": "variable", "doc": "Rotational energy of ND3, in eV\u00b7s/uma\u00b7m^2.
\n", "default_value": "np.float64(0.0003681897605328047)"}, {"fullname": "aton.qrotor.constants.constants_titov2023", "modulename": "aton.qrotor.constants", "qualname": "constants_titov2023", "kind": "variable", "doc": "Potential constants from titov2023.
\n", "default_value": "[[2.786, 0.013, -1.5284, -0.0037, -1.2791], [2.6507, 0.0158, -1.4111, -0.0007, -1.2547], [2.1852, 0.0164, -1.0017, 0.0003, -1.2061], [5.9109, 0.0258, -7.0152, -0.0168, 1.0213], [1.4526, 0.0134, -0.3196, 0.0005, -1.1461]]"}, {"fullname": "aton.qrotor.constants.constants_titov2023_zero", "modulename": "aton.qrotor.constants", "qualname": "constants_titov2023_zero", "kind": "variable", "doc": "Zero potential constants.
\n", "default_value": "[[0, 0, 0, 0, 0]]"}, {"fullname": "aton.qrotor.plot", "modulename": "aton.qrotor.plot", "kind": "module", "doc": "Description
\n\nThis module provides straightforward functions to plot QRotor data.
\n\nIndex
\n\n\n\n
\n\n\n \n\n\n\n \n \n \n\n reduced_energies()
Reduced energies E/B as a function of the reduced potential V/B \n\n \n\n potential()
Potential values as a function of the angle \n\n \n\n energies_DEV()
NOT IMPLEMENTED \n\n \n\n energy_DEV()
NOT IMPLEMENTED \n\n \n\n convergence_DEV()
NOT IMPLEMENTED \n\n \n\n\n eigenvectors_DEV()
NOT IMPLEMENTED \n
\n"}, {"fullname": "aton.qrotor.plot.reduced_energies", "modulename": "aton.qrotor.plot", "qualname": "reduced_energies", "kind": "function", "doc": "Plots the reduced energy of the system, E/B, vs the reduced potential energy, V/B
\n", "signature": "(data: aton.qrotor.classes.QExp):", "funcdef": "def"}, {"fullname": "aton.qrotor.plot.potential", "modulename": "aton.qrotor.plot", "qualname": "potential", "kind": "function", "doc": "Plot the potential values of the system.
\n\nInput
\n", "signature": "(data):", "funcdef": "def"}, {"fullname": "aton.qrotor.plot.energies_DEV", "modulename": "aton.qrotor.plot", "qualname": "energies_DEV", "kind": "function", "doc": "data
can be aQSys
orQExp
object.Plots the energy in separated plots. NOT YET IMPLEMENTED
\n", "signature": "(data: aton.qrotor.classes.QExp):", "funcdef": "def"}, {"fullname": "aton.qrotor.plot.energy_DEV", "modulename": "aton.qrotor.plot", "qualname": "energy_DEV", "kind": "function", "doc": "Plots the energy of the system. NOT YET IMPLEMENTED
\n", "signature": "(data: aton.qrotor.classes.QExp):", "funcdef": "def"}, {"fullname": "aton.qrotor.plot.convergence_DEV", "modulename": "aton.qrotor.plot", "qualname": "convergence_DEV", "kind": "function", "doc": "Plots the energy convergence of the system. NOT YET IMPLEMENTED
\n", "signature": "(data: aton.qrotor.classes.QExp):", "funcdef": "def"}, {"fullname": "aton.qrotor.plot.eigenvectors_DEV", "modulename": "aton.qrotor.plot", "qualname": "eigenvectors_DEV", "kind": "function", "doc": "\n", "signature": "(\tdata: aton.qrotor.classes.QExp,\tlevels=None,\tsquared=False,\tscaling_factor=1):", "funcdef": "def"}, {"fullname": "aton.qrotor.potential", "modulename": "aton.qrotor.potential", "kind": "module", "doc": "Description
\n\nThis module contains functions to calculate the actual
\n\npotential_values
of the system.Index
\n\n\n\n
\n\n\n \n\n\n\n \n \n \n\n load()
Load a system with a custom potential from a potential file \n\n \n\n from_qe()
Creates a potential data file from Quantum ESPRESSO outputs \n\n \n\n interpolate()
Interpolates the current \nQSys.potential_values
to a newQSys.gridsize
\n \n\n solve()
Solve the potential values based on the potential name \n\n \n\n zero()
Zero potential \n\n \n\n sine()
Sine potential \n\n \n\n\n titov2023()
Potential of the hidered methyl rotor, as in titov2023. \n
\n"}, {"fullname": "aton.qrotor.potential.load", "modulename": "aton.qrotor.potential", "qualname": "load", "kind": "function", "doc": "Read a potential rotational energy dataset.
\n\nThe file in
\n", "signature": "(\tfilepath: str = 'potential.dat',\tsystem: aton.qrotor.classes.QSys = None,\tangle_unit: str = 'deg',\tenergy_unit: str = 'eV') -> aton.qrotor.classes.QSys:", "funcdef": "def"}, {"fullname": "aton.qrotor.potential.from_qe", "modulename": "aton.qrotor.potential", "qualname": "from_qe", "kind": "function", "doc": "filepath
should contain two columns with angle and potential energy values.\nDegrees and eV are assumed as default units unless stated inangle_unit
andenergy_unit
.\nUnits will be converted automatically to radians and eV.Creates a potential data file from Quantum ESPRESSO outputs.
\n\nThe angle in degrees is extracted from the output filenames,\nwhich must follow
\n\nwhatever_ANGLE.out
.Outputs from SCF calculations must be located in the provided
\n", "signature": "(\tfolder=None,\toutput: str = 'potential.dat',\tinclude: list = ['.out'],\tignore: list = ['slurm-']) -> None:", "funcdef": "def"}, {"fullname": "aton.qrotor.potential.interpolate", "modulename": "aton.qrotor.potential", "qualname": "interpolate", "kind": "function", "doc": "folder
(CWD if None).\nFiles can be filtered by those containing the specifiedfilters
,\nexcluding those containing any string from theignore
list. \nTheoutput
name ispotential.dat
by default.Interpolates the current
\n", "signature": "(system: aton.qrotor.classes.QSys) -> aton.qrotor.classes.QSys:", "funcdef": "def"}, {"fullname": "aton.qrotor.potential.solve", "modulename": "aton.qrotor.potential", "qualname": "solve", "kind": "function", "doc": "aton.qrotor.classes.QSys.potential_values
to a new grid of sizeaton.qrotor.classes.QSys.gridsize
.Solves
\n\naton.qrotor.classes.QSys.potential_values
,\naccording to theaton.qrotor.classes.QSys.potential_name
.\nReturns the newpotential_values
.If
\n\nQSys.potential_name
is not present or not recognised,\nthe currentQSys.potential_values
are used.If a bigger
\n", "signature": "(system: aton.qrotor.classes.QSys):", "funcdef": "def"}, {"fullname": "aton.qrotor.potential.zero", "modulename": "aton.qrotor.potential", "qualname": "zero", "kind": "function", "doc": "QSys.gridsize
is provided,\nthe potential is also interpolated to the new gridsize.Zero potential.
\n", "signature": "(system: aton.qrotor.classes.QSys):", "funcdef": "def"}, {"fullname": "aton.qrotor.potential.sine", "modulename": "aton.qrotor.potential", "qualname": "sine", "kind": "function", "doc": "Sine potential.
\n\nIf potential_constants are provided, returns:\n$C_0 + C_1 sin(3x + C_2)$.
\n", "signature": "(system: aton.qrotor.classes.QSys):", "funcdef": "def"}, {"fullname": "aton.qrotor.potential.titov2023", "modulename": "aton.qrotor.potential", "qualname": "titov2023", "kind": "function", "doc": "Potential energy function of the hindered methyl rotor, from titov2023.
\n", "signature": "(system: aton.qrotor.classes.QSys):", "funcdef": "def"}, {"fullname": "aton.qrotor.rotate", "modulename": "aton.qrotor.rotate", "kind": "module", "doc": "Description
\n\nThis submodule contains tools to rotate molecular structures.\nWorks with Quantum ESPRESSO input files.
\n\nIndex
\n\n\n\n
\n\n\n \n\n\n\n \n \n \n\n qe()
Rotate specific atoms from a Quantum ESPRESSO input file \n\n \n\n\n rotate_coords()
Rotate a specific list of coordinates \n
\n"}, {"fullname": "aton.qrotor.rotate.qe", "modulename": "aton.qrotor.rotate", "qualname": "qe", "kind": "function", "doc": "Rotates atoms from a Quantum ESPRESSO input file.
\n\nTakes a
\n\nfilepath
with a molecular structure, and three or more atomicpositions
(list).\nThese input positions can be approximate, and are used to identify the target atoms.\nThe decimal precision in the search for these positions is controlled byprecision
.It rotates the atoms by the geometrical center of the first 3 atoms by a specific
\n\nangle
.\nAdditionally, ifrepeat = True
it repeats the same rotation over the whole circunference.\nFinally, it writes the rotated structure(s) to a new structural file(s).\nReturns a list with the output filename(s).To debug,
\n", "signature": "(\tfilepath: str,\tpositions: list,\tangle: float,\trepeat: bool = False,\tprecision: int = 3,\tshow_axis: bool = False) -> list:", "funcdef": "def"}, {"fullname": "aton.qrotor.rotate.rotate_coords", "modulename": "aton.qrotor.rotate", "qualname": "rotate_coords", "kind": "function", "doc": "show_axis = True
adds two additional helium atoms as the rotation vector.Rotates geometrical coordinates.
\n\nTakes a list of atomic
\n\npositions
in cartesian coordinates, as\n[[x1,y1,z1], [x2,y2,z2], [x3,y3,z3]], [etc]
.\nThen rotates said coordinates by a givenangle
(degrees),\ntaking the perpendicular axis that passes through the\ngeometrical center of the first three points as the axis of rotation.\nAny additional coordinates are rotated with the same rotation matrix.\nReturns a list with the updated positions.If
\n", "signature": "(positions: list, angle: float, show_axis: bool = False) -> list:", "funcdef": "def"}, {"fullname": "aton.qrotor.solve", "modulename": "aton.qrotor.solve", "kind": "module", "doc": "show_axis = True
it returns two additional coordinates at the end of the list,\nwith the centroid and the rotation vector.Description
\n\nThis module is used to solve the hamiltonian eigenvalues and eigenvectors for a given quantum system.\nSparse matrices are used to achieve optimal performance.
\n\nIndex
\n\n\n\n
\n\n\n \n\n\n\n \n \n \n\n energies()
Solve the system(s) for the \nQSys
orQExp
object\n \n\n potential()
Solve the potential values of the system \n\n \n\n schrodinger()
Solve the Schr\u00f6diger equation for the system \n\n \n\n hamiltonian_matrix()
Calculate the hamiltonian matrix of the system \n\n \n\n\n laplacian_matrix()
Calculate the second derivative matrix for a given grid \n
\n"}, {"fullname": "aton.qrotor.solve.energies", "modulename": "aton.qrotor.solve", "qualname": "energies", "kind": "function", "doc": "Solves the Schr\u00f6dinger equation for a given
\n", "signature": "(var, filename: str = None) -> aton.qrotor.classes.QExp:", "funcdef": "def"}, {"fullname": "aton.qrotor.solve.potential", "modulename": "aton.qrotor.solve", "qualname": "potential", "kind": "function", "doc": "aton.qrotor.classes.QSys
oraton.qrotor.classes.QExp
object.Solves the potential_values of the system.
\n\nIt uses the potential name, by calling
\n", "signature": "(system: aton.qrotor.classes.QSys) -> aton.qrotor.classes.QSys:", "funcdef": "def"}, {"fullname": "aton.qrotor.solve.schrodinger", "modulename": "aton.qrotor.solve", "qualname": "schrodinger", "kind": "function", "doc": "aton.qrotor.potential.solve
.\nThen it applies extra operations, such as removing the potential offset\nifaton.qrotor.classes.QSys.correct_potential_offset = True
.Solves the Schr\u00f6dinger equation for a given
\n\naton.qrotor.classes.QSys
object.Uses ARPACK in shift-inverse mode to solve the hamiltonian sparse matrix.
\n", "signature": "(system: aton.qrotor.classes.QSys) -> aton.qrotor.classes.QSys:", "funcdef": "def"}, {"fullname": "aton.qrotor.solve.hamiltonian_matrix", "modulename": "aton.qrotor.solve", "qualname": "hamiltonian_matrix", "kind": "function", "doc": "Calculates the Hamiltonian matrix for a given
\n", "signature": "(system: aton.qrotor.classes.QSys):", "funcdef": "def"}, {"fullname": "aton.qrotor.solve.laplacian_matrix", "modulename": "aton.qrotor.solve", "qualname": "laplacian_matrix", "kind": "function", "doc": "aton.qrotor.classes.QSys
object.Calculates the Laplacian (second derivative) matrix for a given
\n", "signature": "(grid):", "funcdef": "def"}, {"fullname": "aton.spx", "modulename": "aton.spx", "kind": "module", "doc": "grid
.Spectra analysis
\n\nThis module contains spectral analysis tools.
\n\nIndex
\n\n\n\n
\n\n\n \n\n\n\n \n \n \n\n aton.spx.classes
Definition of the \nSpectra
,Plotting
andMaterial
classes, instantiated asaton.spx.Class()
\n \n\n aton.spx.fit
Spectral fitting functions \n\n \n\n aton.spx.normalize
Spectra normalisation \n\n \n\n aton.spx.deuterium
Deuteration estimation functions \n\n \n\n aton.spx.samples
Material definition examples \n\n \n\n\n aton.spx.plot
Spectra plotting, as \naton.spx.plot(Spectra)
Examples
\n\nTo load two INS spectra CSV files with cm$^{-1}$ as input units,\nand plot them in meV units, normalizing their heights over the range from 20 to 50 meV:
\n\n\n\n\n\nfrom aton import spx\n# Set plotting parameters\nplotting_options = spx.Plotting(\n title = 'Calculated INS',\n )\n# Load the spectral data\nins = spx.Spectra(\n type = 'INS',\n files = ['example_1.csv', 'example_2.csv'],\n units_in = 'cm-1',\n units = 'meV',\n plotting = plotting_options,\n )\n# Normalize the spectra\nspx.height(spectra=ins, range=[20, 50])\n# Plot the spectra\nspx.plot(ins)\n
More examples in the
\n"}, {"fullname": "aton.spx.classes", "modulename": "aton.spx.classes", "kind": "module", "doc": "Aton/examples/
folder.Description
\n\nThis module contains common classes used to load and manipulate spectral data.\nAny class can be instantiated directly from the
\n\naton.spx
module,\nasaton.spx.Class()
.Index
\n\n\n\n
\n\n\n \n\n\n\n \n \n \n\n Spectra
Used to load and process spectral data \n\n \n\n Plotting
Stores plotting options, used in \nSpectra.plotting
\n \n\n\n Material
Used to store and calculate material parameters, such as molar masses and neutron cross sections \nExamples
\n\nTo load two INS spectra CSV files with cm$^{-1}$ as input units,\nconverting them to meV units, and finally plotting them:
\n\n\n\n\n\nfrom aton import spx\nins = spx.Spectra(\n type = 'ins',\n files = ['example_1.csv', 'example_2.csv'],\n units_in = 'cm-1',\n units = 'meV',\n )\nspx.plot(ins)\n
Check more use examples in the
\n\nATON/examples/
folder.
\n"}, {"fullname": "aton.spx.classes.Plotting", "modulename": "aton.spx.classes", "qualname": "Plotting", "kind": "class", "doc": "Stores plotting options, read by
\n"}, {"fullname": "aton.spx.classes.Plotting.__init__", "modulename": "aton.spx.classes", "qualname": "Plotting.__init__", "kind": "function", "doc": "aton.spx.plot
Default values can be overwritten when initializing the Plotting object.
\n", "signature": "(\ttitle: str = None,\txlim=None,\tylim=None,\tmargins: list = [0, 0],\toffset=True,\tscaling: float = 1.0,\tvline: list = None,\tvline_error: list = None,\tfigsize: tuple = None,\tlog_xscale: bool = False,\tshow_yticks: bool = False,\txlabel: str = None,\tylabel: str = None,\tlegend=None,\tlegend_title: str = None,\tlegend_size='medium',\tlegend_loc='best',\tsave_as: str = None)"}, {"fullname": "aton.spx.classes.Plotting.title", "modulename": "aton.spx.classes", "qualname": "Plotting.title", "kind": "variable", "doc": "Title of the plot. Set it to an empty string to remove the title.
\n"}, {"fullname": "aton.spx.classes.Plotting.xlim", "modulename": "aton.spx.classes", "qualname": "Plotting.xlim", "kind": "variable", "doc": "List with the x-limits of the plot, as in
\n"}, {"fullname": "aton.spx.classes.Plotting.ylim", "modulename": "aton.spx.classes", "qualname": "Plotting.ylim", "kind": "variable", "doc": "[xlim_low, xlim_top]
.List with the y-limits of the plot, as in
\n"}, {"fullname": "aton.spx.classes.Plotting.margins", "modulename": "aton.spx.classes", "qualname": "Plotting.margins", "kind": "variable", "doc": "[ylim_low, ylim_top]
.List with additional margins at the bottom and top of the plot, as in
\n"}, {"fullname": "aton.spx.classes.Plotting.offset", "modulename": "aton.spx.classes", "qualname": "Plotting.offset", "kind": "variable", "doc": "[low_margin, top_margin]
.If
\n\nTrue
, the plots will be separated automatically.It can be set to a float, to equally offset the plots by a given value.
\n"}, {"fullname": "aton.spx.classes.Plotting.scaling", "modulename": "aton.spx.classes", "qualname": "Plotting.scaling", "kind": "variable", "doc": "Scaling factor
\n"}, {"fullname": "aton.spx.classes.Plotting.vline", "modulename": "aton.spx.classes", "qualname": "Plotting.vline", "kind": "variable", "doc": "Vertical line/s to plot. Can be an int or float with the x-position, or a list with several ones.
\n"}, {"fullname": "aton.spx.classes.Plotting.vline_error", "modulename": "aton.spx.classes", "qualname": "Plotting.vline_error", "kind": "variable", "doc": "Plot a shaded area of the specified width around the vertical lines specified at
\n\nvline
.It can be an array of the same length as
\n"}, {"fullname": "aton.spx.classes.Plotting.figsize", "modulename": "aton.spx.classes", "qualname": "Plotting.figsize", "kind": "variable", "doc": "vline
, or a single value to be applied to all.Tuple with the figure size, as in matplotlib.
\n"}, {"fullname": "aton.spx.classes.Plotting.log_xscale", "modulename": "aton.spx.classes", "qualname": "Plotting.log_xscale", "kind": "variable", "doc": "If true, plot the x-axis in logarithmic scale.
\n"}, {"fullname": "aton.spx.classes.Plotting.show_yticks", "modulename": "aton.spx.classes", "qualname": "Plotting.show_yticks", "kind": "variable", "doc": "Show or not the yticks on the plot.
\n"}, {"fullname": "aton.spx.classes.Plotting.xlabel", "modulename": "aton.spx.classes", "qualname": "Plotting.xlabel", "kind": "variable", "doc": "Custom label of the x-axis.
\n\nIf
\n"}, {"fullname": "aton.spx.classes.Plotting.ylabel", "modulename": "aton.spx.classes", "qualname": "Plotting.ylabel", "kind": "variable", "doc": "None
, the default label will be used.\nSet to''
to remove the label of the horizontal axis.Custom label of the y-axis.
\n\nIf
\n"}, {"fullname": "aton.spx.classes.Plotting.legend", "modulename": "aton.spx.classes", "qualname": "Plotting.legend", "kind": "variable", "doc": "None
, the default label will be used.\nSet to''
to remove the label of the vertical axis.Legend of the plot.
\n\nIf
\n"}, {"fullname": "aton.spx.classes.Plotting.legend_title", "modulename": "aton.spx.classes", "qualname": "Plotting.legend_title", "kind": "variable", "doc": "None
, the filenames will be used as legend.\nCan be a bool to show or hide the plot legend.\nIt can also be an array containing the strings to display;\nin that case, elements set toFalse
will not be displayed.Title of the legend, defaults to
\n"}, {"fullname": "aton.spx.classes.Plotting.legend_size", "modulename": "aton.spx.classes", "qualname": "Plotting.legend_size", "kind": "variable", "doc": "None
.Size of the legend, as in matplotlib. Defaults to
\n"}, {"fullname": "aton.spx.classes.Plotting.legend_loc", "modulename": "aton.spx.classes", "qualname": "Plotting.legend_loc", "kind": "variable", "doc": "'medium'
.Location of the legend, as in matplotlib. Defaults to
\n"}, {"fullname": "aton.spx.classes.Plotting.save_as", "modulename": "aton.spx.classes", "qualname": "Plotting.save_as", "kind": "variable", "doc": "'best'
.Filename to save the plot. None by default.
\n"}, {"fullname": "aton.spx.classes.Spectra", "modulename": "aton.spx.classes", "qualname": "Spectra", "kind": "class", "doc": "Spectra object. Used to load and process spectral data.
\n\nMost functions in the
\n"}, {"fullname": "aton.spx.classes.Spectra.__init__", "modulename": "aton.spx.classes", "qualname": "Spectra.__init__", "kind": "function", "doc": "aton.spx
module receive this object as input.All values can be set when initializing the Spectra object.
\n", "signature": "(\ttype: str = None,\tcomment: str = None,\tfiles=None,\tdfs=None,\tunits=None,\tunits_in=None,\tplotting: aton.spx.classes.Plotting = <aton.spx.classes.Plotting object>)"}, {"fullname": "aton.spx.classes.Spectra.type", "modulename": "aton.spx.classes", "qualname": "Spectra.type", "kind": "variable", "doc": "Type of the spectra:
\n"}, {"fullname": "aton.spx.classes.Spectra.comment", "modulename": "aton.spx.classes", "qualname": "Spectra.comment", "kind": "variable", "doc": "'INS'
,'ATR'
, or'RAMAN'
.Custom comment. If
\n"}, {"fullname": "aton.spx.classes.Spectra.files", "modulename": "aton.spx.classes", "qualname": "Spectra.files", "kind": "variable", "doc": "Plotting.title
is None, it will be the title of the plot.List containing the files with the spectral data.
\n\nLoaded automatically to
\n"}, {"fullname": "aton.spx.classes.Spectra.dfs", "modulename": "aton.spx.classes", "qualname": "Spectra.dfs", "kind": "variable", "doc": "dfs
with Pandas at initialization.\nIn order for Pandas to read the files properly, note that the column lines must start by#
.\nAny additional line that is not data must be removed or commented with#
.\nCSV files must be formatted with the first column as the energy or energy transfer,\nand the second column with the intensity or absorbance, depending on the case.\nAn additional third'Error'
column can be used.List containing the pandas dataframes with the spectral data.
\n\nLoaded automatically from
\n"}, {"fullname": "aton.spx.classes.Spectra.units", "modulename": "aton.spx.classes", "qualname": "Spectra.units", "kind": "variable", "doc": "files
at initialization.Target units of the spectral data.
\n\nCan be
\n"}, {"fullname": "aton.spx.classes.Spectra.units_in", "modulename": "aton.spx.classes", "qualname": "Spectra.units_in", "kind": "variable", "doc": "'meV'
or'cm-1'
.Input units of the spectral data, used in the input CSV files.
\n\nCan be
\n"}, {"fullname": "aton.spx.classes.Spectra.plotting", "modulename": "aton.spx.classes", "qualname": "Spectra.plotting", "kind": "variable", "doc": "'meV'
or'cm-1'
.\nIf the input CSV files have different units,\nit can also be set as a list of the same length of the number of input files,\neg.['meV', 'cm-1', 'cm-1']
.\n"}, {"fullname": "aton.spx.classes.Spectra.set_units", "modulename": "aton.spx.classes", "qualname": "Spectra.set_units", "kind": "function", "doc": "
Plotting
object, used to set the plotting options.Method to change between spectral units. ALWAYS use this method to do that.
\n\nFor example, to change to meV from cm-1:
\n\n\n\n", "signature": "(self, units, units_in=None, default_unit='cm-1'):", "funcdef": "def"}, {"fullname": "aton.spx.classes.Material", "modulename": "aton.spx.classes", "qualname": "Material", "kind": "class", "doc": "\nSpectra.set_units('meV', 'cm-1')\n
Material class.
\n\nUsed to calculate molar masses and cross sections,\nand to pass data to different analysis functions\nsuch as
\n"}, {"fullname": "aton.spx.classes.Material.__init__", "modulename": "aton.spx.classes", "qualname": "Material.__init__", "kind": "function", "doc": "aton.spectra.deuterium.impulse_approx().
All values can be set when initializing the Material object.\nHowever, it is recommended to only set the elements and the grams,\nand optionally the name, and calculate the rest with
\n", "signature": "(\telements: dict,\tname: str = None,\tgrams: float = None,\tgrams_error: float = None,\tmols: float = None,\tmols_error: float = None,\tmolar_mass: float = None,\tcross_section: float = None,\tpeaks: dict = None)"}, {"fullname": "aton.spx.classes.Material.elements", "modulename": "aton.spx.classes", "qualname": "Material.elements", "kind": "variable", "doc": "Material.set()
.Dict of atoms in the material, as in
\n\n{'H': 6, 'C':1, 'N':1}
.Isotopes can be expressed as 'H2', 'He4', etc. with the atom symbol + isotope mass number.
\n"}, {"fullname": "aton.spx.classes.Material.name", "modulename": "aton.spx.classes", "qualname": "Material.name", "kind": "variable", "doc": "String with the name of the material.
\n"}, {"fullname": "aton.spx.classes.Material.grams", "modulename": "aton.spx.classes", "qualname": "Material.grams", "kind": "variable", "doc": "Mass, in grams.
\n"}, {"fullname": "aton.spx.classes.Material.grams_error", "modulename": "aton.spx.classes", "qualname": "Material.grams_error", "kind": "variable", "doc": "Error of the measured mass in grams.
\n\nSet automatically with
\n"}, {"fullname": "aton.spx.classes.Material.mols", "modulename": "aton.spx.classes", "qualname": "Material.mols", "kind": "variable", "doc": "Material.set()
.Number of moles.
\n\nSet automatically with
\n"}, {"fullname": "aton.spx.classes.Material.mols_error", "modulename": "aton.spx.classes", "qualname": "Material.mols_error", "kind": "variable", "doc": "Material.set()
.Error of the number of moles.
\n\nSet automatically with
\n"}, {"fullname": "aton.spx.classes.Material.molar_mass", "modulename": "aton.spx.classes", "qualname": "Material.molar_mass", "kind": "variable", "doc": "Material.set()
.Molar mass of the material, in mol/g.
\n\nCalculated automatically with
\n"}, {"fullname": "aton.spx.classes.Material.cross_section", "modulename": "aton.spx.classes", "qualname": "Material.cross_section", "kind": "variable", "doc": "Material.set()
.Neutron total bound scattering cross section, in barns.
\n\nCalculated automatically with
\n"}, {"fullname": "aton.spx.classes.Material.peaks", "modulename": "aton.spx.classes", "qualname": "Material.peaks", "kind": "variable", "doc": "Material.set()
.Dict with interesting peaks that you might want to store for later use.
\n"}, {"fullname": "aton.spx.classes.Material.set", "modulename": "aton.spx.classes", "qualname": "Material.set", "kind": "function", "doc": "Set the molar mass, cross section and errors of the material.
\n", "signature": "(self):", "funcdef": "def"}, {"fullname": "aton.spx.classes.Material.print", "modulename": "aton.spx.classes", "qualname": "Material.print", "kind": "function", "doc": "Print a summary with the material information.
\n", "signature": "(self):", "funcdef": "def"}, {"fullname": "aton.spx.deuterium", "modulename": "aton.spx.deuterium", "kind": "module", "doc": "Description
\n\nThis module contains methods to calculate deuteration levels from different spectra.
\n\nIndex
\n\n\n\n
\n\n\n \n\n\n\n \n \n \n\n impulse_approx()
Calculate the deuteration levels from INS spectra with the Impulse Approximation \n\n \n\n\n peaks_mapbi3()
Estimates CH$_3$NH$_3$PbI$_3$ deuteration by integrating the INS disrotatory peaks \n
\n"}, {"fullname": "aton.spx.deuterium.impulse_approx", "modulename": "aton.spx.deuterium", "qualname": "impulse_approx", "kind": "function", "doc": "Calculate the deuteration levels from INS spectra\nwith the Impulse Approximation, see\nhttps://www.tandfonline.com/doi/full/10.1080/00018732.2017.1317963.
\n\nProtonated and deuterated materials must be specified\nas
\n\naton.spectra.classes.Material
objects.\nNote that this approximation is very sensitive to the mass sample.\nThe threshold controls the start of the plateau (in meV)\nto start considering Deep Inelastic Neutron Scattering (DINS).\nThe protonated and deuterated dataframe indexes are specified\nbyH_df_index
andD_df_index
, respectively.In this approximation, the ideal ratio between\nthe cross-sections and the experimental ratio between\nthe pleteaus at high energies should be the same:\n$$\n\\frac{\\text{plateau_D}}{\\text{plateau_H}} \\approx \\frac{\\text{cross_section_D}}{\\text{cross_section_H}}\n$$\nTaking this into account, the deuteration is estimated as:\n$$\n\\text{Deuteration} = \\frac{1-\\text{real_ratio}}{1-\\text{ideal_ratio}}\n$$
\n", "signature": "(\tins: aton.spx.classes.Spectra,\tmaterial_H: aton.spx.classes.Material,\tmaterial_D: aton.spx.classes.Material,\tthreshold: float = 600,\tH_df_index: int = 0,\tD_df_index: int = 1) -> tuple:", "funcdef": "def"}, {"fullname": "aton.spx.deuterium.peaks_mapbi3", "modulename": "aton.spx.deuterium", "qualname": "peaks_mapbi3", "kind": "function", "doc": "Estimates CH$_3$NH$_3$PbI$_3$ deuteration by integrating the INS disrotatory peaks.
\n\nThe INS disrotatory peaks of CH3NH3 appear at ~38 meV for the fully protonated sample.\nNote that
\n\npeaks
must be a dictionary with the peak limits\nand the baseline, as in the example below:\n\n\n\npeaks = {\n 'baseline' : None,\n 'baseline_error' : None,\n 'h6d0' : [41, 43],\n 'h5d1' : [41, 43],\n 'h4d2' : [41, 43],\n 'h3d3' : [34.7, 37.3],\n 'h2d4' : [31.0, 33.0],\n 'h1d5' : [28.0, 30.5],\n 'h0d6' : [26.5, 28.0],\n }\n
Peak keywords required for selective deuteration (only C or only N):\n
\n\nh6d0
,h5d1
,h4d2
,h3d3
.Additional peak keywords required for total deuteration:\n
\n\nh2d4
,h1d5
,h0d6
.If some peak is not present in your sample,\njust set the limits to a small baseline plateau.
\n", "signature": "(ins: aton.spx.classes.Spectra, peaks: dict, df_index: int = 0) -> str:", "funcdef": "def"}, {"fullname": "aton.spx.fit", "modulename": "aton.spx.fit", "kind": "module", "doc": "Description
\n\nThis module contains functions for fitting and analyzing spectral data.
\n\nIndex
\n\n\n\n
\n\n\n \n\n\n\n \n \n \n\n plateau()
Fit the mean value and the error of a plateau \n\n \n\n area_under_peak()
Calculate the area under a given peak \n\n \n\n ratio_areas()
Check the ratio between two areas \n\n \n\n\n mean()
Get the mean and standard deviation of a list of values \n
\n"}, {"fullname": "aton.spx.fit.plateau", "modulename": "aton.spx.fit", "qualname": "plateau", "kind": "function", "doc": "Fit the mean value and the error of a plateau in a
\n\naton.spectra.Spectra
object.Use as
\n\naton.spx.fit.plateau(spectra, cuts=[low_cut, high_cut], df_index=0)
.If
\n\naton.spx.classes.Spectra.dfs[df_index]
has an 'Error' column, those errors are also taken into account\nalong with the standard deviation of the mean, else only the standard deviation is considered.\nThis is the case if your dataset had a third column with the errors\nwhen you imported theaton.spx.classes.Spectra
object.Note that
\n", "signature": "(spectra: aton.spx.classes.Spectra, cuts=None, df_index: int = 0) -> tuple:", "funcdef": "def"}, {"fullname": "aton.spx.fit.area_under_peak", "modulename": "aton.spx.fit", "qualname": "area_under_peak", "kind": "function", "doc": "cuts
,low_cut
and/ortop_cut
can be set to None.Calculate the area under a given peak.
\n\nPeaks must be defined as
\n", "signature": "(\tspectra: aton.spx.classes.Spectra,\tpeak: list,\tdf_index: int = 0,\terrors_as_in_baseline: bool = True,\tmin_as_baseline: bool = False) -> tuple:", "funcdef": "def"}, {"fullname": "aton.spx.fit.ratio_areas", "modulename": "aton.spx.fit", "qualname": "ratio_areas", "kind": "function", "doc": "peak:list=[xmin, xmax, baseline=0, baseline_error=0]
.\nIf the dataset has noError
column, the error for each point is assumed to be the same\nas the baseline error iferrors_as_in_baseline=True
, otherwise it is assumed to be zero.\nIfmin_as_baseline=True
andbaseline=0
, the baseline is assumed to be the minimum value.\nAlso, ifmin_as_baseline=True
and there are negative areas even after applying the baseline,\nthe baseline will be corrected to the minimum value.Check the ratio between two areas, e.g. to estimate deuteration levels from ATR data.
\n\nThe ratio is calculated as
\n", "signature": "(\tarea: float,\tarea_total: float,\tarea_error: float = 0.0,\tarea_total_error: float = 0.0,\tinverse_ratio: bool = False) -> tuple:", "funcdef": "def"}, {"fullname": "aton.spx.fit.mean", "modulename": "aton.spx.fit", "qualname": "mean", "kind": "function", "doc": "area / area_total
. This behavior is modified ifinverse_ratio = True
,\nso that the ratio is calculated as(area_total - area) / area_total
.\nNote that changing the ratio calculation also affects the error propagation.Takes an
\n\narray
of numerical values and returns the mean and standard deviation.It is calculated with numpy as:
\n\n$\\sigma_{x}=\\sqrt{\\frac{\\sum{(x_{i}-{\\overline{x}})^2}}{N-\\text{ddof}}}$
\n\nwhere ddof are the delta
\n\ndegrees_of_freedom
, zero by default.\nSet it to1
for a corrected sample standard deviation (low N cases),\nsee more details here.The mean is rounded up to the order of the error by default. To override this behaviour, set
\n", "signature": "(array: list, rounded: bool = True, degrees_of_freedom=0) -> tuple:", "funcdef": "def"}, {"fullname": "aton.spx.normalize", "modulename": "aton.spx.normalize", "kind": "module", "doc": "rounded=False
.Description
\n\nThis module contains functions to normalize data and other variables.
\n\nIndex
\n\n\n\n
\n\n\n \n\n\n\n \n \n \n\n height()
Normalize a \nspectra
by height\n \n\n area()
Normalize a \nspectra
by the area under the datasets\n \n\n\n unit_str()
Normalize a \nunit
string from user input
\n"}, {"fullname": "aton.spx.normalize.height", "modulename": "aton.spx.normalize", "qualname": "height", "kind": "function", "doc": "Normalize a set of
\n\nspectra
by height.By default it normalises the spectra over the entire range.\nThis can be modified by setting a specific range,\nas in
\n\nrange = [x_min, x_max]
withaxis = 'x'
.\nIt can also normalise over manual y-positions,\nfor example for peaks with different baselines.\nThis can be done by settingchaxis='y'
, and\nrange = [[y_min_1, y_max_1], ..., [y_min_N, y_max_N]]
.Heights are normalised with respect to the\nreference dataframe
\n", "signature": "(\tspectra: aton.spx.classes.Spectra,\trange: list = None,\taxis: str = 'x',\tdf_index: int = 0) -> aton.spx.classes.Spectra:", "funcdef": "def"}, {"fullname": "aton.spx.normalize.area", "modulename": "aton.spx.normalize", "qualname": "area", "kind": "function", "doc": "df_index
, the first one by default.Normalize
\n", "signature": "(\tspectra: aton.spx.classes.Spectra,\trange: list = None,\tdf_index: int = 0) -> aton.spx.classes.Spectra:", "funcdef": "def"}, {"fullname": "aton.spx.normalize.unit_str", "modulename": "aton.spx.normalize", "qualname": "unit_str", "kind": "function", "doc": "spectra
by the area under the datasets.Normalize
\n", "signature": "(unit: str):", "funcdef": "def"}, {"fullname": "aton.spx.plot", "modulename": "aton.spx.plot", "kind": "module", "doc": "unit
string from user input.Description
\n\nThis module contains the
\n\nplot()
function,\nused to plotaton.spx.classes.Spectra
data,\ncontaining optionalaton.spx.classes.Plotting
parameters.It is used as
\n\naton.spx.plot(Spectra)
\n"}, {"fullname": "aton.spx.plot.plot", "modulename": "aton.spx.plot", "qualname": "plot", "kind": "function", "doc": "Plots a
\n\nspectra
.Optional
\n", "signature": "(spectra: aton.spx.classes.Spectra):", "funcdef": "def"}, {"fullname": "aton.spx.samples", "modulename": "aton.spx.samples", "kind": "module", "doc": "aton.spectra.classes.Plotting
attributes can be used.Description
\n\nThis module contains premade examples of material compositions, for testing purposes.\nThe
\n\naton.spx.classes.Material.grams
is yet to be provided,\nbefore setting the material asaton.spx.Material.set()
.
\n"}, {"fullname": "aton.spx.samples.CH3NH3PbI3", "modulename": "aton.spx.samples", "qualname": "CH3NH3PbI3", "kind": "variable", "doc": "CH$_3$NH$_3$PbI$_3$
\n", "default_value": "<aton.spx.classes.Material object>"}, {"fullname": "aton.spx.samples.CD3ND3PbI3", "modulename": "aton.spx.samples", "qualname": "CD3ND3PbI3", "kind": "variable", "doc": "CD$_3$ND$_3$PbI$_3$.
\n\nWith experimental values of the partially-deuterated amine peaks\nfor the disrotatory mode of MAPbI3's methylammonium.\nMeasured at TOSCA, ISIS RAL, UK, May 2024.
\n", "default_value": "<aton.spx.classes.Material object>"}, {"fullname": "aton.spx.samples.CH3ND3PbI3", "modulename": "aton.spx.samples", "qualname": "CH3ND3PbI3", "kind": "variable", "doc": "CH$_3$ND$_3$PbI$_3$.
\n\nWith experimental values of the partially-deuterated amine peaks\nfor the disrotatory mode of MAPbI3's methylammonium.\nMeasured at TOSCA, ISIS RAL, UK, May 2024.
\n", "default_value": "<aton.spx.classes.Material object>"}, {"fullname": "aton.spx.samples.CD3NH3PbI3", "modulename": "aton.spx.samples", "qualname": "CD3NH3PbI3", "kind": "variable", "doc": "CD$_3$NH$_3$PbI$_3$
\n", "default_value": "<aton.spx.classes.Material object>"}, {"fullname": "aton.spx.samples.CH3NH3I", "modulename": "aton.spx.samples", "qualname": "CH3NH3I", "kind": "variable", "doc": "CH$_3$NH$_3$I
\n", "default_value": "<aton.spx.classes.Material object>"}, {"fullname": "aton.spx.samples.CH3ND3I", "modulename": "aton.spx.samples", "qualname": "CH3ND3I", "kind": "variable", "doc": "CH$_3$ND$_3$I
\n", "default_value": "<aton.spx.classes.Material object>"}, {"fullname": "aton.st", "modulename": "aton.st", "kind": "module", "doc": "System Tools
\n\nCommon system tools across all ATON subpackages.
\n\nIndex
\n\n\n\n
\n"}, {"fullname": "aton.st.alias", "modulename": "aton.st.alias", "kind": "module", "doc": "\n \n\n\n\n \n \n \n\n aton.st.file
File manipulation \n\n \n\n aton.st.call
Run bash scripts and related \n\n \n\n\n aton.st.alias
Useful dictionaries for user input correction \nDescription
\n\nThis module contains common dictionaries to normalise and correct user inputs.\nAll values can be found in lowercase, to allow comparison with the
\n\nstring.lower()
method.Index
\n\n\n\n
units
\nspatial
\nexperiments
\nfiles
\nboolean
Examples
\n\n\n\n\n\nunit = 'Electronvolts'\nif unit.lower() in aton.alias.units['eV']:\n ... do stuff ...\n
\n"}, {"fullname": "aton.st.alias.units", "modulename": "aton.st.alias", "qualname": "units", "kind": "variable", "doc": "Dict with unit names.
\n", "annotation": ": dict", "default_value": "{'mol': ['mol', 'mols', 'mole', 'moles'], 'g': ['g', 'gram', 'grams'], 'kg': ['kg', 'kilogram', 'kilograms'], 'amu': ['amu', 'atomicmassunit', 'atomicmassunits'], 'eV': ['eV', 'ev', 'electronvolt', 'electronvolts'], 'meV': ['meV', 'mev', 'millielectronvolt', 'millielectronvolts'], 'J': ['J', 'j', 'joule', 'joules'], 'cal': ['cal', 'calorie', 'calories'], 'kcal': ['kcal', 'kilocalorie', 'kilocalories'], 'Ry': ['Ry', 'ry', 'rydberg', 'rydbergs'], 'cm-1': ['cm^{-1}', 'cm1', 'cm-1', 'cm^-1'], 'cm': ['cm', 'centimeter', 'centimeters'], 'A': ['A', 'a', 'aa', 'angstrom', 'angstroms', 'armstrong', 'armstrongs'], 'bohr': ['bohr', 'bohrs', 'bohrradii'], 'm': ['m', 'meter', 'meters'], 'deg': ['deg', 'degree', 'degrees'], 'rad': ['rad', 'radian', 'radians'], 'bar': ['bar', 'bars'], 'kbar': ['kbar', 'kilobar', 'kilobars'], 'Pa': ['Pa', 'pa', 'pascal', 'pascals'], 'GPa': ['GPa', 'gpa', 'gigapascal', 'gigapascals'], 's': ['s', 'second', 'seconds'], 'H': ['H', 'h', 'hour', 'hours']}"}, {"fullname": "aton.st.alias.spatial", "modulename": "aton.st.alias", "qualname": "spatial", "kind": "variable", "doc": "Dict with different spatial parameters. Values must be compared to
\n", "annotation": ": dict", "default_value": "{'height': ['height', 'h'], 'area': ['area', 'a'], 'volume': ['volume', 'vol'], 'x': ['x', 'horizontal', 'h'], 'y': ['y', 'vertical', 'v'], 'z': ['z']}"}, {"fullname": "aton.st.alias.chemical", "modulename": "aton.st.alias", "qualname": "chemical", "kind": "variable", "doc": "string.lower()
.Dict with chemical groups.
\n", "annotation": ": dict", "default_value": "{'CH3': ['ch', 'CH', 'ch3', 'CH3', 'methyl'], 'NH3': ['nh', 'NH', 'nh3', 'NH3', 'amine'], 'CD3': ['cd', 'CD', 'cd3', 'CD3', 'deuterated methyl'], 'ND3': ['nd', 'ND', 'nd3', 'ND3', 'deuterated amine']}"}, {"fullname": "aton.st.alias.experiments", "modulename": "aton.st.alias", "qualname": "experiments", "kind": "variable", "doc": "Dictionary with the available experiment types. Values must be compared to
\n", "annotation": ": dict", "default_value": "{'ins': ['ins', 'inelasticneutronscattering', 'inelastic neutron scattering'], 'atr': ['atr', 'ftir', 'attenuatedtotalreflection', 'attenuated total reflection'], 'raman': ['raman'], 'qens': ['qens', 'quasielasticneutronscattering', 'quasielastic neutron scattering', 'quasi elastic neutron scattering']}"}, {"fullname": "aton.st.alias.files", "modulename": "aton.st.alias", "qualname": "files", "kind": "variable", "doc": "string.lower()
.Strings related to files. Values must be compared to
\n", "annotation": ": dict", "default_value": "{'file': ['file', 'files', 'f', 'filepath', 'file path', 'filename', 'file name'], 'dir': ['dir', 'directory', 'd', 'folder'], 'error': ['error', 'errors', 'e', 'err']}"}, {"fullname": "aton.st.alias.boolean", "modulename": "aton.st.alias", "qualname": "boolean", "kind": "variable", "doc": "string.lower()
.Strings with booleans such as 'yes' / 'no'.
\n", "annotation": ": dict", "default_value": "{True: ['yes', 'YES', 'Yes', 'Y', 'y', 'T', 'True', 'TRUE', 't', 'true', True, 'Si', 'SI', 'si', 'S', 's'], False: ['no', 'NO', 'No', 'N', 'n', 'F', 'False', 'FALSE', 'f', 'false', False]}"}, {"fullname": "aton.st.call", "modulename": "aton.st.call", "kind": "module", "doc": "Description
\n\nFunctions to handle bash calls and related operations on Linux systems.
\n\nIndex
\n\n\n\n
\n\n\n \n\n\n\n \n \n \n\n bash()
Run a bash shell commands \n\n \n\n git()
Automatically update a Git repository \n\n \n\n\n here()
Runs the rest of the script inside a given folder \n
\n"}, {"fullname": "aton.st.call.bash", "modulename": "aton.st.call", "qualname": "bash", "kind": "function", "doc": "Run a bash shell commands.
\n\nA given
\n", "signature": "(\tcommand: str,\tcwd=None,\tverbose: bool = True,\treturn_anyway: bool = False):", "funcdef": "def"}, {"fullname": "aton.st.call.git", "modulename": "aton.st.call", "qualname": "git", "kind": "function", "doc": "command
will be executed inside an optionalcwd
directory.\nIf empty, the current working directory will be used.\nPrints the running command and outputs by default, override this withverbose=False
.\nReturns the result of the command used, except for when\nerrors are raised automatically; setreturn_anyway=True
to override this.Automatically update a Git repository
\n", "signature": "(path=None, verbose=True, message=None, tag=None) -> None:", "funcdef": "def"}, {"fullname": "aton.st.call.here", "modulename": "aton.st.call", "qualname": "here", "kind": "function", "doc": "Runs the rest of the script inside the specified
\n\nfolder
.If none is provided, it runs from the same directory where the current script lies.\nThis is really useful to run scripts from the VSCode terminal, etc.\nReturns the path of the used
\n\nfolder
, or the path of the script if folder is not provided.Note that this changes not only the working directory of your script,\nbut also of other scripts that import and run your script.
\n", "signature": "(folder=None) -> str:", "funcdef": "def"}, {"fullname": "aton.st.file", "modulename": "aton.st.file", "kind": "module", "doc": "Description
\n\nFunctions to move files around.
\n\nIndex
\n\n\n\n
\n\n\n \n\n\n\n \n \n \n\n get()
Check that a file exists, and return the full path \n\n \n\n get_list()
Get a list of the files inside a folder, applying optional filters \n\n \n\n get_dir()
Get the full path of a folder or the cwd \n\n \n\n copy()
Copy file \n\n \n\n move()
Move file \n\n \n\n remove()
Remove file or folder \n\n \n\n rename_on_folder()
Batch rename files from a folder \n\n \n\n rename_on_folders()
Barch rename files from subfolders \n\n \n\n copy_to_folders()
Copy files to individual subfolders \n\n \n\n save()
Save a Python object to a binary file, as \n.aton
\n \n\n\n load()
Load a Python object from a binary file, as \n.aton
\n"}, {"fullname": "aton.st.file.get", "modulename": "aton.st.file", "qualname": "get", "kind": "function", "doc": "Check if
\n\nfilepath
exists, and returns its full path.Raises an error if the file is not found,\nunless
\n\nreturn_anyway = True
, in which case it returns None.\nThis can be used to personalize errors.If the provided string is a directory, it checks the files inside it.\nif there is only one file inside, it returns said file;\nif there are more files, it tries to filter them with the
\n", "signature": "(filepath, filters=None, return_anyway: bool = False) -> str:", "funcdef": "def"}, {"fullname": "aton.st.file.get_list", "modulename": "aton.st.file", "qualname": "get_list", "kind": "function", "doc": "filters
keyword(s) to return a single file.\nIf this fails, try using more strict filers to return a single file.Return the files inside a
\n\nfolder
, applying optional filters.Only filenames containing all strings in the
\n\ninclude
list will be returned.\nFilenames containing any string from theignore
list will be ignored.The full paths are returned by default; to get only the base names, set
\n", "signature": "(\tfolder: str = None,\tinclude=None,\tignore=None,\tabspath: bool = True,\talso_folders: bool = False) -> list:", "funcdef": "def"}, {"fullname": "aton.st.file.get_dir", "modulename": "aton.st.file", "qualname": "get_dir", "kind": "function", "doc": "abspath = False
.\nThe CWD folder is used by default if nofolder
is provided.\nIt also returns folders ifalso_folders = True
.Returns the full path of
\n", "signature": "(folder=None) -> str:", "funcdef": "def"}, {"fullname": "aton.st.file.copy", "modulename": "aton.st.file", "qualname": "copy", "kind": "function", "doc": "folder
or the parent folder if it's a file. If none is provided, the current working directory is returned.Copies
\n", "signature": "(old: str, new: str) -> None:", "funcdef": "def"}, {"fullname": "aton.st.file.move", "modulename": "aton.st.file", "qualname": "move", "kind": "function", "doc": "old
file tonew
fileMoves
\n", "signature": "(old: str, new: str) -> None:", "funcdef": "def"}, {"fullname": "aton.st.file.remove", "modulename": "aton.st.file", "qualname": "remove", "kind": "function", "doc": "old
file tonew
file.Removes the given file or folder at
\n\nfilepath
.\n\n", "signature": "(filepath: str) -> None:", "funcdef": "def"}, {"fullname": "aton.st.file.rename_on_folder", "modulename": "aton.st.file", "qualname": "rename_on_folder", "kind": "function", "doc": "WARNING: Removing stuff is always dangerous, be careful!
\nBatch renames files in the given
\n\nfolder
.Replaces the
\n", "signature": "(old: str, new: str, folder=None) -> None:", "funcdef": "def"}, {"fullname": "aton.st.file.rename_on_folders", "modulename": "aton.st.file", "qualname": "rename_on_folders", "kind": "function", "doc": "old
string bynew
string.\nIf no folder is provided, the current working directory is used.Renames the files inside the subfolders in the parent
\n\nfolder
.Renames from an
\n", "signature": "(old: str, new: str, folder=None) -> None:", "funcdef": "def"}, {"fullname": "aton.st.file.copy_to_folders", "modulename": "aton.st.file", "qualname": "copy_to_folders", "kind": "function", "doc": "old
string to thenew
string.\nIf nofolder
is provided, the current working directory is used.Copies the files from the parent
\n\nfolder
with the givenextension
to individual subfolders.The subfolders are named as the original files,\nremoving the strings from the
\n", "signature": "(folder=None, extension: str = None, strings_to_delete: list = []) -> None:", "funcdef": "def"}, {"fullname": "aton.st.file.save", "modulename": "aton.st.file", "qualname": "save", "kind": "function", "doc": "strings_to_delete
list.\nIf nofolder
is provided, it runs in the current working directory.Save a Python object in the current working directory as a binary
\n", "signature": "(object, filename: str = None):", "funcdef": "def"}, {"fullname": "aton.st.file.load", "modulename": "aton.st.file", "qualname": "load", "kind": "function", "doc": "*.aton
file.Load a Python object from a binary
\n\n*.aton
file.Use only if you trust the person who sent you the file!
\n", "signature": "(filepath: str = 'data.aton'):", "funcdef": "def"}, {"fullname": "aton.txt", "modulename": "aton.txt", "kind": "module", "doc": "General text operations
\n\nThis subpackage contains tools for general text operations.\nIt provides the basic functionality that powers more complex subpackages,\nsuch as
\n\naton.interface
.Index
\n\n\n\n
\n\n\n \n\n\n\n \n \n \n\n aton.txt.find
Search for specific content from a text file \n\n \n\n aton.txt.edit
Edit specific content from a text file \n\n \n\n\n aton.txt.extract
Extract data from raw text strings \nExamples
\n\nThe following example shows how to find a value in a text file, extract it and paste it into another file using the txt subpackage:
\n\n\n\n\n\nfrom aton import txt\n# Get an array with all matches\nalat_lines = txt.find.lines('relax.out', 'Lattice parameter =')\n# Extract the numerical value of the last match\nalat = txt.extract.number(alat_lines[-1], 'Lattice parameter')\n# Paste it into another file\ntxt.edit.replace_line('scf.in', 'Lattice parameter =', f'Lattice parameter ='{alat})\n
Advanced usage such as regular expression matching or\nadditional line extraction is detailed in the API documentation.
\n"}, {"fullname": "aton.txt.edit", "modulename": "aton.txt.edit", "kind": "module", "doc": "Description
\n\nFunctions to manipulate the content of text files.
\n\nIndex
\n\n\n\n
insert_at()
\ninsert_under()
\nreplace()
\nreplace_line()
\nreplace_between()
\ndelete_under()
\ncorrect_with_dict()
\nfrom_template()
\n"}, {"fullname": "aton.txt.edit.insert_at", "modulename": "aton.txt.edit", "qualname": "insert_at", "kind": "function", "doc": "Inserts a
\n\ntext
in the line withposition
index of a givenfilepath
.If
\n", "signature": "(filepath, text: str, position: int) -> None:", "funcdef": "def"}, {"fullname": "aton.txt.edit.insert_under", "modulename": "aton.txt.edit", "qualname": "insert_under", "kind": "function", "doc": "position
is negative, starts from the end of the file.Inserts a
\n\ntext
under the line(s) containing thekey
infilepath
.The keyword can be at any position within the line.\nRegular expressions can be used by setting
\n\nregex=True
.By default all matches are inserted with
\n\ninsertions=0
,\nbut it can insert only a specific number of matches\nwith positive numbers (1, 2...), or starting from the bottom with negative numbers.The text can be introduced after a specific number of lines after the match,\nchanging the value
\n", "signature": "(\tfilepath,\tkey: str,\ttext: str,\tinsertions: int = 0,\tskips: int = 0,\tregex: bool = False) -> None:", "funcdef": "def"}, {"fullname": "aton.txt.edit.replace", "modulename": "aton.txt.edit", "qualname": "replace", "kind": "function", "doc": "skips
. Negative integers introduce the text in the previous lines.Replaces the
\n\nkey
withtext
infilepath
.It can also be used to delete the keyword with
\n\ntext=''
.\nTo search with regular expressions, setregex=True
.The value
\n\nreplacements
specifies the number of replacements to perform:\n1 to replace only the first keyword found, 2, 3...\nUse negative values to replace from the end of the file,\neg. to replace the last found key, usereplacements=-1
.\nTo replace all values, setreplacements = 0
, which is the value by default.\n", "signature": "(\tfilepath: str,\tkey: str,\ttext: str,\treplacements: int = 0,\tregex: bool = False) -> None:", "funcdef": "def"}, {"fullname": "aton.txt.edit.replace_line", "modulename": "aton.txt.edit", "qualname": "replace_line", "kind": "function", "doc": "line... key ...line -> line... text ...line\n
Replaces the entire line(s) containing the
\n\nkey
with thetext
infilepath
.It can be used to delete line(s) by setting
\n\ntext=''
.\nRegular expressions can be used withregex=True
.The value
\n\nreplacements
specifies the number of lines to replace:\n1 to replace only the first line with the keyword, 2, 3...\nUse negative values to replace from the end of the file,\ne.g., to replace only the last line containing the keyword, usereplacements = -1
.\nTo replace all lines, setreplacements = 0
, which is the value by default.The default line to replace is the matching line,\nbut it can be any other specific line after or before the matching line;\nthis is indicated with
\n\nskips
as a positive or negative integer.More lines can be replaced with
\n", "signature": "(\tfilepath: str,\tkey: str,\ttext: str,\treplacements: int = 0,\tskips: int = 0,\tadditional: int = 0,\tregex: bool = False,\traise_errors: bool = False) -> None:", "funcdef": "def"}, {"fullname": "aton.txt.edit.replace_between", "modulename": "aton.txt.edit", "qualname": "replace_between", "kind": "function", "doc": "additional
lines (int).\nNote that the matched line plus the additional lines\nwill be replaced, this is, additional lines +1.Replace with
\n\ntext
between keywordskey1
andkey2
infilepath
.It can be used to delete the text between the keys by setting
\n\ntext=''
.\nRegular expressions can be used by settingregex=True
.Key lines are also deleted if
\n\ndelete_keys=True
.Only the first matches of the keywords are used by default;\nyou can use the last ones with
\n\nfrom_end = True
.\n", "signature": "(\tfilepath: str,\tkey1: str,\tkey2: str,\ttext: str,\tdelete_keys: bool = False,\tfrom_end: bool = False,\tregex: bool = False) -> None:", "funcdef": "def"}, {"fullname": "aton.txt.edit.delete_under", "modulename": "aton.txt.edit", "qualname": "delete_under", "kind": "function", "doc": "lines...\nkey1\ntext\nkey2\nlines...\n
Deletes all the content under the line containing the
\n\nkey
infilepath
.The keyword can be at any position within the line.\nRegular expressions can be used by setting
\n\nregex=True
.By default the first
\n\nmatch
is used; it can be any positive integer (0 is treated as 1!),\nincluding negative integers to select a match starting from the end of the file.The content can be deleted after a specific number of lines after the match,\nchanging the value
\n", "signature": "(\tfilepath,\tkey: str,\tmatch: int = 1,\tskips: int = 0,\tregex: bool = False) -> None:", "funcdef": "def"}, {"fullname": "aton.txt.edit.correct_with_dict", "modulename": "aton.txt.edit", "qualname": "correct_with_dict", "kind": "function", "doc": "skips
, that skips the specified number of lines.\nNegative integers start deleting the content from the previous lines.Corrects the given text file
\n", "signature": "(filepath: str, correct: dict) -> None:", "funcdef": "def"}, {"fullname": "aton.txt.edit.from_template", "modulename": "aton.txt.edit", "qualname": "from_template", "kind": "function", "doc": "filepath
using acorrect
dictionary.Creates
\n", "signature": "(old: str, new: str, correct: dict = None, comment: str = None) -> None:", "funcdef": "def"}, {"fullname": "aton.txt.extract", "modulename": "aton.txt.extract", "kind": "module", "doc": "new
file fromold
, replacing values from acorrect
dict, inserting acomment
on top.Description
\n\nFunctions to extract data from raw text strings.
\n\nIndex
\n\n\n\n
number()
\nstring()
\ncolumn()
\ncoords()
\nelement()
Examples
\n\nTo extract a float value from a string,
\n\n\n\n\n\nfrom aton import txt\nline = 'energy = 500.0 Ry'\ntxt.extract.number(line, 'energy')\n# 500.0 (float output)\n
To extract a text value, after and before specific strings,
\n\n\n\n\n\nline = 'energy = 500.0 Ry were calculated'\ntxt.extract.string(line, 'energy', 'were')\n# '500.0 Ry' (String output)\n
To extract a value from a specific column,
\n\n\n\n\n\n# Name, Energy, Force, Error\nline = 'Testing 1.1 1.2 0.3'\nenergy = txt.extract.column(line, 1)\n# '1.1' (String output)\n
To extract coordinates,
\n\n\n\n\n\nline = ' He 0.10 0.20 0.30 '\ntxt.extract.coords(line)\n# [0.1, 0.2, 0.3] (List of floats)\n
To extract chemical elements,
\n\n\n\n\n\nline = ' He4 0.10 Ag 0.20 Pb 0.30 '\nfirst_element = txt.extract.element(line, 0)\n# 'He4'\nthird_element = txt.extract.element(line, 2)\n# 'Pb'\n
\n"}, {"fullname": "aton.txt.extract.number", "modulename": "aton.txt.extract", "qualname": "number", "kind": "function", "doc": "Extracts the float value of a given
\n", "signature": "(text: str, name: str = '') -> float:", "funcdef": "def"}, {"fullname": "aton.txt.extract.string", "modulename": "aton.txt.extract", "qualname": "string", "kind": "function", "doc": "name
variable from a rawtext
.Extracts the
\n\ntext
value of a givenname
variable from a raw string. Stops before an optionalstop
string.Removes leading and trailing commas by default, change this with
\n", "signature": "(text: str, name: str = '', stop: str = '', strip: bool = True) -> str:", "funcdef": "def"}, {"fullname": "aton.txt.extract.column", "modulename": "aton.txt.extract", "qualname": "column", "kind": "function", "doc": "strip = False
.Extracts the desired
\n", "signature": "(text: str, column: int = 0) -> str:", "funcdef": "def"}, {"fullname": "aton.txt.extract.coords", "modulename": "aton.txt.extract", "qualname": "coords", "kind": "function", "doc": "column
index of a givenstring
(0 by default).Returns a list with the float coordinates expressed in a given
\n", "signature": "(text: str) -> list:", "funcdef": "def"}, {"fullname": "aton.txt.extract.element", "modulename": "aton.txt.extract", "qualname": "element", "kind": "function", "doc": "text
string.Extract a chemical element from a raw
\n\ntext
string.If there are several elements, you can return a specific
\n", "signature": "(text: str, index: int = 0) -> str:", "funcdef": "def"}, {"fullname": "aton.txt.find", "modulename": "aton.txt.find", "kind": "module", "doc": "index
match (positive, 0 by default).\nAllows for standard elements (H, He, Na...) and isotopes (H2, He4...).Description
\n\nFunctions to search for specific content inside text files.
\n\nIndex
\n\nFind and return specific text strings from a file
\n\n
\nlines()
\nbetween()
Find the
\n\n(start, end)
position of specific strings in a file
\npos()
\npos_regex()
\nnext_pos()
\nnext_pos_regex()
\nline_pos()
\nbetween_pos()
Examples
\n\nTo find the lines containing the word 'key', plus an additional line below,
\n\n\n\n\n\nfrom aton import txt\n# with split = False\ntxt.find.lines(filepath=file, key='key', additional=1)\n # ['line with key 1\\nline below first match',\n # 'line with key 2\\nline below second match]\n# with split = True\ntxt.find.lines(filepath=file, key='key', additional=1, split=True)\n # ['line with key 1',\n # 'line below first match',\n # 'line with key 2',\n # 'line below second match]\n
To find the text between the lines containing the words 'first' and 'second',
\n\n\n\n\n\nfrom aton import txt\ntxt.find.between(filepath=file, key1='first', key2='second')\n # 'first line\\nadditional\\nlines\\nin\\nbetween\\nsecond line'\n
\n"}, {"fullname": "aton.txt.find.lines", "modulename": "aton.txt.find", "qualname": "lines", "kind": "function", "doc": "Returns a list with the matches containing the
\n\nkey
string infilepath
.If no match is found, returns an empty list.
\n\nTo use regular expressions in the search, set
\n\nregex=True
\n(deactivated by default).The value
\n\nmatches
specifies the max number of matches to be returned.\nDefaults to 0 to return all possible matches. Set it to 1 to return only one match,\nor to negative integers to start the search from the end of the file upwards.The value
\n", "signature": "(\tfilepath: str,\tkey: str,\tmatches: int = 0,\tadditional: int = 0,\tsplit: bool = False,\tregex: bool = False) -> list:", "funcdef": "def"}, {"fullname": "aton.txt.find.between", "modulename": "aton.txt.find", "qualname": "between", "kind": "function", "doc": "additional
specifies the number of additional lines\nbelow the target line that are also returned;\n2 to return the found line plus two additional lines below, etc.\nNegative values return the specified number of lines before the target line.\nThe original ordering from the file is preserved.\nDefaults toadditional=0
, only returning the target line.\nBy default, the additional lines are returned\nin the same list item as the match separated by a\\n
,\nunlesssplit=True
, in which case these additional lines\nare splitted and added as additional items in the list.Returns the content between the lines with
\n\nkey1
andkey2
infilepath
.Keywords can be at any position within the line.\nRegular expressions can be used by setting
\n\nregex=True
.Key lines are omited by default, but can be returned with
\n\ninclude_keys=True
.If there is more than one match, only the first one is considered by default;\nset
\n\nmatch
(int) to specify a particular match (1, 2... 0 is considered as 1!).\nUse negative numbers to start from the end of the file.If no match is found, returns an empty string.
\n\nIf
\n", "signature": "(\tfilepath: str,\tkey1: str,\tkey2: str,\tinclude_keys: bool = True,\tmatch: int = 1,\tregex: bool = False) -> str:", "funcdef": "def"}, {"fullname": "aton.txt.find.pos", "modulename": "aton.txt.find", "qualname": "pos", "kind": "function", "doc": "key2
is not found, it returns all the text fromkey1
to the end of the file.Returns a list with the positions of the
\n\nkey
infilepath
.If no match is found, returns an empty list.
\n\nThe
\n\nfilepath
can be a file or a memory mapped file.The value
\n\nmatches
specifies the max number of matches to return.\nDefaults to 0 to return all possible matches.\nSet it to 1 to return only one match,\n2 to get the first two matches, etc.\nYou can also set it to negative integers to start\nsearching from the end of the file upwards.This method is faster than
\n", "signature": "(filepath, key: str, matches: int = 0) -> list:", "funcdef": "def"}, {"fullname": "aton.txt.find.pos_regex", "modulename": "aton.txt.find", "qualname": "pos_regex", "kind": "function", "doc": "pos_regex()
,\nbut does not search for regular expressions.Returns a list of the positions of a
\n\nkey
in a givenfilepath
(actual file, not mmapped!).The value
\n\nmatches
specifies the max number of matches to return.\nDefaults to 0 to return all possible matches. Set it to 1 to return only one match,\nor to negative integers to start searching from the end of the file upwards.For big files, this method is slower than
\n", "signature": "(filepath, key: str, matches: int = 0) -> list:", "funcdef": "def"}, {"fullname": "aton.txt.find.next_pos", "modulename": "aton.txt.find", "qualname": "next_pos", "kind": "function", "doc": "pos()
, but it can search for regular expressions.Get the next position of the
\n\nkey
in thefilepath
(file or mmapped file), starting from an initialposition
tuple.The
\n\nmatch
number specifies the nonzero index of the next match to return (1, 2... 0 is considered as 1!).\nIt can be negative to search backwards from the initial position.\nThe last known positions will be returned if no more matches are found.This method is specific for normal strings.\nTo use regular expressions, check
\n", "signature": "(filepath, position: tuple, key: str, match: int = 1) -> tuple:", "funcdef": "def"}, {"fullname": "aton.txt.find.next_pos_regex", "modulename": "aton.txt.find", "qualname": "next_pos_regex", "kind": "function", "doc": "next_pos_regex()
.Get the next position of the
\n\nkey
in thefilepath
(actual file, not mmapped!), starting from an initialposition
tuple.The
\n\nmatch
number specifies the next match to return (1, 2... 0 is considered as 1!).\nIt can be negative to search backwards from the initial position.\nThis method is specific for regular expressions.For normal strings, check the faster
\n", "signature": "(filepath, position: tuple, key: str, match: int = 0) -> tuple:", "funcdef": "def"}, {"fullname": "aton.txt.find.line_pos", "modulename": "aton.txt.find", "qualname": "line_pos", "kind": "function", "doc": "next_pos()
method.Get the position of the full line containing the
\n\nposition
tuple infilepath
(whether file or memory mapped file).A specific line below can be returned with
\n", "signature": "(filepath, position: tuple, skips: int = 0) -> tuple:", "funcdef": "def"}, {"fullname": "aton.txt.find.between_pos", "modulename": "aton.txt.find", "qualname": "between_pos", "kind": "function", "doc": "skips
being a natural int,\nor previous lines with negative values.Returns the positions of the content between the lines containing
\n\nkey1
andkey2
in thefilepath
.Keywords can be at any position within the line.\nRegular expressions can be used by setting
\n\nregex=True
.Key lines are omited by default, but can be returned with
\n\ninclude_keys=True
.If there is more than one match, only the first one is considered by default;\nset
\n\nmatch
number to specify a particular match (1, 2... 0 is considered as 1!).\nUse negative numbers to start from the end of the file.If
\n", "signature": "(\tfilepath,\tkey1: str,\tkey2: str,\tinclude_keys: bool = True,\tmatch: int = 1,\tregex: bool = False) -> tuple:", "funcdef": "def"}]; // mirrored in build-search-index.js (part 1) // Also split on html tags. this is a cheap heuristic, but good enough. diff --git a/tests/test_file.py b/tests/test_file.py index bcd58c9..f76a892 100644 --- a/tests/test_file.py +++ b/tests/test_file.py @@ -16,11 +16,7 @@ def test_get(): except: pass # Finds an existing file - try: - assert file.get(sample) != None - assert True - except FileNotFoundError: - assert False + assert file.get(sample) != None # Does not find a non-existing file try: file.get(sample_copy) @@ -28,10 +24,11 @@ def test_get(): except FileNotFoundError: assert True # get_list, 'tests/sample.txt' in 'fullpath/tests/sample.txt' - try: - assert sample in file.get_list(folder, filters='sample')[0] - except: - assert False + file_list = file.get_list(folder, include='sample.txt') + assert len(file_list) == 1 + assert sample in file_list[0] + empty_file_list = file.get_list(folder, include='sample.txt', ignore='txt') + assert len(empty_file_list) == 0 def test_copy(): @@ -41,27 +38,18 @@ def test_copy(): except: pass # Copy files - try: - file.copy(sample, sample_copy) - assert file.get(sample_copy) != None - except FileNotFoundError: - assert False + file.copy(sample, sample_copy) + assert file.get(sample_copy) != None # Move files - try: - file.move(sample_copy, sample_copy_2) - assert file.get(sample_copy_2) != None - except: - assert False + file.move(sample_copy, sample_copy_2) + assert file.get(sample_copy_2) != None try: file.get(sample_copy) assert False except FileNotFoundError: assert True # Remove - try: - file.remove(sample_copy_2) - except: - assert False + file.remove(sample_copy_2) try: file.get(sample_copy_2) assert Falsekey2
is not found, it returns the text position fromkey1
to the end of the file.