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

throw errros if rmin is no less than rmax #3393

Merged
merged 9 commits into from
Mar 5, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
8 changes: 5 additions & 3 deletions deepmd/dpmodel/utils/env_mat.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@
min_mask = distance <= rmin
max_mask = distance >= rmax
mid_mask = np.logical_not(np.logical_or(min_mask, max_mask))
uu = (distance - rmin) / (rmax - rmin)
vv = uu * uu * uu * (-6.0 * uu * uu + 15.0 * uu - 10.0) + 1.0
return vv * mid_mask + min_mask
with np.errstate(divide="ignore"):
uu = (distance - rmin) / (rmax - rmin)
with np.errstate(invalid="ignore"):
vv = uu * uu * uu * (-6.0 * uu * uu + 15.0 * uu - 10.0) + 1.0
return np.where(mid_mask, vv, min_mask.astype(distance.dtype))

Check warning on line 27 in deepmd/dpmodel/utils/env_mat.py

View check run for this annotation

Codecov / codecov/patch

deepmd/dpmodel/utils/env_mat.py#L23-L27

Added lines #L23 - L27 were not covered by tests


def _make_env_mat(
Expand Down
2 changes: 1 addition & 1 deletion deepmd/pt/utils/preprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@
mid_mask = torch.logical_not(torch.logical_or(min_mask, max_mask))
uu = (distance - rmin) / (rmax - rmin)
vv = uu * uu * uu * (-6 * uu * uu + 15 * uu - 10) + 1
return vv * mid_mask + min_mask
return torch.where(mid_mask, vv, min_mask.to(dtype=distance.dtype))

Check warning on line 236 in deepmd/pt/utils/preprocess.py

View check run for this annotation

Codecov / codecov/patch

deepmd/pt/utils/preprocess.py#L236

Added line #L236 was not covered by tests


def make_env_mat(
Expand Down