Fix `adjust_momenta` of `FixCom`
First MR relevant to #1285 (closed).
FixCom
should make the center-of-mass velocity zero (This is also consistent with the RATTLE algorithm), but at the moment, this is not correctly implemented. This MR fixes this issue.
The first commit is for adding the test to demonstrate the issue.
The second commit fixes the issue above.
The third commit is to fix the default adjust_momenta
in the (essentially abstract) class FixConstraint
. At the moment, adjust_momenta
is simply redirected to adjust_forces
. This is however reasonable only for some type of subclasses (IndexedConstraint
etc.) and in general not (FixBondLengths
etc). To let new constraint developers notice about adjust_momenta
I would make it as an abstract method (to force the developers to always implement this method). This commit may be optional but I feel it reasonable.
Note: Just to preserve the present behavior, I also re-implement adjust_momenta
for some subclasses in the same way as the original FixConstraint
(i.e. redirected to adjust_forces
). I am however not immediately sure if some of them are reasonable (or correct) (e.g. for ExternalForce
, should adjust_momenta
really be the same as adjust_forces
?) Since the motivation of this MR is just to fix FixCom
, I will postpone thinking of this point...
Merge request reports
Activity
added 108 commits
-
0efdd7c1...c6274c82 - 105 commits from branch
ase:master
- d0915967 - Add test for `adjust_momenta` of `FixCom`
- 7ac138cb - Add `adjust_momenta` to `FixCom`
- 5fb43fd5 - Make `FixConstraint` a subclass of `ABC`
Toggle commit list-
0efdd7c1...c6274c82 - 105 commits from branch
added 2 commits
mentioned in issue #1300 (closed)
Hi @schiotz, would you be able to have a look please? It sounds very reasonable that the momenta should be updated by constraints, but sometimes thermostats and other MD things have fiendish subtleties.
Of course all the tests pass so in principle all should be good.
Maybe, @yuzie007, if there are implementations that we are not sure about, then it would be good to add comments inside the code pointing to this discussion.
Thank you @askhl for your kind review as always, and I would be very happy to have review also from @schiotz.
Following the suggestion, I made following changes for to let
FixConstraint
inheritABC
.-
ExternalForce
,MirrorForce
,MirrorTorque
probably just modifies forces or torques and not for MD (in the sense of the RATTLE algorithm). So probablyadjust_momenta
should do noting in there (likeHookean
). So I modifiedadjust_momenta
for them to do nothing. -
For
FixedMode
,FixInternals
,FixSymmetry
, maybeadjust_momenta
should not be adjusted in the same way asadjust_forces
, I so addedTODO
(Note just for reminder: I do not modify any code behavior here since previously, and no backward compatibility is broken due to the MR. I just take the default behavior from previousFixConstraint
, which could just be wrong since previously.)
In case you worry about the changes followed by the
ABC
inheritance, we can revert the changes not usingabstractmethod
.-
Hi @schiotz, how is everything? Would you be able to have a look?
added 158 commits
Toggle commit listThank you very much @yuzie007, merging.
You're welcome to suggest the other API change in a separate issue or MR. I think it is a good idea to be more explicit about momenta.
mentioned in commit e0569c49