aiida_lammps.data.trajectory#

Data structure for storing LAMMPS trajectories.

The idea is that each of the steps of the simulation are stored as ZIP files which can then be easily accessed by the user.

Module Contents#

Classes#

LammpsTrajectory

Store a lammps trajectory file.

class aiida_lammps.data.trajectory.LammpsTrajectory(fileobj=None, aliases=None, **kwargs)[source]#

Bases: aiida.orm.Data

Store a lammps trajectory file.

Each trajectory step is stored as a separate file, within a compressed zip folder. This reduces storage space, and allows for fast access to each step.

property number_steps[source]#

Get the number of steps stored in the data.

Returns:

number of steps stored in the data

Return type:

int

property time_steps[source]#

Get the simulation time steps stored in the data.

Returns:

time steps stored in the data.

Return type:

list

property number_atoms[source]#

Get the number of atoms present in the simulation box.

Returns:

number of atoms in the simulation box

Return type:

int

property field_names[source]#

Get the name of the fields as written to file.

Returns:

list of field names as written to file.

Return type:

list

property aliases[source]#

Get the mapping of one or more lammps variables.

Returns:

mapping of one or more lammps variables.

Return type:

list

_zip_prefix = 'step-'[source]#
_trajectory_filename = 'trajectory.zip'[source]#
_timestep_filename = 'timesteps.txt'[source]#
_compression_method[source]#
_validate()[source]#

Validate that a trajectory has been set, before storing.

set_from_fileobj(fileobj, aliases=None)[source]#

Store a lammps trajectory file.

Parameters:
  • fileobj (str) – the file or path to the file

  • aliases (dict[str, list], optional) – mapping of variable names to one or more lammps variables, e.g. {“position”: [“x”, “y”, “z”]}, defaults to None

Raises:
  • ValueError – if the aliases are not of the correct type

  • IOError – if a given step has more atoms than supposed to

  • IOError – if a given step has incompatible field names

  • IOError – if the timesteps are not present in the trajectory file

get_step_string(step_idx)[source]#

Return the content string, for a specific trajectory step.

get_step_data(step_idx)[source]#

Return parsed data, for a specific trajectory step.

iter_step_strings(steps=None)[source]#

Yield the content string, for each trajectory step.

get_step_structure(step_idx: int, symbol_field: str = 'element', position_fields: tuple = ('x', 'y', 'z'), original_structure: aiida.orm.StructureData = None) aiida.orm.StructureData[source]#

Return a StructureData object, for a specific trajectory step.

Parameters:
  • step_idx (int) – trajectory step to be looked at

  • symbol_field (str, optional) – the variable field denoting the symbol for each atom, defaults to ‘element’

  • position_fields (tuple, optional) – tuple, the variable fields denoting the x, y, z position for each atom, defaults to (‘x’, ‘y’, ‘z’)

  • original_structure (orm.StructureData, optional) – a structure that will be used to define kinds for each atom, defaults to None

Returns:

structure of the simulation at the given time step

Return type:

orm.StructureData

write_as_lammps(handle, steps=None)[source]#

Write out the lammps trajectory to file.

Parameters:
  • handle – a file handle, opened in “wb” mode

  • steps – a list of steps to write (default to all)