Skip to content

Commit 73c3c35

Browse files
authored
Merge pull request #161 from deepmodeling/devel
merge devel in to master
2 parents 1af5f40 + 5289b98 commit 73c3c35

File tree

172 files changed

+4531
-1930
lines changed

Some content is hidden

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

172 files changed

+4531
-1930
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,5 @@ dpgen.egg-info
3535
*/__pycache__
3636
*.swp
3737
.eggs
38+
.coverage
39+
dbconfig.json

README.md

Lines changed: 33 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -75,29 +75,42 @@ and if everything works, it gives
7575
```
7676
DeepModeling
7777
------------
78+
Version: 0.5.1.dev53+gddbeee7.d20191020
79+
Date: Oct-07-2019
80+
Path: /home/me/miniconda3/envs/py363/lib/python3.6/site-packages/dpgen-0.5.1.dev53+gddbeee7.d20191020-py3.6.egg/dpgen
7881
79-
Version: 0.2.0
80-
Path: /home/wanghan/.local/lib/python3.6/site-packages/dpgen-0.1.0-py3.6.egg/dpgen
81-
Date: Aug 13, 2019
82-
83-
usage: dpgen [-h] {init_surf,init_bulk,run,test,db} ...
82+
Dependency
83+
------------
84+
numpy 1.17.2 /home/me/miniconda3/envs/py363/lib/python3.6/site-packages/numpy
85+
dpdata 0.1.10 /home/me/miniconda3/envs/py363/lib/python3.6/site-packages/dpdata-0.1.10-py3.6.egg/dpdata
86+
pymatgen 2019.7.2 /home/me/miniconda3/envs/py363/lib/python3.6/site-packages/pymatgen
87+
monty 2.0.4 /home/me/miniconda3/envs/py363/lib/python3.6/site-packages/monty
88+
ase 3.17.0 /home/me/miniconda3/envs/py363/lib/python3.6/site-packages/ase-3.17.0-py3.6.egg/ase
89+
paramiko 2.6.0 /home/me/miniconda3/envs/py363/lib/python3.6/site-packages/paramiko
90+
custodian 2019.2.10 /home/me/miniconda3/envs/py363/lib/python3.6/site-packages/custodian
91+
92+
Description
93+
------------
94+
usage: dpgen [-h] {init_surf,init_bulk,run,run/report,test,db} ...
8495
8596
dpgen is a convenient script that uses DeepGenerator to prepare initial data,
8697
drive DeepMDkit and analyze results. This script works based on several sub-
8798
commands with their own options. To see the options for the sub-commands, type
8899
"dpgen sub-command -h".
89100
90101
positional arguments:
91-
{init_surf,init_bulk,run,test,db}
102+
{init_surf,init_bulk,run,run/report,test,db}
92103
init_surf Generating initial data for surface systems.
93104
init_bulk Generating initial data for bulk systems.
94-
run Main process of Deep Generator.
105+
run Main process of Deep Potential Generator.
106+
run/report Report the systems and the thermodynamic conditions of
107+
the labeled frames.
95108
test Auto-test for Deep Potential.
96-
db Collecting data from DP-GEN.
97-
109+
db Collecting data from Deep Generator.
98110
99111
optional arguments:
100112
-h, --help show this help message and exit
113+
101114
```
102115

103116

@@ -108,8 +121,10 @@ optional arguments:
108121
You may prepare initial data for bulk systems with VASP by:
109122

110123
```bash
111-
dpgen init_bulk PARAM MACHINE
124+
dpgen init_bulk PARAM [MACHINE]
112125
```
126+
The MACHINE configure file is optional. If this parameter exists, then the optimization
127+
tasks or MD tasks will be submitted automatically according to MACHINE.json.
113128

