aiida_lammps.parsers.utils#

Utility functions for the handling of the input files

Module Contents#

Functions#

generate_lammps_structure

Creation of the structure file content.

generate_header

Generate the header for the blocks.

flatten

Flattens a list of list into a flat list.

convert_to_str

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

join_keywords

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

API#

aiida_lammps.parsers.utils.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][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.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