Skip to content

Commit b50a012

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent a12ea0c commit b50a012

23 files changed

+385
-360
lines changed

doc/inference/cxx.md

Lines changed: 48 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,14 @@ The C++ interface of DeePMD-kit is also available for the model interface, which
1111
```cpp
1212
#include "deepmd/DeepPot.h"
1313

14-
int main()
15-
{
16-
deepmd::DeepPot dp("graph.pb");
17-
std::vector<double> coord = {1., 0., 0., 0., 0., 1.5, 1., 0., 3.};
18-
std::vector<double> cell = {10., 0., 0., 0., 10., 0., 0., 0., 10.};
19-
std::vector<int> atype = {1, 0, 1};
20-
double e;
21-
std::vector<double> f, v;
22-
dp.compute(e, f, v, coord, atype, cell);
14+
int main() {
15+
deepmd::DeepPot dp("graph.pb");
16+
std::vector<double> coord = {1., 0., 0., 0., 0., 1.5, 1., 0., 3.};
17+
std::vector<double> cell = {10., 0., 0., 0., 10., 0., 0., 0., 10.};
18+
std::vector<int> atype = {1, 0, 1};
19+
double e;
20+
std::vector<double> f, v;
21+
dp.compute(e, f, v, coord, atype, cell);
2322
}
2423
```
2524

@@ -45,38 +44,40 @@ Although C is harder to write, the C library will not be affected by different v
4544
An example `infer_water.c` is given below:
4645

4746
```cpp
48-
#include "deepmd/c_api.h"
4947
#include <stdio.h>
5048
#include <stdlib.h>
5149

52-
int main()
53-
{
54-
const char *model = "graph.pb";
55-
double coord[] = {1., 0., 0., 0., 0., 1.5, 1., 0., 3.};
56-
double cell[] = {10., 0., 0., 0., 10., 0., 0., 0., 10.};
57-
int atype[] = {1, 0, 1};
58-
// init C pointers with given memory
59-
double *e = malloc(sizeof(*e));
60-
double *f = malloc(sizeof(*f) * 9); // natoms * 3
61-
double *v = malloc(sizeof(*v) * 9);
62-
double *ae = malloc(sizeof(*ae) * 9); // natoms
63-
double *av = malloc(sizeof(*av) * 27); // natoms * 9
64-
// DP model
65-
DP_DeepPot *dp = DP_NewDeepPot(model);
66-
DP_DeepPotCompute(dp, 3, coord, atype, cell, e, f, v, ae, av);
67-
// print results
68-
printf("energy: %f\n", *e);
69-
for (int ii = 0; ii < 9; ++ii)
70-
printf("force[%d]: %f\n", ii, f[ii]);
71-
for (int ii = 0; ii < 9; ++ii)
72-
printf("force[%d]: %f\n", ii, v[ii]);
73-
// free memory
74-
free(e);
75-
free(f);
76-
free(v);
77-
free(ae);
78-
free(av);
79-
DP_DeleteDeepPot(dp);
50+
#include "deepmd/c_api.h"
51+
52+
int main() {
53+
const char* model = "graph.pb";
54+
double coord[] = {1., 0., 0., 0., 0., 1.5, 1., 0., 3.};
55+
double cell[] = {10., 0., 0., 0., 10., 0., 0., 0., 10.};
56+
int atype[] = {1, 0, 1};
57+
// init C pointers with given memory
58+
double* e = malloc(sizeof(*e));
59+
double* f = malloc(sizeof(*f) * 9); // natoms * 3
60+
double* v = malloc(sizeof(*v) * 9);
61+
double* ae = malloc(sizeof(*ae) * 9); // natoms
62+
double* av = malloc(sizeof(*av) * 27); // natoms * 9
63+
// DP model
64+
DP_DeepPot* dp = DP_NewDeepPot(model);
65+
DP_DeepPotCompute(dp, 3, coord, atype, cell, e, f, v, ae, av);
66+
// print results
67+
printf("energy: %f\n", *e);
68+
for (int ii = 0; ii < 9; ++ii) {
69+
printf("force[%d]: %f\n", ii, f[ii]);
70+
}
71+
for (int ii = 0; ii < 9; ++ii) {
72+
printf("force[%d]: %f\n", ii, v[ii]);
73+
}
74+
// free memory
75+
free(e);
76+
free(f);
77+
free(v);
78+
free(ae);
79+
free(av);
80+
DP_DeleteDeepPot(dp);
8081
}
8182
```
8283