114129
Basically `init_bulk` can be devided into four parts , denoted as `stages` in `PARAM`:
115130
1. Relax in folder `00.place_ele`
@@ -119,6 +134,8 @@ Basically `init_bulk` can be devided into four parts , denoted as `stages` in `P
119134

120135
All stages must be **in order**. One doesn't need to run all stages. For example, you may run stage 1 and 2, generating supercells as starting point of exploration in `dpgen run`.
121136

137+
If MACHINE is None, there should be only one stage in stages. Corresponding tasks will be generated, but user's intervention should be involved in, to manunally run the scripts.
138+
122139
Following is an example for `PARAM`, which generates data from a typical structure hcp.
123140
```json
124141
{
@@ -176,8 +193,10 @@ The bold notation of key (such as **Elements**) means that it's a necessary key.
176193
You may prepare initial data for surface systems with VASP by:
177194

178195
```bash
179-
dpgen init_surf PARAM MACHINE
196+
dpgen init_surf PARAM [MACHINE]
180197
```
198+
The MACHINE configure file is optional. If this parameter exists, then the optimization
199+
tasks or MD tasks will be submitted automatically according to MACHINE.json.
181200

182201
Basically `init_surf` can be devided into two parts , denoted as `stages` in `PARAM`:
183202
1. Build specific surface in folder `00.place_ele`
@@ -199,7 +218,7 @@ Following is an example for `PARAM`, which generates data from a typical structu
199218
2,
200219
2
201220
],
202-
"z_min": 9,
221+
"layer_numb": 3,
203222
"vacuum_max": 9,
204223
"vacuum_resol": [
205224
0.5,
@@ -251,7 +270,7 @@ The bold notation of key (such as **Elements**) means that it's a necessary key.
251270
| **Elements** | List of String | ["Mg"] | Atom types
252271
| **cell_type** | String | "hcp" | Specifying which typical structure to be generated. **Options** include fcc, hcp, bcc, sc, diamond.
253272
| **latt** | Float | 4.479 | Lattice constant for single cell.
254-
| **z_min** | Float | 9 | Thickness of slab (Angstrom).
273+
| **layer_numb** | Integer | 3 | Number of equavilent layers of slab.
255274
| **vacuum_max** | Float | 9 | Maximal thickness of vacuum (Angstrom).
256275
| **vacuum_resol** | List of float | [0.5, 1 ] | Interval of thichness of vacuum. If size of `vacuum_resol` is 1, the interval is fixed to its value. If size of `vacuum_resol` is 2, the interval is `vacuum_resol[0]` before `mid_point`, otherwise `vacuum_resol[1]` after `mid_point`.
257276
| **millers** | List of list of Integer | [[1,0,0]] | Miller indices.
@@ -431,6 +450,7 @@ The bold notation of key (such aas **type_map**) means that it's a necessary key
431450
| *#Basics*
432451
| **type_map** | List of string | ["H", "C"] | Atom types
433452
| **mass_map** | List of float | [1, 12] | Standard atom weights.
453+
| **use_ele_temp** | int | 0 | Currently only support fp_style vasp. 0(default): no electron temperature. 1: eletron temperature as frame parameter. 2: electron temperature as atom parameter.
434454
| *#Data*
435455
| init_data_prefix | String | "/sharedext4/.../data/" | Prefix of initial data directories
436456
| ***init_data_sys*** | List of string|["CH4.POSCAR.01x01x01/.../deepmd"] |Directories of initial data. You may use either absolute or relative path here.

dpgen/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
_date.py
2+
_version.py
File renamed without changes.

dpgen/auto_test/cmpt_00_equi.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def comput_lmp_nev(conf_dir, task_name, write_stable = False) :
4747
return None, None, None
4848

4949
def comput_vasp_nev(jdata, conf_dir, write_stable = False) :
50-
kspacing = jdata['vasp_params']['kspacing']
50+
5151
conf_path = re.sub('confs', global_equi_name, conf_dir)
5252
conf_path = os.path.abspath(conf_path)
5353
poscar = os.path.join(conf_path, 'POSCAR')
@@ -59,6 +59,7 @@ def comput_vasp_nev(jdata, conf_dir, write_stable = False) :
5959
if 'relax_incar' in jdata.keys():
6060
vasp_str='vasp-relax_incar'
6161
else:
62+
kspacing = jdata['vasp_params']['kspacing']
6263
vasp_str='vasp-k%.2f' % kspacing
6364

6465
ener_shift = comput_e_shift(poscar, vasp_str)

dpgen/auto_test/cmpt_01_eos.py

Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,31 @@
11
#!/usr/bin/env python3
22

33
import os, glob, argparse, json, re
4+
import dpgen.auto_test.lib.util as util
45
import dpgen.auto_test.lib.lammps as lammps
56
import dpgen.auto_test.lib.vasp as vasp
67

78
global_task_name = '01.eos'
89

9-
def comput_lmp_eos(conf_dir, task_name) :
10+
def comput_lmp_eos(jdata,conf_dir, task_name) :
1011
conf_path = re.sub('confs', global_task_name, conf_dir)
1112
conf_path = os.path.abspath(conf_path)
1213
conf_path = os.path.join(conf_path, task_name)
1314
vol_paths = glob.glob(os.path.join(conf_path, 'vol-*'))
1415
vol_paths.sort()
16+
result = os.path.join(conf_path,'result')
1517
print('Vpa(A^3)\tEpA(eV)')
16-
for ii in vol_paths :
17-
log_lammps = os.path.join(ii, 'log.lammps')
18-
natoms, epa, vpa = lammps.get_nev(log_lammps)
19-
print(vpa, epa)
18+
with open(result,'w') as fp:
19+
fp.write('conf_dir:%s\n VpA(A^3) EpA(eV)\n'% (conf_dir))
20+
for ii in vol_paths :
21+
log_lammps = os.path.join(ii, 'log.lammps')
22+
natoms, epa, vpa = lammps.get_nev(log_lammps)
23+
print(vpa, epa)
24+
fp.write('%7.3f %8.4f \n' % (vpa,epa))
25+
fp.close()
26+
if 'upload_username' in jdata.keys() and task_name =='deepmd':
27+
upload_username=jdata['upload_username']
28+
util.insert_data('eos','deepmd',upload_username,result)
2029

2130
def comput_vasp_eos(jdata, conf_dir) :
2231
conf_path = re.sub('confs', global_task_name, conf_dir)
@@ -30,17 +39,25 @@ def comput_vasp_eos(jdata, conf_dir) :
3039
task_path = os.path.join(conf_path, vasp_str)
3140
vol_paths = glob.glob(os.path.join(task_path, 'vol-*'))
3241
vol_paths.sort()
42+
result = os.path.join(task_path,'result')
3343
print('Vpa(A^3)\tEpA(eV)')
34-
for ii in vol_paths :
35-
outcar = os.path.join(ii, 'OUTCAR')
36-
natoms, epa, vpa = vasp.get_nev(outcar)
37-
print(vpa, epa)
44+
with open(result,'w') as fp:
45+
fp.write('conf_dir:%s\n VpA(A^3) EpA(eV)\n'% (conf_dir))
46+
for ii in vol_paths :
47+
outcar = os.path.join(ii, 'OUTCAR')
48+
natoms, epa, vpa = vasp.get_nev(outcar)
49+
print(vpa, epa)
50+
fp.write('%7.3f %8.4f \n' % (vpa,epa))
51+
fp.close()
52+
if 'upload_username' in jdata.keys():
53+
upload_username=jdata['upload_username']
54+
util.insert_data('eos','vasp',upload_username,result)
3855

3956
def _main():
4057
parser = argparse.ArgumentParser(
4158
description="cmpt 01.eos")
4259
parser.add_argument('TASK', type=str,
43-
choices = ['vasp', 'deepmd', 'meam'],
60+
choices = ['vasp', 'deepmd', 'meam'],
4461
help='the task of generation, vasp or lammps')
4562
parser.add_argument('PARAM', type=str,
4663
help='json parameter file')
@@ -52,14 +69,13 @@ def _main():
5269
jdata = json.load (fp)
5370

5471
if args.TASK == 'vasp':
55-
comput_vasp_eos(jdata, args.CONF)
72+
comput_vasp_eos(jdata, args.CONF)
5673
elif args.TASK == 'deepmd' :
57-
comput_lmp_eos(args.CONF, args.TASK)
74+
comput_lmp_eos(jdata,args.CONF, args.TASK)
5875
elif args.TASK == 'meam' :
59-
comput_lmp_eos(args.CONF, args.TASK)
76+
comput_lmp_eos(jdata,args.CONF, args.TASK)
6077
else :
6178
raise RuntimeError("unknow task ", args.TASK)
6279

6380
if __name__ == '__main__' :
6481
_main()
65-

dpgen/auto_test/cmpt_02_elastic.py

Lines changed: 40 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,33 @@
55
import numpy as np
66
import dpgen.auto_test.lib.vasp as vasp
77
import dpgen.auto_test.lib.lammps as lammps
8+
import dpgen.auto_test.lib.util as util
89
from pymatgen.analysis.elasticity.elastic import ElasticTensor
910
from pymatgen.analysis.elasticity.strain import Strain
1011
from pymatgen.analysis.elasticity.stress import Stress
1112

1213
global_equi_name = '00.equi'
1314
global_task_name = '02.elastic'
1415

15-
def print_et (et):
16+
def result_et(et,conf_dir,result):
17+
with open(result,'w') as fp:
18+
fp.write('conf_dir:%s\n'% (conf_dir))
19+
for ii in range(6) :
20+
for jj in range(6) :
21+
fp.write ("%7.2f " % (et.voigt[ii][jj] / 1e4))
22+
fp.write('\n')
23+
BV = et.k_voigt / 1e4
24+
GV = et.g_voigt / 1e4
25+
EV = 9*BV*GV/(3*BV+GV)
26+
uV = 0.5*(3*BV-2*GV)/(3*BV+GV)
27+
fp.write("# Bulk Modulus BV = %.2f GPa\n" % (BV))
28+
fp.write("# Shear Modulus GV = %.2f GPa\n" % (GV))
29+
fp.write("# Youngs Modulus EV = %.2f GPa\n" % (EV))
30+
fp.write("# Poission Ratio uV = %.2f \n" % (uV))
31+
fp.close()
32+
33+
34+
def print_et (et):
1635
for ii in range(6) :
1736
for jj in range(6) :
1837
sys.stdout.write ("%7.2f " % (et.voigt[ii][jj] / 1e4))
@@ -27,17 +46,15 @@ def print_et (et):
2746
print("# Poission Ratio uV = %.2f " % (uV))
2847

2948
def cmpt_vasp(jdata, conf_dir) :
30-
fp_params = jdata['vasp_params']
31-
kspacing = fp_params['kspacing']
32-
kgamma = fp_params['kgamma']
33-
3449
conf_path = os.path.abspath(conf_dir)
3550
conf_poscar = os.path.join(conf_path, 'POSCAR')
3651
task_path = re.sub('confs', global_task_name, conf_path)
3752
if 'relax_incar' in jdata.keys():
3853
vasp_str='vasp-relax_incar'
3954
else:
40-
vasp_str='vasp-k%.2f' % kspacing
55+
fp_params = jdata['vasp_params']
56+
kspacing = fp_params['kspacing']
57+
vasp_str='vasp-k%.2f' % kspacing
4158
task_path = os.path.join(task_path, vasp_str)
4259

4360
equi_stress = Stress(np.loadtxt(os.path.join(task_path, 'equi.stress.out')))
@@ -55,14 +72,16 @@ def cmpt_vasp(jdata, conf_dir) :
5572
et = ElasticTensor.from_independent_strains(lst_strain, lst_stress, eq_stress = equi_stress, vasp = False)
5673
# et = ElasticTensor.from_independent_strains(lst_strain, lst_stress, eq_stress = None)
5774
# bar to GPa
58-
# et = -et / 1e4
75+
# et = -et / 1e4
5976
print_et(et)
77+
result = os.path.join(task_path,'result')
78+
result_et(et,conf_dir,result)
79+
if 'upload_username' in jdata.keys():
80+
upload_username=jdata['upload_username']
81+
util.insert_data('elastic','vasp',upload_username,result)
6082

61-
def cmpt_deepmd_lammps(jdata, conf_dir, task_name) :
62-
deepmd_model_dir = jdata['deepmd_model_dir']
63-
deepmd_type_map = jdata['deepmd_type_map']
64-
ntypes = len(deepmd_type_map)
6583

84+
def cmpt_deepmd_lammps(jdata, conf_dir, task_name) :
6685
conf_path = os.path.abspath(conf_dir)
6786
conf_poscar = os.path.join(conf_path, 'POSCAR')
6887
task_path = re.sub('confs', global_task_name, conf_path)
@@ -82,8 +101,15 @@ def cmpt_deepmd_lammps(jdata, conf_dir, task_name) :
82101
et = ElasticTensor.from_independent_strains(lst_strain, lst_stress, eq_stress = equi_stress, vasp = False)
83102
# et = ElasticTensor.from_independent_strains(lst_strain, lst_stress, eq_stress = None)
84103
# bar to GPa
85-
# et = -et / 1e4
104+
# et = -et / 1e4
86105
print_et(et)
106+
result = os.path.join(task_path,'result')
107+
result_et(et,conf_dir,task_path)
108+
if 'upload_username' in jdata.keys() and task_name=='deepmd':
109+
upload_username=jdata['upload_username']
110+
util.insert_data('elastic','deepmd',upload_username,result)
111+
112+
87113

88114
def _main() :
89115
parser = argparse.ArgumentParser(
@@ -101,15 +127,13 @@ def _main() :
101127

102128
print('# generate %s task with conf %s' % (args.TASK, args.CONF))
103129
if args.TASK == 'vasp':
104-
cmpt_vasp(jdata, args.CONF)
130+
cmpt_vasp(jdata, args.CONF)
105131
elif args.TASK == 'deepmd' :
106132
cmpt_deepmd_lammps(jdata, args.CONF, args.TASK)
107133
elif args.TASK == 'meam' :
108134
cmpt_deepmd_lammps(jdata, args.CONF, args.TASK)
109135
else :
110136
raise RuntimeError("unknow task ", args.TASK)
111-
137+
112138
if __name__ == '__main__' :
113139
_main()
114-
115-

dpgen/auto_test/cmpt_03_vacancy.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ def comput_e_shift(poscar, task_name) :
2626
return ener_shift
2727

2828
def cmpt_vasp(jdata, conf_dir, supercell) :
29-
fp_params = jdata['vasp_params']
30-
kspacing = fp_params['kspacing']
3129

3230
if 'relax_incar' in jdata.keys():
3331
vasp_str='vasp-relax_incar'

dpgen/auto_test/cmpt_04_interstitial.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ def cmpt_vasp(jdata, conf_dir, supercell, insert_ele) :
1717
_cmpt_vasp(jdata, conf_dir, supercell, ii)
1818

1919
def _cmpt_vasp(jdata, conf_dir, supercell, insert_ele) :
20-
fp_params = jdata['vasp_params']
21-
kspacing = fp_params['kspacing']
2220

2321
if 'relax_incar' in jdata.keys():
2422
vasp_str='vasp-relax_incar'
@@ -56,12 +54,10 @@ def cmpt_deepmd_reprod_traj(jdata, conf_dir, supercell, insert_ele, task_name) :
5654
_cmpt_deepmd_reprod_traj(jdata, conf_dir, supercell, ii, task_name)
5755

5856
def _cmpt_deepmd_reprod_traj(jdata, conf_dir, supercell, insert_ele, task_name) :
59-
fp_params = jdata['vasp_params']
60-
kspacing = fp_params['kspacing']
61-
6257
if 'relax_incar' in jdata.keys():
6358
vasp_str='vasp-relax_incar'
6459
else:
60+
kspacing = jdata['vasp_params']['kspacing']
6561
vasp_str='vasp-k%.2f' % kspacing
6662

6763
conf_path = os.path.abspath(conf_dir)

0 commit comments

Comments
 (0)