|
19 | 19 | )
|
20 | 20 | from deepmd.pt.model.network.mlp import (
|
21 | 21 | MLPLayer,
|
| 22 | + FittingNet, |
22 | 23 | )
|
23 | 24 | from deepmd.pt.model.task.density import (
|
24 | 25 | DensityFittingNet,
|
@@ -58,6 +59,15 @@ def __init__(self, descriptor, fitting, type_map, **kwargs):
|
58 | 59 | activation_function="tanh",
|
59 | 60 | ) for i in range(len(neurons)+1)])
|
60 | 61 |
|
| 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 | + |
61 | 71 | wanted_shape = (1, self.nnei, 4)
|
62 | 72 | mean = torch.zeros(
|
63 | 73 | wanted_shape, dtype=env.GLOBAL_PT_FLOAT_PRECISION, device=env.DEVICE
|
@@ -165,6 +175,8 @@ def forward_atomic(
|
165 | 175 | # electron-to-atom equivariant feature: nb x ngrid x nnei x 4 x ng1
|
166 | 176 | e2aef = h2.unsqueeze(-1) * gg.unsqueeze(-2)
|
167 | 177 |
|
| 178 | + atomic_density = self.atomic_density_network(h2_and_type) |
| 179 | + |
168 | 180 | dmatrix, diff, sw = prod_env_mat(
|
169 | 181 | extended_coord,
|
170 | 182 | nlist,
|
@@ -214,7 +226,7 @@ def forward_atomic(
|
214 | 226 | aparam=aparam,
|
215 | 227 | )
|
216 | 228 | # 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) |
218 | 230 | nei_density = torch.where(grid_nlist_mask.unsqueeze(-1), nei_density, 0)
|
219 | 231 | # nb x ngrid x 1
|
220 | 232 | grid_density = torch.sum(nei_density, -2)
|
|
0 commit comments