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

Potential sign mismatch between the reference formula the implementation of the forces and stresses #3674

Closed
mtaillefumier opened this issue Apr 15, 2024 · 3 comments
Labels

Comments

@mtaillefumier
Copy link

Summary

I am currently working on a deterministic version of this set of functions, prod_force_{a,r}_gpu which is related to the issue #3270. I compared both implementations to the equations found in the PRL paper https://journals.aps.org/prl/supplemental/10.1103/PhysRevLett.120.143001.

After looking at both the CPU and GPU implementation of the forces, I found a possible inconsistency between the code (both on CPU and GPU) and the formula found in the supplementary material. Let me take the CPU variant as all terms are in the same function

the line

force[i_idx_nall * 3 + 0] -= net_deriv[i_idx * ndescrpt + aa] *
has -= which agrees with the formula in the paper but the line after
force[kk * nall * 3 + j_idx * 3 + 0] +=
which describes the "non-local" part of the atomic forces contains a += operation in contradiction with the the second part of the formula for the forces.

All terms in the original article contain a minus sign. The code contains -= and +=.
the net_deriv which corresponds to the gradient of the energy is calculated here

[net_deriv] = tf.gradients(atom_ener, self.descrpt)
.

Why is there a sign change between the article and the implementation ?

DeePMD-kit Version

all

Backend and its version

CPU and GPU

Python Version, CUDA Version, GCC Version, LAMMPS Version, etc

No response

Details

see summary

@mtaillefumier
Copy link
Author

@asedova

@njzjz
Copy link
Member

njzjz commented Apr 15, 2024

The equation in the paper contains a typo. $D_{jk}^\alpha$ in the first term should be $D_{ik}^\alpha$:

image

In the formula $\nabla R_i D_{jk}^\alpha$, when $k$ is $i$, it is equal to $-\nabla R_j D_{jk}^\alpha$, which introduces a sign change.

@mtaillefumier
Copy link
Author

mtaillefumier commented Apr 16, 2024

thank you very much. It was not obvious from the formula and the code combined.

@njzjz njzjz added question and removed wontfix labels Apr 17, 2024
@njzjz njzjz closed this as completed Apr 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants