:py:mod:`aiida_lammps.data.trajectory`
======================================

.. py:module:: aiida_lammps.data.trajectory

.. autoapi-nested-parse::

   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
~~~~~~~

.. autoapisummary::

   aiida_lammps.data.trajectory.LammpsTrajectory




.. py:class:: LammpsTrajectory(fileobj=None, aliases=None, **kwargs)


   Bases: :py:obj:`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.


   .. py:property:: number_steps

      Get the number of steps stored in the data.

      :return: number of steps stored in the data
      :rtype: int


   .. py:property:: time_steps

      Get the simulation time steps stored in the data.

      :return: time steps stored in the data.
      :rtype: list


   .. py:property:: number_atoms

      Get the number of atoms present in the simulation box.

      :return: number of atoms in the simulation box
      :rtype: int


   .. py:property:: field_names

      Get the name of the fields as written to file.

      :return: list of field names as written to file.
      :rtype: list


   .. py:property:: aliases

      Get the mapping of one or more lammps variables.

      :return: mapping of one or more lammps variables.
      :rtype: list


   .. py:attribute:: _zip_prefix
      :value: 'step-'

      

   .. py:attribute:: _trajectory_filename
      :value: 'trajectory.zip'

      

   .. py:attribute:: _timestep_filename
      :value: 'timesteps.txt'

      

   .. py:attribute:: _compression_method

      

   .. py:method:: _validate()

      Validate that a trajectory has been set, before storing.


   .. py:method:: set_from_fileobj(fileobj, aliases=None)

      Store a lammps trajectory file.

      :param fileobj: the file or path to the file
      :type fileobj: str
      :param aliases:  mapping of variable names to one or more lammps variables,
          e.g. {"position": ["x", "y", "z"]}, defaults to None
      :type aliases: dict[str, list], optional
      :raises ValueError: if the aliases are not of the correct type
      :raises IOError: if a given step has more atoms than supposed to
      :raises IOError: if a given step has incompatible field names
      :raises IOError: if the timesteps are not present in the trajectory file


   .. py:method:: get_step_string(step_idx)

      Return the content string, for a specific trajectory step.


   .. py:method:: get_step_data(step_idx)

      Return parsed data, for a specific trajectory step.


   .. py:method:: iter_step_strings(steps=None)

      Yield the content string, for each trajectory step.


   .. py:method:: 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

      Return a StructureData object, for a specific trajectory step.

      :param step_idx: trajectory step to be looked at
      :type step_idx: int
      :param symbol_field: the variable field denoting the symbol
          for each atom, defaults to 'element'
      :type symbol_field: str, optional
      :param position_fields: tuple, the variable fields denoting
          the x, y, z position for each atom, defaults to ('x', 'y', 'z')
      :type position_fields: tuple, optional
      :param original_structure: a structure that will be used to
          define kinds for each atom, defaults to None
      :type original_structure: orm.StructureData, optional
      :return: structure of the simulation at the given time step
      :rtype: orm.StructureData


   .. py:method:: write_as_lammps(handle, steps=None)

      Write out the lammps trajectory to file.

      :param handle: a file handle, opened in "wb" mode
      :param steps: a list of steps to write (default to all)



