diff --git a/aton/phys/units.py b/aton/phys/units.py index 7e979c9..44c933a 100644 --- a/aton/phys/units.py +++ b/aton/phys/units.py @@ -49,21 +49,21 @@ Some examples: ```python -from aton.phys import * +from aton import phys # Constants -h # Planck constant -hbar # reduced Planck constant -a # fine-structure constant (alpha) -ue # electron magnetic moment (mu e) -mn # neutron mass -mnc2 # neutron mass energy equivalent +phys.h # Planck constant +phys.hbar # reduced Planck constant +phys.a # fine-structure constant (alpha) +phys.ue # electron magnetic moment (mu e) +phys.mn # neutron mass +phys.mnc2 # neutron mass energy equivalent # Conversions # meV to 1/cm -energy_in_cm1 = energy_in_meV * meV_to_cm1 +energy_in_cm1 = energy_in_meV * phys.meV_to_cm1 # Bohr to Angstroms -distance_in_angstroms = distance_in_bohr * bohr_to_A +distance_in_angstroms = distance_in_bohr * phys.bohr_to_A # m/s to rad/s (used in neutron scattering) -velocity_in_rads = velocity_in_ms * ms_to_rads +velocity_in_rads = velocity_in_ms * phys.ms_to_rads ``` diff --git a/docs/aton/phys/units.html b/docs/aton/phys/units.html index 3fe0bc5..2b7a959 100644 --- a/docs/aton/phys/units.html +++ b/docs/aton/phys/units.html @@ -750,21 +750,21 @@
Some examples:
from aton.phys import *
+from aton import phys
# Constants
-h # Planck constant
-hbar # reduced Planck constant
-a # fine-structure constant (alpha)
-ue # electron magnetic moment (mu e)
-mn # neutron mass
-mnc2 # neutron mass energy equivalent
+phys.h # Planck constant
+phys.hbar # reduced Planck constant
+phys.a # fine-structure constant (alpha)
+phys.ue # electron magnetic moment (mu e)
+phys.mn # neutron mass
+phys.mnc2 # neutron mass energy equivalent
# Conversions
# meV to 1/cm
-energy_in_cm1 = energy_in_meV * meV_to_cm1
+energy_in_cm1 = energy_in_meV * phys.meV_to_cm1
# Bohr to Angstroms
-distance_in_angstroms = distance_in_bohr * bohr_to_A
+distance_in_angstroms = distance_in_bohr * phys.bohr_to_A
# m/s to rad/s (used in neutron scattering)
-velocity_in_rads = velocity_in_ms * ms_to_rads
+velocity_in_rads = velocity_in_ms * phys.ms_to_rads
The 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\nfrom INS spectra analysis to ab-initio interfaces\nfor Quantum ESPRESSO,\nPhonopy and\nCASTEP.\nConversion factors and universal constants from the 2022 CODATA\nRecommended Values of the Fundamental Physical Constants are also included.
\n\nThe source code is available on GitHub.
\n\nAs always, it is recommended to install your packages in a virtual environment:
\n\npython3 -m venv .venv\nsource .venv/bin/activate\n
\nInstall ATON with
\n\npip install aton\n
\nOr upgrade to a new version as
\n\npip install aton -U\n
\nOptionally, you can install ATON from the GitHub repo.\nClone the repository or download the latest stable release\nas a ZIP, unzip it, and run inside the ATON/
directory:
pip install .\n
\nThe full ATON documentation is available online.
\nAn offline version is found at docs/aton.html
.
\nCode examples are included in the examples/
folder.
The interface module contains Python interfaces for several ab-initio codes.\nThese are powered by the aton.txt module and can be easily extended.
\n\naton.interface
\n | \n |
---|---|
aton.interface.qe | \n Interface for Quantum ESPRESSO's pw.x module | \n
aton.interface.phonopy | \n Interface for Phonopy calculations | \n
aton.interface.castep | \n Interface for CASTEP calculations | \n
aton.interface.slurm | \n Batch jobs via Slurm | \n
The phys module contains physico-chemical definitions.\nValues are accessed directly as phys.value
or phys.function()
.
aton.phys
\n | \n |
---|---|
aton.phys.units | \n Physical constants and conversion factors | \n
aton.phys.atoms | \n Megadictionary with data for all chemical elements | \n
aton.phys.functions | \n Functions to sort and analyse element data | \n
The QRotor module is used to study quantum rotations,\nsuch as those of methyl and amine groups.
\n\naton.qrotor
\n | \n |
---|---|
aton.qrotor.rotate | \n Rotate specific atoms from structural files | \n
aton.qrotor.constants | \n Bond lengths and inertias | \n
aton.qrotor.system | \n Definition of the quantum System object | \n
aton.qrotor.systems | \n Functions to manage several System objects | \n
aton.qrotor.potential | \n Potential definitions and loading functions | \n
aton.qrotor.solve | \n Solve rotation eigenvalues and eigenvectors | \n
aton.qrotor.plot | \n Plotting functions | \n
The spx module includes tools for spectral analysis from\nInelastic Neutron Scattering, Raman, Infrared, etc.
\n\naton.spx
\n | \n |
---|---|
aton.spx.classes | \n Class definitions for the spectra module | \n
aton.spx.fit | \n Spectra fitting functions | \n
aton.spx.normalize | \n Spectra normalization | \n
aton.spx.plot | \n Plotting | \n
aton.spx.deuterium | \n Deuteration estimations via INS | \n
aton.spx.samples | \n Sample materials for testing | \n
The txt module handles text files.\nIt powers more complex subpackages,\nsuch as aton.interface.
\n\naton.txt
\n | \n |
---|---|
aton.txt.find | \n Search for specific content in text files | \n
aton.txt.edit | \n Manipulate text files | \n
aton.txt.extract | \n Extract data from raw text strings | \n
The st module contains System Tools for common system tasks across subpackages.
\n\naton.st
\n | \n |
---|---|
aton.st.file | \n File manipulation | \n
aton.st.call | \n Run bash scripts and related | \n
aton.st.alias | \n Useful dictionaries for user input correction | \n
If you are interested in opening an issue or a pull request, please feel free to do so on GitHub.
\nFor major changes, please get in touch first to discuss the details.
Please try to follow some general guidelines:
\n\nfunction(file, key/s, value/s, optional)
. If you are modifying the source code, you should run the automated tests of the ATON/tests/
folder to check that everything works as intended.\nTo do so, first install PyTest in your environment,
pip install pytest\n
\nAnd then run PyTest inside the ATON/
directory,
pytest -vv\n
\nThe documentation can be compiled automatically to docs/aton.html
with Pdoc and ATON itself, by running:
python3 makedocs.py\n
\nThis runs Pdoc, updating links and pictures, and using the custom theme CSS template from the css/
folder.
ATON development started for the following paper, please cite if you use ATON in your work:
\nCryst. Growth Des. 2024, 24, 391\u2212404
Copyright (C) 2025 Pablo Gila-Herranz
\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.
This module contains interfaces for several ab-initio calculation softwares.\nThese interfaces can be easily expanded with the aton.txt
module.
\n | \n |
---|---|
aton.interface.qe | \n Interface for Quantum ESPRESSO's pw.x module | \n
aton.interface.phonopy | \n Interface for Phonopy calculations | \n
aton.interface.castep | \n Interface for CASTEP calculations | \n
aton.interface.slurm | \n Batch jobs via Slurm | \n
To read the output from a Quantum ESPRESSO pw.x calculation,
\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
\nTo modify values from an input file,
\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
\nCheck the full aton.interface.qe
API reference for more details.
To perform a phonon calculation from a relaxed structure via Quantum ESPRESSO,
\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
\nCheck the full aton.interface.phonopy
API reference for more details.
To read output values from a CASTEP calculation,
\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
\nCheck the full aton.interface.castep
API reference for more details.
Functions to work with CASTEP calculation files.
\n\n\n | \n |
---|---|
read_castep() | \n Output reading | \n
Reads a CASTEP output file, specified in filename
.\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": "Functions to work with Phonopy calculations,\nalong with Quantum ESPRESSO.
\n\n\n | \n |
---|---|
make_supercells() | \n Build supercell SCF inputs for phonon calculations | \n
To create the supercells and run the phonon calculations\nfrom a folder with relax.in
and relax.out
files,\nusing a template.slurm
file,
from aton import interface\ninterface.phonopy.make_supercells()\ninterface.slurm.sbatch('supercell-', 'scf.slurm')\n
\nCreates the supercell inputs of a given dimension
('2 2 2' by default),\nfrom the relax_in
and relax_out
files in the folder
\n('relax.in', 'relax.out' and CWD by default, respectively),\nneeded for the Phonopy calculations with Quantum ESPRESSO.
If slurm_template
is present,\nit checks it with aton.interface.slurm.check_template()
.
Tools to work with the pw.x module from Quantum ESPRESSO.
\n\nInput and output reading
\nread_in()
\nread_out()
\nread_dir()
\nread_dirs()
Input file manipulation
\nset_value()
\nadd_atom()
\nscf_from_relax()
Data extraction
\nget_atom()
\ncount_elements()
\nnormalize_card()
\nto_cartesian()
\nfrom_cartesian()
Dicts with input file description
\npw_namelists
\npw_cards
Reads a Quantum ESPRESSO input filepath
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 filepath
, returns a dict with the output keys.
The output keys are:\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 folder
from a QE calculation, returns a dict with input and output values.
Input and output files are determined automatically,\nbut must be specified with in_str
and out_str
\nif more than one file ends with .in
or .out
.
Reads recursively QE calculations from all the subfolders inside the given directory
.
Results are saved to CSV files inside the current directory.\nInput and output files are determined automatically, but must be specified with\nin_str
and out_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 calc_splitter
('_' by default), calc_type_index
(0) and calc_id_index
(1).\nWith these default values, a subfolder named './CalculationType_CalculationID_AdditionalText/'\nwill be interpreted as follows:
If 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 value
of a key
parameter in an input filepath
.
Delete parameters with value=''
.\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 indent
, 2 spaces by default.
Adds an atom in a given filepath
at a specified position
.
Position must be a string or a list, as follows:\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 indent
, 2 spaces by default.
Takes the approximate position
of an atom, and returns the full line from the filepath
.
It compares the atomic positions rounded up to the specified precision
decimals.\nIf return_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 indent
, 0 spaces by default.
Takes ATOMIC_POSITIONS, returns a dict as {element : number of atoms}
Create a Quantum ESPRESSO scf.in
file from a previous relax calculation.
If no folder
is provided, the current working directory is used.\nThe relax_in
and relax_out
files by default are relax.in
and relax.out
,\nupdate the names if necessary.
Converts a given cordinates
from crystal lattice vectors to cartesian.
Only for ibrav=0
. Uses the cell parameters.\nNote that the result is not multiplied by A
nor celldm(1)
.
Converts a given cordinates
from cartesian to the base of lattice vectors.
Only for ibrav=0
. Uses the cell parameters.\nNote that the result is not divided by A
nor celldm(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": "Functions to handle Slurm calls, to run calculations in clusters.
\n\n\n | \n |
---|---|
sbatch() | \n Sbatch all calculations | \n
scancel() | \n Scancel all calculations, or applying some filters | \n
scancel_here() | \n Scancel all calculations running from a specific folder | \n
squeue() | \n Get a Pandas DataFrame with info about the submitted calculations | \n
check_template() | \n Checks that the slurm template is OK, and provides an example if not | \n
Sbatch all the calculations at once.
\n\nCalculation names should follow prefix_ID.ext
,\nwith prefix
as the common name across calculations,\nfollowed by the calculation ID, used as JOB_NAME.\nThe extensions from in_ext
and out_ext
('.in' and '.out' by default)\nwill be used for the INPUT_FILE and OUTPUT_FILE of the slurm template.
The slurm template, template.slurm
by default,\nmust contain the keywords JOB_ID, INPUT_FILE and OUTPUT_FILE:
#SBATCH --job-name=JOB_NAME\nmpirun pw.x -inp INPUT_FILE > OUTPUT_FILE\n
\n\nRuns from the specified folder
, current working directory if empty.
If more control is required, a custom list of files
can be specified for sbatching.
If testing = True
it skips the final sbatching,\njust printing the commands on the screen.
Cancel all user
jobs.
If a particular status
string is provided,\nonly the calculations with said status will be cancelled.
If a particular text
string is provided,\nonly the calculations containing said text in the name will be deleted.
If testing = True
, it shows the calculations that would be deleted.
if the slurm squeue titles are different in your cluster,\nyou can specify them with key_jobid
, key_status
and key_name
.
Cancel all running jobs
in a given folder
.
If no job is provided, all jobs detected in the current folder will be cancelled.\nThe jobs will be detected from the <prefix>JOBID<sufix>
files, slurm-JOBID.out
by default.
Returns a Pandas DataFrame with the jobs from a specific user
Check the slurm template
inside folder
.
The current working directory is used if folder
is not provided.\nIf the file does not exist or is invalid, creates a template_EXAMPLE.slurm
file for reference.
This subpackage contains universal physical constants,\nas well as chemical data from all known elements.\nIt also includes functions to manage this data.
\n\n\n | \n |
---|---|
aton.phys.units | \n Universal constants and conversion factors | \n
aton.phys.atoms | \n Data from all chemical elements | \n
aton.phys.functions | \n Functions to sort and manage element data from the aton.phys.atoms dict | \n
All values and functions from phys submodules can be\nloaded directly as phys.value
or phys.function()
,\nas in the example below.
from 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
\nSee the API reference of the specific modules for more information.
\n\naton.phys.units
Constant values come from the 2022 CODATA Recommended Values of the Fundamental Physical Constants.
\n\nConversion factors for neutron scattering come from\nM. B\u00e9e, \"Quasielastic Neutron scattering\", Adam Hilger, Bristol and Philadelphia, 1988.
\n\naton.phys.atoms
Atomic mass
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 mass
, mass_number
and abundance
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 cross_section
$\\sigma_s$ are in barns (1 b = 100 fm$^2$).\nFrom Felix Fernandez-Alonso, \"Neutron Scattering Fundamentals\", 2013.
This module contains the atoms
megadictionary,\nwhich contains the properties of all elements.\nIt is managed and updated automatically with aton.phys.functions
.
The atoms
dictionary can be loaded directly as aton.phys.atoms
.
\n | \n |
---|---|
Element | \n Used as values in the atoms dict, stores element properties | \n
Isotope | \n Used as values in Element.isotope , contains isotope properties | \n
atoms | \n The dict with data from all elements | \n
from aton import phys\naluminium_cross_section = phys.atoms['Al'].cross_section # 1.503\nHe4_mass = phys.atoms['H'].isotope[4].mass # 4.0026032497\n
\nUsed in the 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 Isotope
of the element.\nThe keys are the mass number (A).
Used in the 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": "This module contains functions to sort and analyse\nchemical data using the aton.phys.atoms
megadictionary,\nwhich contains the properties of all elements.\nIt also contains the tools needed to\nautomatically update said megadictionary.
\n | \n |
---|---|
export_atoms() | \n Used to update and export the aton.phys.atoms dict | \n
split_isotope() | \n Splits element name and mass number | \n
allowed_isotopes() | \n Returns the available mass numbers for a given element | \n
All functions can be called from the phys subpackage directly, as:
\n\nfrom aton import phys\nphys.split_isotope('He4') # (He, 4)\nphys.allowed_isotopes('Li') # (6, 7)\n
\nExport a dictionary of chemical elements to a python file.
\n\nThis is used to build and update the aton.atoms
megadictionary, that contains\nall the element data, such as masses, cross-sections, etc.\nThe atoms.py
file must be modified here.
Split the name
of an isotope into the element and the mass number, eg. He4 -> He, 4.
If the isotope is not found in the 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 element
.
These mass numbers are used as isotope keys in the aton.atoms
megadictionary.
This module contains the constants from the \n2022 CODATA\nRecommended Values of the Fundamental Physical Constants.
\n\nIt also contains useful conversion factors for neutron scattering,\nfrom M. B\u00e9e, \"Quasielastic Neutron scattering\", Adam Hilger, Bristol and Philadelphia, 1988.
\n\nUnits and constants are named as their standard symbol, removing any /
divider in between.\nInverse of a unit or constant X, as in 1/X or X$^{-1}$, is expressed as X1
.
Universal constant names contain\nromanized greek letters,\nexcept for $\\mu$ which is used as u
.
Some examples:
\n\nfrom aton.phys import *\n# Constants\nh # Planck constant\nhbar # reduced Planck constant\na # fine-structure constant (alpha)\nue # electron magnetic moment (mu e)\nmn # neutron mass\nmnc2 # neutron mass energy equivalent\n# Conversions\n# meV to 1/cm\nenergy_in_cm1 = energy_in_meV * meV_to_cm1\n# Bohr to Angstroms\ndistance_in_angstroms = distance_in_bohr * bohr_to_A\n# m/s to rad/s (used in neutron scattering)\nvelocity_in_rads = velocity_in_ms * ms_to_rads\n
\nUsing SI units unless stated otherwise.
\n\n$c$ | speed of light in vacuum / natural unit of velocity, in m/s
\n", "default_value": "299792458"}, {"fullname": "aton.phys.units.u0", "modulename": "aton.phys.units", "qualname": "u0", "kind": "variable", "doc": "$\\mu_0$ | vacuum magnetic permeability, in N\u00b7A$^{-2}$ ($4\\pi\\alpha\\hbar/e^2 c$)
\n", "default_value": "1.25663706127e-06"}, {"fullname": "aton.phys.units.e0", "modulename": "aton.phys.units", "qualname": "e0", "kind": "variable", "doc": "$\\epsilon_0$ | vacuum electric permittivity, in F\u00b7m$^{-1}$ ($1/\\mu_0 c^2$)
\n", "default_value": "1.25663706127e-06"}, {"fullname": "aton.phys.units.Z0", "modulename": "aton.phys.units", "qualname": "Z0", "kind": "variable", "doc": "$Z_0$ | characteristic impedance of vacuum, in $\\Omega$ ($\\mu_0 c$)
\n", "default_value": "376.730313412"}, {"fullname": "aton.phys.units.G", "modulename": "aton.phys.units", "qualname": "G", "kind": "variable", "doc": "$G$ | Newtonian constant of gravitation, in m$^3$\u00b7kg$^{-1}$\u00b7s$^{-1}$
\n", "default_value": "6.6743e-11"}, {"fullname": "aton.phys.units.h", "modulename": "aton.phys.units", "qualname": "h", "kind": "variable", "doc": "$h$ | 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": "$h$ | 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": "$\\hbar$ | reduced Planck constant / natural unit of action, 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": "$\\hbar$ | reduced Planck constant, in eV\u00b7s
\n\n$e$ | elementary charge, in C
\n", "default_value": "1.602176634e-19"}, {"fullname": "aton.phys.units.P0", "modulename": "aton.phys.units", "qualname": "P0", "kind": "variable", "doc": "$\\Phi_0$ | magnetic flux quantum, in Wb ($2\\pi\\hbar/(2e)$)
\n", "default_value": "2.067833848e-15"}, {"fullname": "aton.phys.units.G0", "modulename": "aton.phys.units", "qualname": "G0", "kind": "variable", "doc": "$G_0$ | conductance quantum, in S ($2e^2/2\\pi h$)
\n", "default_value": "7.748091729e-05"}, {"fullname": "aton.phys.units.KJ", "modulename": "aton.phys.units", "qualname": "KJ", "kind": "variable", "doc": "$K_J$ | Josephson constant, in Hz\u00b7V$^{-1}$ (2e/h)
\n", "default_value": "483597848400000.0"}, {"fullname": "aton.phys.units.RK", "modulename": "aton.phys.units", "qualname": "RK", "kind": "variable", "doc": "$R_K$ | von Klitzing constant, in $\\Omega$ ($\\mu_0 c/2\\alpha = 2\\pi\\hbar/e^2$)
\n", "default_value": "25812.80745"}, {"fullname": "aton.phys.units.uB", "modulename": "aton.phys.units", "qualname": "uB", "kind": "variable", "doc": "$\\mu_B$ | Bohr magneton, in J\u00b7T$^{-1}$ ($e\\hbar / 2m_e$)
\n", "default_value": "9.2740100657e-24"}, {"fullname": "aton.phys.units.uN", "modulename": "aton.phys.units", "qualname": "uN", "kind": "variable", "doc": "$\\mu_N$ | nuclear magneton, in J\u00b7T$^{-1}$ ($e\\hbar / 2m_p$)
\n\n$\\alpha$ | fine-structure constant ($e^2 / 4 \\pi \\epsilon_0 \\hbar c$)
\n", "default_value": "0.0072973525643"}, {"fullname": "aton.phys.units.a1", "modulename": "aton.phys.units", "qualname": "a1", "kind": "variable", "doc": "$\\alpha^{-1}$ | inverse fine-structure constant
\n", "default_value": "137.035999177"}, {"fullname": "aton.phys.units.cRinf", "modulename": "aton.phys.units", "qualname": "cRinf", "kind": "variable", "doc": "$cR\\infty$ | Rydberg frequency, in Hz ($\\alpha^2m_e c^2/2h = E_h/2h$)
\n", "default_value": "3289841960250000.0"}, {"fullname": "aton.phys.units.Rinf", "modulename": "aton.phys.units", "qualname": "Rinf", "kind": "variable", "doc": "$R\\infty$ | Rydberg constant, in $[m^{-1}]^a$
\n", "default_value": "10973731.568157"}, {"fullname": "aton.phys.units.a0", "modulename": "aton.phys.units", "qualname": "a0", "kind": "variable", "doc": "$a_0$ | Bohr radius, in m
\n", "default_value": "5.29177210544e-11"}, {"fullname": "aton.phys.units.Eh", "modulename": "aton.phys.units", "qualname": "Eh", "kind": "variable", "doc": "$E_h$ | Hartree energy, in J ($\\alpha^2m_ec^2=e^2/4\\pi\\epsilon_0a_0=2h c R_{\\infty}$)
\n\n$m_e$ | electron mass / natural unit of mass, in kg
\n", "default_value": "-21.8906162861"}, {"fullname": "aton.phys.units.me_uma", "modulename": "aton.phys.units", "qualname": "me_uma", "kind": "variable", "doc": "$m_e$ | electron mass, in uma
\n", "default_value": "0.0005485799090441"}, {"fullname": "aton.phys.units.mec2", "modulename": "aton.phys.units", "qualname": "mec2", "kind": "variable", "doc": "$m_e c^2$ | electron mass energy equivalent / natural unit of energy, in J
\n", "default_value": "8.187105788e-14"}, {"fullname": "aton.phys.units.mec2_eV", "modulename": "aton.phys.units", "qualname": "mec2_eV", "kind": "variable", "doc": "$m_e c^2$ | electron mass energy equivalent, in eV
\n", "default_value": "510998.95069"}, {"fullname": "aton.phys.units.lC", "modulename": "aton.phys.units", "qualname": "lC", "kind": "variable", "doc": "$\\lambda_C$ | Compton wavelength, in $[m]^a$
\n", "default_value": "2.42631023538e-12"}, {"fullname": "aton.phys.units.re", "modulename": "aton.phys.units", "qualname": "re", "kind": "variable", "doc": "$r_e$ | classical electron radius, in m ($\\alpha^2 a_0$)
\n", "default_value": "2.8179403205e-15"}, {"fullname": "aton.phys.units.se", "modulename": "aton.phys.units", "qualname": "se", "kind": "variable", "doc": "$\\sigma_e$ | Thomson cross section, in m$^2$ ($(8\\pi / 3)r_e^2$)
\n", "default_value": "6.6524587051e-29"}, {"fullname": "aton.phys.units.ue", "modulename": "aton.phys.units", "qualname": "ue", "kind": "variable", "doc": "$\\mu_e$ | electron magnetic moment, in J\u00b7T$^{-1}$
\n\n$m_p$ | proton mass, in kg
\n", "default_value": "-25.32737807405"}, {"fullname": "aton.phys.units.mp_uma", "modulename": "aton.phys.units", "qualname": "mp_uma", "kind": "variable", "doc": "$m_p$ | proton mass, in uma
\n", "default_value": "1.0072764665789"}, {"fullname": "aton.phys.units.mpc2", "modulename": "aton.phys.units", "qualname": "mpc2", "kind": "variable", "doc": "$m_p c^2$ | proton mass energy equivalent, in J
\n", "default_value": "1.50327761802e-10"}, {"fullname": "aton.phys.units.mpc2_eV", "modulename": "aton.phys.units", "qualname": "mpc2_eV", "kind": "variable", "doc": "$m_p c^2$ | proton mass energy equivalent, in eV
\n", "default_value": "938272089.43"}, {"fullname": "aton.phys.units.mpme", "modulename": "aton.phys.units", "qualname": "mpme", "kind": "variable", "doc": "$m_p/m_e$ | proton-electron mass ratio
\n", "default_value": "1836.152673426"}, {"fullname": "aton.phys.units.lCp", "modulename": "aton.phys.units", "qualname": "lCp", "kind": "variable", "doc": "$\\lambda_{C,p}$ | proton Compton wavelength, in $[m]^a$
\n", "default_value": "1.3214098536e-15"}, {"fullname": "aton.phys.units.rp", "modulename": "aton.phys.units", "qualname": "rp", "kind": "variable", "doc": "$r_p$ | proton rms charge radius, in m
\n", "default_value": "8.4075e-16"}, {"fullname": "aton.phys.units.up", "modulename": "aton.phys.units", "qualname": "up", "kind": "variable", "doc": "$\\mu_p$ | proton magnetic moment, in J\u00b7T$^{-1}$
\n\n$m_n$ | neutron mass, in kg
\n", "default_value": "1.67492750056e-27"}, {"fullname": "aton.phys.units.mn_uma", "modulename": "aton.phys.units", "qualname": "mn_uma", "kind": "variable", "doc": "$m_n$ | neutron mass, in uma
\n", "default_value": "1.00866491606"}, {"fullname": "aton.phys.units.mnc2", "modulename": "aton.phys.units", "qualname": "mnc2", "kind": "variable", "doc": "$m_n c^2$ | neutron mass energy equivalent, in J
\n", "default_value": "1.50534976514e-10"}, {"fullname": "aton.phys.units.mnc2_eV", "modulename": "aton.phys.units", "qualname": "mnc2_eV", "kind": "variable", "doc": "$m_n c^2$ | neutron mass energy equivalent, in eV
\n", "default_value": "939565421.94"}, {"fullname": "aton.phys.units.lCn", "modulename": "aton.phys.units", "qualname": "lCn", "kind": "variable", "doc": "$\\lambda_{C,n}$ | neutron compton wavelength, in $[m]^a$
\n", "default_value": "1.31959090382e-15"}, {"fullname": "aton.phys.units.un", "modulename": "aton.phys.units", "qualname": "un", "kind": "variable", "doc": "$\\mu_n$ | neutron magnetic moment, in J\u00b7T$^{-1}$
\n\n$m_d$ | deuteron mass, in kg
\n", "default_value": "3.3435837768e-27"}, {"fullname": "aton.phys.units.md_uma", "modulename": "aton.phys.units", "qualname": "md_uma", "kind": "variable", "doc": "$m_d$ | deuteron mass, in uma
\n", "default_value": "2.013553212544"}, {"fullname": "aton.phys.units.mdc2", "modulename": "aton.phys.units", "qualname": "mdc2", "kind": "variable", "doc": "$m_d c^2$ | deuteron mass energy equivalent, in J
\n", "default_value": "3.00506323491e-10"}, {"fullname": "aton.phys.units.mdc2_eV", "modulename": "aton.phys.units", "qualname": "mdc2_eV", "kind": "variable", "doc": "$m_d c^2$ | deuteron mass energy equivalent, in eV
\n", "default_value": "1875612945"}, {"fullname": "aton.phys.units.rd", "modulename": "aton.phys.units", "qualname": "rd", "kind": "variable", "doc": "$r_d$ | deuteron rms charge radius, in m
\n", "default_value": "2.12778e-15"}, {"fullname": "aton.phys.units.ud", "modulename": "aton.phys.units", "qualname": "ud", "kind": "variable", "doc": "$\\mu_d$ | deuteron magnetic moment, in J\u00b7T$^{-1}$
\n\n$m_\\alpha$ | alpha particle mass, in kg
\n", "default_value": "6.644657345e-27"}, {"fullname": "aton.phys.units.mac2", "modulename": "aton.phys.units", "qualname": "mac2", "kind": "variable", "doc": "$m_\\alpha$ | alpha particle mass energy equivalent, in J
\n", "default_value": "5.9719201997e-10"}, {"fullname": "aton.phys.units.mac2_eV", "modulename": "aton.phys.units", "qualname": "mac2_eV", "kind": "variable", "doc": "$m_\\alpha$ | alpha particle mass energy equivalent, in eV
\n", "default_value": "3727379411.8"}, {"fullname": "aton.phys.units.ra", "modulename": "aton.phys.units", "qualname": "ra", "kind": "variable", "doc": "$r_\\alpha$ | alpha particle rms charge radius, in m
\n\n$N_A$ | Avogadro constant, in mol$^{-1}$
\n", "default_value": "6.02214076e+23"}, {"fullname": "aton.phys.units.k", "modulename": "aton.phys.units", "qualname": "k", "kind": "variable", "doc": "$k$ | Boltzmann constant, in J\u00b7K$^{-1}$
\n", "default_value": "1.380649e-23"}, {"fullname": "aton.phys.units.k_eV", "modulename": "aton.phys.units", "qualname": "k_eV", "kind": "variable", "doc": "$k$ | Boltzmann constant, in eV\u00b7K$^{-1}$
\n", "default_value": "8.617333262e-05"}, {"fullname": "aton.phys.units.mu", "modulename": "aton.phys.units", "qualname": "mu", "kind": "variable", "doc": "$m_u$ | atomic mass constant / unified atomic mass unit, in kg ($\\frac{1}{12}m(^{12}C)$)
\n", "default_value": "1.66053906892e-27"}, {"fullname": "aton.phys.units.muc2", "modulename": "aton.phys.units", "qualname": "muc2", "kind": "variable", "doc": "$m_u c^2$ | atomic mass constant energy equivalent, in J
\n", "default_value": "1.49241808768e-10"}, {"fullname": "aton.phys.units.muc2_eV", "modulename": "aton.phys.units", "qualname": "muc2_eV", "kind": "variable", "doc": "$m_u c^2$ | atomic mass constant energy equivalent, in eV
\n", "default_value": "931494103.72"}, {"fullname": "aton.phys.units.R", "modulename": "aton.phys.units", "qualname": "R", "kind": "variable", "doc": "$R$ | molar gas constant, in J\u00b7mol$^{-1}$K$^{-1}$ ($N_A k$)
\n", "default_value": "8.314462618"}, {"fullname": "aton.phys.units.F", "modulename": "aton.phys.units", "qualname": "F", "kind": "variable", "doc": "$F$ | Faraday constant, in C\u00b7mol$^{-1}$ ($N_A e$)
\n", "default_value": "96485.33212"}, {"fullname": "aton.phys.units.s", "modulename": "aton.phys.units", "qualname": "s", "kind": "variable", "doc": "$\\sigma$ | Stefan-Boltzmann constant, in W\u00b7m$^{-2}$\u00b7K$^{-4}$ ($(\\pi^2/60)k^4 /\\hbar^3 c^2$)
\n\nNote that to change between temperature scales,\nthese constants must be added instead of multiplied.
\n", "default_value": "0.008314"}, {"fullname": "aton.phys.units.C_to_K_scale", "modulename": "aton.phys.units", "qualname": "C_to_K_scale", "kind": "variable", "doc": "\n", "default_value": "273.15"}, {"fullname": "aton.phys.units.K_to_C_scale", "modulename": "aton.phys.units", "qualname": "K_to_C_scale", "kind": "variable", "doc": "The QRotor module is used to study the energy levels and wavefunctions of quantum rotations,\nsuch as those of methyl and amine groups.\nThese quantum systems are represented by the qrotor.System()
object.
QRotor can obtain custom potentials from DFT,\nwhich are used to solve the quantum system.
\n\nThis module uses meV as the default unit in the calculations.
\n\n\n | \n |
---|---|
aton.qrotor.system | \n Definition of the quantum System object | \n
aton.qrotor.systems | \n Functions to manage several System objects, such as a list of systems | \n
aton.qrotor.rotate | \n Rotate specific atoms from structural files | \n
aton.qrotor.constants | \n Bond lengths and inertias | \n
aton.qrotor.potential | \n Potential definitions and loading functions | \n
aton.qrotor.solve | \n Solve rotation eigenvalues and eigenvectors | \n
aton.qrotor.plot | \n Plotting functions | \n
A basic calculation of the eigenvalues for a zero potential goes as follows:
\n\nimport aton.qrotor as qr\nsystem = qr.System()\nsystem.gridsize = 200000 # Size of the potential grid\nsystem.B = 1 # Rotational inertia\nsystem.potential_name = 'zero'\nsystem.solve()\nsystem.eigenvalues\n# [0.0, 1.0, 1.0, 4.0, 4.0, 9.0, 9.0, ...] # approx values\n
\nThe accuracy of the calculation increases with bigger gridsizes,\nbut note that the runtime increases exponentially.
\n\nThe same calculation can be performed for a methyl group,\nin a cosine potential of amplitude 30 meV:
\n\nimport aton.qrotor as qr\nsystem = qr.System()\nsystem.gridsize = 200000 # Size of the potential grid\nsystem.B = qr.B_CH3 # Rotational inertia of a methyl group\nsystem.potential_name = 'cosine'\nsystem.potential_constants = [0, 30, 3, 0] # Offset, max, freq, phase (for cos pot.)\nsystem.solve()\n# Plot potential and eigenvalues\nqr.plot.energies(system)\n# Plot the first wavefunctions\nqr.plot.wavefunction(system, levels=[0,1,2], square=True)\n
\nQRotor can be used to obtain custom rotational potentials from DFT calculations.\nUsing Quantum ESPRESSO, running an SCF calculation for a methyl rotation every 10 degrees:
\n\nimport aton.qrotor as qr\nfrom aton import interface\n# Approx crystal positions of the atoms to rotate\natoms = [\n '1.101 1.204 1.307'\n '2.102 2.205 2.308'\n '3.103 3.206 3.309'\n]\n# Create the input SCF files, saving the filenames to a list\nscf_files = qr.rotate.structure_qe('molecule.in', positions=atoms, angle=10, repeat=True)\n# Run the Quantum ESPRESSO calculations\ninterface.slurm.sbatch(files=scf_files)\n
\nTo load the calculated potential to a QRotor System,
\n\n# Create a 'potential.dat' file with the potential as a function of the angle\nqr.potential.from_qe()\n# Load to the system\nsystem = qr.potential.load()\n# Solve the system, interpolating to a bigger gridsize\nsystem.B = qr.B_CH3\nsystem.solve(200000)\nqr.plot.energies(system)\n
\nCheck the API documentation for more details.
\n"}, {"fullname": "aton.qrotor.constants", "modulename": "aton.qrotor.constants", "kind": "module", "doc": "Common constants and default inertia values used in the QRotor subpackage.
\n\nBond lengths and angles were obtained from MAPbI3,\nsee Cryst. Growth Des. 2024, 24, 391\u2212404.
\n\nDistance 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_CH3", "modulename": "aton.qrotor.constants", "qualname": "I_CH3", "kind": "variable", "doc": "Inertia of CH3, in kg\u00b7m^2.
\n", "default_value": "np.float64(5.37903596799128e-47)"}, {"fullname": "aton.qrotor.constants.I_CD3", "modulename": "aton.qrotor.constants", "qualname": "I_CD3", "kind": "variable", "doc": "Inertia of CD3, in kg\u00b7m^2.
\n", "default_value": "np.float64(1.0748582164136045e-46)"}, {"fullname": "aton.qrotor.constants.I_NH3", "modulename": "aton.qrotor.constants", "qualname": "I_NH3", "kind": "variable", "doc": "Inertia of NH3, in kg\u00b7m^2.
\n", "default_value": "np.float64(4.717299973303422e-47)"}, {"fullname": "aton.qrotor.constants.I_ND3", "modulename": "aton.qrotor.constants", "qualname": "I_ND3", "kind": "variable", "doc": "Inertia of ND3, in kg\u00b7m^2.
\n", "default_value": "np.float64(9.426277618824576e-47)"}, {"fullname": "aton.qrotor.constants.B_CH3", "modulename": "aton.qrotor.constants", "qualname": "B_CH3", "kind": "variable", "doc": "Rotational energy of CH3, in meV\u00b7s/kg\u00b7m^2.
\n", "default_value": "np.float64(0.6452195002679675)"}, {"fullname": "aton.qrotor.constants.B_CD3", "modulename": "aton.qrotor.constants", "qualname": "B_CD3", "kind": "variable", "doc": "Rotational energy of CD3, in meV\u00b7s/kg\u00b7m^2.
\n", "default_value": "np.float64(0.32289457773984676)"}, {"fullname": "aton.qrotor.constants.B_NH3", "modulename": "aton.qrotor.constants", "qualname": "B_NH3", "kind": "variable", "doc": "Rotational energy of NH3, in meV\u00b7s/kg\u00b7m^2.
\n", "default_value": "np.float64(0.7357299554474442)"}, {"fullname": "aton.qrotor.constants.B_ND3", "modulename": "aton.qrotor.constants", "qualname": "B_ND3", "kind": "variable", "doc": "Rotational energy of ND3, in meV\u00b7s/kg\u00b7m^2.
\n", "default_value": "np.float64(0.36818976053280467)"}, {"fullname": "aton.qrotor.constants.constants_titov2023", "modulename": "aton.qrotor.constants", "qualname": "constants_titov2023", "kind": "variable", "doc": "Potential constants from\nK. Titov et al., Phys. Rev. Mater. 7, 073402 (2023)\nfor the aton.qrotor.potential.titov2023
potential.\nIn meV units.
This module provides straightforward functions to plot QRotor data.
\n\n\n | \n |
---|---|
potential() | \n Potential values as a function of the angle | \n
energies() | \n Calculated eigenvalues | \n
reduced_energies() | \n Reduced energies E/B as a function of the reduced potential V/B | \n
wavefunction() | \n Selected wavefunctions or squared wavefunctions of a system | \n
convergence() | \n Energy convergence | \n
Plot the potential values of a system
(System object, or list of systems).
Title can be customized with title
.\nIf empty, system[0].comment will be used as title if no more comments are present.
marker
and linestyle
can be a Matplotlib string or list of strings.
Plot the eigenvalues of data
(System or a list of System objects).
Plots the reduced energy of the system E/B vs the reduced potential energy V/B.
\n\nTakes a data
list of System objects as input.
Plot the wavefunction of a system
for the specified levels
.
Wavefunctions are squared by default, showing the probabilities;\nTo show the actual wavefunctions, set square = False
.
levels
can be a list of indexes, or the number of levels to plot.
Specific wavefunctions can be overlapped with overlap
as a list with the target indexes.\nThe overlap
value can also be the max number of wavefunctions to add.\nAll found wavefunctions can be added together with overlap = True
;\nbut note that this overlap is limited by the number of System.E_levels,\nthat must be specified before solving the system.\nSetting overlap
will ignore the levels
argument.
Plot the energy convergence of a data
list of Systems as a function of the gridsize.
This module contains functions to calculate the actual potential_values
of the system.
\n | \n |
---|---|
save() | \n Save the potential from a System to a data file | \n
load() | \n Load a System with a custom potential from a potential data file | \n
from_qe() | \n Creates a potential data file from Quantum ESPRESSO outputs | \n
interpolate() | \n Interpolates the current System.potential_values to a new System.gridsize | \n
solve() | \n Solve the potential values based on the potential name | \n
A sinthetic potential can be created by specifying its name in System.potential_name
,\nalong with the corresponding System.potential_constants
if required.\nAvailable potentials are:
\n | \n |
---|---|
zero() | \n Zero potential | \n
sine() | \n Sine potential | \n
cosine() | \n Cosine potential | \n
titov2023() | \n Potential of the hindered methyl rotor, as in titov2023. | \n
Save the rotational potential from a system
to a potential data file.
The output filepath
contains angle and energy columns,\nin degrees and meVs by default.\nThe units can be changed with angle
and energy
,\nbut only change these defaults if you know what you are doing.
Read a rotational potential energy dataset.
\n\nThe input file in filepath
should contain two columns with angle and potential energy values.\nDegrees and meV are assumed as default units unless stated in angle
and energy
.\nUnits will be converted automatically to radians and meV.
An optional comment
can be included in the output System.
A previous System object can be provided through system
to update its potential values.
Creates a potential data file from Quantum ESPRESSO outputs.
\n\nThe angle in degrees is extracted from the output filenames,\nwhich must follow whatever_ANGLE.out
.
Outputs from SCF calculations must be located in the provided folder
(CWD if None).\nFiles can be filtered by those containing the specified include
filters,\nexcluding those containing any string from the exclude
list. \nThe output filepath
name is 'potential.dat'
by default.
Energy values are saved to meV by dafault, unless specified in energy
.\nOnly change the energy units if you know what you are doing;\nremember that default energy units in QRotor are meV!
Interpolates the current System.potential_values
\nto a new grid of size System.gridsize
.
Solves System.potential_values
\naccording to the System.potential_name
,\nreturning the new potential_values
.\nAvaliable potential names are zero
, sine
and titov2023
.
If System.potential_name
is not present or not recognised,\nthe current System.potential_values
are used.
This function provides basic solving of the potential energy function.\nTo interpolate to a new gridsize and correct the potential offset after solving,\ncheck aton.qrotor.solve.potential()
.
Zero potential.
\n\n$V(x) = 0$
\n", "signature": "(system: aton.qrotor.system.System):", "funcdef": "def"}, {"fullname": "aton.qrotor.potential.sine", "modulename": "aton.qrotor.potential", "qualname": "sine", "kind": "function", "doc": "Sine potential.
\n\n$V(x) = C_0 + \\frac{C_1}{2} sin(x C_2 + C_3)$
\nWith $C_0$ as the potential offset,\n$C_1$ as the max potential value (without considering the offset),\n$C_2$ as the frequency, and $C_3$ as the phase.\nIf no System.potential_constants
are provided, defaults to $sin(3x)$
Cosine potential.
\n\n$V(x) = C_0 + \\frac{C_1}{2} cos(x C_2 + C_3)$
\nWith $C_0$ as the potential offset,\n$C_1$ as the max potential value (without considering the offset),\n$C_2$ as the frequency, and $C_3$ as the phase.\nIf no System.potential_constants
are provided, defaults to $cos(3x)$
Potential energy function of the hindered methyl rotor, from\nK. Titov et al., Phys. Rev. Mater. 7, 073402 (2023).
\n\n$V(x) = C_0 + C_1 sin(3x) + C_2 cos(3x) + C_3 sin(6x) + C_4 cos(6x)$
\nDefault constants are aton.qrotor.constants.constants_titov2023
[0].
This submodule contains tools to rotate molecular structures.\nWorks with Quantum ESPRESSO input files.
\n\n\n | \n |
---|---|
structure_qe() | \n Rotate specific atoms from a Quantum ESPRESSO input file | \n
rotate_coords() | \n Rotate a specific list of coordinates | \n
Rotates atoms from a Quantum ESPRESSO input file.
\n\nTakes a filepath
with a molecular structure, and three or more atomic positions
(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 by precision
.
It rotates the atoms by a specific angle
in degrees.\nAdditionally, if repeat = 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).
By default, the rotation axis is defined by the perpendicular vector\npassing through the geometrical center of the first three points.\nTo override this and instead use the vector between the first two atoms\nas the rotation axis, set use_centroid = False
.
To debug, show_axis = True
adds two additional helium atoms as the rotation vector.
Rotates geometrical coordinates.
\n\nTakes a list of atomic positions
in cartesian coordinates, as\n[[x1,y1,z1], [x2,y2,z2], [x3,y3,z3], [etc]
.\nThen rotates said coordinates by a given angle
in degrees.\nReturns a list with the updated positions.
By default, the rotation axis is defined by the perpendicular vector\npassing through the geometrical center of the first three points.\nTo override this and use the vector between the first two atoms\nas the rotation axis, set use_centroid = False
.
If show_axis = True
it returns two additional coordinates at the end of the list,\nwith the centroid and the rotation vector. Only works with use_centroid = True
.
This module is used to solve the hamiltonian eigenvalues and eigenvectors for a given quantum system.\nSparse matrices are used to achieve optimal performance.
\n\n\n | \n |
---|---|
energies() | \n Solve the quantum system, including eigenvalues and eigenvectors | \n
potential() | \n Solve the potential values of the system | \n
schrodinger() | \n Solve the Schr\u00f6diger equation for the system | \n
hamiltonian_matrix() | \n Calculate the hamiltonian matrix of the system | \n
laplacian_matrix() | \n Calculate the second derivative matrix for a given grid | \n
Solves the quantum system
.
This includes solving the potential, the eigenvalues and the eigenvectors.
\n\nThe resulting System object is saved with pickle to filename
if specified.
Solves the potential values of the system
.
It interpolates the potential if system.gridsize
is larger than the current grid.\nIt solves the potential according to the potential name,\nby calling aton.qrotor.potential.solve()
.\nThen it applies extra operations, such as removing the potential offset\nif system.correct_potential_offset = True
.
Solves the Schr\u00f6dinger equation for a given system
.
Uses ARPACK in shift-inverse mode to solve the hamiltonian sparse matrix.
\n", "signature": "(system: aton.qrotor.system.System) -> aton.qrotor.system.System:", "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 system
.
Calculates the Laplacian (second derivative) matrix for a given grid
.
The System
object contains all the information needed for a single QRotor calculation.\nThis class can be loaded directly as aton.qrotor.System()
.
Quantum system.
\n\nContains all the data for a single QRotor calculation, with both inputs and outputs.
\n"}, {"fullname": "aton.qrotor.system.System.__init__", "modulename": "aton.qrotor.system", "qualname": "System.__init__", "kind": "function", "doc": "\n", "signature": "(\tcomment: str = None,\tgroup: str = 'CH3',\tE_levels: int = 15,\tcorrect_potential_offset: bool = True,\tsave_eigenvectors: bool = True,\tgridsize: int = None,\tgrid=[],\tB: float = None,\tpotential_name: str = '',\tpotential_constants: list = None,\tpotential_values=[])"}, {"fullname": "aton.qrotor.system.System.version", "modulename": "aton.qrotor.system", "qualname": "System.version", "kind": "variable", "doc": "Version of the package used to generate the data.
\n"}, {"fullname": "aton.qrotor.system.System.comment", "modulename": "aton.qrotor.system", "qualname": "System.comment", "kind": "variable", "doc": "Custom comment for the dataset.
\n", "annotation": ": str"}, {"fullname": "aton.qrotor.system.System.group", "modulename": "aton.qrotor.system", "qualname": "System.group", "kind": "variable", "doc": "Chemical group, methyl or amine: 'CH3'
, 'CD3'
, 'NH3'
, 'ND3'
.
Number of energy levels to be studied.
\n", "annotation": ": int"}, {"fullname": "aton.qrotor.system.System.correct_potential_offset", "modulename": "aton.qrotor.system", "qualname": "System.correct_potential_offset", "kind": "variable", "doc": "Correct the potential offset as V - min(V)
or not.
Save or not the eigenvectors. Final file size will be bigger.
\n", "annotation": ": bool"}, {"fullname": "aton.qrotor.system.System.gridsize", "modulename": "aton.qrotor.system", "qualname": "System.gridsize", "kind": "variable", "doc": "Number of points in the grid.
\n", "annotation": ": int"}, {"fullname": "aton.qrotor.system.System.grid", "modulename": "aton.qrotor.system", "qualname": "System.grid", "kind": "variable", "doc": "The grid with the points to be used in the calculation.
\n\nCan be set automatically over $2 \\pi$ with System.set_grid()
.\nUnits must be in radians.
Rotational inertia, as in $B=\\frac{\\hbar^2}{2I}$.
\n", "annotation": ": float"}, {"fullname": "aton.qrotor.system.System.potential_name", "modulename": "aton.qrotor.system", "qualname": "System.potential_name", "kind": "variable", "doc": "Name of the desired potential: 'zero'
, 'titov2023'
, 'test'
...\nIf empty or unrecognised, the custom potential values inside System.potential_values
will be used.
List of constants to be used in the calculation of the potential energy, in the aton.qrotor.potential
module.
Numpy ndarray with the potential values for each point in the grid.
\n\nCan be calculated with a function available in the qrotor.potential
module,\nor loaded externally with the qrotor.potential.load()
function.\nPotential energy units must be in meV.
min(V)
before offset correction when correct_potential_offset = True
min(V)
max(V)
Calculated eigenvalues of the system. Should be in meV.
\n"}, {"fullname": "aton.qrotor.system.System.eigenvectors", "modulename": "aton.qrotor.system", "qualname": "System.eigenvectors", "kind": "variable", "doc": "Eigenvectors, if save_eigenvectors
is True. Beware of the file size.
max(V) - min(eigenvalues)
eigenvalues[1] - eigenvalues[0]
\n", "annotation": ": float"}, {"fullname": "aton.qrotor.system.System.runtime", "modulename": "aton.qrotor.system", "qualname": "System.runtime", "kind": "variable", "doc": "Time taken to solve the eigenvalues.
\n", "annotation": ": float"}, {"fullname": "aton.qrotor.system.System.summary", "modulename": "aton.qrotor.system", "qualname": "System.summary", "kind": "function", "doc": "\n", "signature": "(self):", "funcdef": "def"}, {"fullname": "aton.qrotor.system.System.set_grid", "modulename": "aton.qrotor.system", "qualname": "System.set_grid", "kind": "function", "doc": "Sets the System.grid
to the specified gridsize
from 0 to $2\\pi$.
If the system had a previous grid and potential values,\nit will interpolate those values to the new gridsize,\nusing aton.qrotor.potential.interpolate()
.
Normalise System.group
name, and set System.B
based on it.
Solves the quantum system.
\n\nThe potential can be interpolated to a new_gridsize
.
Same as running aton.qrotor.solve.energies(System)
.
Discard data that takes too much space,\nlike eigenvectors, potential values and grids.
\n", "signature": "(self):", "funcdef": "def"}, {"fullname": "aton.qrotor.systems", "modulename": "aton.qrotor.systems", "kind": "module", "doc": "This module contains utility functions to handle multiple aton.qrotor.system
calculations.
\n | \n |
---|---|
as_list() | \n Ensures that a list only contains System objects | \n
get_energies() | \n Get the eigenvalues from all systems | \n
get_gridsizes() | \n Get all gridsizes | \n
get_runtimes() | \n Get all runtimes | \n
get_groups() | \n Get the chemical groups in use | \n
sort_by_gridsize() | \n Sort systems by gridsize | \n
reduce_size() | \n Discard data that takes too much space | \n
get_ideal_E() | \n Calculate the ideal energy for a specified level | \n
Ensures that systems
is a list of System objects.
If it is a System, returns a list with that System as the only element.\nIf it is neither a list nor a System,\nor if the list does not contain only System objects,\nit raises an error.
\n", "signature": "(systems) -> None:", "funcdef": "def"}, {"fullname": "aton.qrotor.systems.get_energies", "modulename": "aton.qrotor.systems", "qualname": "get_energies", "kind": "function", "doc": "Get a list with all eigenvalues from all systems.
\n\nIf no eigenvalues are present for a particular system, appends None.
\n", "signature": "(systems: list) -> list:", "funcdef": "def"}, {"fullname": "aton.qrotor.systems.get_gridsizes", "modulename": "aton.qrotor.systems", "qualname": "get_gridsizes", "kind": "function", "doc": "Get a list with all gridsize values.
\n\nIf no gridsize value is present for a particular system, appends None.
\n", "signature": "(systems: list) -> list:", "funcdef": "def"}, {"fullname": "aton.qrotor.systems.get_runtimes", "modulename": "aton.qrotor.systems", "qualname": "get_runtimes", "kind": "function", "doc": "Returns a list with all runtime values.
\n\nIf no runtime value is present for a particular system, appends None.
\n", "signature": "(systems: list) -> list:", "funcdef": "def"}, {"fullname": "aton.qrotor.systems.get_groups", "modulename": "aton.qrotor.systems", "qualname": "get_groups", "kind": "function", "doc": "Returns a list with all System.group
values.
Sorts a list of System objects by System.gridsize
.
Discard data that takes too much space.
\n\nRemoves eigenvectors, potential values and grids,\nfor all System values inside the systems
list.
Calculates the ideal energy for a specified E_level
.
To be used in convergence tests with potential_name = 'zero'
.
This module contains spectral analysis tools.
\n\n\n | \n |
---|---|
aton.spx.classes | \n Definition of the Spectra , Plotting and Material classes, instantiated as aton.spx.Class() | \n
aton.spx.fit | \n Spectral fitting functions | \n
aton.spx.normalize | \n Spectra normalisation | \n
aton.spx.deuterium | \n Deuteration estimation functions | \n
aton.spx.samples | \n Material definition examples | \n
aton.spx.plot | \n Spectra plotting, as aton.spx.plot(Spectra) | \n
To 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\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
\nMore examples in the Aton/examples/
folder.
This module contains common classes used to load and manipulate spectral data.\nAny class can be instantiated directly from the aton.spx
module,\nas aton.spx.Class()
.
\n | \n |
---|---|
Spectra | \n Used to load and process spectral data | \n
Plotting | \n Stores plotting options, used in Spectra.plotting | \n
Material | \n Used to store and calculate material parameters, such as molar masses and neutron cross sections | \n
To load two INS spectra CSV files with cm$^{-1}$ as input units,\nconverting them to meV units, and finally plotting them:
\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
\nCheck more use examples in the ATON/examples/
folder.
Stores plotting options, read by 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 [xlim_low, xlim_top]
.
List with the y-limits of the plot, as in [ylim_low, ylim_top]
.
List with additional margins at the bottom and top of the plot, as in [low_margin, top_margin]
.
If True
, 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 vline
.
It can be an array of the same length as 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 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 None
, the default label will be used.\nSet to ''
to remove the label of the vertical axis.
Legend of the plot.
\n\nIf 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 to False
will not be displayed.
Title of the legend, defaults to None
.
Size of the legend, as in matplotlib. Defaults to 'medium'
.
Location of the legend, as in matplotlib. Defaults to '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 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: 'INS'
, 'ATR'
, or 'RAMAN'
.
Custom comment. If Plotting.title
is None, it will be the title of the plot.
List containing the files with the spectral data.
\n\nLoaded automatically to 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 files
at initialization.
Target units of the spectral data.
\n\nCan be 'meV'
or 'cm-1'
.
Input units of the spectral data, used in the input CSV files.
\n\nCan be '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']
.
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\nSpectra.set_units('meV', 'cm-1')\n
\nMaterial class.
\n\nUsed to calculate molar masses and cross sections,\nand to pass data to different analysis functions\nsuch as 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 Material.set()
.
Dict of atoms in the material, as in {'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 Material.set()
.
Number of moles.
\n\nSet automatically with Material.set()
.
Error of the number of moles.
\n\nSet automatically with Material.set()
.
Molar mass of the material, in mol/g.
\n\nCalculated automatically with Material.set()
.
Neutron total bound scattering cross section, in barns.
\n\nCalculated automatically with 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": "This module contains methods to calculate deuteration levels from different spectra.
\n\n\n | \n |
---|---|
impulse_approx() | \n Calculate the deuteration levels from INS spectra with the Impulse Approximation | \n
peaks_mapbi3() | \n Estimates CH$_3$NH$_3$PbI$_3$ deuteration by integrating the INS disrotatory peaks | \n
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 aton.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\nby H_df_index
and D_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 peaks
must be a dictionary with the peak limits\nand the baseline, as in the example below:
peaks = {\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
\nPeak keywords required for selective deuteration (only C or only N):\nh6d0
, h5d1
, h4d2
, h3d3
.
Additional peak keywords required for total deuteration:\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": "This module contains functions for fitting and analyzing spectral data.
\n\n\n | \n |
---|---|
plateau() | \n Fit the mean value and the error of a plateau | \n
area_under_peak() | \n Calculate the area under a given peak | \n
ratio_areas() | \n Check the ratio between two areas | \n
mean() | \n Get the mean and standard deviation of a list of values | \n
Fit the mean value and the error of a plateau in a aton.spectra.Spectra
object.
Use as aton.spx.fit.plateau(spectra, cuts=[low_cut, high_cut], df_index=0)
.
If aton.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 the aton.spx.classes.Spectra
object.
Note that cuts
, low_cut
and/or top_cut
can be set to None.
Calculate the area under a given peak.
\n\nPeaks must be defined as peak:list=[xmin, xmax, baseline=0, baseline_error=0]
.\nIf the dataset has no Error
column, the error for each point is assumed to be the same\nas the baseline error if errors_as_in_baseline=True
, otherwise it is assumed to be zero.\nIf min_as_baseline=True
and baseline=0
, the baseline is assumed to be the minimum value.\nAlso, if min_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 area / area_total
. This behavior is modified if inverse_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 array
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 degrees_of_freedom
, zero by default.\nSet it to 1
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 rounded=False
.
This module contains functions to normalize data and other variables.
\n\n\n | \n |
---|---|
height() | \n Normalize a spectra by height | \n
area() | \n Normalize a spectra by the area under the datasets | \n
unit_str() | \n Normalize a unit string from user input | \n
Normalize a set of spectra
by height.
By default it normalises the spectra over the entire range.\nThis can be modified by setting a specific range,\nas in range = [x_min, x_max]
with axis = 'x'
.\nIt can also normalise over manual y-positions,\nfor example for peaks with different baselines.\nThis can be done by settingch axis='y'
, and\nrange = [[y_min_1, y_max_1], ..., [y_min_N, y_max_N]]
.
Heights are normalised with respect to the\nreference dataframe df_index
, the first one by default.
Normalize spectra
by the area under the datasets.
Normalize unit
string from user input.
This module contains the plot()
function,\nused to plot aton.spx.classes.Spectra
data,\ncontaining optional aton.spx.classes.Plotting
parameters.
It is used as aton.spx.plot(Spectra)
Plots a spectra
.
Optional aton.spectra.classes.Plotting
attributes can be used.
This module contains premade examples of material compositions, for testing purposes.\nThe aton.spx.classes.Material.grams
is yet to be provided,\nbefore setting the material as aton.spx.Material.set()
.
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": "Common system tools across all ATON subpackages.
\n\n\n | \n |
---|---|
aton.st.file | \n File manipulation | \n
aton.st.call | \n Run bash scripts and related | \n
aton.st.alias | \n Useful dictionaries for user input correction | \n
This module contains common dictionaries to normalise and correct user inputs.\nAll values can be found in lowercase, to allow comparison with the string.lower()
method.
units
\nspatial
\nexperiments
\nfiles
\nboolean
\nmath
unit = 'Electronvolts'\nif unit.lower() in aton.alias.units['eV']:\n ... do stuff ...\n
\nDict 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 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 string.lower()
.
Strings related to files. Values must be compared to 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', 'Si', 'SI', 'si', 'S', 's'], False: ['no', 'NO', 'No', 'N', 'n', 'F', 'False', 'FALSE', 'f', 'false']}"}, {"fullname": "aton.st.alias.math", "modulename": "aton.st.alias", "qualname": "math", "kind": "variable", "doc": "Math-related strings.
\n", "annotation": ": dict", "default_value": "{'sin': ['sin', 'sen', 'sine', 'seno'], 'cos': ['cos', 'cosine', 'coseno'], 'tg': ['tg', 'tangent', 'tangente'], '0': ['zero', 'cero', '0']}"}, {"fullname": "aton.st.call", "modulename": "aton.st.call", "kind": "module", "doc": "Functions to handle bash calls and related operations on Linux systems.
\n\n\n | \n |
---|---|
bash() | \n Run a bash shell commands | \n
git() | \n Automatically update a Git repository | \n
here() | \n Runs the rest of the script inside a given folder | \n
Run a bash shell commands.
\n\nA given command
will be executed inside an optional cwd
directory.\nIf empty, the current working directory will be used.\nPrints the running command and outputs by default, override this with verbose=False
.\nReturns the result of the command used, except for when\nerrors are raised automatically; set return_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 folder
.
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 folder
, 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": "Functions to move files around.
\n\n\n | \n |
---|---|
get() | \n Check that a file exists, and return the full path | \n
get_list() | \n Get a list of the files inside a folder, applying optional filters | \n
get_dir() | \n Get the full path of a folder or the cwd | \n
copy() | \n Copy file | \n
move() | \n Move file | \n
remove() | \n Remove file or folder | \n
rename_on_folder() | \n Batch rename files from a folder | \n
rename_on_folders() | \n Barch rename files from subfolders | \n
copy_to_folders() | \n Copy files to individual subfolders | \n
save() | \n Save a Python object to a binary file, as .aton | \n
load() | \n Load a Python object from a binary file, as .aton | \n
Check if filepath
exists, and returns its full path.
Raises an error if the file is not found,\nunless return_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 include
filters\n(string or list of strings) to return a single file.\nIf this fails, try using more strict filters to return a single file.
Return the files inside a folder
, applying optional filters.
Only filenames containing all strings in the include
list will be returned.\nFilenames containing any string from the exclude
list will be ignored.
The full paths are returned by default; to get only the base names, set abspath = False
.\nThe CWD folder is used by default if no folder
is provided.\nIt also returns folders if also_folders = True
.
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.
Copies old
file to new
file
Moves old
file to new
file.
Removes the given file or folder at filepath
.
\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!
\n
Batch renames files in the given folder
.
Replaces the old
string by new
string.\nIf no folder is provided, the current working directory is used.
Renames the files inside the subfolders in the parent folder
.
Renames from an old
string to the new
string.\nIf no folder
is provided, the current working directory is used.
Copies the files from the parent folder
with the given extension
to individual subfolders.
The subfolders are named as the original files,\nremoving the strings from the strings_to_delete
list.\nIf no folder
is provided, it runs in the current working directory.
Save a Python object in the current working directory as a binary *.aton
file.
Load a Python object from a binary *.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": "This subpackage contains tools for general text operations.\nIt provides the basic functionality that powers more complex subpackages,\nsuch as aton.interface
.
\n | \n |
---|---|
aton.txt.find | \n Search for specific content from a text file | \n
aton.txt.edit | \n Edit specific content from a text file | \n
aton.txt.extract | \n Extract data from raw text strings | \n
The 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\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
\nAdvanced 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": "Functions to manipulate the content of text files.
\n\ninsert_at()
\ninsert_under()
\nreplace()
\nreplace_line()
\nreplace_between()
\ndelete_under()
\ncorrect_with_dict()
\nfrom_template()
Inserts a text
in the line with position
index of a given filepath
.
If position
is negative, starts from the end of the file.
Inserts a text
under the line(s) containing the key
in filepath
.
The keyword can be at any position within the line.\nRegular expressions can be used by setting regex=True
.
By default all matches are inserted with insertions=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 skips
. Negative integers introduce the text in the previous lines.
Replaces the key
with text
in filepath
.
It can also be used to delete the keyword with text=''
.\nTo search with regular expressions, set regex=True
.
The value replacements
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, use replacements=-1
.\nTo replace all values, set replacements = 0
, which is the value by default.
line... key ...line -> line... text ...line\n
\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": "Replaces the entire line(s) containing the key
with the text
in filepath
.
It can be used to delete line(s) by setting text=''
.\nRegular expressions can be used with regex=True
.
The value replacements
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, use replacements = -1
.\nTo replace all lines, set replacements = 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 skips
as a positive or negative integer.
More lines can be replaced with additional
lines (int).\nNote that the matched line plus the additional lines\nwill be replaced, this is, additional lines +1.
Replace with text
between keywords key1
and key2
in filepath
.
It can be used to delete the text between the keys by setting text=''
.\nRegular expressions can be used by setting regex=True
.
Key lines are also deleted if delete_keys=True
.
Only the first matches of the keywords are used by default;\nyou can use the last ones with from_end = True
.
lines...\nkey1\ntext\nkey2\nlines...\n
\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": "Deletes all the content under the line containing the key
in filepath
.
The keyword can be at any position within the line.\nRegular expressions can be used by setting regex=True
.
By default the first match
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 skips
, that skips the specified number of lines.\nNegative integers start deleting the content from the previous lines.
Corrects the given text file filepath
using a correct
dictionary.
Creates new
file from old
, replacing values from a correct
dict, inserting a comment
on top.
Functions to extract data from raw text strings.
\n\nnumber()
\nstring()
\ncolumn()
\ncoords()
\nelement()
To extract a float value from a string,
\n\nfrom aton import txt\nline = 'energy = 500.0 Ry'\ntxt.extract.number(line, 'energy')\n# 500.0 (float output)\n
\nTo extract a text value, after and before specific strings,
\n\nline = 'energy = 500.0 Ry were calculated'\ntxt.extract.string(line, 'energy', 'were')\n# '500.0 Ry' (String output)\n
\nTo extract a value from a specific column,
\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
\nTo extract coordinates,
\n\nline = ' He 0.10 0.20 0.30 '\ntxt.extract.coords(line)\n# [0.1, 0.2, 0.3] (List of floats)\n
\nTo extract chemical elements,
\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
\nExtracts the float value of a given name
variable from a raw text
.
Extracts the text
value of a given name
variable from a raw string. Stops before an optional stop
string.
Removes leading and trailing commas by default, change this with strip = False
.
Extracts the desired column
index of a given string
(0 by default).
Returns a list with the float coordinates expressed in a given text
string.
Extract a chemical element from a raw text
string.
If there are several elements, you can return a specific index
match (positive, 0 by default).\nAllows for standard elements (H, He, Na...) and isotopes (H2, He4...).
Functions to search for specific content inside text files.
\n\nFind and return specific text strings from a file
\nlines()
\nbetween()
Find the (start, end)
position of specific strings in a file
\npos()
\npos_regex()
\nnext_pos()
\nnext_pos_regex()
\nline_pos()
\nbetween_pos()
To find the lines containing the word 'key', plus an additional line below,
\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
\nTo find the text between the lines containing the words 'first' and 'second',
\n\nfrom aton import txt\ntxt.find.between(filepath=file, key1='first', key2='second')\n # 'first line\\nadditional\\nlines\\nin\\nbetween\\nsecond line'\n
\nReturns a list with the matches containing the key
string in filepath
.
If no match is found, returns an empty list.
\n\nTo use regular expressions in the search, set regex=True
\n(deactivated by default).
The value matches
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 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 to additional=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
,\nunless split=True
, in which case these additional lines\nare splitted and added as additional items in the list.
Returns the content between the lines with key1
and key2
in filepath
.
Keywords can be at any position within the line.\nRegular expressions can be used by setting regex=True
.
Key lines are omited by default, but can be returned with include_keys=True
.
If there is more than one match, only the first one is considered by default;\nset match
(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 key2
is not found, it returns all the text from key1
to the end of the file.
Returns a list with the positions of the key
in filepath
.
If no match is found, returns an empty list.
\n\nThe filepath
can be a file or a memory mapped file.
The value matches
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 pos_regex()
,\nbut does not search for regular expressions.
Returns a list of the positions of a key
in a given filepath
(actual file, not mmapped!).
The value matches
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 pos()
, but it can search for regular expressions.
Get the next position of the key
in the filepath
(file or mmapped file), starting from an initial position
tuple.
The match
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 next_pos_regex()
.
Get the next position of the key
in the filepath
(actual file, not mmapped!), starting from an initial position
tuple.
The match
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 next_pos()
method.
Get the position of the full line containing the position
tuple in filepath
(whether file or memory mapped file).
A specific line below can be returned with skips
being a natural int,\nor previous lines with negative values.
Returns the positions of the content between the lines containing key1
and key2
in the filepath
.
Keywords can be at any position within the line.\nRegular expressions can be used by setting regex=True
.
Key lines are omited by default, but can be returned with include_keys=True
.
If there is more than one match, only the first one is considered by default;\nset match
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 key2
is not found, it returns the text position from key1
to the end of the file.
The 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\nfrom INS spectra analysis to ab-initio interfaces\nfor Quantum ESPRESSO,\nPhonopy and\nCASTEP.\nConversion factors and universal constants from the 2022 CODATA\nRecommended Values of the Fundamental Physical Constants are also included.
\n\nThe source code is available on GitHub.
\n\nAs always, it is recommended to install your packages in a virtual environment:
\n\npython3 -m venv .venv\nsource .venv/bin/activate\n
\nInstall ATON with
\n\npip install aton\n
\nOr upgrade to a new version as
\n\npip install aton -U\n
\nOptionally, you can install ATON from the GitHub repo.\nClone the repository or download the latest stable release\nas a ZIP, unzip it, and run inside the ATON/
directory:
pip install .\n
\nThe full ATON documentation is available online.
\nAn offline version is found at docs/aton.html
.
\nCode examples are included in the examples/
folder.
The interface module contains Python interfaces for several ab-initio codes.\nThese are powered by the aton.txt module and can be easily extended.
\n\naton.interface
\n | \n |
---|---|
aton.interface.qe | \n Interface for Quantum ESPRESSO's pw.x module | \n
aton.interface.phonopy | \n Interface for Phonopy calculations | \n
aton.interface.castep | \n Interface for CASTEP calculations | \n
aton.interface.slurm | \n Batch jobs via Slurm | \n
The phys module contains physico-chemical definitions.\nValues are accessed directly as phys.value
or phys.function()
.
aton.phys
\n | \n |
---|---|
aton.phys.units | \n Physical constants and conversion factors | \n
aton.phys.atoms | \n Megadictionary with data for all chemical elements | \n
aton.phys.functions | \n Functions to sort and analyse element data | \n
The QRotor module is used to study quantum rotations,\nsuch as those of methyl and amine groups.
\n\naton.qrotor
\n | \n |
---|---|
aton.qrotor.rotate | \n Rotate specific atoms from structural files | \n
aton.qrotor.constants | \n Bond lengths and inertias | \n
aton.qrotor.system | \n Definition of the quantum System object | \n
aton.qrotor.systems | \n Functions to manage several System objects | \n
aton.qrotor.potential | \n Potential definitions and loading functions | \n
aton.qrotor.solve | \n Solve rotation eigenvalues and eigenvectors | \n
aton.qrotor.plot | \n Plotting functions | \n
The spx module includes tools for spectral analysis from\nInelastic Neutron Scattering, Raman, Infrared, etc.
\n\naton.spx
\n | \n |
---|---|
aton.spx.classes | \n Class definitions for the spectra module | \n
aton.spx.fit | \n Spectra fitting functions | \n
aton.spx.normalize | \n Spectra normalization | \n
aton.spx.plot | \n Plotting | \n
aton.spx.deuterium | \n Deuteration estimations via INS | \n
aton.spx.samples | \n Sample materials for testing | \n
The txt module handles text files.\nIt powers more complex subpackages,\nsuch as aton.interface.
\n\naton.txt
\n | \n |
---|---|
aton.txt.find | \n Search for specific content in text files | \n
aton.txt.edit | \n Manipulate text files | \n
aton.txt.extract | \n Extract data from raw text strings | \n
The st module contains System Tools for common system tasks across subpackages.
\n\naton.st
\n | \n |
---|---|
aton.st.file | \n File manipulation | \n
aton.st.call | \n Run bash scripts and related | \n
aton.st.alias | \n Useful dictionaries for user input correction | \n
If you are interested in opening an issue or a pull request, please feel free to do so on GitHub.
\nFor major changes, please get in touch first to discuss the details.
Please try to follow some general guidelines:
\n\nfunction(file, key/s, value/s, optional)
. If you are modifying the source code, you should run the automated tests of the ATON/tests/
folder to check that everything works as intended.\nTo do so, first install PyTest in your environment,
pip install pytest\n
\nAnd then run PyTest inside the ATON/
directory,
pytest -vv\n
\nThe documentation can be compiled automatically to docs/aton.html
with Pdoc and ATON itself, by running:
python3 makedocs.py\n
\nThis runs Pdoc, updating links and pictures, and using the custom theme CSS template from the css/
folder.
ATON development started for the following paper, please cite if you use ATON in your work:
\nCryst. Growth Des. 2024, 24, 391\u2212404
Copyright (C) 2025 Pablo Gila-Herranz
\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.
This module contains interfaces for several ab-initio calculation softwares.\nThese interfaces can be easily expanded with the aton.txt
module.
\n | \n |
---|---|
aton.interface.qe | \n Interface for Quantum ESPRESSO's pw.x module | \n
aton.interface.phonopy | \n Interface for Phonopy calculations | \n
aton.interface.castep | \n Interface for CASTEP calculations | \n
aton.interface.slurm | \n Batch jobs via Slurm | \n
To read the output from a Quantum ESPRESSO pw.x calculation,
\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
\nTo modify values from an input file,
\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
\nCheck the full aton.interface.qe
API reference for more details.
To perform a phonon calculation from a relaxed structure via Quantum ESPRESSO,
\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
\nCheck the full aton.interface.phonopy
API reference for more details.
To read output values from a CASTEP calculation,
\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
\nCheck the full aton.interface.castep
API reference for more details.
Functions to work with CASTEP calculation files.
\n\n\n | \n |
---|---|
read_castep() | \n Output reading | \n
Reads a CASTEP output file, specified in filename
.\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": "Functions to work with Phonopy calculations,\nalong with Quantum ESPRESSO.
\n\n\n | \n |
---|---|
make_supercells() | \n Build supercell SCF inputs for phonon calculations | \n
To create the supercells and run the phonon calculations\nfrom a folder with relax.in
and relax.out
files,\nusing a template.slurm
file,
from aton import interface\ninterface.phonopy.make_supercells()\ninterface.slurm.sbatch('supercell-', 'scf.slurm')\n
\nCreates the supercell inputs of a given dimension
('2 2 2' by default),\nfrom the relax_in
and relax_out
files in the folder
\n('relax.in', 'relax.out' and CWD by default, respectively),\nneeded for the Phonopy calculations with Quantum ESPRESSO.
If slurm_template
is present,\nit checks it with aton.interface.slurm.check_template()
.
Tools to work with the pw.x module from Quantum ESPRESSO.
\n\nInput and output reading
\nread_in()
\nread_out()
\nread_dir()
\nread_dirs()
Input file manipulation
\nset_value()
\nadd_atom()
\nscf_from_relax()
Data extraction
\nget_atom()
\ncount_elements()
\nnormalize_card()
\nto_cartesian()
\nfrom_cartesian()
Dicts with input file description
\npw_namelists
\npw_cards
Reads a Quantum ESPRESSO input filepath
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 filepath
, returns a dict with the output keys.
The output keys are:\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 folder
from a QE calculation, returns a dict with input and output values.
Input and output files are determined automatically,\nbut must be specified with in_str
and out_str
\nif more than one file ends with .in
or .out
.
Reads recursively QE calculations from all the subfolders inside the given directory
.
Results are saved to CSV files inside the current directory.\nInput and output files are determined automatically, but must be specified with\nin_str
and out_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 calc_splitter
('_' by default), calc_type_index
(0) and calc_id_index
(1).\nWith these default values, a subfolder named './CalculationType_CalculationID_AdditionalText/'\nwill be interpreted as follows:
If 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 value
of a key
parameter in an input filepath
.
Delete parameters with value=''
.\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 indent
, 2 spaces by default.
Adds an atom in a given filepath
at a specified position
.
Position must be a string or a list, as follows:\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 indent
, 2 spaces by default.
Takes the approximate position
of an atom, and returns the full line from the filepath
.
It compares the atomic positions rounded up to the specified precision
decimals.\nIf return_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 indent
, 0 spaces by default.
Takes ATOMIC_POSITIONS, returns a dict as {element : number of atoms}
Create a Quantum ESPRESSO scf.in
file from a previous relax calculation.
If no folder
is provided, the current working directory is used.\nThe relax_in
and relax_out
files by default are relax.in
and relax.out
,\nupdate the names if necessary.
Converts a given cordinates
from crystal lattice vectors to cartesian.
Only for ibrav=0
. Uses the cell parameters.\nNote that the result is not multiplied by A
nor celldm(1)
.
Converts a given cordinates
from cartesian to the base of lattice vectors.
Only for ibrav=0
. Uses the cell parameters.\nNote that the result is not divided by A
nor celldm(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": "Functions to handle Slurm calls, to run calculations in clusters.
\n\n\n | \n |
---|---|
sbatch() | \n Sbatch all calculations | \n
scancel() | \n Scancel all calculations, or applying some filters | \n
scancel_here() | \n Scancel all calculations running from a specific folder | \n
squeue() | \n Get a Pandas DataFrame with info about the submitted calculations | \n
check_template() | \n Checks that the slurm template is OK, and provides an example if not | \n
Sbatch all the calculations at once.
\n\nCalculation names should follow prefix_ID.ext
,\nwith prefix
as the common name across calculations,\nfollowed by the calculation ID, used as JOB_NAME.\nThe extensions from in_ext
and out_ext
('.in' and '.out' by default)\nwill be used for the INPUT_FILE and OUTPUT_FILE of the slurm template.
The slurm template, template.slurm
by default,\nmust contain the keywords JOB_ID, INPUT_FILE and OUTPUT_FILE:
#SBATCH --job-name=JOB_NAME\nmpirun pw.x -inp INPUT_FILE > OUTPUT_FILE\n
\n\nRuns from the specified folder
, current working directory if empty.
If more control is required, a custom list of files
can be specified for sbatching.
If testing = True
it skips the final sbatching,\njust printing the commands on the screen.
Cancel all user
jobs.
If a particular status
string is provided,\nonly the calculations with said status will be cancelled.
If a particular text
string is provided,\nonly the calculations containing said text in the name will be deleted.
If testing = True
, it shows the calculations that would be deleted.
if the slurm squeue titles are different in your cluster,\nyou can specify them with key_jobid
, key_status
and key_name
.
Cancel all running jobs
in a given folder
.
If no job is provided, all jobs detected in the current folder will be cancelled.\nThe jobs will be detected from the <prefix>JOBID<sufix>
files, slurm-JOBID.out
by default.
Returns a Pandas DataFrame with the jobs from a specific user
Check the slurm template
inside folder
.
The current working directory is used if folder
is not provided.\nIf the file does not exist or is invalid, creates a template_EXAMPLE.slurm
file for reference.
This subpackage contains universal physical constants,\nas well as chemical data from all known elements.\nIt also includes functions to manage this data.
\n\n\n | \n |
---|---|
aton.phys.units | \n Universal constants and conversion factors | \n
aton.phys.atoms | \n Data from all chemical elements | \n
aton.phys.functions | \n Functions to sort and manage element data from the aton.phys.atoms dict | \n
All values and functions from phys submodules can be\nloaded directly as phys.value
or phys.function()
,\nas in the example below.
from 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
\nSee the API reference of the specific modules for more information.
\n\naton.phys.units
Constant values come from the 2022 CODATA Recommended Values of the Fundamental Physical Constants.
\n\nConversion factors for neutron scattering come from\nM. B\u00e9e, \"Quasielastic Neutron scattering\", Adam Hilger, Bristol and Philadelphia, 1988.
\n\naton.phys.atoms
Atomic mass
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 mass
, mass_number
and abundance
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 cross_section
$\\sigma_s$ are in barns (1 b = 100 fm$^2$).\nFrom Felix Fernandez-Alonso, \"Neutron Scattering Fundamentals\", 2013.
This module contains the atoms
megadictionary,\nwhich contains the properties of all elements.\nIt is managed and updated automatically with aton.phys.functions
.
The atoms
dictionary can be loaded directly as aton.phys.atoms
.
\n | \n |
---|---|
Element | \n Used as values in the atoms dict, stores element properties | \n
Isotope | \n Used as values in Element.isotope , contains isotope properties | \n
atoms | \n The dict with data from all elements | \n
from aton import phys\naluminium_cross_section = phys.atoms['Al'].cross_section # 1.503\nHe4_mass = phys.atoms['H'].isotope[4].mass # 4.0026032497\n
\nUsed in the 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 Isotope
of the element.\nThe keys are the mass number (A).
Used in the 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": "This module contains functions to sort and analyse\nchemical data using the aton.phys.atoms
megadictionary,\nwhich contains the properties of all elements.\nIt also contains the tools needed to\nautomatically update said megadictionary.
\n | \n |
---|---|
export_atoms() | \n Used to update and export the aton.phys.atoms dict | \n
split_isotope() | \n Splits element name and mass number | \n
allowed_isotopes() | \n Returns the available mass numbers for a given element | \n
All functions can be called from the phys subpackage directly, as:
\n\nfrom aton import phys\nphys.split_isotope('He4') # (He, 4)\nphys.allowed_isotopes('Li') # (6, 7)\n
\nExport a dictionary of chemical elements to a python file.
\n\nThis is used to build and update the aton.atoms
megadictionary, that contains\nall the element data, such as masses, cross-sections, etc.\nThe atoms.py
file must be modified here.
Split the name
of an isotope into the element and the mass number, eg. He4 -> He, 4.
If the isotope is not found in the 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 element
.
These mass numbers are used as isotope keys in the aton.atoms
megadictionary.
This module contains the constants from the \n2022 CODATA\nRecommended Values of the Fundamental Physical Constants.
\n\nIt also contains useful conversion factors for neutron scattering,\nfrom M. B\u00e9e, \"Quasielastic Neutron scattering\", Adam Hilger, Bristol and Philadelphia, 1988.
\n\nUnits and constants are named as their standard symbol, removing any /
divider in between.\nInverse of a unit or constant X, as in 1/X or X$^{-1}$, is expressed as X1
.
Universal constant names contain\nromanized greek letters,\nexcept for $\\mu$ which is used as u
.
Some examples:
\n\nfrom aton import phys\n# Constants\nphys.h # Planck constant\nphys.hbar # reduced Planck constant\nphys.a # fine-structure constant (alpha)\nphys.ue # electron magnetic moment (mu e)\nphys.mn # neutron mass\nphys.mnc2 # neutron mass energy equivalent\n# Conversions\n# meV to 1/cm\nenergy_in_cm1 = energy_in_meV * phys.meV_to_cm1\n# Bohr to Angstroms\ndistance_in_angstroms = distance_in_bohr * phys.bohr_to_A\n# m/s to rad/s (used in neutron scattering)\nvelocity_in_rads = velocity_in_ms * phys.ms_to_rads\n
\nUsing SI units unless stated otherwise.
\n\n$c$ | speed of light in vacuum / natural unit of velocity, in m/s
\n", "default_value": "299792458"}, {"fullname": "aton.phys.units.u0", "modulename": "aton.phys.units", "qualname": "u0", "kind": "variable", "doc": "$\\mu_0$ | vacuum magnetic permeability, in N\u00b7A$^{-2}$ ($4\\pi\\alpha\\hbar/e^2 c$)
\n", "default_value": "1.25663706127e-06"}, {"fullname": "aton.phys.units.e0", "modulename": "aton.phys.units", "qualname": "e0", "kind": "variable", "doc": "$\\epsilon_0$ | vacuum electric permittivity, in F\u00b7m$^{-1}$ ($1/\\mu_0 c^2$)
\n", "default_value": "1.25663706127e-06"}, {"fullname": "aton.phys.units.Z0", "modulename": "aton.phys.units", "qualname": "Z0", "kind": "variable", "doc": "$Z_0$ | characteristic impedance of vacuum, in $\\Omega$ ($\\mu_0 c$)
\n", "default_value": "376.730313412"}, {"fullname": "aton.phys.units.G", "modulename": "aton.phys.units", "qualname": "G", "kind": "variable", "doc": "$G$ | Newtonian constant of gravitation, in m$^3$\u00b7kg$^{-1}$\u00b7s$^{-1}$
\n", "default_value": "6.6743e-11"}, {"fullname": "aton.phys.units.h", "modulename": "aton.phys.units", "qualname": "h", "kind": "variable", "doc": "$h$ | 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": "$h$ | 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": "$\\hbar$ | reduced Planck constant / natural unit of action, 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": "$\\hbar$ | reduced Planck constant, in eV\u00b7s
\n\n$e$ | elementary charge, in C
\n", "default_value": "1.602176634e-19"}, {"fullname": "aton.phys.units.P0", "modulename": "aton.phys.units", "qualname": "P0", "kind": "variable", "doc": "$\\Phi_0$ | magnetic flux quantum, in Wb ($2\\pi\\hbar/(2e)$)
\n", "default_value": "2.067833848e-15"}, {"fullname": "aton.phys.units.G0", "modulename": "aton.phys.units", "qualname": "G0", "kind": "variable", "doc": "$G_0$ | conductance quantum, in S ($2e^2/2\\pi h$)
\n", "default_value": "7.748091729e-05"}, {"fullname": "aton.phys.units.KJ", "modulename": "aton.phys.units", "qualname": "KJ", "kind": "variable", "doc": "$K_J$ | Josephson constant, in Hz\u00b7V$^{-1}$ (2e/h)
\n", "default_value": "483597848400000.0"}, {"fullname": "aton.phys.units.RK", "modulename": "aton.phys.units", "qualname": "RK", "kind": "variable", "doc": "$R_K$ | von Klitzing constant, in $\\Omega$ ($\\mu_0 c/2\\alpha = 2\\pi\\hbar/e^2$)
\n", "default_value": "25812.80745"}, {"fullname": "aton.phys.units.uB", "modulename": "aton.phys.units", "qualname": "uB", "kind": "variable", "doc": "$\\mu_B$ | Bohr magneton, in J\u00b7T$^{-1}$ ($e\\hbar / 2m_e$)
\n", "default_value": "9.2740100657e-24"}, {"fullname": "aton.phys.units.uN", "modulename": "aton.phys.units", "qualname": "uN", "kind": "variable", "doc": "$\\mu_N$ | nuclear magneton, in J\u00b7T$^{-1}$ ($e\\hbar / 2m_p$)
\n\n$\\alpha$ | fine-structure constant ($e^2 / 4 \\pi \\epsilon_0 \\hbar c$)
\n", "default_value": "0.0072973525643"}, {"fullname": "aton.phys.units.a1", "modulename": "aton.phys.units", "qualname": "a1", "kind": "variable", "doc": "$\\alpha^{-1}$ | inverse fine-structure constant
\n", "default_value": "137.035999177"}, {"fullname": "aton.phys.units.cRinf", "modulename": "aton.phys.units", "qualname": "cRinf", "kind": "variable", "doc": "$cR\\infty$ | Rydberg frequency, in Hz ($\\alpha^2m_e c^2/2h = E_h/2h$)
\n", "default_value": "3289841960250000.0"}, {"fullname": "aton.phys.units.Rinf", "modulename": "aton.phys.units", "qualname": "Rinf", "kind": "variable", "doc": "$R\\infty$ | Rydberg constant, in $[m^{-1}]^a$
\n", "default_value": "10973731.568157"}, {"fullname": "aton.phys.units.a0", "modulename": "aton.phys.units", "qualname": "a0", "kind": "variable", "doc": "$a_0$ | Bohr radius, in m
\n", "default_value": "5.29177210544e-11"}, {"fullname": "aton.phys.units.Eh", "modulename": "aton.phys.units", "qualname": "Eh", "kind": "variable", "doc": "$E_h$ | Hartree energy, in J ($\\alpha^2m_ec^2=e^2/4\\pi\\epsilon_0a_0=2h c R_{\\infty}$)
\n\n$m_e$ | electron mass / natural unit of mass, in kg
\n", "default_value": "-21.8906162861"}, {"fullname": "aton.phys.units.me_uma", "modulename": "aton.phys.units", "qualname": "me_uma", "kind": "variable", "doc": "$m_e$ | electron mass, in uma
\n", "default_value": "0.0005485799090441"}, {"fullname": "aton.phys.units.mec2", "modulename": "aton.phys.units", "qualname": "mec2", "kind": "variable", "doc": "$m_e c^2$ | electron mass energy equivalent / natural unit of energy, in J
\n", "default_value": "8.187105788e-14"}, {"fullname": "aton.phys.units.mec2_eV", "modulename": "aton.phys.units", "qualname": "mec2_eV", "kind": "variable", "doc": "$m_e c^2$ | electron mass energy equivalent, in eV
\n", "default_value": "510998.95069"}, {"fullname": "aton.phys.units.lC", "modulename": "aton.phys.units", "qualname": "lC", "kind": "variable", "doc": "$\\lambda_C$ | Compton wavelength, in $[m]^a$
\n", "default_value": "2.42631023538e-12"}, {"fullname": "aton.phys.units.re", "modulename": "aton.phys.units", "qualname": "re", "kind": "variable", "doc": "$r_e$ | classical electron radius, in m ($\\alpha^2 a_0$)
\n", "default_value": "2.8179403205e-15"}, {"fullname": "aton.phys.units.se", "modulename": "aton.phys.units", "qualname": "se", "kind": "variable", "doc": "$\\sigma_e$ | Thomson cross section, in m$^2$ ($(8\\pi / 3)r_e^2$)
\n", "default_value": "6.6524587051e-29"}, {"fullname": "aton.phys.units.ue", "modulename": "aton.phys.units", "qualname": "ue", "kind": "variable", "doc": "$\\mu_e$ | electron magnetic moment, in J\u00b7T$^{-1}$
\n\n$m_p$ | proton mass, in kg
\n", "default_value": "-25.32737807405"}, {"fullname": "aton.phys.units.mp_uma", "modulename": "aton.phys.units", "qualname": "mp_uma", "kind": "variable", "doc": "$m_p$ | proton mass, in uma
\n", "default_value": "1.0072764665789"}, {"fullname": "aton.phys.units.mpc2", "modulename": "aton.phys.units", "qualname": "mpc2", "kind": "variable", "doc": "$m_p c^2$ | proton mass energy equivalent, in J
\n", "default_value": "1.50327761802e-10"}, {"fullname": "aton.phys.units.mpc2_eV", "modulename": "aton.phys.units", "qualname": "mpc2_eV", "kind": "variable", "doc": "$m_p c^2$ | proton mass energy equivalent, in eV
\n", "default_value": "938272089.43"}, {"fullname": "aton.phys.units.mpme", "modulename": "aton.phys.units", "qualname": "mpme", "kind": "variable", "doc": "$m_p/m_e$ | proton-electron mass ratio
\n", "default_value": "1836.152673426"}, {"fullname": "aton.phys.units.lCp", "modulename": "aton.phys.units", "qualname": "lCp", "kind": "variable", "doc": "$\\lambda_{C,p}$ | proton Compton wavelength, in $[m]^a$
\n", "default_value": "1.3214098536e-15"}, {"fullname": "aton.phys.units.rp", "modulename": "aton.phys.units", "qualname": "rp", "kind": "variable", "doc": "$r_p$ | proton rms charge radius, in m
\n", "default_value": "8.4075e-16"}, {"fullname": "aton.phys.units.up", "modulename": "aton.phys.units", "qualname": "up", "kind": "variable", "doc": "$\\mu_p$ | proton magnetic moment, in J\u00b7T$^{-1}$
\n\n$m_n$ | neutron mass, in kg
\n", "default_value": "1.67492750056e-27"}, {"fullname": "aton.phys.units.mn_uma", "modulename": "aton.phys.units", "qualname": "mn_uma", "kind": "variable", "doc": "$m_n$ | neutron mass, in uma
\n", "default_value": "1.00866491606"}, {"fullname": "aton.phys.units.mnc2", "modulename": "aton.phys.units", "qualname": "mnc2", "kind": "variable", "doc": "$m_n c^2$ | neutron mass energy equivalent, in J
\n", "default_value": "1.50534976514e-10"}, {"fullname": "aton.phys.units.mnc2_eV", "modulename": "aton.phys.units", "qualname": "mnc2_eV", "kind": "variable", "doc": "$m_n c^2$ | neutron mass energy equivalent, in eV
\n", "default_value": "939565421.94"}, {"fullname": "aton.phys.units.lCn", "modulename": "aton.phys.units", "qualname": "lCn", "kind": "variable", "doc": "$\\lambda_{C,n}$ | neutron compton wavelength, in $[m]^a$
\n", "default_value": "1.31959090382e-15"}, {"fullname": "aton.phys.units.un", "modulename": "aton.phys.units", "qualname": "un", "kind": "variable", "doc": "$\\mu_n$ | neutron magnetic moment, in J\u00b7T$^{-1}$
\n\n$m_d$ | deuteron mass, in kg
\n", "default_value": "3.3435837768e-27"}, {"fullname": "aton.phys.units.md_uma", "modulename": "aton.phys.units", "qualname": "md_uma", "kind": "variable", "doc": "$m_d$ | deuteron mass, in uma
\n", "default_value": "2.013553212544"}, {"fullname": "aton.phys.units.mdc2", "modulename": "aton.phys.units", "qualname": "mdc2", "kind": "variable", "doc": "$m_d c^2$ | deuteron mass energy equivalent, in J
\n", "default_value": "3.00506323491e-10"}, {"fullname": "aton.phys.units.mdc2_eV", "modulename": "aton.phys.units", "qualname": "mdc2_eV", "kind": "variable", "doc": "$m_d c^2$ | deuteron mass energy equivalent, in eV
\n", "default_value": "1875612945"}, {"fullname": "aton.phys.units.rd", "modulename": "aton.phys.units", "qualname": "rd", "kind": "variable", "doc": "$r_d$ | deuteron rms charge radius, in m
\n", "default_value": "2.12778e-15"}, {"fullname": "aton.phys.units.ud", "modulename": "aton.phys.units", "qualname": "ud", "kind": "variable", "doc": "$\\mu_d$ | deuteron magnetic moment, in J\u00b7T$^{-1}$
\n\n$m_\\alpha$ | alpha particle mass, in kg
\n", "default_value": "6.644657345e-27"}, {"fullname": "aton.phys.units.mac2", "modulename": "aton.phys.units", "qualname": "mac2", "kind": "variable", "doc": "$m_\\alpha$ | alpha particle mass energy equivalent, in J
\n", "default_value": "5.9719201997e-10"}, {"fullname": "aton.phys.units.mac2_eV", "modulename": "aton.phys.units", "qualname": "mac2_eV", "kind": "variable", "doc": "$m_\\alpha$ | alpha particle mass energy equivalent, in eV
\n", "default_value": "3727379411.8"}, {"fullname": "aton.phys.units.ra", "modulename": "aton.phys.units", "qualname": "ra", "kind": "variable", "doc": "$r_\\alpha$ | alpha particle rms charge radius, in m
\n\n$N_A$ | Avogadro constant, in mol$^{-1}$
\n", "default_value": "6.02214076e+23"}, {"fullname": "aton.phys.units.k", "modulename": "aton.phys.units", "qualname": "k", "kind": "variable", "doc": "$k$ | Boltzmann constant, in J\u00b7K$^{-1}$
\n", "default_value": "1.380649e-23"}, {"fullname": "aton.phys.units.k_eV", "modulename": "aton.phys.units", "qualname": "k_eV", "kind": "variable", "doc": "$k$ | Boltzmann constant, in eV\u00b7K$^{-1}$
\n", "default_value": "8.617333262e-05"}, {"fullname": "aton.phys.units.mu", "modulename": "aton.phys.units", "qualname": "mu", "kind": "variable", "doc": "$m_u$ | atomic mass constant / unified atomic mass unit, in kg ($\\frac{1}{12}m(^{12}C)$)
\n", "default_value": "1.66053906892e-27"}, {"fullname": "aton.phys.units.muc2", "modulename": "aton.phys.units", "qualname": "muc2", "kind": "variable", "doc": "$m_u c^2$ | atomic mass constant energy equivalent, in J
\n", "default_value": "1.49241808768e-10"}, {"fullname": "aton.phys.units.muc2_eV", "modulename": "aton.phys.units", "qualname": "muc2_eV", "kind": "variable", "doc": "$m_u c^2$ | atomic mass constant energy equivalent, in eV
\n", "default_value": "931494103.72"}, {"fullname": "aton.phys.units.R", "modulename": "aton.phys.units", "qualname": "R", "kind": "variable", "doc": "$R$ | molar gas constant, in J\u00b7mol$^{-1}$K$^{-1}$ ($N_A k$)
\n", "default_value": "8.314462618"}, {"fullname": "aton.phys.units.F", "modulename": "aton.phys.units", "qualname": "F", "kind": "variable", "doc": "$F$ | Faraday constant, in C\u00b7mol$^{-1}$ ($N_A e$)
\n", "default_value": "96485.33212"}, {"fullname": "aton.phys.units.s", "modulename": "aton.phys.units", "qualname": "s", "kind": "variable", "doc": "$\\sigma$ | Stefan-Boltzmann constant, in W\u00b7m$^{-2}$\u00b7K$^{-4}$ ($(\\pi^2/60)k^4 /\\hbar^3 c^2$)
\n\nNote that to change between temperature scales,\nthese constants must be added instead of multiplied.
\n", "default_value": "0.008314"}, {"fullname": "aton.phys.units.C_to_K_scale", "modulename": "aton.phys.units", "qualname": "C_to_K_scale", "kind": "variable", "doc": "\n", "default_value": "273.15"}, {"fullname": "aton.phys.units.K_to_C_scale", "modulename": "aton.phys.units", "qualname": "K_to_C_scale", "kind": "variable", "doc": "The QRotor module is used to study the energy levels and wavefunctions of quantum rotations,\nsuch as those of methyl and amine groups.\nThese quantum systems are represented by the qrotor.System()
object.
QRotor can obtain custom potentials from DFT,\nwhich are used to solve the quantum system.
\n\nThis module uses meV as the default unit in the calculations.
\n\n\n | \n |
---|---|
aton.qrotor.system | \n Definition of the quantum System object | \n
aton.qrotor.systems | \n Functions to manage several System objects, such as a list of systems | \n
aton.qrotor.rotate | \n Rotate specific atoms from structural files | \n
aton.qrotor.constants | \n Bond lengths and inertias | \n
aton.qrotor.potential | \n Potential definitions and loading functions | \n
aton.qrotor.solve | \n Solve rotation eigenvalues and eigenvectors | \n
aton.qrotor.plot | \n Plotting functions | \n
A basic calculation of the eigenvalues for a zero potential goes as follows:
\n\nimport aton.qrotor as qr\nsystem = qr.System()\nsystem.gridsize = 200000 # Size of the potential grid\nsystem.B = 1 # Rotational inertia\nsystem.potential_name = 'zero'\nsystem.solve()\nsystem.eigenvalues\n# [0.0, 1.0, 1.0, 4.0, 4.0, 9.0, 9.0, ...] # approx values\n
\nThe accuracy of the calculation increases with bigger gridsizes,\nbut note that the runtime increases exponentially.
\n\nThe same calculation can be performed for a methyl group,\nin a cosine potential of amplitude 30 meV:
\n\nimport aton.qrotor as qr\nsystem = qr.System()\nsystem.gridsize = 200000 # Size of the potential grid\nsystem.B = qr.B_CH3 # Rotational inertia of a methyl group\nsystem.potential_name = 'cosine'\nsystem.potential_constants = [0, 30, 3, 0] # Offset, max, freq, phase (for cos pot.)\nsystem.solve()\n# Plot potential and eigenvalues\nqr.plot.energies(system)\n# Plot the first wavefunctions\nqr.plot.wavefunction(system, levels=[0,1,2], square=True)\n
\nQRotor can be used to obtain custom rotational potentials from DFT calculations.\nUsing Quantum ESPRESSO, running an SCF calculation for a methyl rotation every 10 degrees:
\n\nimport aton.qrotor as qr\nfrom aton import interface\n# Approx crystal positions of the atoms to rotate\natoms = [\n '1.101 1.204 1.307'\n '2.102 2.205 2.308'\n '3.103 3.206 3.309'\n]\n# Create the input SCF files, saving the filenames to a list\nscf_files = qr.rotate.structure_qe('molecule.in', positions=atoms, angle=10, repeat=True)\n# Run the Quantum ESPRESSO calculations\ninterface.slurm.sbatch(files=scf_files)\n
\nTo load the calculated potential to a QRotor System,
\n\n# Create a 'potential.dat' file with the potential as a function of the angle\nqr.potential.from_qe()\n# Load to the system\nsystem = qr.potential.load()\n# Solve the system, interpolating to a bigger gridsize\nsystem.B = qr.B_CH3\nsystem.solve(200000)\nqr.plot.energies(system)\n
\nCheck the API documentation for more details.
\n"}, {"fullname": "aton.qrotor.constants", "modulename": "aton.qrotor.constants", "kind": "module", "doc": "Common constants and default inertia values used in the QRotor subpackage.
\n\nBond lengths and angles were obtained from MAPbI3,\nsee Cryst. Growth Des. 2024, 24, 391\u2212404.
\n\nDistance 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_CH3", "modulename": "aton.qrotor.constants", "qualname": "I_CH3", "kind": "variable", "doc": "Inertia of CH3, in kg\u00b7m^2.
\n", "default_value": "np.float64(5.37903596799128e-47)"}, {"fullname": "aton.qrotor.constants.I_CD3", "modulename": "aton.qrotor.constants", "qualname": "I_CD3", "kind": "variable", "doc": "Inertia of CD3, in kg\u00b7m^2.
\n", "default_value": "np.float64(1.0748582164136045e-46)"}, {"fullname": "aton.qrotor.constants.I_NH3", "modulename": "aton.qrotor.constants", "qualname": "I_NH3", "kind": "variable", "doc": "Inertia of NH3, in kg\u00b7m^2.
\n", "default_value": "np.float64(4.717299973303422e-47)"}, {"fullname": "aton.qrotor.constants.I_ND3", "modulename": "aton.qrotor.constants", "qualname": "I_ND3", "kind": "variable", "doc": "Inertia of ND3, in kg\u00b7m^2.
\n", "default_value": "np.float64(9.426277618824576e-47)"}, {"fullname": "aton.qrotor.constants.B_CH3", "modulename": "aton.qrotor.constants", "qualname": "B_CH3", "kind": "variable", "doc": "Rotational energy of CH3, in meV\u00b7s/kg\u00b7m^2.
\n", "default_value": "np.float64(0.6452195002679675)"}, {"fullname": "aton.qrotor.constants.B_CD3", "modulename": "aton.qrotor.constants", "qualname": "B_CD3", "kind": "variable", "doc": "Rotational energy of CD3, in meV\u00b7s/kg\u00b7m^2.
\n", "default_value": "np.float64(0.32289457773984676)"}, {"fullname": "aton.qrotor.constants.B_NH3", "modulename": "aton.qrotor.constants", "qualname": "B_NH3", "kind": "variable", "doc": "Rotational energy of NH3, in meV\u00b7s/kg\u00b7m^2.
\n", "default_value": "np.float64(0.7357299554474442)"}, {"fullname": "aton.qrotor.constants.B_ND3", "modulename": "aton.qrotor.constants", "qualname": "B_ND3", "kind": "variable", "doc": "Rotational energy of ND3, in meV\u00b7s/kg\u00b7m^2.
\n", "default_value": "np.float64(0.36818976053280467)"}, {"fullname": "aton.qrotor.constants.constants_titov2023", "modulename": "aton.qrotor.constants", "qualname": "constants_titov2023", "kind": "variable", "doc": "Potential constants from\nK. Titov et al., Phys. Rev. Mater. 7, 073402 (2023)\nfor the aton.qrotor.potential.titov2023
potential.\nIn meV units.
This module provides straightforward functions to plot QRotor data.
\n\n\n | \n |
---|---|
potential() | \n Potential values as a function of the angle | \n
energies() | \n Calculated eigenvalues | \n
reduced_energies() | \n Reduced energies E/B as a function of the reduced potential V/B | \n
wavefunction() | \n Selected wavefunctions or squared wavefunctions of a system | \n
convergence() | \n Energy convergence | \n
Plot the potential values of a system
(System object, or list of systems).
Title can be customized with title
.\nIf empty, system[0].comment will be used as title if no more comments are present.
marker
and linestyle
can be a Matplotlib string or list of strings.
Plot the eigenvalues of data
(System or a list of System objects).
Plots the reduced energy of the system E/B vs the reduced potential energy V/B.
\n\nTakes a data
list of System objects as input.
Plot the wavefunction of a system
for the specified levels
.
Wavefunctions are squared by default, showing the probabilities;\nTo show the actual wavefunctions, set square = False
.
levels
can be a list of indexes, or the number of levels to plot.
Specific wavefunctions can be overlapped with overlap
as a list with the target indexes.\nThe overlap
value can also be the max number of wavefunctions to add.\nAll found wavefunctions can be added together with overlap = True
;\nbut note that this overlap is limited by the number of System.E_levels,\nthat must be specified before solving the system.\nSetting overlap
will ignore the levels
argument.
Plot the energy convergence of a data
list of Systems as a function of the gridsize.
This module contains functions to calculate the actual potential_values
of the system.
\n | \n |
---|---|
save() | \n Save the potential from a System to a data file | \n
load() | \n Load a System with a custom potential from a potential data file | \n
from_qe() | \n Creates a potential data file from Quantum ESPRESSO outputs | \n
interpolate() | \n Interpolates the current System.potential_values to a new System.gridsize | \n
solve() | \n Solve the potential values based on the potential name | \n
A sinthetic potential can be created by specifying its name in System.potential_name
,\nalong with the corresponding System.potential_constants
if required.\nAvailable potentials are:
\n | \n |
---|---|
zero() | \n Zero potential | \n
sine() | \n Sine potential | \n
cosine() | \n Cosine potential | \n
titov2023() | \n Potential of the hindered methyl rotor, as in titov2023. | \n
Save the rotational potential from a system
to a potential data file.
The output filepath
contains angle and energy columns,\nin degrees and meVs by default.\nThe units can be changed with angle
and energy
,\nbut only change these defaults if you know what you are doing.
Read a rotational potential energy dataset.
\n\nThe input file in filepath
should contain two columns with angle and potential energy values.\nDegrees and meV are assumed as default units unless stated in angle
and energy
.\nUnits will be converted automatically to radians and meV.
An optional comment
can be included in the output System.
A previous System object can be provided through system
to update its potential values.
Creates a potential data file from Quantum ESPRESSO outputs.
\n\nThe angle in degrees is extracted from the output filenames,\nwhich must follow whatever_ANGLE.out
.
Outputs from SCF calculations must be located in the provided folder
(CWD if None).\nFiles can be filtered by those containing the specified include
filters,\nexcluding those containing any string from the exclude
list. \nThe output filepath
name is 'potential.dat'
by default.
Energy values are saved to meV by dafault, unless specified in energy
.\nOnly change the energy units if you know what you are doing;\nremember that default energy units in QRotor are meV!
Interpolates the current System.potential_values
\nto a new grid of size System.gridsize
.
Solves System.potential_values
\naccording to the System.potential_name
,\nreturning the new potential_values
.\nAvaliable potential names are zero
, sine
and titov2023
.
If System.potential_name
is not present or not recognised,\nthe current System.potential_values
are used.
This function provides basic solving of the potential energy function.\nTo interpolate to a new gridsize and correct the potential offset after solving,\ncheck aton.qrotor.solve.potential()
.
Zero potential.
\n\n$V(x) = 0$
\n", "signature": "(system: aton.qrotor.system.System):", "funcdef": "def"}, {"fullname": "aton.qrotor.potential.sine", "modulename": "aton.qrotor.potential", "qualname": "sine", "kind": "function", "doc": "Sine potential.
\n\n$V(x) = C_0 + \\frac{C_1}{2} sin(x C_2 + C_3)$
\nWith $C_0$ as the potential offset,\n$C_1$ as the max potential value (without considering the offset),\n$C_2$ as the frequency, and $C_3$ as the phase.\nIf no System.potential_constants
are provided, defaults to $sin(3x)$
Cosine potential.
\n\n$V(x) = C_0 + \\frac{C_1}{2} cos(x C_2 + C_3)$
\nWith $C_0$ as the potential offset,\n$C_1$ as the max potential value (without considering the offset),\n$C_2$ as the frequency, and $C_3$ as the phase.\nIf no System.potential_constants
are provided, defaults to $cos(3x)$
Potential energy function of the hindered methyl rotor, from\nK. Titov et al., Phys. Rev. Mater. 7, 073402 (2023).
\n\n$V(x) = C_0 + C_1 sin(3x) + C_2 cos(3x) + C_3 sin(6x) + C_4 cos(6x)$
\nDefault constants are aton.qrotor.constants.constants_titov2023
[0].
This submodule contains tools to rotate molecular structures.\nWorks with Quantum ESPRESSO input files.
\n\n\n | \n |
---|---|
structure_qe() | \n Rotate specific atoms from a Quantum ESPRESSO input file | \n
rotate_coords() | \n Rotate a specific list of coordinates | \n
Rotates atoms from a Quantum ESPRESSO input file.
\n\nTakes a filepath
with a molecular structure, and three or more atomic positions
(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 by precision
.
It rotates the atoms by a specific angle
in degrees.\nAdditionally, if repeat = 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).
By default, the rotation axis is defined by the perpendicular vector\npassing through the geometrical center of the first three points.\nTo override this and instead use the vector between the first two atoms\nas the rotation axis, set use_centroid = False
.
To debug, show_axis = True
adds two additional helium atoms as the rotation vector.
Rotates geometrical coordinates.
\n\nTakes a list of atomic positions
in cartesian coordinates, as\n[[x1,y1,z1], [x2,y2,z2], [x3,y3,z3], [etc]
.\nThen rotates said coordinates by a given angle
in degrees.\nReturns a list with the updated positions.
By default, the rotation axis is defined by the perpendicular vector\npassing through the geometrical center of the first three points.\nTo override this and use the vector between the first two atoms\nas the rotation axis, set use_centroid = False
.
If show_axis = True
it returns two additional coordinates at the end of the list,\nwith the centroid and the rotation vector. Only works with use_centroid = True
.
This module is used to solve the hamiltonian eigenvalues and eigenvectors for a given quantum system.\nSparse matrices are used to achieve optimal performance.
\n\n\n | \n |
---|---|
energies() | \n Solve the quantum system, including eigenvalues and eigenvectors | \n
potential() | \n Solve the potential values of the system | \n
schrodinger() | \n Solve the Schr\u00f6diger equation for the system | \n
hamiltonian_matrix() | \n Calculate the hamiltonian matrix of the system | \n
laplacian_matrix() | \n Calculate the second derivative matrix for a given grid | \n
Solves the quantum system
.
This includes solving the potential, the eigenvalues and the eigenvectors.
\n\nThe resulting System object is saved with pickle to filename
if specified.
Solves the potential values of the system
.
It interpolates the potential if system.gridsize
is larger than the current grid.\nIt solves the potential according to the potential name,\nby calling aton.qrotor.potential.solve()
.\nThen it applies extra operations, such as removing the potential offset\nif system.correct_potential_offset = True
.
Solves the Schr\u00f6dinger equation for a given system
.
Uses ARPACK in shift-inverse mode to solve the hamiltonian sparse matrix.
\n", "signature": "(system: aton.qrotor.system.System) -> aton.qrotor.system.System:", "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 system
.
Calculates the Laplacian (second derivative) matrix for a given grid
.
The System
object contains all the information needed for a single QRotor calculation.\nThis class can be loaded directly as aton.qrotor.System()
.
Quantum system.
\n\nContains all the data for a single QRotor calculation, with both inputs and outputs.
\n"}, {"fullname": "aton.qrotor.system.System.__init__", "modulename": "aton.qrotor.system", "qualname": "System.__init__", "kind": "function", "doc": "\n", "signature": "(\tcomment: str = None,\tgroup: str = 'CH3',\tE_levels: int = 15,\tcorrect_potential_offset: bool = True,\tsave_eigenvectors: bool = True,\tgridsize: int = None,\tgrid=[],\tB: float = None,\tpotential_name: str = '',\tpotential_constants: list = None,\tpotential_values=[])"}, {"fullname": "aton.qrotor.system.System.version", "modulename": "aton.qrotor.system", "qualname": "System.version", "kind": "variable", "doc": "Version of the package used to generate the data.
\n"}, {"fullname": "aton.qrotor.system.System.comment", "modulename": "aton.qrotor.system", "qualname": "System.comment", "kind": "variable", "doc": "Custom comment for the dataset.
\n", "annotation": ": str"}, {"fullname": "aton.qrotor.system.System.group", "modulename": "aton.qrotor.system", "qualname": "System.group", "kind": "variable", "doc": "Chemical group, methyl or amine: 'CH3'
, 'CD3'
, 'NH3'
, 'ND3'
.
Number of energy levels to be studied.
\n", "annotation": ": int"}, {"fullname": "aton.qrotor.system.System.correct_potential_offset", "modulename": "aton.qrotor.system", "qualname": "System.correct_potential_offset", "kind": "variable", "doc": "Correct the potential offset as V - min(V)
or not.
Save or not the eigenvectors. Final file size will be bigger.
\n", "annotation": ": bool"}, {"fullname": "aton.qrotor.system.System.gridsize", "modulename": "aton.qrotor.system", "qualname": "System.gridsize", "kind": "variable", "doc": "Number of points in the grid.
\n", "annotation": ": int"}, {"fullname": "aton.qrotor.system.System.grid", "modulename": "aton.qrotor.system", "qualname": "System.grid", "kind": "variable", "doc": "The grid with the points to be used in the calculation.
\n\nCan be set automatically over $2 \\pi$ with System.set_grid()
.\nUnits must be in radians.
Rotational inertia, as in $B=\\frac{\\hbar^2}{2I}$.
\n", "annotation": ": float"}, {"fullname": "aton.qrotor.system.System.potential_name", "modulename": "aton.qrotor.system", "qualname": "System.potential_name", "kind": "variable", "doc": "Name of the desired potential: 'zero'
, 'titov2023'
, 'test'
...\nIf empty or unrecognised, the custom potential values inside System.potential_values
will be used.
List of constants to be used in the calculation of the potential energy, in the aton.qrotor.potential
module.
Numpy ndarray with the potential values for each point in the grid.
\n\nCan be calculated with a function available in the qrotor.potential
module,\nor loaded externally with the qrotor.potential.load()
function.\nPotential energy units must be in meV.
min(V)
before offset correction when correct_potential_offset = True
min(V)
max(V)
Calculated eigenvalues of the system. Should be in meV.
\n"}, {"fullname": "aton.qrotor.system.System.eigenvectors", "modulename": "aton.qrotor.system", "qualname": "System.eigenvectors", "kind": "variable", "doc": "Eigenvectors, if save_eigenvectors
is True. Beware of the file size.
max(V) - min(eigenvalues)
eigenvalues[1] - eigenvalues[0]
\n", "annotation": ": float"}, {"fullname": "aton.qrotor.system.System.runtime", "modulename": "aton.qrotor.system", "qualname": "System.runtime", "kind": "variable", "doc": "Time taken to solve the eigenvalues.
\n", "annotation": ": float"}, {"fullname": "aton.qrotor.system.System.summary", "modulename": "aton.qrotor.system", "qualname": "System.summary", "kind": "function", "doc": "\n", "signature": "(self):", "funcdef": "def"}, {"fullname": "aton.qrotor.system.System.set_grid", "modulename": "aton.qrotor.system", "qualname": "System.set_grid", "kind": "function", "doc": "Sets the System.grid
to the specified gridsize
from 0 to $2\\pi$.
If the system had a previous grid and potential values,\nit will interpolate those values to the new gridsize,\nusing aton.qrotor.potential.interpolate()
.
Normalise System.group
name, and set System.B
based on it.
Solves the quantum system.
\n\nThe potential can be interpolated to a new_gridsize
.
Same as running aton.qrotor.solve.energies(System)
.
Discard data that takes too much space,\nlike eigenvectors, potential values and grids.
\n", "signature": "(self):", "funcdef": "def"}, {"fullname": "aton.qrotor.systems", "modulename": "aton.qrotor.systems", "kind": "module", "doc": "This module contains utility functions to handle multiple aton.qrotor.system
calculations.
\n | \n |
---|---|
as_list() | \n Ensures that a list only contains System objects | \n
get_energies() | \n Get the eigenvalues from all systems | \n
get_gridsizes() | \n Get all gridsizes | \n
get_runtimes() | \n Get all runtimes | \n
get_groups() | \n Get the chemical groups in use | \n
sort_by_gridsize() | \n Sort systems by gridsize | \n
reduce_size() | \n Discard data that takes too much space | \n
get_ideal_E() | \n Calculate the ideal energy for a specified level | \n
Ensures that systems
is a list of System objects.
If it is a System, returns a list with that System as the only element.\nIf it is neither a list nor a System,\nor if the list does not contain only System objects,\nit raises an error.
\n", "signature": "(systems) -> None:", "funcdef": "def"}, {"fullname": "aton.qrotor.systems.get_energies", "modulename": "aton.qrotor.systems", "qualname": "get_energies", "kind": "function", "doc": "Get a list with all eigenvalues from all systems.
\n\nIf no eigenvalues are present for a particular system, appends None.
\n", "signature": "(systems: list) -> list:", "funcdef": "def"}, {"fullname": "aton.qrotor.systems.get_gridsizes", "modulename": "aton.qrotor.systems", "qualname": "get_gridsizes", "kind": "function", "doc": "Get a list with all gridsize values.
\n\nIf no gridsize value is present for a particular system, appends None.
\n", "signature": "(systems: list) -> list:", "funcdef": "def"}, {"fullname": "aton.qrotor.systems.get_runtimes", "modulename": "aton.qrotor.systems", "qualname": "get_runtimes", "kind": "function", "doc": "Returns a list with all runtime values.
\n\nIf no runtime value is present for a particular system, appends None.
\n", "signature": "(systems: list) -> list:", "funcdef": "def"}, {"fullname": "aton.qrotor.systems.get_groups", "modulename": "aton.qrotor.systems", "qualname": "get_groups", "kind": "function", "doc": "Returns a list with all System.group
values.
Sorts a list of System objects by System.gridsize
.
Discard data that takes too much space.
\n\nRemoves eigenvectors, potential values and grids,\nfor all System values inside the systems
list.
Calculates the ideal energy for a specified E_level
.
To be used in convergence tests with potential_name = 'zero'
.
This module contains spectral analysis tools.
\n\n\n | \n |
---|---|
aton.spx.classes | \n Definition of the Spectra , Plotting and Material classes, instantiated as aton.spx.Class() | \n
aton.spx.fit | \n Spectral fitting functions | \n
aton.spx.normalize | \n Spectra normalisation | \n
aton.spx.deuterium | \n Deuteration estimation functions | \n
aton.spx.samples | \n Material definition examples | \n
aton.spx.plot | \n Spectra plotting, as aton.spx.plot(Spectra) | \n
To 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\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
\nMore examples in the Aton/examples/
folder.
This module contains common classes used to load and manipulate spectral data.\nAny class can be instantiated directly from the aton.spx
module,\nas aton.spx.Class()
.
\n | \n |
---|---|
Spectra | \n Used to load and process spectral data | \n
Plotting | \n Stores plotting options, used in Spectra.plotting | \n
Material | \n Used to store and calculate material parameters, such as molar masses and neutron cross sections | \n
To load two INS spectra CSV files with cm$^{-1}$ as input units,\nconverting them to meV units, and finally plotting them:
\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
\nCheck more use examples in the ATON/examples/
folder.
Stores plotting options, read by 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 [xlim_low, xlim_top]
.
List with the y-limits of the plot, as in [ylim_low, ylim_top]
.
List with additional margins at the bottom and top of the plot, as in [low_margin, top_margin]
.
If True
, 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 vline
.
It can be an array of the same length as 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 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 None
, the default label will be used.\nSet to ''
to remove the label of the vertical axis.
Legend of the plot.
\n\nIf 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 to False
will not be displayed.
Title of the legend, defaults to None
.
Size of the legend, as in matplotlib. Defaults to 'medium'
.
Location of the legend, as in matplotlib. Defaults to '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 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: 'INS'
, 'ATR'
, or 'RAMAN'
.
Custom comment. If Plotting.title
is None, it will be the title of the plot.
List containing the files with the spectral data.
\n\nLoaded automatically to 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 files
at initialization.
Target units of the spectral data.
\n\nCan be 'meV'
or 'cm-1'
.
Input units of the spectral data, used in the input CSV files.
\n\nCan be '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']
.
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\nSpectra.set_units('meV', 'cm-1')\n
\nMaterial class.
\n\nUsed to calculate molar masses and cross sections,\nand to pass data to different analysis functions\nsuch as 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 Material.set()
.
Dict of atoms in the material, as in {'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 Material.set()
.
Number of moles.
\n\nSet automatically with Material.set()
.
Error of the number of moles.
\n\nSet automatically with Material.set()
.
Molar mass of the material, in mol/g.
\n\nCalculated automatically with Material.set()
.
Neutron total bound scattering cross section, in barns.
\n\nCalculated automatically with 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": "This module contains methods to calculate deuteration levels from different spectra.
\n\n\n | \n |
---|---|
impulse_approx() | \n Calculate the deuteration levels from INS spectra with the Impulse Approximation | \n
peaks_mapbi3() | \n Estimates CH$_3$NH$_3$PbI$_3$ deuteration by integrating the INS disrotatory peaks | \n
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 aton.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\nby H_df_index
and D_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 peaks
must be a dictionary with the peak limits\nand the baseline, as in the example below:
peaks = {\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
\nPeak keywords required for selective deuteration (only C or only N):\nh6d0
, h5d1
, h4d2
, h3d3
.
Additional peak keywords required for total deuteration:\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": "This module contains functions for fitting and analyzing spectral data.
\n\n\n | \n |
---|---|
plateau() | \n Fit the mean value and the error of a plateau | \n
area_under_peak() | \n Calculate the area under a given peak | \n
ratio_areas() | \n Check the ratio between two areas | \n
mean() | \n Get the mean and standard deviation of a list of values | \n
Fit the mean value and the error of a plateau in a aton.spectra.Spectra
object.
Use as aton.spx.fit.plateau(spectra, cuts=[low_cut, high_cut], df_index=0)
.
If aton.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 the aton.spx.classes.Spectra
object.
Note that cuts
, low_cut
and/or top_cut
can be set to None.
Calculate the area under a given peak.
\n\nPeaks must be defined as peak:list=[xmin, xmax, baseline=0, baseline_error=0]
.\nIf the dataset has no Error
column, the error for each point is assumed to be the same\nas the baseline error if errors_as_in_baseline=True
, otherwise it is assumed to be zero.\nIf min_as_baseline=True
and baseline=0
, the baseline is assumed to be the minimum value.\nAlso, if min_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 area / area_total
. This behavior is modified if inverse_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 array
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 degrees_of_freedom
, zero by default.\nSet it to 1
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 rounded=False
.
This module contains functions to normalize data and other variables.
\n\n\n | \n |
---|---|
height() | \n Normalize a spectra by height | \n
area() | \n Normalize a spectra by the area under the datasets | \n
unit_str() | \n Normalize a unit string from user input | \n
Normalize a set of spectra
by height.
By default it normalises the spectra over the entire range.\nThis can be modified by setting a specific range,\nas in range = [x_min, x_max]
with axis = 'x'
.\nIt can also normalise over manual y-positions,\nfor example for peaks with different baselines.\nThis can be done by settingch axis='y'
, and\nrange = [[y_min_1, y_max_1], ..., [y_min_N, y_max_N]]
.
Heights are normalised with respect to the\nreference dataframe df_index
, the first one by default.
Normalize spectra
by the area under the datasets.
Normalize unit
string from user input.
This module contains the plot()
function,\nused to plot aton.spx.classes.Spectra
data,\ncontaining optional aton.spx.classes.Plotting
parameters.
It is used as aton.spx.plot(Spectra)
Plots a spectra
.
Optional aton.spectra.classes.Plotting
attributes can be used.
This module contains premade examples of material compositions, for testing purposes.\nThe aton.spx.classes.Material.grams
is yet to be provided,\nbefore setting the material as aton.spx.Material.set()
.
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": "Common system tools across all ATON subpackages.
\n\n\n | \n |
---|---|
aton.st.file | \n File manipulation | \n
aton.st.call | \n Run bash scripts and related | \n
aton.st.alias | \n Useful dictionaries for user input correction | \n
This module contains common dictionaries to normalise and correct user inputs.\nAll values can be found in lowercase, to allow comparison with the string.lower()
method.
units
\nspatial
\nexperiments
\nfiles
\nboolean
\nmath
unit = 'Electronvolts'\nif unit.lower() in aton.alias.units['eV']:\n ... do stuff ...\n
\nDict 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 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 string.lower()
.
Strings related to files. Values must be compared to 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', 'Si', 'SI', 'si', 'S', 's'], False: ['no', 'NO', 'No', 'N', 'n', 'F', 'False', 'FALSE', 'f', 'false']}"}, {"fullname": "aton.st.alias.math", "modulename": "aton.st.alias", "qualname": "math", "kind": "variable", "doc": "Math-related strings.
\n", "annotation": ": dict", "default_value": "{'sin': ['sin', 'sen', 'sine', 'seno'], 'cos': ['cos', 'cosine', 'coseno'], 'tg': ['tg', 'tangent', 'tangente'], '0': ['zero', 'cero', '0']}"}, {"fullname": "aton.st.call", "modulename": "aton.st.call", "kind": "module", "doc": "Functions to handle bash calls and related operations on Linux systems.
\n\n\n | \n |
---|---|
bash() | \n Run a bash shell commands | \n
git() | \n Automatically update a Git repository | \n
here() | \n Runs the rest of the script inside a given folder | \n
Run a bash shell commands.
\n\nA given command
will be executed inside an optional cwd
directory.\nIf empty, the current working directory will be used.\nPrints the running command and outputs by default, override this with verbose=False
.\nReturns the result of the command used, except for when\nerrors are raised automatically; set return_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 folder
.
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 folder
, 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": "Functions to move files around.
\n\n\n | \n |
---|---|
get() | \n Check that a file exists, and return the full path | \n
get_list() | \n Get a list of the files inside a folder, applying optional filters | \n
get_dir() | \n Get the full path of a folder or the cwd | \n
copy() | \n Copy file | \n
move() | \n Move file | \n
remove() | \n Remove file or folder | \n
rename_on_folder() | \n Batch rename files from a folder | \n
rename_on_folders() | \n Barch rename files from subfolders | \n
copy_to_folders() | \n Copy files to individual subfolders | \n
save() | \n Save a Python object to a binary file, as .aton | \n
load() | \n Load a Python object from a binary file, as .aton | \n
Check if filepath
exists, and returns its full path.
Raises an error if the file is not found,\nunless return_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 include
filters\n(string or list of strings) to return a single file.\nIf this fails, try using more strict filters to return a single file.
Return the files inside a folder
, applying optional filters.
Only filenames containing all strings in the include
list will be returned.\nFilenames containing any string from the exclude
list will be ignored.
The full paths are returned by default; to get only the base names, set abspath = False
.\nThe CWD folder is used by default if no folder
is provided.\nIt also returns folders if also_folders = True
.
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.
Copies old
file to new
file
Moves old
file to new
file.
Removes the given file or folder at filepath
.
\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!
\n
Batch renames files in the given folder
.
Replaces the old
string by new
string.\nIf no folder is provided, the current working directory is used.
Renames the files inside the subfolders in the parent folder
.
Renames from an old
string to the new
string.\nIf no folder
is provided, the current working directory is used.
Copies the files from the parent folder
with the given extension
to individual subfolders.
The subfolders are named as the original files,\nremoving the strings from the strings_to_delete
list.\nIf no folder
is provided, it runs in the current working directory.
Save a Python object in the current working directory as a binary *.aton
file.
Load a Python object from a binary *.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": "This subpackage contains tools for general text operations.\nIt provides the basic functionality that powers more complex subpackages,\nsuch as aton.interface
.
\n | \n |
---|---|
aton.txt.find | \n Search for specific content from a text file | \n
aton.txt.edit | \n Edit specific content from a text file | \n
aton.txt.extract | \n Extract data from raw text strings | \n
The 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\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
\nAdvanced 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": "Functions to manipulate the content of text files.
\n\ninsert_at()
\ninsert_under()
\nreplace()
\nreplace_line()
\nreplace_between()
\ndelete_under()
\ncorrect_with_dict()
\nfrom_template()
Inserts a text
in the line with position
index of a given filepath
.
If position
is negative, starts from the end of the file.
Inserts a text
under the line(s) containing the key
in filepath
.
The keyword can be at any position within the line.\nRegular expressions can be used by setting regex=True
.
By default all matches are inserted with insertions=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 skips
. Negative integers introduce the text in the previous lines.
Replaces the key
with text
in filepath
.
It can also be used to delete the keyword with text=''
.\nTo search with regular expressions, set regex=True
.
The value replacements
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, use replacements=-1
.\nTo replace all values, set replacements = 0
, which is the value by default.
line... key ...line -> line... text ...line\n
\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": "Replaces the entire line(s) containing the key
with the text
in filepath
.
It can be used to delete line(s) by setting text=''
.\nRegular expressions can be used with regex=True
.
The value replacements
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, use replacements = -1
.\nTo replace all lines, set replacements = 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 skips
as a positive or negative integer.
More lines can be replaced with additional
lines (int).\nNote that the matched line plus the additional lines\nwill be replaced, this is, additional lines +1.
Replace with text
between keywords key1
and key2
in filepath
.
It can be used to delete the text between the keys by setting text=''
.\nRegular expressions can be used by setting regex=True
.
Key lines are also deleted if delete_keys=True
.
Only the first matches of the keywords are used by default;\nyou can use the last ones with from_end = True
.
lines...\nkey1\ntext\nkey2\nlines...\n
\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": "Deletes all the content under the line containing the key
in filepath
.
The keyword can be at any position within the line.\nRegular expressions can be used by setting regex=True
.
By default the first match
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 skips
, that skips the specified number of lines.\nNegative integers start deleting the content from the previous lines.
Corrects the given text file filepath
using a correct
dictionary.
Creates new
file from old
, replacing values from a correct
dict, inserting a comment
on top.
Functions to extract data from raw text strings.
\n\nnumber()
\nstring()
\ncolumn()
\ncoords()
\nelement()
To extract a float value from a string,
\n\nfrom aton import txt\nline = 'energy = 500.0 Ry'\ntxt.extract.number(line, 'energy')\n# 500.0 (float output)\n
\nTo extract a text value, after and before specific strings,
\n\nline = 'energy = 500.0 Ry were calculated'\ntxt.extract.string(line, 'energy', 'were')\n# '500.0 Ry' (String output)\n
\nTo extract a value from a specific column,
\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
\nTo extract coordinates,
\n\nline = ' He 0.10 0.20 0.30 '\ntxt.extract.coords(line)\n# [0.1, 0.2, 0.3] (List of floats)\n
\nTo extract chemical elements,
\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
\nExtracts the float value of a given name
variable from a raw text
.
Extracts the text
value of a given name
variable from a raw string. Stops before an optional stop
string.
Removes leading and trailing commas by default, change this with strip = False
.
Extracts the desired column
index of a given string
(0 by default).
Returns a list with the float coordinates expressed in a given text
string.
Extract a chemical element from a raw text
string.
If there are several elements, you can return a specific index
match (positive, 0 by default).\nAllows for standard elements (H, He, Na...) and isotopes (H2, He4...).
Functions to search for specific content inside text files.
\n\nFind and return specific text strings from a file
\nlines()
\nbetween()
Find the (start, end)
position of specific strings in a file
\npos()
\npos_regex()
\nnext_pos()
\nnext_pos_regex()
\nline_pos()
\nbetween_pos()
To find the lines containing the word 'key', plus an additional line below,
\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
\nTo find the text between the lines containing the words 'first' and 'second',
\n\nfrom aton import txt\ntxt.find.between(filepath=file, key1='first', key2='second')\n # 'first line\\nadditional\\nlines\\nin\\nbetween\\nsecond line'\n
\nReturns a list with the matches containing the key
string in filepath
.
If no match is found, returns an empty list.
\n\nTo use regular expressions in the search, set regex=True
\n(deactivated by default).
The value matches
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 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 to additional=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
,\nunless split=True
, in which case these additional lines\nare splitted and added as additional items in the list.
Returns the content between the lines with key1
and key2
in filepath
.
Keywords can be at any position within the line.\nRegular expressions can be used by setting regex=True
.
Key lines are omited by default, but can be returned with include_keys=True
.
If there is more than one match, only the first one is considered by default;\nset match
(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 key2
is not found, it returns all the text from key1
to the end of the file.
Returns a list with the positions of the key
in filepath
.
If no match is found, returns an empty list.
\n\nThe filepath
can be a file or a memory mapped file.
The value matches
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 pos_regex()
,\nbut does not search for regular expressions.
Returns a list of the positions of a key
in a given filepath
(actual file, not mmapped!).
The value matches
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 pos()
, but it can search for regular expressions.
Get the next position of the key
in the filepath
(file or mmapped file), starting from an initial position
tuple.
The match
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 next_pos_regex()
.
Get the next position of the key
in the filepath
(actual file, not mmapped!), starting from an initial position
tuple.
The match
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 next_pos()
method.
Get the position of the full line containing the position
tuple in filepath
(whether file or memory mapped file).
A specific line below can be returned with skips
being a natural int,\nor previous lines with negative values.
Returns the positions of the content between the lines containing key1
and key2
in the filepath
.
Keywords can be at any position within the line.\nRegular expressions can be used by setting regex=True
.
Key lines are omited by default, but can be returned with include_keys=True
.
If there is more than one match, only the first one is considered by default;\nset match
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 key2
is not found, it returns the text position from key1
to the end of the file.