pymatgen.io.jdftx package
Submodules
pymatgen.io.jdftx.inputs module
Classes for reading/manipulating/writing JDFTx input files.
Classes for reading/manipulating/writing JDFTx input files.
Note: JDFTXInfile will be moved back to its own module once a more broad inputs class is written.
@mkhorton - This file is ready to review.
- class JDFTXInfile(params: dict[str, Any] | None = None)[source]
Bases:
dict
,MSONable
Class for reading/writing JDFtx input files.
JDFTxInfile object for reading and writing JDFTx input files. Essentially a dictionary with some helper functions.
Create a JDFTXInfile object.
- Parameters:
params (dict) – Input parameters as a dictionary.
- append_tag(tag: str, value: Any) None [source]
Append a value to a tag.
Append a value to a tag. Use this method instead of directly appending the list contained in the tag, such that the value is properly processed.
- Parameters:
tag (str) – Tag to append to.
value (Any) – Value to append.
- as_dict(sort_tags: bool = True, skip_module_keys: bool = False) dict [source]
Return JDFTXInfile as MSONable dict.
- Parameters:
sort_tags (bool, optional) – Whether to sort the tags. Defaults to True.
skip_module_keys (bool, optional) – Whether to skip the module keys. Defaults to False.
- Returns:
JDFTXInfile as MSONable dict.
- Return type:
dict
- copy() JDFTXInfile [source]
Return a copy of the JDFTXInfile object.
- Returns:
Copy of the JDFTXInfile object.
- Return type:
- classmethod from_dict(d: dict[str, Any]) JDFTXInfile [source]
Create JDFTXInfile from a dictionary.
- Parameters:
d (dict) – Dictionary to create JDFTXInfile from.
- Returns:
The created JDFTXInfile object.
- Return type:
- classmethod from_file(filename: PathLike, dont_require_structure: bool = False, sort_tags: bool = True, assign_path_parent: bool = True) Self [source]
Read a JDFTXInfile object from a file.
- Parameters:
filename (PathLike) – Filename to read from.
dont_require_structure (bool, optional) – Whether to require structure tags. Defaults to False.
sort_tags (bool, optional) – Whether to sort the tags. Defaults to True.
assign_path_parent (bool, optional) – Whether to assign the parent directory of the input file for include tags. Defaults to True.
- Returns:
The created JDFTXInfile object.
- Return type:
- classmethod from_jdftxstructure(jdftxstructure: JDFTXStructure) JDFTXInfile [source]
Create a JDFTXInfile object from a JDFTXStructure object.
- Parameters:
jdftxstructure (JDFTXStructure) – JDFTXStructure object to convert.
- Returns:
The created JDFTXInfile object.
- Return type:
- classmethod from_str(string: str, dont_require_structure: bool = False, sort_tags: bool = True, path_parent: Path | None = None) JDFTXInfile [source]
Read a JDFTXInfile object from a string.
- Parameters:
string (str) – String to read from.
dont_require_structure (bool, optional) – Whether to require structure tags. Defaults to False.
sort_tags (bool, optional) – Whether to sort the tags. Defaults to True.
path_parent (Path, optional) – Path to the parent directory of the input file for include tags. Defaults to None.
- Returns:
The created JDFTXInfile object.
- Return type:
- classmethod from_structure(structure: Structure, selective_dynamics: ArrayLike | None = None, write_cart_coords: bool = False) JDFTXInfile [source]
Create a JDFTXInfile object from a pymatgen Structure.
- Parameters:
structure (Structure) – Structure to convert.
selective_dynamics (ArrayLike, optional) – Selective dynamics attribute for each site if available. Shape Nx1, by default None.
- Returns:
The created JDFTXInfile object.
- Return type:
- classmethod get_dict_representation(jdftxinfile: JDFTXInfile) JDFTXInfile [source]
Convert JDFTXInfile object properties into dict representation.
- Parameters:
jdftxinfile (JDFTXInfile) – JDFTXInfile object to convert.
- classmethod get_list_representation(jdftxinfile: JDFTXInfile) JDFTXInfile [source]
Convert JDFTXInfile object properties into list representation.
- Parameters:
jdftxinfile (JDFTXInfile) – JDFTXInfile object to convert.
- get_text_list() list[str] [source]
Get a list of strings representation of the JDFTXInfile.
- Returns:
List of strings representation of the JDFTXInfile.
- Return type:
list[str]
- property structure: Structure[source]
Return a pymatgen Structure object.
- Returns:
Pymatgen structure object.
- Return type:
- classmethod to_jdftxstructure(jdftxinfile: JDFTXInfile, sort_structure: bool = False) JDFTXStructure [source]
Convert JDFTXInfile to JDFTXStructure object.
Converts JDFTx lattice, lattice-scale, ion tags into JDFTXStructure, with Pymatgen structure as attribute.
- Parameters:
jdftxinfile (JDFTXInfile) – JDFTXInfile object to convert.
sort_structure (bool, optional) – Whether to sort the structure. Useful if species are not grouped properly together. Defaults to False.
- classmethod to_pmg_structure(jdftxinfile: JDFTXInfile, sort_structure: bool = False) Structure [source]
Convert JDFTXInfile to pymatgen Structure object.
Converts JDFTx lattice, lattice-scale, ion tags into pymatgen Structure.
- Parameters:
jdftxinfile (JDFTXInfile) – JDFTXInfile object to convert.
sort_structure (bool, optional) – Whether to sort the structure. Useful if species are not grouped properly together. Defaults to False.
- Returns:
The created pymatgen Structure object.
- Return type:
- validate_tags(try_auto_type_fix: bool = False, error_on_failed_fix: bool = True, return_list_rep: bool = False) None [source]
Validate the tags in the JDFTXInfile.
Validate the tags in the JDFTXInfile. If try_auto_type_fix is True, will attempt to fix the tags. If error_on_failed_fix is True, will raise an error if the tags cannot be fixed. If return_list_rep is True, will return the tags in list representation.
- Parameters:
try_auto_type_fix (bool, optional) – Whether to attempt to fix the tags. Defaults to False.
error_on_failed_fix (bool, optional) – Whether to raise an error if the tags cannot be fixed. Defaults to True.
return_list_rep (bool, optional) – Whether to return the tags in list representation. Defaults to False.
- class JDFTXStructure(structure: Structure = None, selective_dynamics: ArrayLike | None = None, sort_structure: bool = False, write_cart_coords: bool = False)[source]
Bases:
MSONable
Object for representing the data in JDFTXStructure tags.
- selective_dynamics[source]
Selective dynamics attribute for each site if available. Shape Nx1.
- Type:
ArrayLike
- sort_structure[source]
Whether to sort the structure. Useful if species are not grouped properly together. Defaults to False.
- Type:
bool
- as_dict() dict [source]
MSONable dict.
- Returns:
MSONable dictionary representation of the JDFTXStructure.
- Return type:
dict
- classmethod from_dict(params: dict) Self [source]
Get JDFTXStructure from dict.
- Parameters:
params (dict) – Serialized JDFTXStructure.
- Returns:
The created JDFTXStructure object.
- Return type:
- classmethod from_file(filename: str) JDFTXStructure [source]
Read JDFTXStructure from file.
- Parameters:
filename (str) – Filename to read from.
- Returns:
The created JDFTXStructure object.
- Return type:
- classmethod from_jdftxinfile(jdftxinfile: JDFTXInfile, sort_structure: bool = False) JDFTXStructure [source]
Get JDFTXStructure from JDFTXInfile.
- Parameters:
jdftxinfile (JDFTXInfile) – JDFTXInfile object.
sort_structure (bool, optional) – Whether to sort the structure. Useful if species are not grouped properly together as JDFTx output will have species sorted.
- Returns:
The created JDFTXStructure object.
- Return type:
- classmethod from_str(data: str) JDFTXStructure [source]
Read JDFTXStructure from string.
- Parameters:
data (str) – String to read from.
- Returns:
The created JDFTXStructure object.
- Return type:
- get_str(in_cart_coords: bool | None = None) str [source]
Return a string to be written as JDFTXInfile tags.
Allows extra options as compared to calling str(JDFTXStructure) directly.
- Parameters:
in_cart_coords (bool, optional) – Whether coordinates are output in direct or Cartesian.
- Returns:
Representation of JDFTXInfile structure tags.
- Return type:
str
- write_file(filename: PathLike, **kwargs) None [source]
Write JDFTXStructure to a file.
The supported kwargs are the same as those for the JDFTXStructure.get_str method and are passed through directly.
- Parameters:
filename (PathLike) – Filename to write to.
**kwargs – Kwargs to pass to JDFTXStructure.get_str.
pymatgen.io.jdftx.jdftxinfile_master_format module
Master list of AbstractTag-type objects for JDFTx input file generation.
This module contains; - MASTER_TAG_LIST: a dictionary mapping tag categories to dictionaries mapping
tag names to AbstractTag-type objects.
- get_tag_object: a function that returns an AbstractTag-type object from
MASTER_TAG_LIST given a tag name.
@mkhorton - this file is ready to review.
- get_dump_tag_container() DumpTagContainer [source]
Initialize a dump tag container.
- Returns:
The dump tag container.
- Return type:
- get_tag_object(tag: str) AbstractTag [source]
Get the tag object for a given tag name.
- Parameters:
tag (str) – The tag name.
- Returns:
The tag object.
- Return type:
pymatgen.io.jdftx.jdftxinfile_ref_options module
Module for containing reference data for JDFTx tags.
This module contains reference data for JDFTx tags, such as valid options for functionals, pseudopotentials, etc.
@mkhorton - this file is ready to review.
pymatgen.io.jdftx.jdftxoutfileslice module
JDFTx Outfile Slice Class.
This module defines the JDFTxOutfileSlice class, which is used to read and process a JDFTx out file.
- class JDFTXOutfileSlice(prefix: str | None = None, jstrucs: JOutStructures | None = None, jsettings_fluid: JMinSettings | None = None, jsettings_electronic: JMinSettings | None = None, jsettings_lattice: JMinSettings | None = None, jsettings_ionic: JMinSettings | None = None, constant_lattice: bool | None = None, xc_func: str | None = None, lattice_initial: np.ndarray | None = None, lattice_final: np.ndarray | None = None, lattice: np.ndarray | None = None, a: float | None = None, b: float | None = None, c: float | None = None, fftgrid: list[int] | None = None, geom_opt: bool | None = None, geom_opt_type: str | None = None, efermi: float | None = None, egap: float | None = None, emin: float | None = None, emax: float | None = None, homo: float | None = None, lumo: float | None = None, homo_filling: float | None = None, lumo_filling: float | None = None, is_metal: bool | None = None, etype: str | None = None, broadening_type: str | None = None, broadening: float | None = None, kgrid: list | None = None, truncation_type: str | None = None, truncation_radius: float | None = None, pwcut: float | None = None, rhocut: float | None = None, pp_type: str | None = None, semicore_electrons: int | None = None, valence_electrons: float | None = None, total_electrons_uncharged: int | None = None, semicore_electrons_uncharged: int | None = None, valence_electrons_uncharged: int | None = None, nbands: int | None = None, atom_elements: list | None = None, atom_elements_int: list | None = None, atom_types: list | None = None, spintype: str | None = None, nspin: int | None = None, nat: int | None = None, atom_coords_initial: list[list[float]] | None = None, atom_coords_final: list[list[float]] | None = None, atom_coords: list[list[float]] | None = None, has_solvation: bool = False, fluid: str | None = None, is_gc: bool | None = None, is_bgw: bool = False, has_eigstats: bool = False, has_parsable_pseudo: bool = False, _total_electrons_backup: int | None = None, total_electrons: float | None = None, _mu_backup: int | None = None, t_s: float | None = None, converged: bool | None = None, structure: Structure | None = None, trajectory: Trajectory | None = None, electronic_output: dict | None = None, eopt_type: str | None = None, elecmindata: JElSteps | None = None, stress: np.ndarray | None = None, strain: np.ndarray | None = None, forces: np.ndarray | None = None, nstep: int | None = None, e: float | None = None, grad_k: float | None = None, alpha: float | None = None, linmin: float | None = None, abs_magneticmoment: float | None = None, tot_magneticmoment: float | None = None, mu: float | None = None, elec_nstep: int | None = None, elec_e: float | None = None, elec_grad_k: float | None = None, elec_alpha: float | None = None, elec_linmin: float | None = None)[source]
Bases:
object
A class to read and process a slice of a JDFTx out file.
A class to read and process a slice of a JDFTx out file, where a “slice” is a segment of an out file corresponding to a single call of JDFTx.
- from_out_slice(text
list[str]): Read slice of out file into a JDFTXOutfileSlice instance.
- jstrucs[source]
JOutStructures instance containing intermediate structures. Holds a “slices” attribute, which is a list of JOutStructure instances. (A JOutStructure instance functions as a Structure object, along with a JElSteps instance (stored as elecmindata) and other JDFTx-calculation-specific data.)
- Type:
JOutStructures | None
- jsettings_fluid[source]
JMinSettings instance containing fluid optimization settings.
- Type:
JMinSettings | None
- jsettings_electronic[source]
JMinSettings instance containing electronic optimization settings.
- Type:
JMinSettings | None
- jsettings_lattice[source]
JMinSettings instance containing lattice optimization settings.
- Type:
JMinSettings | None
- jsettings_ionic[source]
JMinSettings instance containing ionic optimization settings.
- Type:
JMinSettings | None
- geom_opt[source]
True if geometric (lattice or ionic) optimization was performed.
- Type:
bool | None
- geom_opt_type[source]
Type of geometric optimization performed (lattice or ionic, where lattice implies ionic as well unless geometry was given in direct coordinates).
- Type:
str | None
- homo[source]
Energy of last band-state before Fermi level (acronym for Highest Occupied Molecular Orbital, even though these are not molecular orbitals and this state may not be entirely occupied) (None if eigstats are not dumped).
- Type:
float | None
- lumo[source]
Energy of first band-state after Fermi level (acronym for Lowest Unoccupied Molecular Orbital, even though these are not molecular orbitals, and this state may not be entirely unoccupied) (None if eigstats are not dumped).
- Type:
float | None
- homo_filling[source]
Filling of “homo” band-state as calculated within this class object from the homo energy, Fermi level, electronic broadening type and electronic broadening parameter. (None if eigstats are not dumped).
- Type:
float | None
- lumo_filling[source]
Filling of “lumo” band-state as calculated within this class object from the homo energy, Fermi level, electronic broadening type and electronic broadening parameter. (None if eigstats are not dumped).
- Type:
float | None
- is_metal[source]
True if fillings of homo and lumo band-states are off-set by 1 and 0 by at least an arbitrary tolerance of 0.01 (ie 1 - 0.015 and 0.012 for homo/lumo fillings would be metallic, while 1-0.001 and 0 would not be). (Only available if eigstats was dumped).
- Type:
bool | None
- etype[source]
String representation of total energy-type of system. Commonly “G” (grand-canonical potential) for GC calculations, and “F” for canonical (fixed electron count) calculations.
- Type:
str | None
- broadening_type[source]
Type of broadening for electronic filling about Fermi-level requested. Either “Fermi”, “Cold”, “MP1”, or “Gauss”.
- Type:
str
- kgrid[source]
Shape of k-point grid used in calculation. (equivalent to k-point folding).
- Type:
list[int]
- truncation_type[source]
Type of coulomb truncation used to prevent interaction between periodic images along certain directions. “periodic” means no coulomb truncation was used.
- Type:
str
- truncation_radius[source]
If spherical truncation_type, this is the radius of the coulomb truncation sphere.
- Type:
float | None
- pwcut[source]
The plane-wave cutoff energy in Hartrees used in the most recent JDFTx call.
- Type:
float
- rhocut[source]
The density cutoff energy in Hartrees used in the most recent JDFTx call.
- Type:
float
- pp_type[source]
The pseudopotential library used in the most recent JDFTx call. Currently only “GBRV” and “SG15” are supported by this output parser.
- Type:
str
- total_electrons[source]
The total number of electrons in the most recent JDFTx call (redundant to nelectrons).
- Type:
float
- semicore_electrons[source]
The number of semicore electrons in the most recent JDFTx call.
- Type:
int
- valence_electrons[source]
The number of valence electrons in the most recent JDFTx call.
- Type:
float
- total_electrons_uncharged[source]
The total number of electrons in the most recent JDFTx call, uncorrected for charge. (ie total_electrons + charge).
- Type:
int
- semicore_electrons_uncharged[source]
The number of semicore electrons in the most recent JDFTx call, uncorrected for charge. (ie semicore_electrons + charge).
- Type:
int
- valence_electrons_uncharged[source]
The number of valence electrons in the most recent JDFTx call, uncorrected for charge. (ie valence_electrons + charge).
- Type:
int
- atom_elements[source]
The list of each ion’s element symbol in the most recent JDFTx call.
- Type:
list[str]
- atom_elements_int[source]
The list of ion’s atomic numbers in the most recent JDFTx call.
- Type:
list[int]
- atom_types[source]
Non-repeating list of each ion’s element symbol in the most recent JDFTx call.
- Type:
list[str]
- spintype[source]
The spin type used in the most recent JDFTx call. Options are “none”, “collinear”.
- Type:
str
- atom_coords_initial[source]
The initial atomic coordinates of the most recent JDFTx call.
- Type:
list[list[float]]
- atom_coords_final[source]
The final atomic coordinates of the most recent JDFTx call.
- Type:
list[list[float]]
- has_solvation[source]
True if the most recent JDFTx call included a solvation calculation.
- Type:
bool
- has_parsable_pseudo[source]
True if the most recent JDFTx call used a pseudopotential that can be parsed by this output parser. Options are currently “GBRV” and “SG15”.
- Type:
bool
- Properties:
t_s (float | None): The total time in seconds for the calculation. converged (bool | None): True if calculation converged. trajectory (Trajectory): pymatgen Trajectory object containing intermediate Structure’s of outfile slice
calculation.
electronic_output (dict): Dictionary with all relevant electronic information dumped from an eigstats log. structure (Structure): Calculation result as pymatgen Structure. eopt_type (str | None): eopt_type from most recent JOutStructure. elecmindata (JElSteps): elecmindata from most recent JOutStructure. stress (np.ndarray | None): Stress tensor from most recent JOutStructure in units eV/Ang^3. strain (np.ndarray | None): Strain tensor from most recent JOutStructure (unitless). nstep (int | None): (geometric) nstep from most recent JOutStructure. e (float | None): Energy of system “etype” from most recent JOutStructure. grad_k (float): The final norm of the preconditioned gradient for geometric optimization of the most recent
JDFTx call (evaluated as dot(g, Kg), where g is the gradient and Kg is the preconditioned gradient). (written as “|grad|_K” in JDFTx output).
alpha (float): The step size of the final geometric step in the most recent JDFTx call. linmin (float): The final normalized projection of the geometric step direction onto the gradient for the most
recent JDFTx call.
abs_magneticmoment (float | None): The absolute magnetic moment of the most recent JDFTx call. tot_magneticmoment (float | None): The total magnetic moment of the most recent JDFTx call. mu (float): The Fermi energy of the most recent JDFTx call. elec_e (float): The final energy of the most recent electronic optimization step. elec_nstep (int): The number of electronic optimization steps in the most recent JDFTx call. elec_grad_k (float): The final norm of the preconditioned gradient for electronic optimization of the most
recent JDFTx call (evaluated as dot(g, Kg), where g is the gradient and Kg is the preconditioned gradient). (written as “|grad|_K” in JDFTx output).
elec_alpha (float): The step size of the final electronic step in the most recent JDFTx call. elec_linmin (float): The final normalized projection of the electronic step direction onto the gradient for the
most recent JDFTx call.
- Magic Methods:
- __getattr__(name: str) -> Any: Overwrite of default __getattr__ method to allow for reference of un-defined
attributes to the “jstrucs” class field. This referring behavior is ideally never used as (currently) all referrable attributes are defined properties, but is included to prevent errors in the case of future changes.
__str__() -> str: Return a string representation of the class instance using pprint module. __repr__() -> str: Create string representation of the class instance. Overwritten from default behavior for
dataclass so that properties are included in the string, and verbose attributes with redundant information are trimmed.
- determine_is_metal() bool | None [source]
Determine if the system is a metal based on the fillings of homo and lumo.
- Returns:
True if system is metallic.
- Return type:
bool
- jsettings_electronic: JMinSettings | None = None[source]
- jsettings_fluid: JMinSettings | None = None[source]
- jsettings_ionic: JMinSettings | None = None[source]
- jsettings_lattice: JMinSettings | None = None[source]
- jstrucs: JOutStructures | None = None[source]
- to_dict() dict [source]
Convert dataclass to dictionary representation.
- Returns:
JDFTXOutfileSlice in dictionary format.
- Return type:
dict
- trajectory: Trajectory | None = None[source]
- get_pseudo_read_section_bounds(text: list[str]) list[list[int]] [source]
Get the boundary line numbers for the pseudopotential read section.
- Parameters:
text (list[str]) – Output of read_file for out file.
- Returns:
List of line numbers for the pseudopotential read sections.
- Return type:
list[list[int]]
pymatgen.io.jdftx.jelstep module
Module for parsing single SCF step from JDFTx.
This module contains the JElStep class for parsing single SCF step from a JDFTx out file.
- class JElStep(opt_type: str | None = None, etype: str | None = None, nstep: int | None = None, e: float | None = None, grad_k: float | None = None, alpha: float | None = None, linmin: float | None = None, t_s: float | None = None, mu: float | None = None, nelectrons: float | None = None, abs_magneticmoment: float | None = None, tot_magneticmoment: float | None = None, subspacerotationadjust: float | None = None, converged: bool = False, converged_reason: str | None = None)[source]
Bases:
object
Electronic minimization data for a single SCF step.
Class object for storing logged electronic minimization data for a single SCF step.
- opt_type[source]
The type of electronic minimization step (almost always ElecMinimize).
- Type:
str | None
- grad_k[source]
The gradient of the Kohn-Sham energy (along the line minimization direction).
- Type:
float | None
- linmin[source]
Normalized line minimization direction / energy gradient projection (-1 for perfectly opposite, 1 for perfectly aligned).
- Type:
float | None
- class JElSteps(opt_type: str | None = None, etype: str | None = None, iter_flag: str | None = None, converged: bool | None = None, converged_reason: str | None = None, slices: list[~pymatgen.io.jdftx.jelstep.JElStep] = <factory>)[source]
Bases:
object
Class object for series of SCF steps.
Class object for collecting and storing a series of SCF steps done between geometric optimization steps.
- iter_flag[source]
The flag that indicates the start of a log message for a JDFTx optimization step.
- Type:
str | None
- grad_k[source]
The gradient of the Kohn-Sham energy (along the line minimization direction).
- Type:
float | None
- linmin[source]
Normalized line minimization direction / energy gradient projection (-1 for perfectly opposite, 1 for perfectly aligned).
- Type:
float | None
pymatgen.io.jdftx.jminsettings module
Store generic minimization settings read from a JDFTx out file.
This module contains the JMinSettings class for storing generic minimization and mutants for storing specific minimization settings read from a JDFTx out file.
@mkhorton - this file is ready to review.
- class JMinSettings(params: dict[str, Any] | None = None)[source]
Bases:
object
Store generic minimization settings read from a JDFTx out file.
Store generic minimization settings read from a JDFTx out file.
Initialize a generic JMinSettings class.
- Parameters:
params (dict[str, Any] | None) – A dictionary of minimization settings.
- class JMinSettingsElectronic(params: dict[str, Any] | None = None)[source]
Bases:
JMinSettings
JMInSettings mutant for electronic minimization settings.
A class for storing electronic minimization settings read from a JDFTx out file.
Initialize a generic JMinSettings class.
- Parameters:
params (dict[str, Any] | None) – A dictionary of minimization settings.
- class JMinSettingsFluid(params: dict[str, Any] | None = None)[source]
Bases:
JMinSettings
JMInSettings mutant for fluid minimization settings.
A class for storing fluid minimization settings read from a JDFTx out file.
Initialize a generic JMinSettings class.
- Parameters:
params (dict[str, Any] | None) – A dictionary of minimization settings.
- class JMinSettingsIonic(params: dict[str, Any] | None = None)[source]
Bases:
JMinSettings
JMInSettings mutant for ionic minimization settings.
A class for storing ionic minimization settings read from a JDFTx out file.
Initialize a generic JMinSettings class.
- Parameters:
params (dict[str, Any] | None) – A dictionary of minimization settings.
- class JMinSettingsLattice(params: dict[str, Any] | None = None)[source]
Bases:
JMinSettings
JMInSettings mutant for lattice minimization settings.
A class for storing lattice minimization settings read from a JDFTx out file.
Initialize a generic JMinSettings class.
- Parameters:
params (dict[str, Any] | None) – A dictionary of minimization settings.
pymatgen.io.jdftx.joutstructure module
Class object for storing a single JDFTx geometric optimization step.
A mutant of the pymatgen Structure class for flexibility in holding JDFTx.
- class JOutStructure(lattice: ndarray, species: list[str], coords: list[ndarray], site_properties: dict[str, list], **kwargs)[source]
Bases:
Structure
Class object for storing a single JDFTx optimization step.
A mutant of the pymatgen Structure class for flexibility in holding JDFTx optimization data.
- Properties:
charges (np.ndarray | None): The Lowdin charges of the atoms in the system. magnetic_moments (np.ndarray | None): The magnetic moments of the atoms in the system.
- emin_flag[source]
The flag that indicates the start of a log message for a JDFTx optimization step.
- Type:
str | None
- grad_k[source]
The gradient of the electronic density along the most recent line minimization.
- Type:
float | None
- alpha[source]
The step size of the most recent SCF step along the line minimization.
- Type:
float | None
- linmin[source]
The normalized alignment projection of the electronic energy gradient to the line minimization direction.
- Type:
float | None
- selective_dynamics[source]
The selective dynamics flags for the atoms in the system.
- Type:
list[int] | None
- abs_magneticmoment[source]
The absolute magnetic moment of the electron density.
- Type:
float | None
- structure[source]
The Structure object of the system. (helpful for uses where the JOutStructure metadata causes issues)
- Type:
Structure | None
Create a periodic structure.
- Parameters:
lattice – The lattice, either as a pymatgen.core.Lattice or simply as any 2D array. Each row should correspond to a lattice vector. e.g. [[10,0,0], [20,10,0], [0,0,30]] specifies a lattice with lattice vectors [10,0,0], [20,10,0] and [0,0,30].
species –
List of species on each site. Can take in flexible input, including:
A sequence of element / species specified either as string symbols, e.g. [“Li”, “Fe2+”, “P”, …] or atomic numbers, e.g. (3, 56, …) or actual Element or Species objects.
List of dict of elements/species and occupancies, e.g. [{“Fe” : 0.5, “Mn”:0.5}, …]. This allows the setup of disordered structures.
coords (Nx3 array) – list of fractional/cartesian coordinates of each species.
charge (float) – overall charge of the structure. Defaults to behavior in SiteCollection where total charge is the sum of the oxidation states.
validate_proximity (bool) – Whether to check if there are sites that are less than 0.01 Ang apart. Defaults to False.
to_unit_cell (bool) – Whether to map all sites into the unit cell, i.e., fractional coords between 0 and 1. Defaults to False.
coords_are_cartesian (bool) – Set to True if you are providing coordinates in Cartesian coordinates. Defaults to False.
site_properties (dict) – Properties associated with the sites as a dict of sequences, e.g. {“magmom”:[5,5,5,5]}. The sequences have to be the same length as the atomic species and fractional_coords. Defaults to None for no properties.
labels (list[str]) – Labels associated with the sites as a list of strings, e.g. [‘Li1’, ‘Li2’]. Must have the same length as the species and fractional coords. Defaults to None for no labels.
properties (dict) – Properties associated with the whole structure. Will be serialized when writing the structure to JSON or YAML but is lost when converting to other formats.
- property charges: ndarray | None[source]
Return the Lowdin charges.
- Returns:
The Lowdin charges of the atoms in the system.
- Return type:
np.ndarray
- line_types: ClassVar[list[str]] = ['emin', 'lattice', 'strain', 'stress', 'posns', 'forces', 'ecomp', 'lowdin', 'opt'][source]
- property magnetic_moments: ndarray | None[source]
Return the magnetic moments.
- Returns:
The magnetic moments of the atoms in the system.
- Return type:
np.ndarray
pymatgen.io.jdftx.joutstructures module
Module for JOutStructures class.
This module contains the JOutStructures class for storing a series of JOutStructure.
- class JOutStructures(opt_type: str | None = None, geom_converged: bool = False, geom_converged_reason: str | None = None, elec_converged: bool = False, elec_converged_reason: str | None = None, _t_s: float | None = None, slices: list[JOutStructure] = <factory>, eopt_type: str | None = None, etype: str | None = None, emin_flag: str | None = None, ecomponents: list[str] | None = None, elecmindata: JElSteps = None, stress: np.ndarray | None = None, strain: np.ndarray | None = None, forces: np.ndarray | None = None, nstep: int | None = None, e: float | None = None, grad_k: float | None = None, alpha: float | None = None, linmin: float | None = None, nelectrons: float | None = None, abs_magneticmoment: float | None = None, tot_magneticmoment: float | None = None, mu: float | None = None, elec_nstep: int | None = None, elec_e: float | None = None, elec_grad_k: float | None = None, elec_alpha: float | None = None, elec_linmin: float | None = None, charges: np.ndarray[float] | None = None, magnetic_moments: np.ndarray[float] | None = None, selective_dynamics: list[int] | None = None, structure: Structure | None = None)[source]
Bases:
object
Class for storing a series of JStructure objects.
A class for storing a series of JStructure objects.
- out_slice_start_flag[source]
The string that marks the beginning of the portion of an out file slice that contains data for a JOutStructures object.
- Type:
str
- opt_type[source]
The type of optimization performed on the structures in the JOutStructures object.
- Type:
str | None
- geom_converged[source]
Whether the geometry of the last structure in the list has converged.
- Type:
bool
- geom_converged_reason[source]
The reason the geometry of the last structure in the list has converged.
- Type:
str | None
- elec_converged[source]
Whether the electronic density of the last structure in the list has converged.
- Type:
bool
- elec_converged_reason[source]
The reason the electronic density of the last structure in the list has converged.
- Type:
str | None
- slices[source]
A list of JOutStructure objects.
- Type:
list[JOutStructure]
- eopt_type[source]
The type of electronic optimization performed on the last structure in the list.
- Type:
str | None
- (grand-canonical potential) for GC calculations, and "F" for canonical
- Type:
fixed electron count
- grad_k[source]
The final norm of the preconditioned gradient for geometric optimization of the most recent JDFTx call (evaluated as dot(g, Kg), where g is the gradient and Kg is the preconditioned gradient). (written as “|grad|_K” in JDFTx output).
- Type:
float | None
- alpha[source]
The step size of the final geometric step in the most recent JDFTx call.
- Type:
float | None
- linmin[source]
The final normalized projection of the geometric step direction onto the gradient for the most recent JDFTx call.
- Type:
float | None
- abs_magneticmoment[source]
The absolute magnetic moment of the most recent JDFTx call.
- Type:
float | None
- tot_magneticmoment[source]
The total magnetic moment of the most recent JDFTx call.
- Type:
float | None
- elec_nstep[source]
The number of electronic optimization steps in the most recent JDFTx call.
- Type:
int
- elec_grad_k[source]
The final norm of the preconditioned gradient for electronic optimization of the most recent JDFTx call (evaluated as dot(g, Kg), where g is the gradient and Kg is the preconditioned gradient). (written as “|grad|_K” in JDFTx output).
- Type:
float | None
- elec_alpha[source]
The step size of the final electronic step in the most recent JDFTx call.
- Type:
float
- elec_linmin[source]
The final normalized projection of the electronic step direction onto the gradient for the most recent JDFTx call.
- Type:
float | None
- selective_dynamics[source]
The selective dynamics flags for the most recent JDFTx call.
- Type:
list[int] | None
- slices: list[JOutStructure][source]
pymatgen.io.jdftx.outputs module
JDFTx outputs parsing module.
Module for parsing outputs of JDFTx.
Note: JDFTXOutfile will be moved back to its own module once a more broad outputs class is written.
- class JDFTXOutfile(slices: list[~pymatgen.io.jdftx.jdftxoutfileslice.JDFTXOutfileSlice] = <factory>)[source]
Bases:
object
JDFTx out file parsing class.
A class to read and process a JDFTx out file.
- from_file(file_path
str | Path) -> JDFTXOutfile: Return JDFTXOutfile object from the path to a JDFTx out file.
- slices[source]
A list of JDFTXOutfileSlice objects. Each slice corresponds to an individual call of the JDFTx executable. Subsequent JDFTx calls within the same directory and prefix will append outputs to the same out file. More than one slice may correspond to restarted calculations, geom + single point calculations, or optimizations done with 3rd-party wrappers like ASE.
- Type:
list[JDFTXOutfileSlice]
- jstrucs[source]
The JOutStructures object from the most recent JDFTx call. This object contains a series of JOutStructure objects in its ‘slices’ attribute, each corresponding to a single structure (multiple iff performing a geometric optimization) as well as convergence data for the structures as a series.
- Type:
- jsettings_fluid[source]
The JMinSettingsFluid object from the most recent JDFTx call. This object contains only a ‘params’ attribute, which is a dictionary of the input parameters for the fluid optimization.
- Type:
- jsettings_electronic[source]
The JMinSettingsElectronic object from the most recent JDFTx call. This object contains only a ‘params’ attribute, which is a dictionary of the input parameters for the electronic optimization.
- Type:
- jsettings_lattice[source]
The JMinSettingsLattice object from the most recent JDFTx call. This object contains only a ‘params’ attribute, which is a dictionary of the input parameters for the lattice optimization.
- Type:
- jsettings_ionic[source]
The JMinSettingsIonic object from the most recent JDFTx call. This object contains only a ‘params’ attribute, which is a dictionary of the input parameters for the ionic optimization.
- Type:
- xc_func[source]
The exchange-correlation functional used in the most recent JDFTx call. See documentation for JDFTx online for a list of available exchange-correlation functionals.
- Type:
str
- lattice_initial[source]
The initial lattice vectors of the most recent JDFTx call as a 3x3 numpy array. In units of Angstroms.
- Type:
np.ndarray
- lattice_final[source]
The final lattice vectors of the most recent JDFTx call as a 3x3 numpy array. In units of Angstroms.
- Type:
np.ndarray
- lattice[source]
The lattice vectors of the most recent JDFTx call as a 3x3 numpy array (redundant to lattice_final).
- Type:
np.ndarray
- fftgrid[source]
The FFT grid shape used in the most recent JDFTx call. Can be used to properly shape densities dumped as binary files.
- Type:
list[int]
- geom_opt[source]
True if the most recent JDFTx call was a geometry optimization (lattice or ionic).
- Type:
bool
- geom_opt_type[source]
The type of geometry optimization performed in the most recent JDFTx call. Options are ‘lattice’ or ‘ionic’ if geom_opt, else “single point”. (‘lattice’ optimizations perform ionic optimizations as well unless ion positions are given in direct coordinates).
- Type:
str
- ecomponents[source]
The components of the total energy in eV of the most recent JDFTx call.
- Type:
dict
- efermi[source]
The Fermi energy in eV of the most recent JDFTx call. Equivalent to “mu”.
- Type:
float
- egap[source]
The band gap in eV of the most recent JDFTx call. (Only available if eigstats was dumped).
- Type:
float
- emin[source]
The minimum energy in eV (smallest Kohn-Sham eigenvalue) of the most recent JDFTx call. (Only available if eigstats was dumped).
- Type:
float
- emax[source]
The maximum energy in eV (largest Kohn-Sham eigenvalue) of the most recent JDFTx call. (Only available if eigstats was dumped).
- Type:
float
- homo[source]
The energy in eV of the band-gap lower bound (Highest Occupied Molecular Orbital) (Only available if eigstats was dumped).
- Type:
float
- lumo[source]
The energy in eV of the band-gap upper bound (Lowest Unoccupied Molecular Orbital) (Only available if eigstats was dumped).
- Type:
float
- homo_filling[source]
The electron filling at the homo band-state. (Only available if eigstats was dumped).
- Type:
float
- lumo_filling[source]
The electron filling at the lumo band-state. (Only available if eigstats was dumped).
- Type:
float
- is_metal[source]
True if fillings of homo and lumo band-states are off-set by 1 and 0 by at least an arbitrary tolerance of 0.01 (ie 1 - 0.015 and 0.012 for homo/lumo fillings would be metallic, while 1-0.001 and 0 would not be). (Only available if eigstats was dumped).
- Type:
bool
- converged[source]
True if most recent SCF cycle converged (and geom forces converged is calc is geom_opt)
- Type:
bool
- etype[source]
String representation of total energy-type of system. Commonly “G” (grand-canonical potential) for GC calculations, and “F” for canonical (fixed electron count) calculations.
- Type:
str
- broadening_type[source]
Type of broadening for electronic filling about Fermi-level requested. Either “Fermi”, “Cold”, “MP1”, or “Gauss”.
- Type:
str
- kgrid[source]
Shape of k-point grid used in calculation. (equivalent to k-point folding)
- Type:
list[int]
- truncation_type[source]
Type of coulomb truncation used to prevent interaction between periodic images along certain directions. “periodic” means no coulomb truncation was used.
- Type:
str
- truncation_radius[source]
If spherical truncation_type, this is the radius of the coulomb truncation sphere.
- Type:
float | None
- pwcut[source]
The plane-wave cutoff energy in Hartrees used in the most recent JDFTx call.
- Type:
float
- rhocut[source]
The density cutoff energy in Hartrees used in the most recent JDFTx call.
- Type:
float
- pp_type[source]
The pseudopotential library used in the most recent JDFTx call. Currently only “GBRV” and “SG15” are supported by this output parser.
- Type:
str
- total_electrons[source]
The total number of electrons in the most recent JDFTx call (redundant to nelectrons).
- Type:
float
- semicore_electrons[source]
The number of semicore electrons in the most recent JDFTx call.
- Type:
int
- valence_electrons[source]
The number of valence electrons in the most recent JDFTx call.
- Type:
float
- total_electrons_uncharged[source]
The total number of electrons in the most recent JDFTx call, uncorrected for charge. (ie total_electrons + charge)
- Type:
int
- semicore_electrons_uncharged[source]
The number of semicore electrons in the most recent JDFTx call, uncorrected for charge. (ie semicore_electrons + charge)
- Type:
int
- valence_electrons_uncharged[source]
The number of valence electrons in the most recent JDFTx call, uncorrected for charge. (ie valence_electrons + charge)
- Type:
int
- atom_elements[source]
The list of each ion’s element symbol in the most recent JDFTx call.
- Type:
list[str]
- atom_elements_int[source]
The list of ion’s atomic numbers in the most recent JDFTx call.
- Type:
list[int]
- atom_types[source]
Non-repeating list of each ion’s element symbol in the most recent JDFTx call.
- Type:
list[str]
- spintype[source]
The spin type used in the most recent JDFTx call. Options are “none”, “collinear”,
- Type:
str
- atom_coords_initial[source]
The initial atomic coordinates of the most recent JDFTx call.
- Type:
list[list[float]]
- atom_coords_final[source]
The final atomic coordinates of the most recent JDFTx call.
- Type:
list[list[float]]
- has_solvation[source]
True if the most recent JDFTx call included a solvation calculation.
- Type:
bool
- elecmindata[source]
The JElSteps object from the most recent JDFTx call. This object contains a series of JElStep objects in its ‘steps’ attribute, each corresponding to a single energy iteration.
- Type:
- stress[source]
The stress tensor of the most recent JDFTx call as a 3x3 numpy array. In units of eV/Angstrom^3.
- Type:
np.ndarray
- strain[source]
The strain tensor of the most recent JDFTx call as a 3x3 numpy array.
- Type:
np.ndarray
- e[source]
The final energy in eV of the most recent JDFTx call (equivalent to the call’s etype).
- Type:
float
- grad_k[source]
The final norm of the preconditioned gradient for geometric optimization of the most recent JDFTx call (evaluated as dot(g, Kg), where g is the gradient and Kg is the preconditioned gradient). (written as “|grad|_K” in JDFTx output).
- Type:
float
- linmin[source]
The final normalized projection of the geometric step direction onto the gradient for the most recent JDFTx call.
- Type:
float
- abs_magneticmoment[source]
The absolute magnetic moment of the most recent JDFTx call.
- Type:
float | None
- tot_magneticmoment[source]
The total magnetic moment of the most recent JDFTx call.
- Type:
float | None
- elec_nstep[source]
The number of electronic optimization steps in the most recent JDFTx call.
- Type:
int
- elec_grad_k[source]
The final norm of the preconditioned gradient for electronic optimization of the most recent JDFTx call (evaluated as dot(g, Kg), where g is the gradient and Kg is the preconditioned gradient). (written as “|grad|_K” in JDFTx output).
- Type:
float
- elec_alpha[source]
The step size of the final electronic step in the most recent JDFTx call.
- Type:
float
- elec_linmin[source]
The final normalized projection of the electronic step direction onto the gradient for the most recent JDFTx call.
- Type:
float
- Magic Methods:
- __getitem__(key: str | int) -> Any: Decides behavior of how JDFTXOutfile objects are indexed. If the key is a
string, it will return the value of the property with the same name. If the key is an integer, it will return the slice of the JDFTXOutfile object at that index.
__len__() -> int: Returns the number of slices in the JDFTXOutfile object. __getattr__(name: str) -> Any: Returns the value of the property with the same name as the input string. __str__() -> str: Returns a string representation of the JDFTXOutfile object.
- classmethod from_calc_dir(calc_dir: str | Path, is_bgw: bool = False, none_slice_on_error: bool = False) JDFTXOutfile [source]
Create a JDFTXOutfile object from a directory containing JDFTx out files.
- Parameters:
calc_dir (str | Path) – The path to the directory containing the JDFTx out files.
is_bgw (bool) – Mark True if data must be usable for BGW calculations. This will change the behavior of the parser to be stricter with certain criteria.
none_slice_on_error (bool) – If True, will return None if an error occurs while parsing a slice instead of halting the parsing process. This can be useful for parsing files with multiple slices where some slices may be incomplete or corrupted.
- Returns:
The JDFTXOutfile object.
- Return type:
- classmethod from_file(file_path: str | Path, is_bgw: bool = False, none_slice_on_error: bool | None = None) JDFTXOutfile [source]
Create a JDFTXOutfile object from a JDFTx out file.
- Parameters:
file_path (str | Path) – The path to the JDFTx out file.
is_bgw (bool) – Mark True if data must be usable for BGW calculations. This will change the behavior of the parser to be stricter with certain criteria.
none_slice_on_error (bool | None) – If True, will return None if an error occurs while parsing a slice instead of halting the parsing process. This can be useful for parsing files with multiple slices where some slices may be incomplete or corrupted. If False, all slices may raise errors. If None, only the final slice can raise an error upon parsing (default behavior)
- Returns:
The JDFTXOutfile object.
- Return type:
- jsettings_electronic: JMinSettingsElectronic[source]
- jsettings_fluid: JMinSettingsFluid[source]
- jsettings_ionic: JMinSettingsIonic[source]
- jsettings_lattice: JMinSettingsLattice[source]
- jstrucs: JOutStructures[source]
- slices: list[JDFTXOutfileSlice][source]
- to_dict() dict [source]
Convert the JDFTXOutfile object to a dictionary.
- Returns:
A dictionary representation of the JDFTXOutfile object.
- Return type:
dict
- trajectory: Trajectory[source]
- class JDFTXOutputs(calc_dir: str | ~pathlib.Path, outfile_name: str | ~pathlib.Path | None, store_vars: list[str] = <factory>)[source]
Bases:
object
JDFTx outputs parsing class.
A class to read and process JDFTx outputs.
- from_calc_dir(calc_dir
str | Path, store_vars: list[str] = None) -> JDFTXOutputs: Return JDFTXOutputs object from the path to a directory containing JDFTx out files.
- bandProjections[source]
The band projections. Stored in shape (nstates, nbands, nproj) where nstates is nspin*nkpts (nkpts may not equal prod(kfolding) if symmetry reduction occurred), nbands is the number of bands, and nproj is the number of projections. This shape is chosen instead of the pymatgen convention of (nspin, nkpt, nbands, nion, nionproj) to save on memory as nonionproj is different depending on the ion type. This array may also be complex if specified in ‘band-projections-params’ in the JDFTx input, allowing for pCOHP analysis.
- Type:
np.ndarray
- eigenvals[source]
The eigenvalues. Stored in shape (nstates, nbands) where nstates is nspin*nkpts (nkpts may not equal prod(kfolding) if symmetry reduction occurred) and nbands is the number of bands.
- Type:
np.ndarray
- orb_label_list[source]
A tuple of the orbital labels for the bandProjections file, where the i’th element describes the i’th orbital. Orbital labels are formatted as “<ion>#<ion-number>(<orbital>)”, where <ion> is the element symbol of the ion, <ion-number> is the 1-based index of the ion-type in the structure (ie C#2 would be the second carbon atom, but not necessarily the second ion in the structure), and <orbital> is a string describing “l” and “ml” quantum numbers (ie “p_x” or “d_yz”). Note that while “z” corresponds to the “z” axis, “x” and “y” are arbitrary and may not correspond to the actual x and y axes of the structure. In the case where multiple shells of a given “l” are available within the projections, a 0-based index will appear mimicking a principle quantum number (ie “0px” for first shell and “1px” for second shell). The actual principal quantum number is not stored in the JDFTx output files and must be inferred by the user.
- Type:
tuple[str, …]
- classmethod from_calc_dir(calc_dir: str | Path, store_vars: list[str] | None = None, outfile_name: str | Path | None = None) JDFTXOutputs [source]
Create a JDFTXOutputs object from a directory containing JDFTx out files.
- Parameters:
calc_dir (str | Path) – The path to the directory containing the JDFTx out files.
is_bgw (bool) – Mark True if data must be usable for BGW calculations. This will change the behavior of the parser to be stricter with certain criteria.
none_slice_on_error (bool) – If True, will return None if an error occurs while parsing a slice instead of halting the parsing process. This can be useful for parsing files with multiple slices where some slices may be incomplete or corrupted.
outfile_name (str | Path) – The name of the outfile to use. If None, will search for the outfile in the calc_dir. If provided, will concatenate with calc_dir as the outfile path. Use this if the calc_dir contains multiple files that may be mistaken for the outfile (ie multiple files with the ‘.out’ suffix).
- Returns:
The JDFTXOutputs object.
- Return type:
- outfile: JDFTXOutfile[source]