Skip to content

Commit 516c994

Browse files
committed
add the first commit
1 parent e807db7 commit 516c994

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+17386
-1
lines changed

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2023 Zhuoyuan Li
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

+35-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,35 @@
1-
APEX: Alloy Properties EXplorer using simulations
1+
# APEX
2+
## General alloy properties test with VASP, ABACUS, and LAMMPS.
3+
This workflow is a part of [AI Square](https://aissquare.com/). We want to refract the autotest code based on dflow.
4+
This is "general properties test" (elastic parameters, EOS, surface energy, interstitial energy, vacancy energy and stacking fault energy supported so far) using VASP, LAMMPS, or ABACUS.
5+
6+
## Easy Install:
7+
```
8+
pip install "git+https://github.com/deepmodeling/APEX.git"
9+
```
10+
11+
## Quick Start
12+
You can go to the `example` folder and there are some examples for reference. You can go to one of them and fill in the `global.json` file. Then you can submit the workflow.
13+
14+
If you want to use VASP code to do the DFT autotest, like the folder `vasp_demo`. You need to prepare `INCAR`, `POTCAR`, `POSCAR`, `global.json`(notice that json files for relaxation and properties task are needed as input arguments), then :
15+
```
16+
apex param_relax.json para_props.json --vasp
17+
```
18+
If you want to run only relaxation or only properties test (notice that properties test requires relaxation results under corresponding path in ./confs), for example for relaxation, just give one argument like:
19+
```
20+
apex param_relax.json --vasp
21+
```
22+
23+
If you want to use ABACUS code, like the folder `abacus_demo`. You need to prepare `INPUT`, `STRU`, `*.UPF`, `global.json`, `param_relax.json`, `param_props.json` (notice that `*.orb` and `KPT` are optional ), then:
24+
```
25+
apex param_relax.json param_props.json --abacus
26+
```
27+
28+
If you want to use LAMMPS to do MD calculation, like the folder `lammps_demo`. You need to prepare `POSCAR`, `frozen_model.pb`, `global.json`, `param_relax.json`, `param_props.json`, then:
29+
```
30+
apex param_relax.json param_props.json --lammps
31+
```
32+
33+
You can monitor the workflow process on the [website](https://workflows.deepmodeling.com).
34+
35+

apex/ABACUS_OPs.py

+283
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,283 @@
1+
from dflow.python import (
2+
PythonOPTemplate,
3+
OP,
4+
OPIO,
5+
OPIOSign,
6+
Artifact,
7+
Slices,
8+
upload_packages
9+
)
10+
11+
import subprocess, os, shutil, glob, dpdata, pathlib
12+
from pathlib import Path
13+
from typing import List
14+
from monty.serialization import loadfn
15+
16+
from dflow.python import upload_packages
17+
18+
upload_packages.append(__file__)
19+
20+
from apex.lib.utils import return_prop_list
21+
try:
22+
from apex.property.common_equi import (make_equi, post_equi)
23+
from apex.property.common_prop import (make_property, post_property)
24+
except:
25+
pass
26+
27+
28+
class RelaxMakeABACUS(OP):
29+
"""
30+
class for making calculation tasks
31+
"""
32+
33+
def __init__(self):
34+
pass
35+
36+
@classmethod
37+
def get_input_sign(cls):
38+
return OPIOSign({
39+
'input': Artifact(Path),
40+
'param': Artifact(Path)
41+
})
42+
43+
@classmethod
44+
def get_output_sign(cls):
45+
return OPIOSign({
46+
'output': Artifact(Path),
47+
'njobs': int,
48+
'task_paths': Artifact(List[Path])
49+
})
50+
51+
@OP.exec_sign_check
52+
def execute(
53+
self,
54+
op_in: OPIO,
55+
) -> OPIO:
56+
from apex.property.common_equi import make_equi
57+
58+
cwd = os.getcwd()
59+
os.chdir(op_in["input"])
60+
work_d = os.getcwd()
61+
param_argv = op_in["param"]
62+
structures = loadfn(param_argv)["structures"]
63+
inter_parameter = loadfn(param_argv)["interaction"]
64+
parameter = loadfn(param_argv)["relaxation"]
65+
66+
make_equi(structures, inter_parameter, parameter)
67+
68+
conf_dirs = []
69+
for conf in structures:
70+
conf_dirs.extend(glob.glob(conf))
71+
conf_dirs.sort()
72+
73+
task_list = []
74+
for ii in conf_dirs:
75+
conf_dir_global = os.path.join(work_d, ii)
76+
task_list.append(os.path.join(conf_dir_global, 'relaxation/relax_task'))
77+
78+
all_jobs = task_list
79+
njobs = len(all_jobs)
80+
jobs = []
81+
for job in all_jobs:
82+
jobs.append(pathlib.Path(job))
83+
84+
os.chdir(cwd)
85+
op_out = OPIO({
86+
"output": op_in["input"],
87+
"njobs": njobs,
88+
"task_paths": jobs
89+
})
90+
return op_out
91+
92+
93+
class RunABACUS(OP):
94+
"""
95+
class for ABACUS calculation
96+
"""
97+
98+
def __init__(self, infomode=1):
99+
self.infomode = infomode
100+
101+
@classmethod
102+
def get_input_sign(cls):
103+
return OPIOSign({
104+
'input_abacus': Artifact(Path),
105+
'run_command': str
106+
})
107+
108+
@classmethod
109+
def get_output_sign(cls):
110+
return OPIOSign({
111+
'output_abacus': Artifact(Path, sub_path=False)
112+
})
113+
114+
@OP.exec_sign_check
115+
def execute(self, op_in: OPIO) -> OPIO:
116+
cwd = os.getcwd()
117+
os.chdir(op_in["input_abacus"])
118+
cmd = op_in["run_command"]
119+
subprocess.call(cmd, shell=True)
120+
os.chdir(cwd)
121+
op_out = OPIO({
122+
"output_abacus": op_in["input_abacus"]
123+
})
124+
return op_out
125+
126+
127+
class RelaxPostABACUS(OP):
128+
"""
129+
class for analyzing calculation results
130+
"""
131+
132+
def __init__(self):
133+
pass
134+
135+
@classmethod
136+
def get_input_sign(cls):
137+
return OPIOSign({
138+
'input_post': Artifact(Path, sub_path=False),
139+
'input_all': Artifact(Path, sub_path=False),
140+
'param': Artifact(Path),
141+
'path': str
142+
})
143+
144+
@classmethod
145+
def get_output_sign(cls):
146+
return OPIOSign({
147+
'output_all': Artifact(Path, sub_path=False),
148+
'output_post': Artifact(Path, sub_path=False)
149+
})
150+
151+
@OP.exec_sign_check
152+
def execute(self, op_in: OPIO) -> OPIO:
153+
from apex.property.common_equi import post_equi
154+
155+
cwd = os.getcwd()
156+
os.chdir(str(op_in['input_all']) + op_in['path'])
157+
shutil.copytree(str(op_in['input_post']) + op_in['path'], './', dirs_exist_ok=True)
158+
159+
param_argv = op_in['param']
160+
post_equi(loadfn(param_argv)["structures"], loadfn(param_argv)["interaction"])
161+
162+
os.chdir(cwd)
163+
shutil.copytree(str(op_in['input_all']) + op_in['path'] + '/confs', './confs', dirs_exist_ok=True)
164+
165+
op_out = OPIO({
166+
'output_all': Path(str(op_in["input_all"]) + op_in['path']),
167+
'output_post': Path('./confs')
168+
})
169+
return op_out
170+
171+
172+
class PropsMakeABACUS(OP):
173+
"""
174+
class for making calculation tasks
175+
"""
176+
177+
def __init__(self):
178+
pass
179+
180+
@classmethod
181+
def get_input_sign(cls):
182+
return OPIOSign({
183+
'input': Artifact(Path),
184+
'param': Artifact(Path)
185+
})
186+
187+
@classmethod
188+
def get_output_sign(cls):
189+
return OPIOSign({
190+
'output': Artifact(Path),
191+
'njobs': int,
192+
'task_paths': Artifact(List[Path])
193+
})
194+
195+
@OP.exec_sign_check
196+
def execute(
197+
self,
198+
op_in: OPIO,
199+
) -> OPIO:
200+
from apex.property.common_prop import make_property
201+
202+
cwd = os.getcwd()
203+
os.chdir(op_in["input"])
204+
work_d = os.getcwd()
205+
param_argv = op_in["param"]
206+
structures = loadfn(param_argv)["structures"]
207+
inter_parameter = loadfn(param_argv)["interaction"]
208+
parameter = loadfn(param_argv)["properties"]
209+
make_property(structures, inter_parameter, parameter)
210+
211+
conf_dirs = []
212+
for conf in structures:
213+
conf_dirs.extend(glob.glob(conf))
214+
conf_dirs.sort()
215+
216+
prop_list = return_prop_list(parameter)
217+
task_list = []
218+
for ii in conf_dirs:
219+
conf_dir_global = os.path.join(work_d, ii)
220+
for jj in prop_list:
221+
prop = os.path.join(conf_dir_global, jj)
222+
os.chdir(prop)
223+
prop_tasks = glob.glob(os.path.join(prop, 'task.*'))
224+
prop_tasks.sort()
225+
for kk in prop_tasks:
226+
task_list.append(kk)
227+
228+
all_jobs = task_list
229+
njobs = len(all_jobs)
230+
jobs = []
231+
for job in all_jobs:
232+
jobs.append(pathlib.Path(job))
233+
234+
os.chdir(cwd)
235+
op_out = OPIO({
236+
"output": op_in["input"],
237+
"njobs": njobs,
238+
"task_paths": jobs
239+
})
240+
return op_out
241+
242+
243+
class PropsPostABACUS(OP):
244+
"""
245+
class for analyzing calculation results
246+
"""
247+
248+
def __init__(self):
249+
pass
250+
251+
@classmethod
252+
def get_input_sign(cls):
253+
return OPIOSign({
254+
'input_post': Artifact(Path, sub_path=False),
255+
'input_all': Artifact(Path, sub_path=False),
256+
'param': Artifact(Path),
257+
'path': str
258+
})
259+
260+
@classmethod
261+
def get_output_sign(cls):
262+
return OPIOSign({
263+
'output_post': Artifact(Path, sub_path=False)
264+
})
265+
266+
@OP.exec_sign_check
267+
def execute(self, op_in: OPIO) -> OPIO:
268+
from apex.property.common_prop import post_property
269+
270+
cwd = os.getcwd()
271+
os.chdir(str(op_in['input_all']) + op_in['path'])
272+
shutil.copytree(str(op_in['input_post']) + op_in['path'], './', dirs_exist_ok=True)
273+
274+
param_argv = op_in["param"]
275+
post_property(loadfn(param_argv)["structures"], loadfn(param_argv)["interaction"], loadfn(param_argv)["properties"])
276+
277+
os.chdir(cwd)
278+
shutil.copytree(str(op_in['input_all']) + op_in['path'] + '/confs', './confs', dirs_exist_ok=True)
279+
280+
op_out = OPIO({
281+
'output_post': Path('./confs')
282+
})
283+
return op_out

0 commit comments

Comments
 (0)