aiida_lammps.parsers.inputfile#

Set of functions for the generation of the LAMMPS input file

These functions will be called depending on what options are present in the calculation parameters. The input file is generated via ‘blocks’, each of these blocks will be responsible for printing and/or generate the data that needs to be set in the LAMMPS file in accordance to the user defined parameters.

Certain blocks are conditionally called, e.g. if no fixes are specified the fixes block is never called, on the other hand the control block is always called since it is necessary for the functioning of LAMMPS.

Module Contents#

Functions#

generate_input_file(→ str)

Generate the text for the lammps input file.

write_control_block(→ str)

Generate the input block with global control options.

write_potential_block(→ str)

Generate the input block with potential options.

write_structure_block(→ tuple[str, list[str]])

Generate the input block with the structure options.

write_minimize_block(→ str)

Generate the input block with the minimization options.

write_md_block(→ str)

Generate the input block with the MD options.

write_final_variables_block(→ str)

Generate the block to print the final values of the compute variables.

generate_velocity_string(→ str)

Generate the velocity string for the MD block.

generate_velocity_options(→ str)

Generate the options string for every velocity.

generate_integration_options(→ str)

Create a string with the integration options.

write_fix_block(→ str)

Generate the input block with the fix options.

write_compute_block(→ str)

Generate the input block with the compute options.

write_dump_block(→ str)

Generate the block with dumps commands.

write_thermo_block(→ tuple[str, list[str]])

Generate the block with the thermo command.

write_restart_block(→ dict[str, Any])

Generate the block to write the restart file.

write_read_restart_block(→ str)

Generate the block to read the restart file.

generate_printing_string(→ str)

Generate string for the quantities that will be printed.

generate_id_tag(→ str)

Generate an id tag for fixes and/or computes.

join_keywords(→ str)

Generate a string for the compute/fix options.

aiida_lammps.parsers.inputfile.generate_input_file(parameters: dict[str, Any], potential: aiida_lammps.data.potential.LammpsPotentialData, structure: aiida.orm.StructureData, trajectory_filename: str = 'aiida_lammps.trajectory.dump', restart_filename: str = 'lammps.restart', potential_filename: str = 'potential.dat', structure_filename: str = 'structure.dat', variables_filename: str = 'aiida_lammps.yaml', read_restart_filename: str | None = None) str[source]#

Generate the text for the lammps input file.

It takes the parameters and other inputs needed to generate the lammps input file. All the required input blocks are always written, whilst some such as the compute and fixes block are only written if required.

Note

If the read_restart_filename is provided the read_data command is used to overwrite the structure and set the velocity and other parameters from a previous calculation.

Parameters:
  • parameters (dict) – calculation parameters used to control the LAMMPS calculation

  • potential (LammpsPotentialData) – potential used during the LAMMPS calculation

  • structure (orm.StructureData) – structure used during the LAMMPS calculation

  • trajectory_filename (str, optional) – filename used to write the trajectory information, defaults to ‘aiida_lammps.trajectory.dump’

  • restart_filename (str, optional) – filename used to write the restart information, defaults to ‘restart.aiida’

  • potential_filename (str, optional) – filename used to read the potential, defaults to ‘potential.dat’

  • structure_filename (str, optional) – filename used to read the structure, defaults to ‘structure.dat’

  • variables_filename (str, optional) – filename used to store the final variables, defaults to ‘aiida_lammps.yaml’

  • read_restart_filename (str, optional) – filename used to read the restart information, defaults to None

Returns:

contents of the lammps input file.

Return type:

str

aiida_lammps.parsers.inputfile.write_control_block(parameters_control: dict[str, Any]) str[source]#

Generate the input block with global control options.

This takes the general options that affect the entire simulation, these are then used (or their default values) to generate the control block.

Parameters:

parameters_control (dict) – dictionary with the basic control parameters

Returns:

control block with general parameters of the simulation.

Return type:

str

aiida_lammps.parsers.inputfile.write_potential_block(potential: aiida_lammps.data.potential.LammpsPotentialData, structure: aiida.orm.StructureData, parameters_potential: dict[str, Any], potential_file: str) str[source]#

Generate the input block with potential options.

This will take into consideration the type of potential, as well as other parameters which affect the usage of the potential (such as neighbor information) and generate a block that is written in the LAMMPS input file.

