Skip to content

Commit

Permalink
do not change diff directly
Browse files Browse the repository at this point in the history
Signed-off-by: Jinzhe Zeng <[email protected]>
  • Loading branch information
njzjz authored Oct 25, 2024
1 parent 0517b59 commit d0b576f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions deepmd/dpmodel/utils/env_mat.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ def _make_env_mat(
diff = coord_r - coord_l
# nf x nloc x nnei
# the grad of JAX vector_norm is NaN at x=0
diff = xp.where(xp.abs(diff) < 1e-30, xp.full_like(diff, 1e-30), diff)
length = xp.linalg.vector_norm(diff, axis=-1, keepdims=True)
diff_ = xp.where(xp.abs(diff) < 1e-30, xp.full_like(diff, 1e-30), diff)
length = xp.linalg.vector_norm(diff_, axis=-1, keepdims=True)
# for index 0 nloc atom
length = length + xp.astype(~xp.expand_dims(mask, axis=-1), length.dtype)
t0 = 1 / (length + protection)
Expand Down

0 comments on commit d0b576f

Please sign in to comment.