Skip to content
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

Fix: PairTab Data #3812

Merged
merged 9 commits into from
May 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
12 changes: 10 additions & 2 deletions deepmd/pt/model/atomic_model/linear_atomic_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -501,8 +501,13 @@
extended_coord, masked_nlist
)
numerator = torch.sum(
pairwise_rr * torch.exp(-pairwise_rr / self.smin_alpha), dim=-1
) # masked nnei will be zero, no need to handle
torch.where(
nlist_larger != -1,
pairwise_rr * torch.exp(-pairwise_rr / self.smin_alpha),
torch.zeros_like(nlist_larger),
),
dim=-1,
)
denominator = torch.sum(
torch.where(
nlist_larger != -1,
Expand All @@ -522,5 +527,8 @@
smooth = -6 * u**5 + 15 * u**4 - 10 * u**3 + 1
coef[mid_mask] = smooth[mid_mask]
coef[right_mask] = 0

# to handle masked atoms
coef = torch.where(sigma != 0, coef, torch.zeros_like(coef))

Check warning on line 532 in deepmd/pt/model/atomic_model/linear_atomic_model.py

View check run for this annotation

Codecov / codecov/patch

deepmd/pt/model/atomic_model/linear_atomic_model.py#L532

Added line #L532 was not covered by tests
self.zbl_weight = coef # nframes, nloc
return [1 - coef.unsqueeze(-1), coef.unsqueeze(-1)] # to match the model order.
4 changes: 2 additions & 2 deletions source/tests/pt/model/test_autodiff.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class ForceTest:
def test(
self,
):
places = 8
places = 5
delta = 1e-5
natoms = 5
cell = torch.rand([3, 3], dtype=dtype, device="cpu")
Expand Down Expand Up @@ -126,7 +126,7 @@ class VirialTest:
def test(
self,
):
places = 8
places = 5
delta = 1e-4
natoms = 5
cell = torch.rand([3, 3], dtype=dtype, device="cpu")
Expand Down
2 changes: 1 addition & 1 deletion source/tests/pt/model/test_permutation.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
"use_srtab": f"{CUR_DIR}/water/data/zbl_tab_potential/H2O_tab_potential.txt",
"smin_alpha": 0.1,
"sw_rmin": 0.2,
"sw_rmax": 1.0,
"sw_rmax": 4.0,
"descriptor": {
"type": "se_atten",
"sel": 40,
Expand Down
2 changes: 1 addition & 1 deletion source/tests/pt/model/test_smooth.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ def setUp(self):
model_params = copy.deepcopy(model_zbl)
self.type_split = False
self.model = get_model(model_params).to(env.DEVICE)
self.epsilon, self.aprec = 1e-10, None
self.epsilon, self.aprec = None, 5e-2


class TestEnergyModelSpinSeA(unittest.TestCase, SmoothTest):
Expand Down
Loading