Skip to content

add DPRc implementation #729

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

Merged
merged 55 commits into from
May 31, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
e6680d4
add amber model_devi_engine and amber/corr fp_style
njzjz Jun 21, 2021
ba7fbc8
fix show error
felix5572 Jun 29, 2021
2e1ffae
use new dpdispatcher
felix5572 Jun 29, 2021
e096734
update new dpdispatcher
felix5572 Jun 29, 2021
d211bfc
update for new dpdispatcher
felix5572 Jun 29, 2021
62d0c91
support dpdispatcher
felix5572 Jun 29, 2021
5863de9
fix bug when using new dpdispatcher
felix5572 Jun 29, 2021
476d5dc
update for new dpdispatcher init_bulk
felix5572 Jun 29, 2021
077dcde
update examples for new dpdispatcher
felix5572 Jun 29, 2021
f083dcd
fix install
felix5572 Jun 29, 2021
fdaa155
fix typo use LooseVersion
felix5572 Jun 30, 2021
6abe6fd
update LooseVersion
felix5572 Jun 30, 2021
0950fe6
Merge remote-tracking branch 'origin/devel' into devel
felix5572 Jun 30, 2021
a30e4c2
update dependency dpdispatcher min version
felix5572 Jun 30, 2021
35cded2
Merge branch 'devel' into amber4
njzjz Jun 30, 2021
6e04b61
kk
njzjz Jul 29, 2021
956c651
support hybrid descriptor (fix #458) (#459)
njzjz Aug 11, 2021
a7f7605
support multiple param7 files
njzjz Nov 20, 2021
64917a9
hdf5 & other improvements
njzjz Jan 27, 2022
4d0144a
disable sort
njzjz Jan 31, 2022
18ca1a8
kk
njzjz Feb 7, 2022
9c5c43b
migrate parameters into parm file
njzjz Feb 16, 2022
cacb93c
fix the issue to detect the list in the yaml
njzjz Feb 16, 2022
4ea8fea
append ref to sander command
njzjz Feb 17, 2022
c77cc5f
bugfix
njzjz Feb 18, 2022
3ac4026
skip the first "active learning" line
njzjz Feb 18, 2022
329430a
bugfix
njzjz Feb 19, 2022
bd61a72
separate low level and high level mdin
njzjz Feb 19, 2022
ea4c387
add quote to dpamber command
njzjz Feb 19, 2022
87c7890
Revert "skip the first "active learning" line"
njzjz Feb 25, 2022
16d0f2c
only skip first active line if not restarting
njzjz Feb 25, 2022
d900e0e
generate sub models
njzjz Mar 17, 2022
60d8af7
fix the bug of sys_counter
njzjz Mar 29, 2022
1f1a39c
set the seed of type_embedding network
njzjz Mar 29, 2022
a8af407
merge from devel
njzjz Mar 30, 2022
c380291
sync with devel
njzjz Mar 30, 2022
31e04b0
sync with devel
njzjz Mar 30, 2022
f8a05ee
make symlink symlink
njzjz Mar 30, 2022
9787924
fix
njzjz Mar 30, 2022
05e3040
fix merge issue
njzjz Mar 30, 2022
663edab
rewrite simplify; support hdf5 as initial training data
njzjz Apr 4, 2022
c4a35ff
bugfix
njzjz Apr 13, 2022
44137fd
fix typo
njzjz Apr 17, 2022
fb97839
revert changes to simplify; going to submit in another PR
njzjz May 12, 2022
6f82a55
Merge branch 'devel' into amber-submit
njzjz May 12, 2022
53dd33a
revert training
njzjz May 12, 2022
7563c51
revert changes
njzjz May 12, 2022
e8e4ba0
fix bug
njzjz May 12, 2022
a58adbb
add comments
njzjz May 12, 2022
dd4b68c
add comments
njzjz May 12, 2022
3966d09
add tests
njzjz May 12, 2022
8837775
fix typo
njzjz May 12, 2022
62a8db7
add an example
njzjz May 12, 2022
faa9185
add netCDF4 to require
njzjz May 12, 2022
44b56c7
raise RuntimeError when model_devi_engine is unknown
njzjz May 13, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
479 changes: 439 additions & 40 deletions dpgen/generator/run.py

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions examples/run/dprc/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
## Deep Potential Range Correction (DPRc)

This example shows how to train a DPRc model.

For details, refer to [10.1021/acs.jctc.1c00201](https://doi.org/10.1021/acs.jctc.1c00201).
215 changes: 215 additions & 0 deletions examples/run/dprc/generator.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,215 @@
type_map:
- C
- H
- O
- "N"
- P
- HW
- OW
init_data_sys:
- /path/to/initial_data
# qm_region: the Amber mask of the QM region in the parm file
qm_region:
- ":1"
# qm_charge: the charge of the QM region
qm_charge:
- 0
# parm7: absolute path to parm7 file
parm7:
- /path/to/MON.parm7
# mdin: absolute path to mdin file
mdin:
- /path/to/ml.mdin
# disang: absolute path to disang template file
disang:
- /path/to/mon.disang
# sys_configs: abosulute path to initial configurations
sys_configs:
- - /path/to/init_-1.20.rst7
- /path/to/init_-0.80.rst7
- /path/to/init_-0.40.rst7
- /path/to/init_0.00.rst7
# r: reaction coordinates to replace RVAL in the template; can be a list for 2D
r:
- - -1.20
- -0.80
- -0.40
- 0.00
numb_models: 4
# same as the simplify
default_training_param:
model:
# type_map: same as above
type_map:
- C
- H
- O
- "N"
- P
- HW
- OW
descriptor:
type: hybrid
list:
# QM-QM descriptor
- type: se_a
# sel: refer https://docs.deepmodeling.org/projects/deepmd/en/latest/model/sel.html to obatin the proper sel
# In a DPRc model, sel of MM atoms for the QM-QM descriptor should be set to zero.
sel:
- 6
- 7
- 6
- 1
- 1
- 0
- 0
rcut_smth: 1.0
rcut: 9.0
neuron:
- 25
- 50
- 100
resnet_dt: false
axis_neuron: 12
# exclude_types: In the QM-QM descriptor, MM-MM and QM-MM descriptor should be disabled.
# >>> from itertools import combinations_with_replacement, product
# >>> qm = range(5)
# >>> mm = range(5,7)
# >>> list(map(list,list(combinations_with_replacement(mm,2))+list(product(qm,mm))))
exclude_types: [[5, 5], [5, 6], [6, 6], [0, 5], [0, 6], [1, 5], [1, 6], [2, 5], [2, 6], [3, 5], [3, 6], [4, 5], [4, 6]]
# set_davg_zero: In a DPRc model, it must be set to true.
set_davg_zero: true
type_one_side: true
precision: "float32"
# QM-MM descriptor
- type: se_a
# *1.2 for MM atoms
sel:
- 6
- 7
- 6
- 1
- 1
- 88
- 44
rcut_smth: 1.0
rcut: 6.0
neuron:
- 25
- 50
- 100
resnet_dt: false
axis_neuron: 12
# exclude_types: In the QM-MM descriptor, QM-QM and MM-MM descriptor should be disabled.
# >>> from itertools import combinations_with_replacement, product
# >>> qm = range(5)
# >>> mm = range(5,7)
# >>> list(map(list,list(combinations_with_replacement(qm,2))+list(combinations_with_replacement(mm,2))))
exclude_types: [[0, 0], [0, 1], [0, 2], [0, 3], [0, 4], [1, 1], [1, 2], [1, 3], [1, 4], [2, 2], [2, 3], [2, 4], [3, 3], [3, 4], [4, 4], [5, 5], [5, 6], [6, 6]]
set_davg_zero: true
type_one_side: true
precision: "float32"
fitting_net:
neuron:
- 240
- 240
- 240
resnet_dt: true
# atom_ener: In a DPRc model, the atom_ener of MM atoms should be set to 0
atom_ener:
- null
- null
- null
- null
- null
- 0.0
- 0.0
precision: "float32"
# learning_rate: from 1.e-3 to 5.e-8
learning_rate:
type: exp
start_lr: 1.e-3
decay_steps: 400
stop_lr: 5.e-8
loss:
start_pref_e: 0.02
limit_pref_e: 1
start_pref_f: 1000
limit_pref_f: 1
start_pref_v: 0
limit_pref_v: 0
training:
numb_steps: 400000
disp_file: lcurve.out
disp_freq: 100
save_freq: 1000
disp_training: true
time_training: true
profiling: false
profiling_file: timeline.json
dp_compress: true

model_devi_f_trust_lo: 0.08
model_devi_f_trust_hi: 0.25
training_reuse_iter: 2


# nsteps: the number of steps to run
nsteps:
- 10000
model_devi_jobs:
- sys_idx: [0]
trj_freq: 40
#1
- sys_idx: [0]
trj_freq: 40
#2
- sys_idx: [0]
trj_freq: 40
#3
- sys_idx: [0]
trj_freq: 40
#4
- sys_idx: [0]
trj_freq: 40
#5
- sys_idx: [0]
trj_freq: 40
#6
- sys_idx: [0]
trj_freq: 40
#7
- sys_idx: [0]
trj_freq: 40
#8
- sys_idx: [0]
trj_freq: 40
#9
- sys_idx: [0]
trj_freq: 40
#10
- sys_idx: [0]
trj_freq: 40

# fp_task_max: the maximum fp tasks to calculate
fp_task_max: 1000
fp_task_min: 10
fp_params:
low_level_mdin: /path/to/low_level.mdin
high_level_mdin: /path/to/high_level.mdin

low_level: MNDOD
high_level: PBE0
# cutoff: QM-MM cutoff radius
cutoff: 6.

# do not change the value below
sys_format: amber/rst7
init_multi_systems: true
model_devi_clean_traj: false
model_devi_engine: amber
model_devi_skip: 0
shuffle_poscar: false
fp_style: amber/diff
detailed_report_make_fp: true
use_clusters: true
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
with open(path.join('dpgen', '_date.py'), 'w') as fp :
fp.write('date = \'%s\'' % today)

install_requires=['numpy>=1.14.3', 'dpdata>=0.2.6', 'pymatgen>=2019.1.13', 'ase', 'monty>2.0.0', 'paramiko', 'custodian','GromacsWrapper>=0.8.0', 'dpdispatcher>=0.3.11']
install_requires=['numpy>=1.14.3', 'dpdata>=0.2.6', 'pymatgen>=2019.1.13', 'ase', 'monty>2.0.0', 'paramiko', 'custodian','GromacsWrapper>=0.8.0', 'dpdispatcher>=0.3.11', 'netCDF4']

setuptools.setup(
name=NAME,
Expand Down
Empty file.
77 changes: 77 additions & 0 deletions tests/generator/amber/ml.mdin
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
title
&cntrl
! IO =======================================
irest = 1 ! 0 = start, 1 = restart
ntx = 5 ! 1 = start, 5 = restart
ntxo = 1 ! read/write rst as formatted file
iwrap = 1 ! wrap crds to unit cell
ioutfm = 1 ! write mdcrd as netcdf
imin = 0
ntmin = 1
ntpr = @freq@
ntwr = @freq@
ntwx = @freq@
ntwf = 0
! DYNAMICS =================================
nstlim = @nstlim@ ! number of time steps
dt = 0.001 ! ps/step
ntb = 1 ! 1=NVT periodic, 2=NPT periodic, 0=no box
! TEMPERATURE ==============================
temp0 = 298 ! target temp
gamma_ln = 5.0 ! Langevin collision freq
ntt = 3 ! thermostat (3=Langevin)
! PRESSURE ================================
ntp = 0 ! 0=no scaling, 1=isotropic, 2=anisotropic
! SHAKE ====================================
ntc = 2 ! 1=no shake, 2=HX constrained, 3=all constrained
noshakemask = "@qm_region@" ! do not shake these
ntf = 1 ! 1=cpt all bond E, 2=ignore HX bond E, 3=ignore all bond E
! MISC =====================================
cut = 9.0
ifqnt = 1
ig = -1
nmropt = 1
/

&wt
type='DUMPFREQ', istep1=25
&end
&wt
type='END',
&end
DISANG=TEMPLATE.disang
DUMPAVE=TEMPLATE.dumpave

&ewald
dsum_tol = 1.e-6
/

&qmmm
qm_theory = '@qm_theory@'
qmmask = '@qm_region@'
qmcharge = @qm_charge@
spin = 1
qmshake = 0
qm_ewald = 1
qmmm_switch = 1
scfconv = 1.e-10
verbosity = 0
tight_p_conv = 1
diag_routine = 0
pseudo_diag = 1
dftb_maxiter = 100
/

&ml
iml=1
mlmask="@qm_region@"
rcut = @rcut@
intrafile=""
alskip = @freq@
althresh = 1.e-6
interfile(1)="@GRAPH_FILE0@"
interfile(2)="@GRAPH_FILE1@"
interfile(3)="@GRAPH_FILE2@"
interfile(4)="@GRAPH_FILE3@"
/

1 change: 1 addition & 0 deletions tests/generator/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
param_pwmat_file = 'param-pyridine-pwmat.json'
param_abacus_file = 'param-pyridine-abacus.json'
param_abacus_post_file = 'param-methane-abacus.json'
param_amber_file = "param-amber.json"

def my_file_cmp(test, f0, f1):
with open(f0) as fp0 :
Expand Down
54 changes: 54 additions & 0 deletions tests/generator/param-amber.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{
"model_devi_jobs": [
{
"sys_idx": [0]
}
],
"use_multi_systems": true,
"model_devi_engine": "amber",
"fp_style": "amber/diff",
"numb_models": 4,
"mdin_prefix": "amber",
"parm7_prefix": "amber",
"sys_prefix": "amber",
"disang_prefix": "amber",
"sys_configs": [
[
"init_-1.20.rst7"
]
],
"disang": [
"init_-1.20.disang"
],
"parm7": [
"MON.parm7"
],
"mdin": [
"ml.mdin"
],
"qm_region": [
":1"
],
"qm_charge": [
0
],
"r": [
[-1.20]
],
"nsteps": [
1000
],
"type_map": ["C", "H", "O", "N", "P", "HW", "OW"],
"shuffle_poscar": false,
"low_level": "DFTB2",
"high_level": "PBE0",
"cutoff": 6.0,
"fp_task_max": 1000,
"model_devi_skip": 0,
"model_devi_f_trust_lo": 0.10,
"model_devi_f_trust_hi": 0.25,
"fp_params": {
"low_level_mdin": "ml.mdin",
"high_level_mdin": "ml.mdin"
}
}
Loading