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

support generalized force loss #2690

Merged
merged 4 commits into from Jul 25, 2023

Conversation

njzjz
Copy link
Member

@njzjz njzjz commented Jul 20, 2023

Support the loss for generalized forces. Tests and examples have been added.

Generalized forces are given by

$$Q_j = \sum_{i=1}^n \mathbf F_i \cdot \frac {\partial \mathbf r_i} {\partial q_j},\quad j=1,\ldots, m.$$

The loss for generalized forces is given by

$$L_Q = \frac{1}{m} \sum_{j=1}^m (Q_j - Q_j^*)^2.$$

In the example, the generalized coordinates $q$ are the restraint coordinates in the enhanced sampling.

This PR also improves documentation for other arguments in the loss.

Signed-off-by: Jinzhe Zeng <jinzhe.zeng@rutgers.edu>
@codecov
Copy link

codecov bot commented Jul 20, 2023

Codecov Report

Patch coverage: 92.15% and project coverage change: +0.51 🎉

Comparison is base (0d2bc7a) 78.17% compared to head (925fba2) 78.69%.

Additional details and impacted files
@@            Coverage Diff             @@
##            devel    #2690      +/-   ##
==========================================
+ Coverage   78.17%   78.69%   +0.51%     
==========================================
  Files         238      239       +1     
  Lines       24859    25549     +690     
  Branches     1509     1517       +8     
==========================================
+ Hits        19433    20105     +672     
- Misses       5034     5054      +20     
+ Partials      392      390       -2     
Impacted Files Coverage Δ
deepmd/loss/ener.py 68.14% <88.23%> (+1.88%) ⬆️
deepmd/utils/argcheck.py 95.81% <100.00%> (+0.05%) ⬆️

... and 32 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

Signed-off-by: Jinzhe Zeng <jinzhe.zeng@rutgers.edu>
Signed-off-by: Jinzhe Zeng <jinzhe.zeng@rutgers.edu>
Signed-off-by: Jinzhe Zeng <jinzhe.zeng@rutgers.edu>
@njzjz njzjz marked this pull request as ready for review July 21, 2023 22:31
@njzjz njzjz requested a review from wanghan-iapcm July 21, 2023 22:49
Copy link
Collaborator

@wanghan-iapcm wanghan-iapcm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

I am not sure how would it be useful in practice, because a low normal force loss would naturally lead to a low generalized force loss if dr/dq is not degenerate.

@njzjz
Copy link
Member Author

njzjz commented Jul 23, 2023

I am not sure how would it be useful in practice,

This is Tim's idea. Here is my understanding.

In umbrella sampling free energy calculation, the only quantity from simulations directly used to calculate free energy is the reaction coordinates (we make it the generalized coordinates $q$ in this context). Thus, the generalized forces $Q=\frac{\partial{E}}{\partial{q}}$ will be more important than the normal force in such an application.

because a low normal force loss would naturally lead to a low generalized force loss if dr/dq is not degenerate.

I agree it has been low (the papers I published have proved it), but what we expect is that generalized force has even better accuracy than before, without significantly decreasing the accuracy of the normal force.

@wanghan-iapcm wanghan-iapcm merged commit b0b2b73 into deepmodeling:devel Jul 25, 2023
39 checks passed
@wanghan-iapcm
Copy link
Collaborator

Clear, Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants