ai2_kit.domain.lammps module#

class ai2_kit.domain.lammps.CllLammpsContext(path_prefix: str, resource_manager: ai2_kit.core.resource_manager.ResourceManager, config: ai2_kit.domain.lammps.CllLammpsContextConfig)[source]#

Bases: BaseCllContext

config: CllLammpsContextConfig#
pydantic model ai2_kit.domain.lammps.CllLammpsContextConfig[source]#

Bases: BaseModel

Show JSON schema
{
   "title": "CllLammpsContextConfig",
   "type": "object",
   "properties": {
      "script_template": {
         "$ref": "#/$defs/BashTemplate"
      },
      "lammps_cmd": {
         "default": "lmp",
         "title": "Lammps Cmd",
         "type": "string"
      },
      "concurrency": {
         "default": 5,
         "title": "Concurrency",
         "type": "integer"
      },
      "multi_gpus_per_job": {
         "default": false,
         "title": "Multi Gpus Per Job",
         "type": "boolean"
      }
   },
   "$defs": {
      "BashTemplate": {
         "additionalProperties": false,
         "properties": {
            "shebang": {
               "default": "#!/bin/bash",
               "title": "Shebang",
               "type": "string"
            },
            "header": {
               "default": "",
               "title": "Header",
               "type": "string"
            },
            "setup": {
               "default": "",
               "title": "Setup",
               "type": "string"
            },
            "teardown": {
               "default": "",
               "title": "Teardown",
               "type": "string"
            }
         },
         "title": "BashTemplate",
         "type": "object"
      }
   },
   "additionalProperties": false,
   "required": [
      "script_template"
   ]
}

Config:
  • extra: str = forbid

Fields:
field concurrency: int = 5#
field lammps_cmd: str = 'lmp'#
field multi_gpus_per_job: bool = False#
field script_template: BashTemplate [Required]#
class ai2_kit.domain.lammps.CllLammpsInput(config: ai2_kit.domain.lammps.CllLammpsInputConfig, type_map: List[str], mass_map: List[float], mode: Literal['default', 'dpff', 'fep-redox', 'fep-pka'], preset_template: str, new_system_files: List[ai2_kit.core.artifact.Artifact], dp_models: Mapping[str, List[ai2_kit.core.artifact.Artifact]], dp_modifier: dict | None, dp_sel_type: List[int] | None)[source]#

Bases: object

config: CllLammpsInputConfig#
dp_models: Mapping[str, List[Artifact]]#
dp_modifier: dict | None#
dp_sel_type: List[int] | None#
mass_map: List[float]#
mode: Literal['default', 'dpff', 'fep-redox', 'fep-pka']#
new_system_files: List[Artifact]#
preset_template: str#
type_map: List[str]#
pydantic model ai2_kit.domain.lammps.CllLammpsInputConfig[source]#

Bases: BaseModel