Parameters:
  • potential (LammpsPotentialData,) – md-potential which will be used in the calculation

  • structure (orm.StructureData) – structure used for the calculation

  • parameters_potential (dict) – parameters which have to deal with the potential

  • potential_file – filename for the potential to be used.

Returns:

block with the information needed to setup the potential part of the LAMMPS calculation.

Return type:

str

aiida_lammps.parsers.inputfile.write_structure_block(parameters_structure: dict[str, Any], structure: aiida.orm.StructureData, structure_filename: str) tuple[str, list[str]][source]#

Generate the input block with the structure options.

Takes the AiiDA StructureData as well as as a series of user defined parameters to generate the structure related input block. This is also responsible of defining the distinct groups that can then be used for different compute and/or fixes operations.

Parameters:
  • parameters_structure (Dict[str, Any]) – set of user defined parameters relating to the structure.

  • structure (orm.StructureData) – structure that will be studied

  • structure_filename (str) – name of the file where the structure will be written so that LAMMPS can read it

Returns:

block with the structural information and list of groups present

Return type:

Tuple[str, List[str]]

aiida_lammps.parsers.inputfile.write_minimize_block(parameters_minimize: dict[str, str | float | int]) str[source]#

Generate the input block with the minimization options.

If the user wishes to do a minimization calculation the parameters will be passed to this routine and the necessary block for the input file will be generated.

Note

this mode is mutually exclusive with the md mode.

Parameters:

parameters_minimize (dict) – user defined parameters for the minimization

Returns:

block with the minimization options.

Return type:

str

aiida_lammps.parsers.inputfile.write_md_block(parameters_md: dict[str, Any]) str[source]#

Generate the input block with the MD options.

If the user wishes to perform an MD run this will take the user defined parameters and set them in a LAMMPS compliant form.

Note

For MD to function an integrator must be provided, this is done by providing a fix in the fix part of the input. The existence of at least one integrator is checked by the schema.

Note

this mode is mutually exclusive with the minimize mode.

Parameters:

parameters_md (dict) – user defined parameters for the MD run

Returns:

block with the MD options.

Return type:

str

aiida_lammps.parsers.inputfile.write_final_variables_block(fixed_thermo: list[str], final_file: str = 'aiida_lammps.yaml') str[source]#

Generate the block to print the final values of the compute variables.

This takes all the global computes and other thermo values evaluated in the simulation and appends them to a final yaml file for recovery.

Parameters:

fixed_thermo (list) – list of thermo values (including computes)

Returns:

input block with the final variables of the calculation.

Return type:

str

aiida_lammps.parsers.inputfile.generate_velocity_string(parameters_velocity: list[dict[str, Any]]) str[source]#

Generate the velocity string for the MD block.

This takes the different possible velocity settings and generate a string which is LAMMPS compatible.

Parameters:

parameters_velocity (dict) – dictionary with the velocity parameters

Returns:

string with the velocity options

Return type:

str

aiida_lammps.parsers.inputfile.generate_velocity_options(options_velocity: dict[str, Any]) str[source]#

Generate the options string for every velocity.

Independent of the way in which one specifies the velocity there are several options that are global, this functions allows them to be setup.

Parameters:

options_velocity (dict) – dictionary with the velocity parameters

Returns:

string with the velocity options

Return type:

str

aiida_lammps.parsers.inputfile.generate_integration_options(style: str, integration_parameters: dict[str, Any]) str[source]#

Create a string with the integration options.

This will check that the appropriate options are setup for each of the supported integrators. These will be appended to a string which is then passed to each of the integrators.

Parameters:
  • style (str) – Integration style performed in MD mode

  • integration_parameters (dict) – dictionary with the constraints for the integration

Returns:

string with the integration options.

Return type:

str

aiida_lammps.parsers.inputfile.write_fix_block(parameters_fix: dict[str, Any], group_names: list[str] | None = None) str[source]#

Generate the input block with the fix options.

This takes the user defined fixes and generates a block where each one of them is defined. They can be applied to different groups which can be selected by the user and are checked to exist with the previously defined groups in the structure setup.

Note

fixes which are incompatible with the minimize option are checked by the validation schema.

Note

the md mode required one of the integrators (nve, nvt, etc) to be defined their existence is checked by the schema.

Parameters:
  • parameters_fix (dict) – fixes that will be applied to the calculation

  • group_names (list, optional) – list of groups names as defined during structure generation, defaults to None

Returns:

block with the fixes information

Return type:

str