@@ -105,15 +106,14 @@ To use it, include `deepmd/deepmd.hpp`.
105106
```cpp
106107
#include "deepmd/deepmd.hpp"
107108

108-
int main()
109-
{
110-
deepmd::hpp::DeepPot dp("graph.pb");
111-
std::vector<double> coord = {1., 0., 0., 0., 0., 1.5, 1., 0., 3.};
112-
std::vector<double> cell = {10., 0., 0., 0., 10., 0., 0., 0., 10.};
113-
std::vector<int> atype = {1, 0, 1};
114-
double e;
115-
std::vector<double> f, v;
116-
dp.compute(e, f, v, coord, atype, cell);
109+
int main() {
110+
deepmd::hpp::DeepPot dp("graph.pb");
111+
std::vector<double> coord = {1., 0., 0., 0., 0., 1.5, 1., 0., 3.};
112+
std::vector<double> cell = {10., 0., 0., 0., 10., 0., 0., 0., 10.};
113+
std::vector<int> atype = {1, 0, 1};
114+
double e;
115+
std::vector<double> f, v;
116+
dp.compute(e, f, v, coord, atype, cell);
117117
}
118118
```
119119

@@ -138,7 +138,7 @@ In some cases, one may want to pass the custom neighbor list instead of the nati
138138
// neighbor list
139139
std::vector<std::vector<int>> nlist_vec = {{1, 2}, {0, 2}, {0, 1}};
140140
std::vector<int> ilist(3), numneigh(3);
141-
std::vector<int *> firstneigh(3);
141+
std::vector<int*> firstneigh(3);
142142
InputNlist nlist(3, &ilist[0], &numneigh[0], &firstneigh[0]);
143143
convert_nlist(nlist, nlist_vec);
144144
dp.compute(e, f, v, coord, atype, cell, 0, nlist, 0);

doc/model/dplr.md

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,12 @@ It is noted that **the tutorial dataset is not enough for training a productive
5050
Two settings make the training input script different from an energy training input:
5151

5252
```json
53-
"fitting_net" : {"type" : "dipole", "dipole_type" : [0], "neuron" : [ 128, 128, 128 ], "seed" : 1},
53+
"fitting_net" : {
54+
"type" : "dipole",
55+
"dipole_type" : [0],
56+
"neuron" : [ 128, 128, 128 ],
57+
"seed" : 1
58+
},
5459
```
5560

5661
The type of fitting is set to {ref}`dipole <model[standard]/fitting_net[dipole]>`. The dipole is associated with type 0 atoms (oxygens), by the setting `"dipole_type": [0]`. What we trained is the displacement of the WC from the corresponding oxygen atom. It shares the same training input as the atomic dipole because both are 3-dimensional vectors defined on atoms.
@@ -74,12 +79,12 @@ The training of the DPLR model is very similar to the standard short-range DP mo
7479

7580
```json
7681
"modifier" : {
77-
"type" : "dipole_charge",
78-
"model_name" : "dw.pb",
79-
"model_charge_map" : [-8],
80-
"sys_charge_map" : [ 6, 1 ],
81-
"ewald_h" : 1.00,
82-
"ewald_beta" : 0.40
82+
"type" : "dipole_charge",
83+
"model_name" : "dw.pb",
84+
"model_charge_map" : [-8],
85+
"sys_charge_map" : [ 6, 1 ],
86+
"ewald_h" : 1.00,
87+
"ewald_beta" : 0.40
8388
},
8489
```
8590

doc/model/dprc.md

Lines changed: 66 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -73,37 +73,36 @@ As described in the paper, the DPRc model only corrects $E_\text{QM}$ and $E_\te
7373
:::{tab-item} TensorFlow {{ tensorflow_icon }}
7474

