aiida_lammps.parsers.parse_raw#

Set of functions to parse the unformatted raw files generated by lammps

Submodules#

Package Contents#

Functions#

parse_final_data(→ dict)

Read the yaml file with the global final data.

parse_outputfile(→ Union[dict, dict])

Parse the lammps output file file, this is the redirected screen output.

create_structure(, original_structure)

Generate a structure from the atomic positions at a given step.

iter_trajectories(file_obj)

Parse a LAMMPS Trajectory file, yielding data for each time step.

parse_step(→ collections.namedtuple)

Parse a given trajectory step

aiida_lammps.parsers.parse_raw.parse_final_data(filename: str | None = None, file_contents: str | None = None) dict[source]#

Read the yaml file with the global final data.

The final iteration for each of computed variables is sotred into a yaml file which is then read and stored as a dictionary.

Parameters:
  • filename (str, optional) – name of the yaml file where the variables are stored, defaults to None

  • file_contents (str, optional) – contents of the yaml file where the variables are stored, defaults to None

Returns:

dictionary with the final compute variables

Return type:

dict

aiida_lammps.parsers.parse_raw.parse_outputfile(filename: str | None = None, file_contents: str | None = None) dict | dict[source]#

Parse the lammps output file file, this is the redirected screen output.

This will gather the time dependent data stored in the output file and stores it as a dictionary. It will also gather single quantities and stores them into a different dictionary.

Parameters:
  • filename (str, optional) – name of the lammps output file, defaults to None

  • file_contents (str, optional) – contents of the lammps output file, defaults to None

Returns:

dictionary with the time dependent data, dictionary with the global data

Return type:

dict

aiida_lammps.parsers.parse_raw.create_structure(trajectory_block: collections.namedtuple, symbol_field: str = 'element', position_fields: tuple = ('x', 'y', 'z'), original_structure: aiida.orm.StructureData = None) aiida.orm.StructureData[source]#

Generate a structure from the atomic positions at a given step.

Parameters:
  • trajectory_block (namedtuple) – block with the trajectory information

  • symbol_field (str, optional) – field name where the element symbols are found, defaults to ‘element’

  • position_fields (tuple, optional) – name of the files where the positions are found, defaults to (‘x’, ‘y’, ‘z’)

  • original_structure (orm.StructureData, optional) – original structure of the calculation, defaults to None

Raises:
  • ValueError – if the symbols of the structure and of the trajectory info differ

  • NotImplementedError – If the boundary conditions are not periodic or free

Returns:

structure of the current time step

Return type:

orm.StructureData

aiida_lammps.parsers.parse_raw.iter_trajectories(file_obj)[source]#

Parse a LAMMPS Trajectory file, yielding data for each time step.

aiida_lammps.parsers.parse_raw.parse_step(lines, initial_line=0) collections.namedtuple[source]#

Parse a given trajectory step

Parameters:
  • lines (str) – subset fo the file content to be parsed.

  • initial_line (int, optional) – place where the parsing starts, defaults to 0

Raises:
  • IOError – if no timestep is found

  • IOError – if no number of atoms is found

  • IOError – if the box bounds are not found

  • IOError – if the header for the atomic positions is not found

Returns:

[description]

Return type:

namedtuple