aiida_lammps.parsers.utils#

Utility functions for the handling of the input files

Module Contents#

Functions#

_transform_cell(→ Union[numpy.array, numpy.array])

Transform the cell to an orientation, compatible with LAMMPS

generate_lammps_structure(→ Union[str, numpy.array])

Creation of the structure file content.

generate_header(→ str)

Generate the header for the blocks.

flatten(→ list)

Flattens a list of list into a flat list.

convert_to_str(→ str)

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

_convert_values(→ str)

join_keywords(→ str)

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

aiida_lammps.parsers.utils._transform_cell(cell) numpy.array | numpy.array[source]#

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

Parameters:

cell – crystal cell of the original structure

Returns:

LAMMPS compatible cell, transformation between original and final cell

Return type:

Union[np.array, np.array]

aiida_lammps.parsers.utils.generate_lammps_structure(structure: aiida.orm.StructureData, atom_style: str = 'atomic', charge_dict: dict[str, float] | None = None, round_dp: float | None = None, docstring: str = 'generated by aiida_lammps') str | numpy.array[source]#

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.

Parameters:
  • structure (orm.StructureData) – the structure to use in the simulation

  • atom_style (str, optional) – treatment of the particles according to lammps, defaults to ‘atomic’

  • charge_dict (dict, optional) – dictionary with the charge for the particles, defaults to None

  • round_dp (float, optional) – precision to which to round the positions, defaults to None

  • docstring (str, optional) – header for the structure file, defaults to ‘generated by aiida_lammps’

Raises:

ValueError – if the atom_style does not belong to either ‘atomic’ or ‘charge’

Returns:

the structure file content, the transformation matrix applied to the structure cell and coordinates

Return type:

Union[str, np.array]

aiida_lammps.parsers.utils.generate_header(value: str) str[source]#

Generate the header for the blocks.

Parameters:

value (str) – string indicating the input block

Returns:

header/footer for the input block

Return type:

str

aiida_lammps.parsers.utils.flatten(full_list: list) list[source]#

Flattens a list of list into a flat list.

Parameters:

full_list (list) – list of lists to be flattened

Yield:

flattened list

Return type:

list

aiida_lammps.parsers.utils.convert_to_str(value) str[source]#

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

aiida_lammps.parsers.utils._convert_values(value) str[source]#
aiida_lammps.parsers.utils.join_keywords(dct, ignore=None) str[source]#

join a dict of {keyword: value, …} into a string ‘keyword value …’

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