Add new fix to compute force and torque due to electric potential#4241
Add new fix to compute force and torque due to electric potential#4241akohlmey merged 35 commits intolammps:developfrom
Conversation
|
@gsalkuin Thank you for your submission. Also, many thanks for making the effort to adapt to the LAMMPS programming style, providing (and integrating!!) documentation. You've made my job a lot easier. I've made a few more cosmetic changes on top of that and added a couple of tests for the automated testing. So, from the formal point of view this is ready to go it. I'll leave it to other LAMMPS developers that are more competent in this area of simulations to check the implementation itself. |
|
Thank you for the positive feedback and for making the additional changes. This is my first PR and I'm still learning C++, but I hope to make more contributions in the future. |
|
@gsalkuin thanks for the contribution! It's important to see that fix efield with a non-uniform e-field misses a force component. I have only a comment in the source code to make the for loop(s) over |
|
@ndtrung81 Thanks for the feedback. You are right, I found that the loop is very inefficient when compared to fix efield for the uniform efield case. I think the main cause is lines 195-212 in |
Add flags for .getVariableReference() Add initialization in constructor
|
@gsalkuin it looks like we have a portability issue with Windows and Microsoft Visual C++ Otherwise, I can take a look (I have a Windows Virtual machine that I can use for that purpose). |
|
@akohlmey I think the issue is due to a missing |
Add #include that prevents Windows compile minor touch-ups
|
Hi @gsalkuin , this is a great addition to the LAMMPS codebase -- even though I've marked my review as needing addressed, this is really well done (as well as including good documentation and tests!) My main question is around the intended treatment of periodicity -- should the Lepton expression act on wrapped coordinates or unwrapped? There are problems either way -- acting on wrapped coordinates would impose artificial force-mismatches on molecules straddling periodic boundaries. But acting on unwrapped coordinates would result in a non-periodic simulation, where particles with similar box coordinates might experience completely different forces depending on their image flags. I am not familiar with periodic simulations involving inhomogeneous fields, so I am happy to defer to your expertise -- but periodicity should be more clearly documented. My other main questions were around having lots of RAIIs being built and destroyed inside the Cheers, |
|
Hi @srtee, Thanks for the detailed feedback and suggestions! I will try to answer what I can based on my limited expertise. I mostly use LAMMPS for mesh-free simulations in solid mechanics, so I rarely use PBC. The intended use case for this fix is to simulate electric/magnetic control, which usually has the field localized in a region. But that is an excellent point on the force becoming mismatched or unbounded in traditional MD use cases. I used unwrapped coordinates to avoid possible discontinuities in the potential, but perhaps this is not an issue for LEPTON, and wrapped coordinates will be better. I will defer this to your and other MD experts' judgment. I am also not that familiar with the many box-changing commands, but as long as the expression can be written as a function of "x", "y", "z" I think it should be pretty flexible. As for the I will try to address your other concerns when time permits. Thanks! |
If you do not have PBC, wrapped and unwrapped coordinates are the same. Recent versions of LAMMPS will drop image flags != 0 for non-periodic dimensions when reading coordinates from data files. The code should print a warning if there is a periodic dimension, and there should be an explanation in the documentation that using it for periodic boundaries is likely going to cause problems and unphysical behavior for atoms crossing the boundary. |
stanmoore1
left a comment
There was a problem hiding this comment.
When the comments/feedback from other reviewers are addressed then I approve this PR. I don't have any additional comments or concerns.
|
Thanks @gsalkuin for this addition. I have 3 cosmetic suggestions. |
|
Thanks, @stanmoore1 and @sjplimp! @sjplimp, I'll work on making the changes you suggested. For (3), I didn't name it efield/lepton to avoid confusion since it doesn't follow the same syntax as efield and efield/tip4p. But if this isn't an issue, I can rename it to efield/lepton. |
|
@gsalkuin Having the same or similar syntax is more an issue when the new class is derived from a parent class. In this case it is more a conceptual motivation. Have all the fixes which apply an efield to charged particles, start with the same name. Kind of like all the compute temp variants, many of which have different syntax, but all conceptually calculate a temperature. Let's see if Stan or Axel have feedback on the (3) name change. |
I agree with calling it fix efield/lepton. It helps people look in the right places for what they need. All /lepton styles are by their very nature different from others, so there is not a problem with having a different syntax than fix efield. |
|
@akohlmey nothing major from me, just suggestions to documentation and code style (perhaps minor performance improvements). I hope to finish those within 24 hours from this comment but if they're not in before then that's on me, I'm happy to merge. @gsalkuin very good job on moving the heavy Lepton machinery out of the inner loops!! Notes to self:
|
Fix efield/lepton updates
…nd dphi flagging uniform
|
Hi @gsalkuin, I've put my proposed changes in a PR to your branch, with more detailed comments there. In brief:
I did think about adding things to the documentation but -- it's on users to know the physics and realism of their simulations. I also checked that the regression test you added does, in fact, fail when I randomly flip one of the force signs in the source code, good job! To be clear -- if the changes I suggested make the code less sensible to you, rather than more, just let me know in this comment thread and I'm happy to approve the PR as-is. I think we should have this PR merged in pretty soon :) |
Efield lepton updates
|
Hi @srtee, The changes you made are excellent—they make the code much more concise. I’ve merged your PR. Thanks! |
Summary
This PR adds a new fix that computes the force/torque on both charges and dipoles given an electric potential. Currently, the fix efield command does not compute the force on dipoles due to the gradient of the electric field. Instead of requiring the components of the electric field and its gradients, this fix only takes a Lepton expression of the form V(x,y,z).
Related Issue(s)
N/A
Author(s)
Gabriel Alkuino (Syracuse University) - gsalkuino@outlook.com
Licensing
By submitting this pull request, I agree, that my contribution will be included in LAMMPS and redistributed under either the GNU General Public License version 2 (GPL v2) or the GNU Lesser General Public License version 2.1 (LGPL v2.1).
Backward Compatibility
No known issues.
Implementation Notes
Post Submission Checklist
Further Information, Files, and Links