Show JSON schema
{
   "title": "CllLammpsInputConfig",
   "type": "object",
   "properties": {
      "n_wise": {
         "default": 0,
         "title": "N Wise",
         "type": "integer"
      },
      "explore_vars": {
         "additionalProperties": {
            "items": {},
            "type": "array"
         },
         "title": "Explore Vars",
         "type": "object"
      },
      "broadcast_vars": {
         "default": {},
         "title": "Broadcast Vars",
         "type": "object"
      },
      "preset_template": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Preset Template"
      },
      "input_template": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Input Template"
      },
      "template_vars": {
         "default": {},
         "title": "Template Vars",
         "type": "object"
      },
      "plumed_config": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Plumed Config"
      },
      "system_files": {
         "items": {
            "type": "string"
         },
         "title": "System Files",
         "type": "array"
      },
      "ensemble": {
         "anyOf": [
            {
               "enum": [
                  "nvt",
                  "npt",
                  "npt-i",
                  "npt-a",
                  "npt-iso",
                  "npt-aniso",
                  "npt-t",
                  "npt-tri",
                  "npt-x",
                  "npt-y",
                  "npt-z",
                  "nve",
                  "csvr"
               ],
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Ensemble"
      },
      "fix_statement": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Fix Statement"
      },
      "no_pbc": {
         "default": false,
         "title": "No Pbc",
         "type": "boolean"
      },
      "nsteps": {
         "title": "Nsteps",
         "type": "integer"
      },
      "timestep": {
         "default": 0.0005,
         "title": "Timestep",
         "type": "number"
      },
      "sample_freq": {
         "default": 100,
         "title": "Sample Freq",
         "type": "integer"
      },
      "ignore_error": {
         "default": false,
         "title": "Ignore Error",
         "type": "boolean"
      },
      "type_alias": {
         "additionalProperties": {
            "items": {
               "type": "string"
            },
            "type": "array"
         },
         "default": {},
         "title": "Type Alias",
         "type": "object"
      },
      "custom_ff": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Custom Ff"
      },
      "fep_opts": {
         "allOf": [
            {
               "$ref": "#/$defs/FepOptions"
            }
         ],
         "default": {
            "ini_ghost_types": [],
            "fin_ghost_types": []
         }
      }
   },
   "$defs": {
      "FepOptions": {
         "additionalProperties": false,
         "properties": {
            "ini_ghost_types": {
               "default": [],
               "items": {
                  "type": "string"
               },
               "title": "Ini Ghost Types",
               "type": "array"
            },
            "fin_ghost_types": {
               "default": [],
               "items": {
                  "type": "string"
               },
               "title": "Fin Ghost Types",
               "type": "array"
            }
         },
         "title": "FepOptions",
         "type": "object"
      }
   },
   "additionalProperties": false,
   "required": [
      "explore_vars",
      "system_files",
      "nsteps"
   ]
}

Config:
  • extra: str = forbid

Fields:
Validators:
field broadcast_vars: Mapping[str, Any] = {}#

Variants to be explore by broadcast.

Variables defined here won’t join the combination, but will be broadcasted to all combinations.

This can be used to avoid combination explosion.

`yaml LAMBDA_f: [0.0, 0.25, 0.5, 0.75, 1.0] `

Validated by:
field custom_ff: str | None = None#

Allow user to set custom force field. If set, the custom force field will be used instead of the default one. The use can use $$DP_MODELS to reference the deepmd models, and $$SPECORDER to reference the atom type order. For example:

pair_style hybrid/overlay &

deepmd $$DP_MODELS out_freq ${THERMO_FREQ} out_file model_devi.out $$FEP_DP_OPT & buck/coul/long 10.0 10.0

pair_coeff * * deepmd 1 $$SPECORDER pair_coeff * * buck/coul/long 10.0 10.0

Validated by:
field ensemble: Literal['nvt', 'npt', 'npt-i', 'npt-a', 'npt-iso', 'npt-aniso', 'npt-t', 'npt-tri', 'npt-x', 'npt-y', 'npt-z', 'nve', 'csvr'] | None = None#
Validated by:
field explore_vars: Mapping[str, List[Any]] [Required]#

Variants to be explore by full combination or n_wise combination.

Variables defined here will become LAMMPS variables. If multiple value has been set for a variable, the cartesian product will be used to generate the combination. For example,

`yaml TEMP: [330, 430, 530]  # Can be a scalar, e.g. 330 PRES: 1                # Can be a vector, e.g. [1, 2, 3] ` Then you can reference them in the LAMMPS input template as ${TEMP}, ${LAMBDA_f}, ${N_STEPS}, etc.

Validated by:
field fep_opts: FepOptions = FepOptions(ini_ghost_types=[], fin_ghost_types=[])#
Validated by:
field fix_statement: str | None = None#
Validated by:
field ignore_error: bool = False#
Validated by:
field input_template: str | None = None#

LAMMPS input template file content. If set, the preset_template will be ignored.

Validated by:
field n_wise: int = 0#

The way of combining variants. if n_wise is less than 2 or greater than total fields, the full combination will be used. Or else, the n_wise combination will be used. It is strongly recommended to use n_wise when the full combination is too large.

Validated by:
field no_pbc: bool = False#
Validated by:
field nsteps: int [Required]#
Validated by:
field plumed_config: str | None = None#

Plumed config file content.

Validated by:
field preset_template: str | None = None#

Name of the preset template.

Validated by:
field sample_freq: int = 100#
Validated by:
field system_files: List[str] [Required]#

Artifacts key of lammps input data

Validated by:
field template_vars: Mapping[str, Any] = {}#

input_template may provide extra injection points for user to inject custom settings. Those value could be set here.

Those vars can be referenced in the LAMMPS input template as $$VAR_NAME.

Validated by:
field timestep: float = 0.0005#
Validated by:
field type_alias: Mapping[str, List[str]] = {}#

Type alias for atoms. For example, if you want to distinguish ghost H and H of HF molecule from other H atoms, you can define the alias as follows: ```yaml type_alias:

H: [ H_ghost, H_hf ]

` And then you can reference them in the LAMMPS input template, for example ` set atom 1 type ${H_hf} set atom 2 type ${H_ghost} ```

Validated by:
assert_var(var: str, msg: str = '')[source]#
validator validate_domain  »  all fields[source]#
validator validate_explore_variants  »  explore_vars[source]#
pydantic model ai2_kit.domain.lammps.FepOptions[source]#

Bases: BaseModel

Show JSON schema
{
   "title": "FepOptions",
   "type": "object",
   "properties": {
      "ini_ghost_types": {
         "default": [],
         "items": {
            "type": "string"
         },
         "title": "Ini Ghost Types",
         "type": "array"
      },
      "fin_ghost_types": {
         "default": [],
         "items": {
            "type": "string"
         },
         "title": "Fin Ghost Types",
         "type": "array"
      }
   },
   "additionalProperties": false
}

Config:
  • extra: str = forbid

Fields:
field fin_ghost_types: List[str] = []#
field ini_ghost_types: List[str] = []#
class ai2_kit.domain.lammps.GenericLammpsOutput(model_devi_outputs: List[ai2_kit.core.artifact.Artifact])[source]#

Bases: ICllExploreOutput

get_model_devi_dataset() List[Artifact][source]#
model_devi_outputs: List[Artifact]#
class ai2_kit.domain.lammps.LammpsInputTemplate(template)[source]#

Bases: Template

delimiter = '$$'#
pattern = re.compile('\n            \\$\\$(?:\n              (?P<escaped>\\$\\$)  |   # Escape sequence of two delimiters\n              (?P<named>(?a:[_a-z][_a-z0-9]*))       |   # delimiter and a Python identifier\n    , re.IGNORECASE|re.VERBOSE)#
async ai2_kit.domain.lammps.cll_lammps(input: CllLammpsInput, ctx: CllLammpsContext)[source]#
ai2_kit.domain.lammps.get_ensemble(ensemble: str, group='all')[source]#
ai2_kit.domain.lammps.get_types_template_vars(type_map: List[str], mass_map: List[float], type_alias: Mapping[str, List[str]], sel_type: List[int] | None, fep_ini_ghost_types: List[str], fep_fin_ghost_types: List[str])[source]#

generate template vars that related to type_map, mass_map, type_alias, sel_type

the order of atom type index is: real atoms (defined in type_map), virtual atoms (defined in sel_type) and then alias (defined in type_alias)

ai2_kit.domain.lammps.make_lammps_task_dirs(combination_vars: Mapping[str, Sequence[Any]], broadcast_vars: Mapping[str, Sequence[Any]], data_files: List[ArtifactDict], dp_models: Mapping[str, List[str]], n_steps: int, timestep: float, sample_freq: float, no_pbc: bool, n_wise: int, ensemble: str | None, fix_statement: str | None, preset_template: str, input_template: str | None, plumed_config: str | None, extra_template_vars: Mapping[str, Any], type_map: List[str], mass_map: List[float], type_alias: Mapping[str, List[str]], work_dir: str, dp_modifier: dict | None, dp_sel_type: List[int] | None, mode: Literal['default', 'dpff', 'fep-redox', 'fep-pka'], fep_opts: FepOptions, rel_path: bool = False, custom_ff: str | None = None)[source]#