shnitsel.io.newtonx.parse

Classes

NewtonXSettingsResult

Class to keep track of key settings from the NewtonX log files

Functions

parse_newtonx(traj_path[, loading_parameters])

Function to read a NewtonX trajectory directory into a Dataset with standard shnitsel annotations and units

parse_settings_from_nx_log(f)

Function to parse key settings from the NewtonX RESULTS/nx.log file

parse_en_data(endata_path, dataset, default_attributes)

Function to read energy data from en.dat in case the reading from nx.log has not succeeded:

parse_dyn_out(f, dataset)

Function to gather dynamics data (e_kin and velocities) from the RESULTS/dyn.out file, if it exists.

parse_nx_log_data(f, dataset, settings, default_attributes)

Function to parse the nx.log data into a dataset from the input stream f.

parse_nx_misc_input_settings(path)

Function to parse various input settings from the newtonx trajectory directory.

Module Contents

parse_newtonx(traj_path, loading_parameters=None)

Function to read a NewtonX trajectory directory into a Dataset with standard shnitsel annotations and units

Parameters:
  • pathlist (PathOptionsType) – Path to the NewtonX trajectory output

  • loading_parameters (LoadingParameters | None, optional) – Parameter settings for e.g. standard units or state names.

  • traj_path (shnitsel.io.helpers.PathOptionsType)

Returns:

The Dataset object containing all of the loaded data in default shnitsel units

Return type:

xr.Dataset

class NewtonXSettingsResult

Bases: NamedTuple

Class to keep track of key settings from the NewtonX log files

t_max: float
delta_t: float
num_steps: int
num_atoms: int
num_states: int
completed: bool
newtonx_version: str
parse_settings_from_nx_log(f)

Function to parse key settings from the NewtonX RESULTS/nx.log file

Parameters:

f (TextIOWrapper) – The input stream of lines from nx.log

Returns:

Key setting parameters from nx.log dict[str, Any]: A Dict of all relevant settings loaded from nx.log

Return type:

NewtonXSettingsResult

parse_en_data(endata_path, dataset, default_attributes)

Function to read energy data from en.dat in case the reading from nx.log has not succeeded:

Parameters:
  • endata_path (pathlib.Path) – Path to a RESULTS/en.dat file

  • dataset (xr.Dataset) – The dataset to update

  • default_attributes (dict) – Default attributes for the newtonx format

Returns:

the updated dataset

Return type:

xr.Dataset

parse_dyn_out(f, dataset)

Function to gather dynamics data (e_kin and velocities) from the RESULTS/dyn.out file, if it exists.

Parameters:
  • f (TextIOWrapper) – The stream of lines from the dyn.out file

  • dataset (xr.Dataset) – The dataset to write the data to

Returns:

The updated dataset after the read

Return type:

xr.Dataset

parse_nx_log_data(f, dataset, settings, default_attributes)

Function to parse the nx.log data into a dataset from the input stream f.

Will return the total number of actual timesteps read and the resulting dataset. Usual read data includes: forces, active state (“astate”)

Parameters:
  • f (TextIOWrapper) – Input filestream of a nx.log file

  • dataset (xr.Dataset) – The dataset to parse the data into

  • default_attributes (dict) – Default attributes for the newtonx format

  • settings (NewtonXSettingsResult)

Returns:

The total number of actual timesteps read and the resulting dataset after applying modifications.

Return type:

Tuple[int, xr.Dataset]

parse_nx_misc_input_settings(path)

Function to parse various input settings from the newtonx trajectory directory.

Parameters:

path (pathlib.Path) – The path of the base trajectory folder. Should Contain RESULTS, control.dyn and either JOB_AD or JOB_NAD

Returns:

The collected miscallenous settings. For specific settings, the keys “nx.log”, “control.dyn”

allow for searching through specific settings if the files were present.

NewtonXSettingsResult: The combined key settings if they could be extracted.

Return type:

Dict