7575
```json
76-
"descriptor":
77-
{
78-
"type" : "hybrid", "list" : [
79-
{
80-
"type" : "se_a_ebd_v2",
81-
"sel" : [ 6, 11, 0, 6, 0, 1 ],
82-
"rcut_smth" : 1.00,
83-
"rcut" : 9.00,
84-
"neuron" : [ 12, 25, 50 ],
85-
"exclude_types" : [
86-
[ 2, 2 ], [ 2, 4 ], [ 4, 4 ], [ 0, 2 ], [ 0, 4 ], [ 1, 2 ], [ 1, 4 ], [ 3, 2 ], [ 3, 4 ], [ 5, 2 ],
87-
[ 5, 4 ]
88-
],
89-
"axis_neuron" : 12,
90-
"_comment" : " QM/QM interaction"
91-
},
92-
{
93-
"type" : "se_a_ebd_v2",
94-
"sel" : [ 6, 11, 100, 6, 50, 1 ],
95-
"rcut_smth" : 0.50,
96-
"rcut" : 6.00,
97-
"neuron" : [ 12, 25, 50 ],
98-
"exclude_types" : [
99-
[ 0, 0 ], [ 0, 1 ], [ 0, 3 ], [ 0, 5 ], [ 1, 1 ], [ 1, 3 ], [ 1, 5 ], [ 3, 3 ], [ 3, 5 ], [ 5, 5 ],
100-
[ 2, 2 ], [ 2, 4 ], [ 4, 4 ]
101-
],
102-
"axis_neuron" : 12,
103-
"set_davg_zero" : true,
104-
"_comment" : " QM/MM interaction"
105-
}
106-
]
76+
"descriptor" : {
77+
"type" : "hybrid", "list" : [
78+
{
79+
"type" : "se_a_ebd_v2",
80+
"sel" : [ 6, 11, 0, 6, 0, 1 ],
81+
"rcut_smth" : 1.00,
82+
"rcut" : 9.00,
83+
"neuron" : [ 12, 25, 50 ],
84+
"exclude_types" : [
85+
[ 2, 2 ], [ 2, 4 ], [ 4, 4 ], [ 0, 2 ], [ 0, 4 ], [ 1, 2 ], [ 1, 4 ],
86+
[ 3, 2 ], [ 3, 4 ], [ 5, 2 ], [ 5, 4 ]
87+
],
88+
"axis_neuron" : 12,
89+
"_comment" : " QM/QM interaction"
90+
},
91+
{
92+
"type" : "se_a_ebd_v2",
93+
"sel" : [ 6, 11, 100, 6, 50, 1 ],
94+
"rcut_smth" : 0.50,
95+
"rcut" : 6.00,
96+
"neuron" : [ 12, 25, 50 ],
97+
"exclude_types" : [
98+
[ 0, 0 ], [ 0, 1 ], [ 0, 3 ], [ 0, 5 ], [ 1, 1 ], [ 1, 3 ], [ 1, 5 ],
99+
[ 3, 3 ], [ 3, 5 ], [ 5, 5 ], [ 2, 2 ], [ 2, 4 ], [ 4, 4 ]
100+
],
101+
"axis_neuron" : 12,
102+
"set_davg_zero" : true,
103+
"_comment" : " QM/MM interaction"
104+
}
105+
]
107106
}
108107
```
109108

@@ -112,39 +111,38 @@ As described in the paper, the DPRc model only corrects $E_\text{QM}$ and $E_\te
112111
:::{tab-item} PyTorch {{ pytorch_icon }}
113112

114113
```json
115-
"descriptor":
116-
{
117-
"type" : "hybrid", "list" : [
118-
{
119-
"type" : "se_e2_a",
120-
"sel" : [ 6, 11, 0, 6, 0, 1 ],
121-
"rcut_smth" : 1.00,
122-
"rcut" : 9.00,
123-
"neuron" : [ 12, 25, 50 ],
124-
"exclude_types" : [
125-
[ 2, 2 ], [ 2, 4 ], [ 4, 4 ], [ 0, 2 ], [ 0, 4 ], [ 1, 2 ], [ 1, 4 ], [ 3, 2 ], [ 3, 4 ], [ 5, 2 ],
126-
[ 5, 4 ]
127-
],
128-
"axis_neuron" : 12,
129-
"type_one_side" : true,
130-
"_comment" : " QM/QM interaction"
131-
},
132-
{
133-
"type" : "se_e2_a",
134-
"sel" : [ 6, 11, 100, 6, 50, 1 ],
135-
"rcut_smth" : 0.50,
136-
"rcut" : 6.00,
137-
"neuron" : [ 12, 25, 50 ],
138-
"exclude_types" : [
139-
[ 0, 0 ], [ 0, 1 ], [ 0, 3 ], [ 0, 5 ], [ 1, 1 ], [ 1, 3 ], [ 1, 5 ], [ 3, 3 ], [ 3, 5 ], [ 5, 5 ],
140-
[ 2, 2 ], [ 2, 4 ], [ 4, 4 ]
141-
],
142-
"axis_neuron" : 12,
143-
"set_davg_zero" : true,
144-
"type_one_side" : true,
145-
"_comment" : " QM/MM interaction"
146-
}
147-
]
114+
"descriptor" : {
115+
"type" : "hybrid", "list" : [
116+
{
117+
"type" : "se_e2_a",
118+
"sel" : [ 6, 11, 0, 6, 0, 1 ],
119+
"rcut_smth" : 1.00,
120+
"rcut" : 9.00,
121+
"neuron" : [ 12, 25, 50 ],
122+
"exclude_types" : [
123+
[ 2, 2 ], [ 2, 4 ], [ 4, 4 ], [ 0, 2 ], [ 0, 4 ], [ 1, 2 ], [ 1, 4 ],
124+
[ 3, 2 ], [ 3, 4 ], [ 5, 2 ], [ 5, 4 ]
125+
],
126+
"axis_neuron" : 12,
127+
"type_one_side" : true,
128+
"_comment" : " QM/QM interaction"
129+
},
130+
{
131+
"type" : "se_e2_a",
132+
"sel" : [ 6, 11, 100, 6, 50, 1 ],
133+
"rcut_smth" : 0.50,
134+
"rcut" : 6.00,
135+
"neuron" : [ 12, 25, 50 ],
136+
"exclude_types" : [
137+
[ 0, 0 ], [ 0, 1 ], [ 0, 3 ], [ 0, 5 ], [ 1, 1 ], [ 1, 3 ], [ 1, 5 ],
138+
[ 3, 3 ], [ 3, 5 ], [ 5, 5 ], [ 2, 2 ], [ 2, 4 ], [ 4, 4 ]
139+
],
140+
"axis_neuron" : 12,
141+
"set_davg_zero" : true,
142+
"type_one_side" : true,
143+
"_comment" : " QM/MM interaction"
144+
}
145+
]
148146
}
149147
```
150148