aiida_lammps.parsers.inputfile.write_compute_block(parameters_compute: dict[str, Any], group_names: list[str] | None = None) str[source]#

Generate the input block with the compute options.

This takes the user defined computes and generates a block where each one of them is defined. They can be applied to different groups which can be selected by the user and are checked to exist with the previously defined groups in the structure setup.

Parameters:
  • parameters_compute (dict) – computes that will be applied to the calculation

  • group_names (list, optional) – list of groups names as defined during structure generation, defaults to None

Returns:

block with the computes information

Return type:

str

aiida_lammps.parsers.inputfile.write_dump_block(parameters_dump: dict[str, Any], trajectory_filename: str, atom_style: str, kind_symbols: list[str], parameters_compute: dict[str, Any] | None = None) str[source]#

Generate the block with dumps commands.

This will check for any compute and/or fix that generates atom dependent data and will make sure that it is written to file in a controllable manner, so that they can be easily parsed afterwards.

Parameters:
  • parameters_dump (dict) – set of user defined parameters for the writing of data

  • trajectory_filename (str) – name of the file where the trajectory is written.

  • atom_style – which kind of LAMMPS atomic style is used for the calculation.

  • parameters_compute (dict) – computes that will be applied to the calculation

Returns:

block with the dump options for the calculation

Return type:

str

aiida_lammps.parsers.inputfile.write_thermo_block(parameters_thermo: dict[str, Any], parameters_compute: dict[str, Any] | None = None) tuple[str, list[str]][source]#

Generate the block with the thermo command.

This will take all the global computes which were generated during the calculation plus the ‘common’ thermodynamic parameters set by LAMMPS and set them so that they are printed to the LAMMPS output file.

Parameters:
  • parameters_thermo (dict) – user defined parameters to control the output data.

  • parameters_compute (dict) – computes that will be applied to the calculation

Returns:

block with the thermo options for the calculation, list of thermo printing variables

Return type:

Union[str, list]

aiida_lammps.parsers.inputfile.write_restart_block(parameters_restart: dict[str, Any], restart_filename: str, max_number_steps: int) dict[str, Any][source]#

Generate the block to write the restart file.

Parameters:
  • parameters_restart (dict) – set of parameters controlling the printing of the restartfile

  • restart_filename (str) – Name of the LAMMPS restart file

  • max_number_steps (int) – maximum number of steps in the simulation

Returns:

dictionary with the string block indicating the printing of the final restart file and intermediate files.

Return type:

dict

aiida_lammps.parsers.inputfile.write_read_restart_block(restart_filename: str) str[source]#

Generate the block to read the restart file.

Parameters:

restart_filename (str) – Name of the LAMMPS restart file

Returns:

string block indicating the reading of a restart file.

Return type:

str

aiida_lammps.parsers.inputfile.generate_printing_string(name: str, group: str, calculation_type: str) str[source]#

Generate string for the quantities that will be printed.

The idea is to take the name as well as the group of the parameter that one wishes to print, then in conjunction with the information stored for each parameter one can generate a string for either the thermo or dump commands.

Parameters:
  • name (str) – Name of the compute/fix that one wishes to print

  • group (str) – Name of the group where the compute/fix is calculated

Returns:

string for the compute/fix that will be used for printing

Return type:

str

aiida_lammps.parsers.inputfile.generate_id_tag(name: str, group: str) str[source]#

Generate an id tag for fixes and/or computes.

To standardize the naming of computes and/or fixes and to ensure that one can programmatically recreate them their name will consist of the name of the fix/compute with the group at which is applied appended plus the aiida keyword. Of this way one can always regenerate these tags by knowing which fix/computes were asked of the calculation.

Parameters:
  • name (str, optional) – name of the fix/compute, defaults to None

  • group (str, optional) – group which at which the fix/compute will be applied to, defaults to None

Returns:

if tag for the compute/fix

Return type:

str

aiida_lammps.parsers.inputfile.join_keywords(value: list[Any]) str[source]#

Generate a string for the compute/fix options.

Depending on the desired fix/compute several options might need to be passed to it to dictate its behavior. Having the user pass these options as a single string is a bad idea, instead it is simple if the user passes them as a list, where key,value pairs dictionaries can be present and or single entries. These items will be taken and concatenated to ensure that a LAMMPS compliant string is produced out of all these options.

Parameters:

value (list) – list with the options for a given fix/compute

Returns:

LAMMPS compliant string with the fix/compute options

Return type:

str