aesp.calculator package#
Submodules#
aesp.calculator.abacus module#
- class aesp.calculator.abacus.AbacusInputs(input_file: str | Path, pp_files: Dict[str, str | Path], element_mass: Dict[str, float] | None = None, kpt_file: str | Path | None = None, orb_files: Dict[str, str | Path] | None = None, deepks_descriptor: str | Path | None = None, deepks_model: str | Path | None = None)#
Bases:
object
- get_deepks_descriptor()#
- get_deepks_model()#
- get_input()#
- get_mass(element_list: List[str]) List[float] #
Get the mass of elements. If the element is not specified in self._mass, this funciton will firstly search it in a standard element-mass dictionary. And if the element is also not found in the dictionary, the mass will be set to 1.0.
Parameters#
- element_listList[str]
element name
Returns#
- List[float]
the mass of each element
- get_orb()#
- get_pp()#
- static read_inputf(inputf: str | Path) dict #
Read INPUT and transfer to a dict.
Parameters#
- inputfstr
INPUT file name
Returns#
- dict[str,str]
all input parameters
- set_deepks_descriptor(value: str)#
- set_deepks_model(value: str)#
- set_input(key: str, value: Any)#
- set_mass(key: str, value: float)#
- set_orb(key: str, value: str)#
- set_pp(key: str, value: str)#
- write_deepks()#
Check if INPUT is a deepks job, if yes, will return the deepks descriptor file name, else will return None.
Returns#
- str
deepks descriptor file name or None.
- write_input(inputf: str = 'INPUT')#
- write_kpt(kptf='KPT')#
- class aesp.calculator.abacus.FpOpAbacusInputs(input_file: str | Path, pp_files: Dict[str, str | Path], element_mass: Dict[str, float] | None = None, kpt_file: str | Path | None = None, orb_files: Dict[str, str | Path] | None = None, deepks_descriptor: str | Path | None = None, deepks_model: str | Path | None = None)#
Bases:
AbacusInputs
- static args()#
- class aesp.calculator.abacus.PrepAbacus(*args, **kwargs)#
Bases:
PrepFp
- prep_task(conf_frame, inputs: AbacusInputs, prepare_image_config: Dict | None = None, optional_input: Dict | None = None, optional_artifact: Dict | None = None)#
Define how one Abacus task is prepared.
Parameters#
- conf_framedpdata.System
One frame of configuration in the dpdata format.
- inputs: AbacusInputs
The AbacusInputs object handels all other input files of the task.
- prepare_image_config: Dict
Definition of runtime parameters in the process of preparing tasks.
- optional_input:
Other parameters the developers or users may need.
- optional_artifact
Other files that users or developers need.
- class aesp.calculator.abacus.PrepFpOpAbacus(*args, **kwargs)#
Bases:
OP
- execute(ip: OPIO) OPIO #
Run the OP
- classmethod get_input_sign()#
Get the signature of the inputs
- classmethod get_output_sign()#
Get the signature of the outputs
- class aesp.calculator.abacus.RunAbacus(*args, **kwargs)#
Bases:
RunFp
- check_run_success(log_name)#
- input_files(task_path) List[str] #
The mandatory input files to run an abacus task. Returns ——- files: List[str]
A list of madatory input files names.
- run_task(backward_dir_name, log_name, backward_list: List[str], run_image_config: Dict | None = None, optional_input: Dict | None = None) str #
Defines how one FP task runs Parameters ———- backward_dir_name:
The name of the directory which contains the backward files.
- log_name:
The name of log file.
- backward_list:
The output files the users need.
- run_image_config:
Keyword args defined by the developer.For example: {
“command”: “source /opt/intel/oneapi/setvars.sh && mpirun -n 16 abacus”
}
- optional_input:
The parameters developers need in runtime.
Returns#
- backward_dir_name: str
The directory name which containers the files users need.
- class aesp.calculator.abacus.RunFpOpAbacus(*args, **kwargs)#
Bases:
OP
- static args()#
- execute(ip: OPIO) OPIO #
Run the OP
- classmethod get_input_sign()#
Get the signature of the inputs
- classmethod get_output_sign()#
Get the signature of the outputs
- aesp.calculator.abacus.get_pporbdpks_from_stru(stru: str = 'STRU')#
read the label, pp, orb, cell, coord, deepks-descriptor
- aesp.calculator.abacus.get_suffix_calculation(INPUT: List[str]) Tuple[str, str] #
aesp.calculator.base module#
- class aesp.calculator.base.PrepFp(*args, **kwargs)#
Bases:
OP
,ABC
Prepares the working directories for first-principles (FP) tasks.
A list of (same length as ip[“confs”]) working directories containing all files needed to start FP tasks will be created. The paths of the directories will be returned as op[“task_paths”]. The identities of the tasks are returned as op[“task_names”].
- execute(ip: OPIO) OPIO #
Execute the OP.
Parameters#
- ipdict
Input dict with components:
config : (dict) Should have config[‘inputs’], which defines the input files of the FP task.
confs : (Artifact(List[Path])) Configurations for the FP tasks. Stored in folders as deepmd/npy format. Can be parsed as dpdata.MultiSystems.
Returns#
- opdict
Output dict with components:
task_names: (List[str]) The name of tasks. Will be used as the identities of the tasks. The names of different tasks are different.
task_paths: (Artifact(List[Path])) The parepared working paths of the tasks. Contains all input files needed to start the FP. The order fo the Paths should be consistent with op[“task_names”]
- classmethod get_input_sign()#
Get the signature of the inputs
- classmethod get_output_sign()#
Get the signature of the outputs
- abstractmethod prep_task(conf_frame: System, inputs: Any)#
Define how one FP task is prepared.
Parameters#
- conf_framedpdata.System
One frame of configuration in the dpdata format.
- inputsAny
The class object handels all other input files of the task. For example, pseudopotential file, k-point file and so on.
- class aesp.calculator.base.RunFp(*args, **kwargs)#
Bases:
OP
,ABC
Execute a first-principles (FP) task.
A working directory named task_name is created. All input files are copied or symbol linked to directory task_name. The FP command is exectuted from directory task_name. The op[“labeled_data”] in “deepmd/npy” format (HF5 in the future) provided by dpdata will be created.
- abstractmethod static args() List[Argument] #
The argument definition of the run_task method.
Returns#
- arguments: List[dargs.Argument]
List of dargs.Argument defines the arguments of run_task method.
- execute(ip: OPIO) OPIO #
Execute the OP.
Parameters#
- ipdict
Input dict with components:
config: (dict) The config of FP task. Should have config[‘run’], which defines the runtime configuration of the FP task.
task_name: (str) The name of task.
task_path: (Artifact(Path)) The path that contains all input files prepareed by PrepFp.
Returns#
Output dict with components: - log: (Artifact(Path)) The log file of FP. - labeled_data: (Artifact(Path)) The path to the labeled data in “deepmd/npy” format provided by dpdata.
Raises#
- TransientError
On the failure of FP execution.
- FatalError
When mandatory files are not found.
- classmethod get_input_sign()#
Get the signature of the inputs
- classmethod get_output_sign()#
Get the signature of the outputs
- abstractmethod input_files() List[str] #
The mandatory input files to run a FP task.
Returns#
- files: List[str]
A list of madatory input files names.
- classmethod normalize_config(data: Dict = {}, strict: bool = True) Dict #
Normalized the argument.
Parameters#
- dataDict
The input dict of arguments.
- strictbool
Strictly check the arguments.
Returns#
- data: Dict
The normalized arguments.
- abstractmethod optional_input_files() List[str] #
The optional input files to run a FP task.
Returns#
- files: List[str]
A list of optional input files names.
- abstractmethod run_task(**kwargs) Tuple[str, str] #
Defines how one FP task runs
Parameters#
- **kwargs
Keyword args defined by the developer. The fp/run_config session of the input file will be passed to this function.
Returns#
- out_name: str
The file name of the output data. Should be in dpdata.LabeledSystem format.
- log_name: str
The file name of the log.
- aesp.calculator.base.run_command(cmd: str | List[str], shell: bool = False) Tuple[int, str, str] #
aesp.calculator.cp2k module#
- class aesp.calculator.cp2k.Cp2kInputs(inp_file: str)#
Bases:
object
- static args()#
Define the arguments required by the Cp2kInputs class.
- inp_file_from_file(fname: str)#
Read the content of the input file and store it.
Parameters#
- fnamestr
The path to the input file.
- property inp_template#
Return the template content of the input file.
- class aesp.calculator.cp2k.FpOpCp2kInputs(inp_file: str)#
Bases:
Cp2kInputs
- static args()#
Define the arguments required by the Cp2kInputs class.
- class aesp.calculator.cp2k.PrepCp2k(*args, **kwargs)#
Bases:
PrepFp
- prep_task(conf_frame: System, inputs: Cp2kInputs, prepare_image_config: Dict | None = None, optional_input: Dict | None = None, optional_artifact: Dict | None = None)#
Define how one CP2K task is prepared.
Parameters#
- conf_framedpdata.System
One frame of configuration in the dpdata format.
- inputs: Cp2kInputs
The Cp2kInputs object handles the input file of the task.
- prepare_image_config: Dict, optional
Definition of runtime parameters in the process of preparing tasks.
- optional_input: Dict, optional
Other parameters the developers or users may need.
- optional_artifact: Dict[str, Path], optional
Other files that users or developers need.
- class aesp.calculator.cp2k.PrepFpOpCp2k(*args, **kwargs)#
Bases:
OP
- execute(ip: OPIO) OPIO #
Run the OP
- classmethod get_input_sign()#
Get the signature of the inputs
- classmethod get_output_sign()#
Get the signature of the outputs
- class aesp.calculator.cp2k.RunCp2k(*args, **kwargs)#
Bases:
RunFp
- check_run_success(log_name)#
Check if the CP2K task ran successfully by examining the output file.
Returns#
- successbool
True if the task ran successfully with warnings line, False otherwise.
- input_files(task_path) List[str] #
The mandatory input files to run a CP2K task.
Returns#
- files: List[str]
A list of mandatory input file names.
- run_task(backward_dir_name, log_name, backward_list: List[str], run_image_config: Dict | None = None, optional_input: Dict | None = None) str #
Defines how one FP task runs.
Parameters#
- backward_dir_namestr
The name of the directory which contains the backward files.
- log_namestr
The name of log file.
- backward_listList[str]
The output files the users need. For example: [“output.log”, “trajectory.xyz”]
- run_image_configDict, optional
Keyword args defined by the developer. For example: {
“command”: “source /opt/intel/oneapi/setvars.sh && mpirun -n 64 /opt/cp2k/bin/cp2k.popt”
}
- optional_inputDict, optional
The parameters developers need in runtime. For example: {
“conf_format”: “cp2k/input”
}
Returns#
- backward_dir_namestr
The directory name which contains the files users need.
- class aesp.calculator.cp2k.RunFpOpCp2k(*args, **kwargs)#
Bases:
OP
- static args()#
- execute(ip: OPIO) OPIO #
Run the OP
- classmethod get_input_sign()#
Get the signature of the inputs
- classmethod get_output_sign()#
Get the signature of the outputs
- aesp.calculator.cp2k.get_run_type(lines: List[str]) str | None #
aesp.calculator.dpmd module#
- class aesp.calculator.dpmd.DpmdInputs(pstress, relax_cell, step_max, f_max, model: str)#
Bases:
object
- static args()#
- incar_from_file(pstress, relax_cell, step_max, f_max, model: str)#
- property incar_template#
- static normalize_config(data={}, strict=True)#
- class aesp.calculator.dpmd.PrepDpmd(*args, **kwargs)#
Bases:
PrepFp
- prep_task(conf_frame: System, dpmd_inputs: DpmdInputs)#
Define how one Vasp task is prepared.
Parameters#
- conf_framedpdata.System
One frame of configuration in the dpdata format.
- vasp_inputsVaspInputs
The VaspInputs object handels all other input files of the task.
- class aesp.calculator.dpmd.RunDpmd(*args, **kwargs)#
Bases:
RunFp
- static args()#
The argument definition of the run_task method.
Returns#
- arguments: List[dargs.Argument]
List of dargs.Argument defines the arguments of run_task method.
- input_files() List[str] #
The mandatory input files to run a vasp task.
Returns#
- files: List[str]
A list of madatory input files names.
- optional_input_files() List[str] #
The optional input files to run a vasp task.
Returns#
- files: List[str]
A list of optional input files names.
- run_task(command: str, out: str, log: str) Tuple[str, str] #
Defines how one FP task runs
Parameters#
- commandstr
The command of running vasp task
- outstr
The name of the output data file.
- logstr
The name of the log file
Returns#
- out_name: str
The file name of the output data in the dpdata.LabeledSystem format.
- log_name: str
The file name of the log.
aesp.calculator.emt module#
- class aesp.calculator.emt.EmtInputs(pstress, relax_cell, step_max, f_max)#
Bases:
object
- static args()#
- incar_from_file(pstress, relax_cell, step_max, f_max)#
- property incar_template#
- static normalize_config(data={}, strict=True)#
- class aesp.calculator.emt.RunEmt(*args, **kwargs)#
Bases:
RunFp
- static args()#
The argument definition of the run_task method.
Returns#
- arguments: List[dargs.Argument]
List of dargs.Argument defines the arguments of run_task method.
- input_files() List[str] #
The mandatory input files to run a vasp task.
Returns#
- files: List[str]
A list of madatory input files names.
- optional_input_files() List[str] #
The optional input files to run a vasp task.
Returns#
- files: List[str]
A list of optional input files names.
- run_task(command: str, out: str, log: str) Tuple[str, str] #
Defines how one FP task runs
Parameters#
- commandstr
The command of running vasp task
- outstr
The name of the output data file.
- logstr
The name of the log file
Returns#
- out_name: str
The file name of the output data in the dpdata.LabeledSystem format.
- log_name: str
The file name of the log.
aesp.calculator.gaussian module#
Prep and Run Gaussian tasks.
- class aesp.calculator.gaussian.GaussianInputs(**kwargs: Any)#
Bases:
object
- static args() List[Argument] #
The arguments of the GaussianInputs class.
- class aesp.calculator.gaussian.PrepGaussian(*args, **kwargs)#
Bases:
PrepFp
- prep_task(conf_frame: System, inputs: GaussianInputs)#
Define how one Gaussian task is prepared.
Parameters#
- conf_framedpdata.System
One frame of configuration in the dpdata format.
- inputsGaussianInputs
The GaussianInputs object handels all other input files of the task.
- class aesp.calculator.gaussian.RunGaussian(*args, **kwargs)#
Bases:
RunFp
- static args() List[Argument] #
The argument definition of the run_task method.
Returns#
- arguments: List[dargs.Argument]
List of dargs.Argument defines the arguments of run_task method.
- input_files() List[str] #
The mandatory input files to run a Gaussian task.
Returns#
- files: List[str]
A list of madatory input files names.
- optional_input_files() List[str] #
The optional input files to run a Gaussian task.
Returns#
- files: List[str]
A list of optional input files names.
- run_task(command: str, out: str) Tuple[str, str] #
Defines how one FP task runs
Parameters#
- commandstr
The command of running gaussian task
- outstr
The name of the output data file.
Returns#
- out_name: str
The file name of the output data in the dpdata.LabeledSystem format.
- log_name: str
The file name of the log.
aesp.calculator.gulp module#
- class aesp.calculator.gulp.GulpInputs(kw_file: str, pp_file: str)#
Bases:
object
- static args()#
- from_file(fname: str)#
- static normalize_config(data={}, strict=True)#
- class aesp.calculator.gulp.PrepGulp(*args, **kwargs)#
Bases:
PrepFp
- prep_task(conf_frame: System, gulp_inputs: GulpInputs)#
Define how one Vasp task is prepared.
Parameters#
- conf_framedpdata.System
One frame of configuration in the dpdata format.
- vasp_inputsVaspInputs
The VaspInputs object handels all other input files of the task.
- class aesp.calculator.gulp.RunGulp(*args, **kwargs)#
Bases:
RunFp
- static args()#
The argument definition of the run_task method.
Returns#
- arguments: List[dargs.Argument]
List of dargs.Argument defines the arguments of run_task method.
- input_files() List[str] #
The mandatory input files to run a vasp task.
Returns#
- files: List[str]
A list of madatory input files names.
- optional_input_files() List[str] #
The optional input files to run a vasp task.
Returns#
- files: List[str]
A list of optional input files names.
- static process_data(out_name, log_name)#
- run_task(command: str, out: str, log: str) Tuple[str, str] #
Defines how one FP task runs
Parameters#
- commandstr
The command of running vasp task
- outstr
The name of the output data file.
- logstr
The name of the log file
Returns#
- out_name: str
The file name of the output data in the dpdata.LabeledSystem format.
- log_name: str
The file name of the log.
aesp.calculator.matgl module#
- class aesp.calculator.matgl.MatglInputs(pstress, relax_cell, step_max, f_max, model: str)#
Bases:
object
- static args()#
- incar_from_file(pstress, relax_cell, step_max, f_max, model: str)#
- property incar_template#
- static normalize_config(data={}, strict=True)#
- class aesp.calculator.matgl.PrepMatgl(*args, **kwargs)#
Bases:
PrepFp
- prep_task(conf_frame: System, matgl_inputs: MatglInputs)#
Define how one Vasp task is prepared.
Parameters#
- conf_framedpdata.System
One frame of configuration in the dpdata format.
- vasp_inputsVaspInputs
The VaspInputs object handels all other input files of the task.
- class aesp.calculator.matgl.RunMatgl(*args, **kwargs)#
Bases:
RunFp
- static args()#
The argument definition of the run_task method.
Returns#
- arguments: List[dargs.Argument]
List of dargs.Argument defines the arguments of run_task method.
- input_files() List[str] #
The mandatory input files to run a vasp task.
Returns#
- files: List[str]
A list of madatory input files names.
- optional_input_files() List[str] #
The optional input files to run a vasp task.
Returns#
- files: List[str]
A list of optional input files names.
- static process_data(out_name)#
- run_task(command: str, out: str, log: str) Tuple[str, str] #
Defines how one FP task runs
Parameters#
- commandstr
The command of running vasp task
- outstr
The name of the output data file.
- logstr
The name of the log file
Returns#
- out_name: str
The file name of the output data in the dpdata.LabeledSystem format.
- log_name: str
The file name of the log.
aesp.calculator.vasp module#
- class aesp.calculator.vasp.PrepVasp(*args, **kwargs)#
Bases:
PrepFp
- prep_task(conf_frame: System, vasp_inputs: VaspInputs)#
Define how one Vasp task is prepared.
Parameters#
- conf_framedpdata.System
One frame of configuration in the dpdata format.
- vasp_inputsVaspInputs
The VaspInputs object handels all other input files of the task.
- class aesp.calculator.vasp.RunVasp(*args, **kwargs)#
Bases:
RunFp
- static args()#
The argument definition of the run_task method.
Returns#
- arguments: List[dargs.Argument]
List of dargs.Argument defines the arguments of run_task method.
- input_files() List[str] #
The mandatory input files to run a vasp task.
Returns#
- files: List[str]
A list of madatory input files names.
- optional_input_files() List[str] #
The optional input files to run a vasp task.
Returns#
- files: List[str]
A list of optional input files names.
- run_task(command: str, out: str, log: str) Tuple[str, str] #
Defines how one FP task runs
Parameters#
- commandstr
The command of running vasp task
- outstr
The name of the output data file.
- logstr
The name of the log file
Returns#
- out_name: str
The file name of the output data in the dpdata.LabeledSystem format.
- log_name: str
The file name of the log.
- class aesp.calculator.vasp.VaspInputs(kspacing: float | List[float], incar: str, pp_files: Dict[str, str], kgamma: bool = True)#
Bases:
object
- static args()#
- incar_from_file(fname: str)#
- property incar_template#
- make_kpoints(box: ndarray) str #
- make_potcar(atom_names) str #
- static normalize_config(data={}, strict=True)#
- property potcars#
- potcars_from_file(dict_fnames: Dict[str, str])#
- aesp.calculator.vasp.make_kspacing_kpoints(box, kspacing, kgamma)#