:py:mod:`aiida_lammps.parsers.utils`
====================================

.. py:module:: aiida_lammps.parsers.utils

.. autoapi-nested-parse::

   Utility functions for the handling of the input files



Module Contents
---------------


Functions
~~~~~~~~~

.. autoapisummary::

   aiida_lammps.parsers.utils._transform_cell
   aiida_lammps.parsers.utils.generate_lammps_structure
   aiida_lammps.parsers.utils.generate_header
   aiida_lammps.parsers.utils.flatten
   aiida_lammps.parsers.utils.convert_to_str
   aiida_lammps.parsers.utils._convert_values
   aiida_lammps.parsers.utils.join_keywords



.. py:function:: _transform_cell(cell) -> Union[numpy.array, numpy.array]

   Transform the cell to an orientation, compatible with LAMMPS

   LAMMPS requires the simulation cell to be in the format of a
   lower triangular matrix (right-handed basis).
   Therefore the cell and positions may require rotation and inversion.
   See https://lammps.sandia.gov/doc/Howto_triclinic.html

   :param cell: crystal cell of the original structure
   :returns: LAMMPS compatible cell, transformation between original and final cell
   :rtype: Union[np.array, np.array]


.. py:function:: generate_lammps_structure(structure: aiida.orm.StructureData, atom_style: str = 'atomic', charge_dict: Optional[dict[str, float]] = None, round_dp: Optional[float] = None, docstring: str = 'generated by aiida_lammps') -> Union[str, numpy.array]

   Creation of the structure file content.

   As allowing the users to create their lattices using LAMMPS' would be too
   complex, one must ensure that the aiida StructureData is written to file in
   a format that is compatible to LAMMPS.

   In the case of non-orthogonal structures, this will take care of generating
   a triclinic cell compatible with what LAMMPS expects.

   :param structure: the structure to use in the simulation
   :type structure: orm.StructureData
   :param atom_style: treatment of the particles according to lammps, defaults to 'atomic'
   :type atom_style: str, optional
   :param charge_dict: dictionary with the charge for the particles, defaults to None
   :type charge_dict: dict, optional
   :param round_dp: precision to which to round the positions, defaults to None
   :type round_dp: float, optional
   :param docstring: header for the structure file, defaults to 'generated by aiida_lammps'
   :type docstring: str, optional
   :raises ValueError: if the atom_style does not belong to either 'atomic' or 'charge'
   :return: the structure file content, the transformation matrix applied to
       the structure cell and coordinates
   :rtype: Union[str, np.array]


.. py:function:: generate_header(value: str) -> str

   Generate the header for the blocks.

   :param value: string indicating the input block
   :type value: str
   :return: header/footer for the input block
   :rtype: str


.. py:function:: flatten(full_list: list) -> list

   Flattens a list of list into a flat list.

   :param full_list: list of lists to be flattened
   :type full_list: list
   :yield: flattened list
   :rtype: list


.. py:function:: convert_to_str(value) -> str

   convert True/False to yes/no and all values to strings


.. py:function:: _convert_values(value) -> str


.. py:function:: join_keywords(dct, ignore=None) -> str

   join a dict of {keyword: value, ...} into a string 'keyword value ...'

   value can be a single value or a list/tuple of values


