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 the text for the lammps input file. |
|
Generate the input block with global control options. |
|
Generate the input block with potential options. |
|
Generate the input block with the structure options. |
|
Generate the input block with the minimization options. |
|
Generate the input block with the MD options. |
|
Generate the block to print the final values of the compute variables. |
|
Generate the velocity string for the MD block. |
|
Generate the options string for every velocity. |
|
Create a string with the integration options. |
|
Generate the input block with the fix options. |
|
Generate the input block with the compute options. |
|
Generate the block with dumps commands. |
|
Generate the block with the thermo command. |
|
Generate the block to write the restart file. |
|
Generate the block to read the restart file. |
|
Generate string for the quantities that will be printed. |
|
Generate an id tag for fixes and/or computes. |
|
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 theread_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:
- 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.
- 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:
- 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:
- Returns:
block with the structural information and list of groups present
- Return type:
- 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.
- 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.
- 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.
- 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.
- 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.
- 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.
- 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.
- 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.
- 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:
- 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.
- 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:
- Returns:
dictionary with the string block indicating the printing of the final restart file and intermediate files.
- Return type:
- aiida_lammps.parsers.inputfile.write_read_restart_block(restart_filename: str) str [source]#
Generate the block to read the restart file.
- 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.
- 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.
- 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.