ai2_kit.domain.cp2k module#

class ai2_kit.domain.cp2k.CllCp2kContext(path_prefix: str, resource_manager: ai2_kit.core.resource_manager.ResourceManager, config: ai2_kit.domain.cp2k.CllCp2kContextConfig)[source]#

Bases: BaseCllContext

config: CllCp2kContextConfig#
pydantic model ai2_kit.domain.cp2k.CllCp2kContextConfig[source]#

Bases: BaseModel

Show JSON schema
{
   "title": "CllCp2kContextConfig",
   "type": "object",
   "properties": {
      "script_template": {
         "$ref": "#/$defs/BashTemplate"
      },
      "cp2k_cmd": {
         "default": "cp2k",
         "title": "Cp2K Cmd",
         "type": "string"
      },
      "post_cp2k_cmd": {
         "default": "echo \"no post_cp2k_cmd\"",
         "title": "Post Cp2K Cmd",
         "type": "string"
      },
      "concurrency": {
         "default": 5,
         "title": "Concurrency",
         "type": "integer"
      }
   },
   "$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 cp2k_cmd: str = 'cp2k'#
field post_cp2k_cmd: str = 'echo "no post_cp2k_cmd"'#
field script_template: BashTemplate [Required]#
class ai2_kit.domain.cp2k.CllCp2kInput(config: ai2_kit.domain.cp2k.CllCp2kInputConfig, mode: Literal['default', 'dpff', 'fep-redox', 'fep-pka'], system_files: List[ai2_kit.core.artifact.Artifact], type_map: List[str], initiated: bool = False)[source]#

Bases: object

config: CllCp2kInputConfig#
initiated: bool = False#
mode: Literal['default', 'dpff', 'fep-redox', 'fep-pka']#
system_files: List[Artifact]#
type_map: List[str]#
pydantic model ai2_kit.domain.cp2k.CllCp2kInputConfig[source]#

Bases: BaseModel

Show JSON schema
{
   "title": "CllCp2kInputConfig",
   "type": "object",
   "properties": {
      "init_system_files": {
         "default": [],
         "items": {
            "type": "string"
         },
         "title": "Init System Files",
         "type": "array"
      },
      "wfn_warmup_template": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Wfn Warmup Template"
      },
      "input_template": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Input Template"
      },
      "template_vars": {
         "default": {},
         "title": "Template Vars",
         "type": "object"
      },
      "limit": {
         "default": 50,
         "title": "Limit",
         "type": "integer"
      },
      "limit_method": {
         "default": "even",
         "enum": [
            "even",
            "random",
            "truncate"
         ],
         "title": "Limit Method",
         "type": "string"
      },
      "ignore_error": {
         "default": false,
         "title": "Ignore Error",
         "type": "boolean"
      }
   },
   "additionalProperties": false
}

Config:
  • extra: str = forbid

Fields:
field ignore_error: bool = False#

Ignore error when running cp2k.

field init_system_files: List[str] = []#
field input_template: str | None = None#

Input template for cp2k. Could be a dict or content of a cp2k input file.

field limit: int = 50#

Limit of the number of systems to be labeled.

field limit_method: Literal['even', 'random', 'truncate'] = 'even'#
field template_vars: Mapping[str, Any] = {}#

Template variables for input_template and wfn_warmup_template.

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

field wfn_warmup_template: str | None = None#

Warmup template for cp2k. Could be a dict or content of a cp2k input file. This template will be used to generate input files for warmup runs. The warmup runs can be used to generate wave function files for the main runs.

class ai2_kit.domain.cp2k.Cp2kInputTemplate(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)#
class ai2_kit.domain.cp2k.GenericCp2kOutput(cp2k_outputs: List[ai2_kit.core.artifact.Artifact])[source]#

Bases: ICllLabelOutput

cp2k_outputs: List[Artifact]#
get_labeled_system_dataset()[source]#
async ai2_kit.domain.cp2k.cll_cp2k(input: CllCp2kInput, ctx: CllCp2kContext) GenericCp2kOutput[source]#
ai2_kit.domain.cp2k.dump_coord_n_cell(fp, atoms: Atoms)[source]#
ai2_kit.domain.cp2k.lammps_efield_to_cp2k(efield: Iterable[float])[source]#

IN CP2K, the efield is defined as INTENSITY and POLARIZATION (direction of the electric field)

Parameters:

efield – list of 3 floats, the electric field in lammps unit

Returns:

intensity, polarization

ai2_kit.domain.cp2k.make_cp2k_task_dirs(system_files: List[ArtifactDict], type_map: List[str], input_template: str | None, template_vars: Mapping[str, Any], base_dir: str, mode: Literal['default', 'dpff', 'fep-redox', 'fep-pka'], limit: int = 0, wfn_warmup_template: str | None = None, limit_method: Literal['even', 'random', 'truncate'] = 'even', input_file_name: str = 'input.inp', warmup_file_name: str = 'wfn_warmup.inp') List[ArtifactDict][source]#

Generate CP2K input files from LAMMPS dump files or XYZ files.