nonrad.ccd module
Convenience utilities for nonrad.
This module contains various convenience utilities for working with and preparing input for nonrad.
- nonrad.ccd.get_PES_from_vaspruns(ground: Structure, excited: Structure, vasprun_paths: list[str], tol: float = 0.001) tuple[ndarray, ndarray][source]
Extract the potential energy surface (PES) from vasprun.xml files.
This function reads in vasprun.xml files to extract the energy and Q value of each calculation and then returns it as a list.
- Parameters:
ground (pymatgen.core.structure.Structure) – pymatgen structure corresponding to the ground (final) state
excited (pymatgen.core.structure.Structure) – pymatgen structure corresponding to the excited (initial) state
vasprun_paths (list(strings)) – a list of paths to each of the vasprun.xml files that make up the PES. Note that the minimum (0% displacement) should be included in the list, and each path should end in ‘vasprun.xml’ (e.g. /path/to/vasprun.xml)
tol (float) – tolerance to pass to get_Q_from_struct
- Returns:
Q (np.array(float)) – array of Q values (amu^{1/2} Angstrom) corresponding to each vasprun
energy (np.array(float)) – array of energies (eV) corresponding to each vasprun
- nonrad.ccd.get_Q_from_struct(ground: Structure, excited: Structure, struct: Structure | str, tol: float = 0.0001, nround: int = 5) float[source]
Calculate the Q value for a given structure.
This function calculates the Q value for a given structure, knowing the endpoints and assuming linear interpolation.
- Parameters:
ground (pymatgen.core.structure.Structure) – pymatgen structure corresponding to the ground (final) state
excited (pymatgen.core.structure.Structure) – pymatgen structure corresponding to the excited (initial) state
struct (pymatgen.core.structure.Structure or str) – pymatgen structure corresponding to the structure we want to calculate the Q value for (may also be a path to a file containing a structure)
tol (float) – distance cutoff to throw away coordinates for determining Q (sites that don’t move very far could introduce numerical noise)
nround (int) – number of decimal places to round to in determining Q value
- Returns:
the Q value (amu^{1/2} Angstrom) of the structure
- Return type:
float
- nonrad.ccd.get_barrier_harmonic(dQ: float, dE: float, wi: float, wf: float) float | None[source]
Calculate the barrier height within the Harmonic approximation.
- Parameters:
dQ (float) – displacement between harmonic oscillators in amu^{1/2} Angstrom
dE (float) – energy offset between the two harmonic oscillators
wi (float) – frequencies of the harmonic oscillators in eV
wf (float) – frequencies of the harmonic oscillators in eV
- Returns:
barrier energy in eV or None if no crossing found
- Return type:
float, None
- nonrad.ccd.get_cc_structures(ground: Structure, excited: Structure, displacements: ndarray, remove_zero: bool = True) tuple[list, list][source]
Generate the structures for a CC diagram.
- Parameters:
ground (pymatgen.core.structure.Structure) – pymatgen structure corresponding to the ground (final) state
excited (pymatgen.core.structure.Structure) – pymatgen structure corresponding to the excited (initial) state
displacements (list(float)) – list of displacements to compute the perturbed structures. Note: the displacements are for only one potential energy surface and will be applied to both (e.g. displacements=np.linspace(-0.1, 0.1, 5)) will return 10 structures 5 of the ground state displaced at +-10%, +-5%, and 0% and 5 of the excited state displaced similarly)
remove_zero (bool) – remove 0% displacement from list (default is True)
- Returns:
ground_structs = list(pymatgen.core.structure.Struture) – a list of structures corresponding to the displaced ground state
excited_structs = list(pymatgen.core.structure.Structure) – a list of structures corresponding to the displaced excited state
- nonrad.ccd.get_dQ(ground: Structure, excited: Structure) float[source]
Calculate dQ from the initial and final structures.
- Parameters:
ground (pymatgen.core.structure.Structure) – pymatgen structure corresponding to the ground (final) state
excited (pymatgen.core.structure.Structure) – pymatgen structure corresponding to the excited (initial) state
- Returns:
the dQ value (amu^{1/2} Angstrom)
- Return type:
float
- nonrad.ccd.get_omega_from_PES(Q: ndarray, energy: ndarray, Q0: float | None = None, ax=None, q: ndarray | None = None) float[source]
Calculate the harmonic phonon frequency for the given PES.
- Parameters:
Q (np.array(float)) – array of Q values (amu^{1/2} Angstrom) corresponding to each vasprun
energy (np.array(float)) – array of energies (eV) corresponding to each vasprun
Q0 (float) – fix the minimum of the parabola (default is None)
ax (matplotlib.axes.Axes) – optional axis object to plot the resulting fit (default is None)
q (np.array(float)) – array of Q values to evaluate the fitting function at
- Returns:
harmonic phonon frequency from the PES in eV
- Return type:
float