Skip to content

Commit 7582312

Browse files
committed
DRRG Σ[exp(atom)+2e-3*fitting]
Signed-off-by: zjgemi <zjgemi@gmail.com>
1 parent d37c9c8 commit 7582312

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

deepmd/pt/model/atomic_model/density_atomic_model.py

+13-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
)
2020
from deepmd.pt.model.network.mlp import (
2121
MLPLayer,
22+
FittingNet,
2223
)
2324
from deepmd.pt.model.task.density import (
2425
DensityFittingNet,
@@ -58,6 +59,15 @@ def __init__(self, descriptor, fitting, type_map, **kwargs):
5859
activation_function="tanh",
5960
) for i in range(len(neurons)+1)])
6061

62+
atomic_density_neurons = [240, 240, 240]
63+
self.atomic_density_network = FittingNet(
64+
1 + self.descriptor.repinit_args.tebd_dim,
65+
1,
66+
atomic_density_neurons,
67+
activation_function="tanh",
68+
resnet_dt=True,
69+
)
70+
6171
wanted_shape = (1, self.nnei, 4)
6272
mean = torch.zeros(
6373
wanted_shape, dtype=env.GLOBAL_PT_FLOAT_PRECISION, device=env.DEVICE
@@ -165,6 +175,8 @@ def forward_atomic(
165175
# electron-to-atom equivariant feature: nb x ngrid x nnei x 4 x ng1
166176
e2aef = h2.unsqueeze(-1) * gg.unsqueeze(-2)
167177

178+
atomic_density = self.atomic_density_network(h2_and_type)
179+
168180
dmatrix, diff, sw = prod_env_mat(
169181
extended_coord,
170182
nlist,
@@ -214,7 +226,7 @@ def forward_atomic(
214226
aparam=aparam,
215227
)
216228
# nb x ngrid x nnei x 1
217-
nei_density = torch.exp(fit_ret["density"].view(nframes, ngrid, nnei, 1))
229+
nei_density = torch.exp(atomic_density) + 2e-3*fit_ret["density"].view(nframes, ngrid, nnei, 1)
218230
nei_density = torch.where(grid_nlist_mask.unsqueeze(-1), nei_density, 0)
219231
# nb x ngrid x 1
220232
grid_density = torch.sum(nei_density, -2)

0 commit comments

Comments
 (0)