Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fpop support for CP2K #27

Merged
merged 14 commits into from
Jun 27, 2024
10 changes: 10 additions & 0 deletions examples/cp2k/POSCAR-1
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
generated by phonopy
1.0
2.7523087463752396 0.0000000000000000 0.0000000000000000
0.0000000000000000 2.7523087463752396 0.0000000000000000
0.0000000000000000 0.0000000000000000 2.7523087463752396
Na
2
Direct
0.0000000000000000 0.0000000000000000 0.0000000000000000
0.5000000000000000 0.5000000000000000 0.5000000000000000
10 changes: 10 additions & 0 deletions examples/cp2k/POSCAR-2
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
generated by phonopy
1.0
2.7236843018032482 0.0000000000000000 0.0000000000000000
0.0000000000000000 2.7236843018032482 0.0000000000000000
0.0000000000000000 0.0000000000000000 2.7236843018032482
Na
2
Direct
0.0000000000000000 0.0000000000000000 0.0000000000000000
0.5000000000000000 0.5000000000000000 0.5000000000000000
10 changes: 10 additions & 0 deletions examples/cp2k/POSCAR-3
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
generated by phonopy
1.0
2.6974919917106432 0.0000000000000000 0.0000000000000000
0.0000000000000000 2.6974919917106432 0.0000000000000000
0.0000000000000000 0.0000000000000000 2.6974919917106432
Na
2
Direct
0.5000000000000000 0.5000000000000000 0.5000000000000000
0.0000000000000000 0.0000000000000000 0.0000000000000000
71 changes: 71 additions & 0 deletions examples/cp2k/input.inp
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
#Generated by Multiwfn
&GLOBAL
PROJECT POSCAR-1
PRINT_LEVEL LOW
RUN_TYPE ENERGY_FORCE
&END GLOBAL

&FORCE_EVAL
METHOD Quickstep
&SUBSYS
&CELL
@INCLUDE CELL_PARAMETER
PERIODIC XYZ #Direction(s) of applied PBC (geometry aspect)
&END CELL
&COORD
@INCLUDE coord.xyz
&END COORD
&KIND Na
ELEMENT Na
BASIS_SET DZVP-MOLOPT-SR-GTH-q9
POTENTIAL GTH-PBE
&END KIND
&END SUBSYS

&DFT
BASIS_SET_FILE_NAME BASIS_MOLOPT
POTENTIAL_FILE_NAME POTENTIAL
# WFN_RESTART_FILE_NAME POSCAR-1-RESTART.wfn
CHARGE 0 #Net charge
MULTIPLICITY 1 #Spin multiplicity
&QS
EPS_DEFAULT 1.0E-12 #Set all EPS_xxx to values such that the energy will be correct up to this value
&END QS
&POISSON
PERIODIC XYZ #Direction(s) of PBC for calculating electrostatics
PSOLVER PERIODIC #The way to solve Poisson equation
&END POISSON
&XC
&XC_FUNCTIONAL PBE
&END XC_FUNCTIONAL
&END XC
&MGRID
CUTOFF 400
REL_CUTOFF 55
&END MGRID
&SCF
MAX_SCF 25 #Maximum number of steps of inner SCF
EPS_SCF 1.0E-06 #Convergence threshold of density matrix of inner SCF
# SCF_GUESS RESTART #Use wavefunction from WFN_RESTART_FILE_NAME file as initial guess
&OT
PRECONDITIONER FULL_ALL #Usually best but expensive for large system. Cheaper: FULL_SINGLE_INVERSE and FULL_KINETIC
MINIMIZER DIIS #CG is worth to consider in difficult cases
LINESEARCH 2PNT #1D line search algorithm for CG. 2PNT is default, 3PNT is better but more costly. GOLD is best but very expensive
ALGORITHM STRICT #Algorithm of OT. Can be STRICT (default) or IRAC
&END OT
&OUTER_SCF
MAX_SCF 20 #Maximum number of steps of outer SCF
EPS_SCF 1.0E-06 #Convergence threshold of outer SCF
&END OUTER_SCF
&PRINT
&RESTART #Note: Use "&RESTART OFF" can prevent generating .wfn file
BACKUP_COPIES 0 #Maximum number of backup copies of wfn file. 0 means never
&END RESTART
&END PRINT
&END SCF
&END DFT
&PRINT
&FORCES ON #Print atomic forces
&END FORCES
&END PRINT
&END FORCE_EVAL
97 changes: 97 additions & 0 deletions examples/cp2k/prepruncp2k.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
from dflow import (
Workflow,
Step,
upload_artifact,
download_artifact,
InputArtifact,
OutputArtifact,
ShellOPTemplate,
)
from dflow.python import (
PythonOPTemplate,
OP,
OPIO,
OPIOSign,
Artifact,
TransientError,
FatalError,
BigParameter,
upload_packages,
)
from pathlib import Path
import fpop
from fpop.cp2k import PrepCp2k,Cp2kInputs,RunCp2k
from fpop.preprun_fp import PrepRunFp
from dflow.plugins.dispatcher import DispatcherExecutor

prep_template_config={}
prep_step_config={}
run_template_config={}
run_slice_config={}
run_step_config={
"executor":{
"type": "dispatcher",
"machine_dict":{
"batch_type": "Bohrium",
"context_type": "Bohrium",
"remote_profile": {
"input_data": {
"job_type": "container",
"platform": "ali",
"scass_type": "c16_m32_cpu",
}
}
}
}
}
prep_image_config={}
run_image_config={
"command": "ulimit -s unlimited && ulimit -m unlimited && mpirun -n 16 --allow-run-as-root --oversubscribe cp2k.popt -i input.inp",
}
upload_python_packages=list(fpop.__path__)

steps = PrepRunFp(
"prep-run-cp2k",
PrepCp2k,
RunCp2k,
"registry.dp.tech/dptech/prod-15842/ubuntu:22.04-py3.10-ase",
"registry.dp.tech/dptech/prod-25571/initreaction:cp2k0410",
prep_template_config,
prep_step_config,
run_template_config,
run_slice_config,
run_step_config,
upload_python_packages,
)

confs = ["POSCAR-1","POSCAR-2","POSCAR-3"]


cp2k_inputs = Cp2kInputs('input.inp') # input files
prep_run_step = Step(
'prep-run-step',
template = steps,
parameters = {
'type_map' : ["Na"],
'prep_image_config' : prep_image_config,
'run_image_config' : run_image_config,
"log_name" : "output.log",
'inputs' : cp2k_inputs,
'optional_input' : {"conf_format":"vasp/poscar"},
'backward_list' : ["output.log"],
},
artifacts = {
"confs" : upload_artifact(confs),
},
)

wf = Workflow(name="prepruncp2k")
wf.add(prep_run_step)
wf.submit()

import time
while wf.query_status() in ["Pending", "Running"]:
time.sleep(4)
assert(wf.query_status() == 'Succeeded')
step = wf.query_step(name="prep-run-step")[0]
download_artifact(step.outputs.artifacts["backward_dirs"])
Loading
Loading