@@ -178,9 +176,10 @@ print(
178176
Also, DPRc assumes MM atom energies ({ref}`atom_ener <model[standard]/fitting_net[ener]/atom_ener>`) are zero:
179177

180178
```json
181-
"fitting_net":
182-
{
183-
"neuron" : [ 240, 240, 240 ], "resnet_dt" : true, "atom_ener" : [ null, null, 0.0, null, 0.0, null ]
179+
"fitting_net" : {
180+
"neuron" : [ 240, 240, 240 ],
181+
"resnet_dt" : true,
182+
"atom_ener" : [ null, null, 0.0, null, 0.0, null ]
184183
}
185184
```
186185

doc/model/linear.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,12 @@ One can linearly combine existing models with arbitrary coefficients:
88

99
```json
1010
"model" : {
11-
"type" : "linear_ener",
12-
"models" : [ {"type" : "frozen", "model_file" : "model0.pb"}, {"type" : "frozen", "model_file" : "model1.pb"} ],
13-
"weights" : [ 0.5, 0.5 ]
11+
"type" : "linear_ener",
12+
"models" : [
13+
{"type" : "frozen", "model_file" : "model0.pb"},
14+
{"type" : "frozen", "model_file" : "model1.pb"}
15+
],
16+
"weights" : [ 0.5, 0.5 ]
1417
},
1518
```
1619

doc/model/overall.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,10 @@ For example, if $y_i$ represents the potential energy contribution of atom $i$,
3131
A model has two parts, a descriptor that maps atomic configuration to a set of symmetry invariant features, and a fitting net that takes descriptor as input and predicts the atomic contribution to the target physical property. It's defined in the {ref}`model <model>` section of the `input.json`, for example,
3232

3333
```json
34-
"model":
35-
{
36-
"type_map" : [ "O", "H" ], "descriptor" : {"..." : "..."}, "fitting_net" : {"..." : "..."}
34+
"model" : {
35+
"type_map" : [ "O", "H" ],
36+
"descriptor" : {"..." : "..."},
37+
"fitting_net" : {"..." : "..."}
3738
}
3839
```
3940

doc/model/pairtab.md

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,11 @@ In instances where the interaction at the cut-off distance is not delineated wit
7070

7171
```json
7272
"model" : {
73-
"use_srtab" : "H2O_tab_potential.txt",
74-
"smin_alpha" : 0.1,
75-
"sw_rmin" : 0.8,
76-
"sw_rmax" : 1.0,
77-
"_comment" : "Below uses a normal DP model"
73+
"use_srtab" : "H2O_tab_potential.txt",
74+
"smin_alpha" : 0.1,
75+
"sw_rmin" : 0.8,
76+
"sw_rmax" : 1.0,
77+
"_comment" : "Below uses a normal DP model"
7878
}
7979
```
8080

@@ -85,12 +85,11 @@ In instances where the interaction at the cut-off distance is not delineated wit
8585
To combine with a pairwise potential, use the [linear model](./linear.md):
8686

8787
```json
88-
"model":
89-
{
90-
"type" : "linear_ener", "weights" : "sum", "models" : [
91-
{"_comment" : "Here uses a normal DP model"},
92-
{"type" : "pairtab", "tab_file" : "dftd3.txt", "rcut" : 10.0, "sel" : 534}
93-
]
88+
"model" : {
89+
"type" : "linear_ener", "weights" : "sum", "models" : [
90+
{"_comment" : "Here uses a normal DP model"},
91+
{"type" : "pairtab", "tab_file" : "dftd3.txt", "rcut" : 10.0, "sel" : 534}
92+
]
9493
}
9594
```
9695

0 commit comments

Comments
 (0)