shnitsel.io.sharc.parse_initial_conditions¶
Attributes¶
Classes¶
Functions¶
|
|
|
Retrieve a list of all potential initial condition directories to be parsed given the input path and matching patter. |
Function to also read the relevant dimensions (number of atoms, number of states) from WM.out |
|
|
Function to retrieve the listed number of states and the number of atoms from the Qm.log file of initial conditions |
|
Function to obtain the number of atoms and states across all input paths. |
|
Function to expand the initial conditions dataset with a time dimension. |
|
Function to read initial a single initial condition directory into a Dataset with standard shnitsel annotations and units |
|
Function to read settings of initial conditions from QM.in file. |
|
Function to parse main information from the QM.log file |
|
Read geometry into an xr.Dataset object from the provided file input stream f. |
Function to optionally read the current state id or transition identification line. |
|
|
Function to read all information about forces, energies, dipoles, nacs, etc. from initial condition QM.out files. |
|
Function to convert the icond coordinate into a trajid coordinate and also build a combined frame`+`time multiindex as frame |
Module Contents¶
- _re_grads¶
- _re_nacs¶
- _re_state_map_entry¶
- class IcondPath¶
Bases:
NamedTuple- path: pathlib.Path¶
- nans(*dims)¶
- list_iconds(iconds_path='./iconds/', glob_expr='**/ICOND_*')¶
Retrieve a list of all potential initial condition directories to be parsed given the input path and matching patter.
- Parameters:
iconds_path (str | os.PathLike, optional) – The path where to look for initial condition directories. Defaults to ‘./iconds/’.
glob_expr (str, optional) – The pattern for finding initial conditions. Defaults to ‘**/ICOND_*’.
- Raises:
FileNotFoundError – If no directories match the pattern.
- Returns:
The list of Tuples of the parsed ID and the full path of the initial conditions
- Return type:
List[IcondPath]
- dims_from_QM_out(f)¶
Function to also read the relevant dimensions (number of atoms, number of states) from WM.out
- dims_from_QM_log(log)¶
Function to retrieve the listed number of states and the number of atoms from the Qm.log file of initial conditions
- Parameters:
log (TextIOWrapper) – Input file handle to read the log file contents from
- Raises:
ValueError – If the log file contains an inconsistently structured Line about states but does neither specify Singlet nor Triplet states.
- Returns:
First the number of states, then the number of atoms. This is followed by the number of singlet, doublet and triplet states (if available). If a value is not available, it will default to 0.
- Return type:
- check_dims(pathlist)¶
Function to obtain the number of atoms and states across all input paths.
Will only return the tuple of (number_states, number_atoms) if these numbers are consistent across all paths. Otherwise, an error will be raised.
- Parameters:
pathlist (Sequence[pathlib.Path]) – The list of paths belonging to the same system to check for consistent dimensions
- Raises:
FileNotFoundError – If the number of valid input paths in pathlist is zero, a FileNotFoundError is raised
ValueError – If the number of states and the number of atoms does not agree across all systems a ValueError is raised
- Returns:
The number of states and the number of atoms, then the number of singlets, doublets and triplets in this order
- Return type:
- finalize_icond_dataset(dataset, loading_parameters, default_format_attributes)¶
Function to expand the initial conditions dataset with a time dimension.
Also sets the default unit on the time dimension based on default_format_attributes.
- Parameters:
dataset (xr.Dataset) – The initial conditions dataset. Should not have a “time” dimension yet.
loading_parameters (LoadingParameters) – Loading parameters to override units
default_format_attributes (Dict[str, Dict[str, Any]]) – Default attributes to set on variables, mostly used to set the time dimension attributes
- Returns:
The modified dataset
- Return type:
xr.Dataset
- read_iconds_individual(path, loading_parameters=None)¶
Function to read initial a single initial condition directory into a Dataset with standard shnitsel annotations and units
- Parameters:
path (PathOptionsType) – The path to a initial conditions directory
loading_parameters (LoadingParameters | None, optional) – Parameter settings for e.g. standard units or state names.
- Returns:
The Dataset object containing all of the loaded data from the initial condition in default shnitsel units
- Return type:
xr.Dataset
- parse_QM_in(qm_in)¶
Function to read settings of initial conditions from QM.in file.
Will attempt to read key settings and initial positions that would usually be read form QM.log.
- Parameters:
qm_in (TextIOWrapper) – File stream of the found QM.in file containing some key settings and positional information.
- Raises:
FileNotFoundError – If parts of the file are malformed or missing.
- Returns:
the resulting settings in a key-value pair. Contains num_atoms, num_states, atNames and atXYZ.
- Return type:
Dict[str, Any]
- parse_QM_log(log)¶
Function to parse main information from the QM.log file
- Parameters:
log (TextIOWrapper) – Input file wrapper to read the information from
- Raises:
ValueError – If there are neither singlet nor triplet states listed in the QM.log file
- Returns:
Dictionary with key information about the system
- Return type:
Dict[str, Any]
- parse_QM_log_geom(f, out)¶
Read geometry into an xr.Dataset object from the provided file input stream f.
f must be the contents of a QM.log file.
- Parameters:
f (TextIOWrapper) – File wrapper for a QM.log file’s contents
out (xr.Dataset) – The dataset to write the resulting geometry to
- _transition_identification_re¶
- _read_dim_or_transition_identification_line(f, main_version)¶
Function to optionally read the current state id or transition identification line.
Only for versions 3.0 and up do we need to read the identification. :param f: Input stream of text file :type f: TextIOWrapper :param main_version: The main sharc version to switch the behavior :type main_version: int
- Raises:
ValueError – _description_
- Returns:
_description_
- Return type:
_type_
- Parameters:
f (io.TextIOWrapper)
main_version (int)
- parse_QM_out(f, out, loading_parameters=None)¶
Function to read all information about forces, energies, dipoles, nacs, etc. from initial condition QM.out files.
if
out=Noneis provided, a new Dataset is constructed and returned by the function- Parameters:
f (TextIOWrapper) – File input of the QM.out file to parse the data from
out (xr.Dataset) – Target Dataset to write the loaded data into. Defaults to None.
loading_parameters (LoadingParameters,optional) – Optional loading parameters to override variable mappings and units.
- Returns:
If a new Dataset was constructed instead of being written to out, it will be returned.
- Return type:
xr.Dataset | None
- iconds_to_frames(iconds)¶
Function to convert the icond coordinate into a trajid coordinate and also build a combined frame`+`time multiindex as frame
Will exempt atNames and atNums from the rearrangement.
- Parameters:
iconds (xr.Dataset) – input dataset to replace the dimension in
- Raises:
ValueError – Raised if at least one array has size 0 in one coordinate
- Returns:
The transformed dataset
- Return type:
xr.Dataset