Skip to content

Commit cedd26b

Browse files
author
Han Wang
committed
Merge branch 'devel'
2 parents 93b833a + 00a74ed commit cedd26b

Some content is hidden

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

73 files changed

+8122
-143
lines changed

.github/workflows/release.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,7 @@ jobs:
3232
repository: ${{ env.GITHUB_REPOSITORY }}
3333
env:
3434
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
35+
release-to-pypi:
36+
uses: deepmodeling/workflows/.github/workflows/release-to-pypi.yml@main
37+
secrets:
38+
PYPI_PASSWORD: ${{ secrets.PYPI_PASSWORD }}

README.md

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,10 @@ If you want to specify a structure as starting point for `init_bulk`, you may se
189189
"from_poscar": true,
190190
"from_poscar_path": "....../C_mp-47_conventional.POSCAR",
191191
```
192+
`init_bulk` support both VASP and ABACUS for first-principle calculation. You can choose the software by specifying the key `init_fp_style`. If `init_fp_style` is not specified, the default software will be VASP.
193+
194+
When using ABACUS for `init_fp_style`, the keys of the paths of `INPUT` files for relaxation and MD simulations are the same as `INCAR` for VASP, which are `relax_incar` and `md_incar` respectively. You have to additionally specify `relax_kspacing` and `md_kspacing` for k points spacing, and dpgen will automatically generate `KPT` files according to them. You may also use `relax_kpt` and `md_kpt` instead of them for the relative path for `KPT` files of relaxation and MD simulations. However, either `relax_kspacing` and `md_kspacing`, or `relax_kpt` and `md_kpt` is needed. If `from_poscar` is set to `false`, you have to specify `atom_masses` in the same order as `elements`.
195+
192196
The following table gives explicit descriptions on keys in `PARAM`.
193197

194198
The bold notation of key (such as **Elements**) means that it's a necessary key.
@@ -200,9 +204,9 @@ The bold notation of key (such as **Elements**) means that it's a necessary key.
200204
| cell_type | String | "hcp" | Specifying which typical structure to be generated. **Options** include fcc, hcp, bcc, sc, diamond.
201205
| latt | Float | 4.479 | Lattice constant for single cell.
202206
| from_poscar | Boolean | True | Deciding whether to use a given poscar as the beginning of relaxation. If it's true, keys (`cell_type`, `latt`) will be aborted. Otherwise, these two keys are **necessary**.
203-
| from_poscar_path | String | "....../C_mp-47_conventional.POSCAR" | Path of POSCAR. **Necessary** if `from_poscar` is true.
204-
| relax_incar | String | "....../INCAR" | Path of INCAR for relaxation in VASP. **Necessary** if `stages` include 1.
205-
| md_incar | String | "....../INCAR" | Path of INCAR for MD in VASP. **Necessary** if `stages` include 3.|
207+
| from_poscar_path | String | "....../C_mp-47_conventional.POSCAR" | Path of POSCAR for VASP or STRU for ABACUS. **Necessary** if `from_poscar` is true.
208+
| relax_incar | String | "....../INCAR" | Path of INCAR for VASP or INPUT for ABACUS for relaxation in VASP. **Necessary** if `stages` include 1.
209+
| md_incar | String | "....../INCAR" | Path of INCAR for VASP or INPUT for ABACUS for MD in VASP. **Necessary** if `stages` include 3.|
206210
| **scale** | List of float | [0.980, 1.000, 1.020] | Scales for transforming cells.
207211
| **skip_relax** | Boolean | False | If it's true, you may directly run stage 2 (pertub and scale) using an unrelaxed POSCAR.
208212
| **pert_numb** | Integer | 30 | Number of pertubations for each POSCAR.
@@ -211,6 +215,12 @@ The bold notation of key (such as **Elements**) means that it's a necessary key.
211215
| **md_nstep** | Integer | 10 | Steps of AIMD in stage 3. If it's not equal to settings via `NSW` in `md_incar`, DP-GEN will follow `NSW`.
212216
| **coll_ndata** | Integer | 5000 | Maximal number of collected data.
213217
| type_map | List | [ "Mg", "Al"] | The indices of elements in deepmd formats will be set in this order.
218+
| init_fp_style | String | "ABACUS" or "VASP" | First-principle software. If this key is abscent, the default value will be "VASP".
219+
| relax_kpt | String | "....../KPT" | Path of `KPT` file for relaxation in stage 1. Only useful if `init_fp_style` is "ABACUS".
220+
| relax_kspacing | Integer or List of 3 integers | 10 | kspacing parameter for relaxation in stage 1. Only useful if `init_fp_style` is "ABACUS".
221+
| md_kpt | String | "....../KPT" | Path of `KPT` file for MD simulations in stage 3. Only useful if `init_fp_style` is "ABACUS".
222+
| md_kspacing | Integer or List of 3 integers | 10 | kspacing parameter for MD simulations in stage 3. Only useful if `init_fp_style` is "ABACUS".
223+
| atom_masses | List of float | [24] | List of atomic masses of elements. The order should be the same as `Elements`. Only useful if `init_fp_style` is "ABACUS".
214224

215225
### Init_surf
216226

doc/conf.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
# ]
3939

4040
extensions = [
41+
'deepmodeling_sphinx',
4142
"sphinx_rtd_theme",
4243
'myst_parser',
4344
'sphinx.ext.autosummary',

doc/requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ recommonmark==0.7.1
33
sphinx_rtd_theme==0.5.2
44
sphinx_markdown_tables==0.0.15
55
myst-parser==0.13.7
6+
deepmodeling_sphinx

dpgen/auto_test/EOS.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,8 @@ def _compute_lower(self,
169169
# vol = self.vol_start + ii * self.vol_step
170170
vol = loadfn(os.path.join(all_tasks[ii], 'eos.json'))['volume']
171171
task_result = loadfn(all_res[ii])
172-
res_data[vol] = task_result['energies'][-1] / task_result['atom_numbs'].sum()
173-
ptr_data += '%7.3f %8.4f \n' % (vol, task_result['energies'][-1] / task_result['atom_numbs'].sum())
172+
res_data[vol] = task_result['energies'][-1] / sum(task_result['atom_numbs'])
173+
ptr_data += '%7.3f %8.4f \n' % (vol, task_result['energies'][-1] / sum(task_result['atom_numbs']))
174174
# res_data[vol] = all_res[ii]['energy'] / len(all_res[ii]['force'])
175175
# ptr_data += '%7.3f %8.4f \n' % (vol, all_res[ii]['energy'] / len(all_res[ii]['force']))
176176

dpgen/auto_test/common_equi.py

Lines changed: 40 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -114,46 +114,6 @@ def make_equi(confs,
114114
inter.make_input_file(ii, 'relaxation', relax_param)
115115

116116

117-
def worker(work_path,
118-
run_task,
119-
forward_common_files,
120-
forward_files,
121-
backward_files,
122-
mdata,
123-
inter_type):
124-
machine, resources, command, group_size = util.get_machine_info(mdata, inter_type)
125-
disp = make_dispatcher(machine, resources, work_path, [run_task], group_size)
126-
print("%s --> Runing... " % (work_path))
127-
128-
api_version = mdata.get('api_version', '0.9')
129-
if LooseVersion(api_version) < LooseVersion('1.0'):
130-
warnings.warn(f"the dpdispatcher will be updated to new version."
131-
f"And the interface may be changed. Please check the documents for more details")
132-
disp.run_jobs(resources,
133-
command,
134-
work_path,
135-
[run_task],
136-
group_size,
137-
forward_common_files,
138-
forward_files,
139-
backward_files,
140-
outlog='outlog',
141-
errlog='errlog')
142-
elif LooseVersion(api_version) >= LooseVersion('1.0'):
143-
submission = make_submission(
144-
mdata_machine=machine,
145-
mdata_resources=resources,
146-
commands=[command],
147-
work_path=work_path,
148-
run_tasks=run_task,
149-
group_size=group_size,
150-
forward_common_files=forward_common_files,
151-
forward_files=forward_files,
152-
backward_files=backward_files,
153-
outlog='outlog',
154-
errlog='errlog'
155-
)
156-
submission.run_submission()
157117

158118
def run_equi(confs,
159119
inter_param,
@@ -166,18 +126,16 @@ def run_equi(confs,
166126
conf_dirs.sort()
167127

168128
processes = len(conf_dirs)
169-
pool = Pool(processes=processes)
170-
print("Submit job via %d processes" % processes)
171129

172130
# generate a list of task names like mp-xxx/relaxation/relax_task
173131
# ...
174132
work_path_list = []
175133
for ii in conf_dirs:
176-
work_path_list.append(os.path.abspath(os.path.join(ii, 'relaxation')))
134+
work_path_list.append(os.path.join(ii, 'relaxation'))
177135
all_task = []
178136
for ii in work_path_list:
179137
all_task.append(os.path.join(ii, 'relax_task'))
180-
138+
run_tasks = all_task
181139
inter_type = inter_param['type']
182140
# vasp
183141
if inter_type == "vasp":
@@ -186,41 +144,51 @@ def run_equi(confs,
186144
mdata = convert_mdata(mdata, ["model_devi"])
187145
else:
188146
raise RuntimeError("unknown task %s, something wrong" % inter_type)
189-
147+
190148
# dispatch the tasks
191149
# POSCAR here is useless
192150
virtual_calculator = make_calculator(inter_param, "POSCAR")
193151
forward_files = virtual_calculator.forward_files()
194152
forward_common_files = virtual_calculator.forward_common_files()
195153
backward_files = virtual_calculator.backward_files()
196154
# backward_files += logs
197-
# ...
198-
run_tasks = util.collect_task(all_task, inter_type)
199-
if len(run_tasks) == 0:
200-
return
201-
else:
202-
run_tasks = [os.path.basename(ii) for ii in all_task]
203-
machine, resources, command, group_size = util.get_machine_info(mdata, inter_type)
204-
print('%d tasks will be submited '%len(run_tasks))
205-
multiple_ret = []
206-
for ii in range(len(work_path_list)):
207-
work_path = work_path_list[ii]
208-
209-
ret = pool.apply_async(worker, (work_path,
210-
run_tasks[ii],
211-
forward_common_files,
212-
forward_files,
213-
backward_files,
214-
mdata,
215-
inter_type,
216-
))
217-
multiple_ret.append(ret)
218-
pool.close()
219-
pool.join()
220-
for ii in range(len(multiple_ret)):
221-
if not multiple_ret[ii].successful():
222-
raise RuntimeError("Task %d is not successful! work_path: %s " % (ii, work_path_list[ii]))
223-
print('finished')
155+
machine, resources, command, group_size = util.get_machine_info(mdata, inter_type)
156+
work_path = os.getcwd()
157+
print("%s --> Runing... " % (work_path))
158+
159+
api_version = mdata.get('api_version', '0.9')
160+
if LooseVersion(api_version) < LooseVersion('1.0'):
161+
warnings.warn(f"the dpdispatcher will be updated to new version."
162+
f"And the interface may be changed. Please check the documents for more details")
163+
disp = make_dispatcher(machine, resources, work_path, run_tasks, group_size)
164+
disp.run_jobs(resources,
165+
command,
166+
work_path,
167+
run_tasks,
168+
group_size,
169+
forward_common_files,
170+
forward_files,
171+
backward_files,
172+
outlog='outlog',
173+
errlog='errlog')
174+
elif LooseVersion(api_version) >= LooseVersion('1.0'):
175+
176+
submission = make_submission(
177+
mdata_machine=machine,
178+
mdata_resources=resources,
179+
commands=[command],
180+
work_path=work_path,
181+
run_tasks=run_tasks,
182+
group_size=group_size,
183+
forward_common_files=forward_common_files,
184+
forward_files=forward_files,
185+
backward_files=backward_files,
186+
outlog='outlog',
187+
errlog='errlog'
188+
)
189+
submission.run_submission()
190+
191+
224192

225193
def post_equi(confs, inter_param):
226194
# find all POSCARs and their name like mp-xxx

dpgen/auto_test/common_prop.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ def run_property(confs,
173173
pool.join()
174174
for ii in range(len(multiple_ret)):
175175
if not multiple_ret[ii].successful():
176+
print("ERROR:", multiple_ret[ii].get())
176177
raise RuntimeError("Job %d is not successful!" % ii)
177178
print('%d jobs are finished' % len(multiple_ret))
178179

@@ -186,11 +187,11 @@ def worker(work_path,
186187
inter_type):
187188
run_tasks = [os.path.basename(ii) for ii in all_task]
188189
machine, resources, command, group_size = util.get_machine_info(mdata, inter_type)
189-
disp = make_dispatcher(machine, resources, work_path, run_tasks, group_size)
190190
api_version = mdata.get('api_version', '0.9')
191191
if LooseVersion(api_version) < LooseVersion('1.0'):
192192
warnings.warn(f"the dpdispatcher will be updated to new version."
193193
f"And the interface may be changed. Please check the documents for more details")
194+
disp = make_dispatcher(machine, resources, work_path, run_tasks, group_size)
194195
disp.run_jobs(resources,
195196
command,
196197
work_path,

dpgen/auto_test/lib/lammps.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,8 @@ def make_lammps_equi(conf, type_map, interaction, param,
241241
ret += "fix 1 all box/relax iso 0.0 \n"
242242
ret += "minimize %e %e %d %d\n" % (etol, ftol, maxiter, maxeval)
243243
ret += "fix 1 all box/relax aniso 0.0 \n"
244+
ret += "minimize %e %e %d %d\n" % (etol, ftol, maxiter, maxeval)
245+
ret += "fix 1 all box/relax tri 0.0 \n"
244246
ret += "minimize %e %e %d %d\n" % (etol, ftol, maxiter, maxeval)
245247
ret += "variable N equal count(all)\n"
246248
ret += "variable V equal vol\n"

0 commit comments

Comments
 (0)