Skip to content

Commit 0767dce

Browse files
authored
Merge pull request #720 from amcadmus/master
Merge devel into master
2 parents dc57c9a + f454b5d commit 0767dce

File tree

95 files changed

+3378
-3023
lines changed

Some content is hidden

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

95 files changed

+3378
-3023
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,4 @@ dbconfig.json
4040
.vscode/*
4141
.idea/*
4242
_build
43+
tests/generator/calypso_test_path

README.md

+35-46
Original file line numberDiff line numberDiff line change
@@ -92,50 +92,6 @@ To test if the installation is successful, you may execute
9292
```bash
9393
dpgen -h
9494
```
95-
and if everything works, it gives
96-
```
97-
DeepModeling
98-
------------
99-
Version: 0.9.2
100-
Date: Mar-25-2021
101-
Path: /root/yuzhi/dpgen-test/lib/python3.6/site-packages/dpgen
102-
103-
Reference
104-
------------
105-
Please cite:
106-
Yuzhi Zhang, Haidi Wang, Weijie Chen, Jinzhe Zeng, Linfeng Zhang, Han Wang, and Weinan E,
107-
DP-GEN: A concurrent learning platform for the generation of reliable deep learning
108-
based potential energy models, Computer Physics Communications, 2020, 107206.
109-
------------
110-
111-
Description
112-
------------
113-
usage: dpgen [-h]
114-
{init_surf,init_bulk,auto_gen_param,init_reaction,run,run/report,collect,simplify,autotest,db}
115-
...
116-
117-
dpgen is a convenient script that uses DeepGenerator to prepare initial data,
118-
drive DeepMDkit and analyze results. This script works based on several sub-
119-
commands with their own options. To see the options for the sub-commands, type
120-
"dpgen sub-command -h".
121-
122-
positional arguments:
123-
{init_surf,init_bulk,auto_gen_param,init_reaction,run,run/report,collect,simplify,autotest,db}
124-
init_surf Generating initial data for surface systems.
125-
init_bulk Generating initial data for bulk systems.
126-
auto_gen_param auto gen param.json
127-
init_reaction Generating initial data for reactive systems.
128-
run Main process of Deep Potential Generator.
129-
run/report Report the systems and the thermodynamic conditions of
130-
the labeled frames.
131-
collect Collect data.
132-
simplify Simplify data.
133-
autotest Auto-test for Deep Potential.
134-
db Collecting data from DP-GEN.
135-
136-
optional arguments:
137-
-h, --help show this help message and exit
138-
```
13995

14096

14197
## Init: Preparing Initial Data
@@ -378,7 +334,7 @@ In each iteration, there are three stages of work, namely, `00.train 01.model_d
378334

379335
+ 00.train: DP-GEN will train several (default 4) models based on initial and generated data. The only difference between these models is the random seed for neural network initialization.
380336

381-
+ 01.model_devi : represent for model-deviation. DP-GEN will use models obtained from 00.train to run Molecular Dynamics(default LAMMPS). Larger deviation for structure properties (default is force of atoms) means less accuracy of the models. Using this criterion, a few fructures will be selected and put into next stage `02.fp` for more accurate calculation based on First Principles.
337+
+ 01.model_devi : represent for model-deviation. Model-deviation engine in `01.model_devi` can be chosen between Molecular Dynamics(LAMMPS and GROMACS) or Structures Prediction(CALYPSO). DP-GEN will use models obtained from 00.train to run Molecular Dynamics or to run structure optimization with ASE in CALYPSO. Larger deviation for structure properties (default is force of atoms) means less accuracy of the models. Using this criterion, a few structures will be selected and put into next stage `02.fp` for more accurate calculation based on First Principles.
382338

383339
+ 02.fp : Selected structures will be calculated by first principles methods(default VASP). DP-GEN will obtain some new data and put them together with initial data and data generated in previous iterations. After that a new training will be set up and DP-GEN will enter next iteration!
384340

@@ -614,7 +570,40 @@ The bold notation of key (such aas **type_map**) means that it's a necessary key
614570
| *fp_style == cp2k*
615571
| **user_fp_params** | Dict | |Parameters for cp2k calculation. find detail in manual.cp2k.org. only the kind section must be set before use. we assume that you have basic knowledge for cp2k input.
616572
| **external_input_path** | String | | Conflict with key:user_fp_params, use the template input provided by user, some rules should be followed, read the following text in detail.
573+
| *fp_style == ABACUS*
574+
| **user_fp_params** | Dict | |Parameters for ABACUS INPUT. find detail [Here](https://github.com/deepmodeling/abacus-develop/blob/develop/docs/input-main.md#out-descriptor). If `deepks_model` is set, the model file should be in the pseudopotential directory.
575+
| **fp_orb_files** | List | |List of atomic orbital files. The files should be in pseudopotential directory.
576+
| **fp_dpks_descriptor** | String | |DeePKS descriptor file name. The file should be in pseudopotential directory.
577+
578+
One can choose the model-deviation engine by specifying the key `model_devi_engine`. If `model_devi_engine` is not specified, the default model-deviation engine will be LAMMPS.
579+
580+
There are some new keys needed to be added into `param` and `machine` if CALYPSO as model-deviation engine.
617581

582+
The bold notation of key (such as **calypso_path**) means that it's a necessary key.
583+
584+
Key | Type | Example | Discription |
585+
| :---------------- | :--------------------- | :-------------------------------------- | :-------------------------------------------------------------|
586+
| *in param file*
587+
| **model_devi_engine** | string | "calypso" | CALYPSO as model-deviation engine.|
588+
| **calypso_input_path** | string | "/home/zhenyu/workplace/debug" | The absolute path of CALYPSO input file named input.dat(PSTRESS and fmax should be included), when this keys exists, all the iters will use the same CALYPSO input file until reach the number of max iter specified by **model_devi_max_iter** and **model_devi_jobs** key will not work.|
589+
| **model_devi_max_iter** | int | 10 | The max iter number code can run, it works when **calypso_input_path** exists.|
590+
| **model_devi_jobs** | List of Dict | [{ "times":[3],"NameOfAtoms":["Al","Cu"],"NumberOfAtoms":[1,10],"NumberOfFormula":[1,2],"Volume":[300],"DistanceOfIon":[[ 1.48,1.44],[ 1.44,1.41]],"PsoRatio":[0.6],"PopSize":[5],"MaxStep":[3],"ICode":[1],"Split":"T"},...] | Settings for exploration in `01.model_devi`. Different number in `times` List means different iteration index and iterations mentioned in List wil use same CALYPSO parameters.|
591+
| **model_devi_jobs["times"]** | List of int | [0,1,2] | Different number in `times` List means different iteration index and iterations mentioned in List wil use same CALYPSO parameters.|
592+
| **model_devi_jobs["NameOfAtoms"]** | List of string |["Al","Cu"] | Parameter of CALYPSO input file, means the element species of structures to be generated. |
593+
| **model_devi_jobs["NumberOfAtoms"]** | List of int |[1,10] | Parameter of CALYPSO input file, means the number of atoms for each chemical species in one formula unit. |
594+
| **model_devi_jobs["NumberOfFormula"]** | List of int |[1,2] | Parameter of CALYPSO input file, means the range of formula unit per cell. |
595+
| **model_devi_jobs["Volume"]** | List of int |[300] | Parameter of CALYPSO input file, means the colume per formula unit(angstrom^3). |
596+
| **model_devi_jobs["DistanceOfIon"]** | List of float |[[ 1.48,1.44],[ 1.44,1.41]] | Parameter of CALYPSO input file, means minimal distance between atoms of each chemical species. Unit is in angstrom. |
597+
| **model_devi_jobs["PsoRatio"]** | List of float |[0.6] | Parameter of CALYPSO input file, means the proportion of the structures generated by PSO. |
598+
| **model_devi_jobs["PopSize"]** | List of int |[5] | Parameter of CALYPSO input file, means the number of structures to be generated in one step in CALYPSO. |
599+
| **model_devi_jobs["MaxStep"]** | List of int |[3] | Parameter of CALYPSO input file, means the number of max step in CALYPSO.|
600+
| **model_devi_jobs["ICode"]** | List of int |[13] | Parameter of CALYPSO input file, means the chosen of local optimization, 1 is vasp and 13 is ASE with dp. |
601+
| **model_devi_jobs["Split"]** | String |"T" | Parameter of CALYPSO input file, means that generating structures and optimizing structures are split into two parts, in dpgen workflow, Split must be T. |
602+
| **model_devi_jobs["PSTRESS"]** | List of float |[0.001] | Same as PSTRESS in INCAR. |
603+
| **model_devi_jobs["fmax"]** | List of float |[0.01] | The convergence criterion is that the force on all individual atoms should be less than *fmax*. |
604+
| *in machine file*
605+
| **model_devi["deepmdkit_python"]** | String | "/home/zhenyu/soft/deepmd-kit/bin/python" | A python path with deepmd package. |
606+
| **model_devi["calypso_path"]** | string | "/home/zhenyu/workplace/debug" | The absolute path of calypso.x.|
618607

619608
#### Rules for cp2k input at dictionary form
620609
Converting cp2k input is very simple as dictionary used to dpgen input. You just need follow some simple rule:
@@ -1352,7 +1341,7 @@ mem_limit | Interger | 16 | Maximal memory permitted to apply for the job.
13521341
| group_size | Integer | 5 | DP-GEN will put these jobs together in one submitting script.
13531342
| user_forward_files | List of str | ["/path_to/vdw_kernel.bindat"] | These files will be uploaded in each calculation task. You should make sure provide the path exists.
13541343
| user_backward_files | List of str | ["HILLS"] | Besides DP-GEN's normal output, these files will be downloaded after each calculation. You should make sure these files can be generated.
1355-
1344+
13561345
## Troubleshooting
13571346
1. The most common problem is whether two settings correspond with each other, including:
13581347
- The order of elements in `type_map` and `mass_map` and **`fp_pp_files`**.

doc/conf.py

+8
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
# documentation root, use os.path.abspath to make it absolute, like shown here.
1212
#
1313
import os
14+
import sys
1415
import subprocess
1516
# import sys
1617
import recommonmark
@@ -79,3 +80,10 @@
7980
autodoc_default_flags = ['members']
8081
autosummary_generate = True
8182
master_doc = 'index'
83+
84+
85+
def generate_arginfo(app):
86+
subprocess.check_output((sys.executable, "gen_arginfo.py"), universal_newlines=True)
87+
88+
def setup(app):
89+
app.connect('builder-inited', generate_arginfo)

doc/gen_arginfo.py

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from dpgen.generator.arginfo import run_mdata_arginfo
2+
3+
run_mdata_doc = run_mdata_arginfo().gen_doc()
4+
with open('run-mdata-auto.rst', 'w') as f:
5+
f.write(run_mdata_doc)

doc/index.rst

+8
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@
22
DPGEN's documentation
33
==========================
44

5+
.. _parameters::
6+
7+
.. toctree::
8+
:maxdepth: 2
9+
:caption: Parameters
10+
11+
run-mdata.rst
12+
513
.. _tutorial:
614

715
.. toctree::

doc/requirements.txt

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
sphinx==3.2.1
2-
recommonmark==0.7.1
3-
sphinx_rtd_theme==0.5.2
4-
sphinx_markdown_tables==0.0.15
5-
myst-parser==0.13.7
1+
sphinx>=4.0.2
2+
recommonmark
3+
sphinx_rtd_theme
4+
sphinx_markdown_tables
5+
myst-parser
66
deepmodeling_sphinx
7+
.

doc/run-mdata.rst

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
dpgen run machine parameters
2+
============================
3+
4+
.. include:: run-mdata-auto.rst

dpgen/auto_test/Interstitial.py

+114
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,120 @@ def make_confs(self,
172172
dumpfn(self.supercell, 'supercell.json')
173173
os.chdir(cwd)
174174

175+
176+
if 'bcc_self' in self.parameter and self.parameter['bcc_self']:
177+
os.chdir(path_to_work)
178+
with open('POSCAR', 'r') as fin:
179+
fin.readline()
180+
scale = float(fin.readline().split()[0])
181+
latt_param = float(fin.readline().split()[0])
182+
latt_param *= scale
183+
184+
if not os.path.isfile('task.000000/POSCAR'):
185+
raise RuntimeError("need task.000000 structure as reference")
186+
187+
with open('task.000000/POSCAR', 'r') as fin:
188+
pos_line = fin.read().split('\n')
189+
190+
super_latt_param = float(pos_line[2].split()[0])
191+
192+
output_task1 = os.path.join(path_to_work, 'task.%06d' % (len(dss)))
193+
os.makedirs(output_task1, exist_ok=True)
194+
os.chdir(output_task1)
195+
task_list.append(output_task1)
196+
with open(insert_element_task, 'a+') as fout:
197+
print(self.insert_ele[0], file=fout)
198+
dumpfn(self.supercell, 'supercell.json')
199+
pos_line[-2] = '%.6f' % float(latt_param/4/super_latt_param) + ' ' + '%.6f' % float(latt_param/2/super_latt_param) + ' 0.000000 ' + self.insert_ele[0]
200+
with open('POSCAR', 'w+') as fout:
201+
for ii in pos_line:
202+
print(ii, file=fout)
203+
print('gen bcc tetrahedral')
204+
os.chdir(cwd)
205+
206+
output_task2 = os.path.join(path_to_work, 'task.%06d' % (len(dss)+1))
207+
os.makedirs(output_task2, exist_ok=True)
208+
os.chdir(output_task2)
209+
task_list.append(output_task2)
210+
with open(insert_element_task, 'a+') as fout:
211+
print(self.insert_ele[0], file=fout)
212+
dumpfn(self.supercell, 'supercell.json')
213+
pos_line[-2] = '%.6f' % float(latt_param/2/super_latt_param) + ' ' + '%.6f' % float(latt_param/2/super_latt_param) + ' 0.000000 ' + self.insert_ele[0]
214+
with open('POSCAR', 'w+') as fout:
215+
for ii in pos_line:
216+
print(ii, file=fout)
217+
print('gen bcc octahedral')
218+
os.chdir(cwd)
219+
220+
output_task3 = os.path.join(path_to_work, 'task.%06d' % (len(dss)+2))
221+
os.makedirs(output_task3, exist_ok=True)
222+
os.chdir(output_task3)
223+
task_list.append(output_task3)
224+
with open(insert_element_task, 'a+') as fout:
225+
print(self.insert_ele[0], file=fout)
226+
dumpfn(self.supercell, 'supercell.json')
227+
pos_line[-2] = '%.6f' % float(latt_param/4/super_latt_param) + ' ' + '%.6f' % float(latt_param/4/super_latt_param) + ' ' + '%.6f' % float(latt_param/4/super_latt_param) + ' ' + self.insert_ele[0]
228+
with open('POSCAR', 'w+') as fout:
229+
for ii in pos_line:
230+
print(ii, file=fout)
231+
print('gen bcc crowdion')
232+
os.chdir(cwd)
233+
234+
for idx, ii in enumerate(pos_line):
235+
ss = ii.split()
236+
if len(ss) > 3:
237+
if abs(latt_param/2/super_latt_param - float(ss[0])) < 1e-5 and abs(latt_param/2/super_latt_param - float(ss[1])) < 1e-5 and abs(latt_param/2/super_latt_param - float(ss[2])) < 1e-5:
238+
replace_label = idx
239+
240+
output_task4 = os.path.join(path_to_work, 'task.%06d' % (len(dss)+3))
241+
os.makedirs(output_task4, exist_ok=True)
242+
os.chdir(output_task4)
243+
task_list.append(output_task4)
244+
with open(insert_element_task, 'a+') as fout:
245+
print(self.insert_ele[0], file=fout)
246+
dumpfn(self.supercell, 'supercell.json')
247+
pos_line[-2] = '%.6f' % float(latt_param/3/super_latt_param) + ' ' + '%.6f' % float(latt_param/3/super_latt_param) + ' ' + '%.6f' % float(latt_param/3/super_latt_param) + ' ' + self.insert_ele[0]
248+
pos_line[replace_label] = '%.6f' % float(latt_param/3*2/super_latt_param) + ' ' + '%.6f' % float(latt_param/3*2/super_latt_param) + ' ' + '%.6f' % float(latt_param/3*2/super_latt_param) + ' ' + self.insert_ele[0]
249+
250+
with open('POSCAR', 'w+') as fout:
251+
for ii in pos_line:
252+
print(ii, file=fout)
253+
print('gen bcc <111> dumbbell')
254+
os.chdir(cwd)
255+
256+
output_task5 = os.path.join(path_to_work, 'task.%06d' % (len(dss)+4))
257+
os.makedirs(output_task5, exist_ok=True)
258+
os.chdir(output_task5)
259+
task_list.append(output_task5)
260+
with open(insert_element_task, 'a+') as fout:
261+
print(self.insert_ele[0], file=fout)
262+
dumpfn(self.supercell, 'supercell.json')
263+
pos_line[-2] = '%.6f' % float((latt_param+2.1/2**0.5)/2/super_latt_param) + ' ' + '%.6f' % float((latt_param-2.1/2**0.5)/2/super_latt_param) + ' ' + '%.6f' % float(latt_param/2/super_latt_param) + ' ' + self.insert_ele[0]
264+
pos_line[replace_label] = '%.6f' % float((latt_param-2.1/2**0.5)/2/super_latt_param) + ' ' + '%.6f' % float((latt_param+2.1/2**0.5)/2/super_latt_param) + ' ' + '%.6f' % float(latt_param/2/super_latt_param) + ' ' + self.insert_ele[0]
265+
266+
with open('POSCAR', 'w+') as fout:
267+
for ii in pos_line:
268+
print(ii, file=fout)
269+
print('gen bcc <110> dumbbell')
270+
os.chdir(cwd)
271+
272+
output_task6 = os.path.join(path_to_work, 'task.%06d' % (len(dss)+5))
273+
os.makedirs(output_task6, exist_ok=True)
274+
os.chdir(output_task6)
275+
task_list.append(output_task6)
276+
with open(insert_element_task, 'a+') as fout:
277+
print(self.insert_ele[0], file=fout)
278+
dumpfn(self.supercell, 'supercell.json')
279+
pos_line[-2] = '%.6f' % float(latt_param/2/super_latt_param) + ' ' + '%.6f' % float(latt_param/2/super_latt_param) + ' ' + '%.6f' % float((latt_param-2.1)/2/super_latt_param) + ' ' + self.insert_ele[0]
280+
pos_line[replace_label] = '%.6f' % float(latt_param/2/super_latt_param) + ' ' + '%.6f' % float(latt_param/2/super_latt_param) + ' ' + '%.6f' % float((latt_param+2.1)/2/super_latt_param) + ' ' + self.insert_ele[0]
281+
282+
with open('POSCAR', 'w+') as fout:
283+
for ii in pos_line:
284+
print(ii, file=fout)
285+
print('gen bcc <100> dumbbell')
286+
os.chdir(cwd)
287+
288+
175289
return task_list
176290

177291
def post_process(self, task_list):

dpgen/auto_test/Lammps.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ def compute(self,
289289
if len(line) and str(ii) == line[0]:
290290
try:
291291
[float(kk) for kk in line]
292-
except:
292+
except Exception:
293293
continue
294294
stress.append([])
295295
virial.append([])

0 commit comments

Comments
 (0)