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
CutoffNonPeriodic should not use reaction-field electrostatics #397
Comments
Why? Whether you want to assume a uniform dielectric beyond the cutoff has nothing to do with whether you're modelling a periodic system. |
Because the reaction field approximation is derived assuming that the entirety of the region within the cutoff is filled with explicit particles. Near the boundaries of a nonperiodic system, the reaction field form you use is no longer an accurate model of anything. |
I think we may have previously discussed leaving this in (during a discussion about GB with cutoffs) because it was sort of like a switching function, but now that we have a real switching function that is twice continuously differentiable, that need is no longer present. |
The switching function is only applied to LJ, not to Coulomb. As for what's realistic, that depends on what you're trying to model. If you're doing explicit solvent without periodic boundary conditions, that won't be realistic at the edge of the system no matter what you do. But towards the interior (which is what you presumably care about in that case), RF will be more realistic. If you're using implicit solvent, then things are completely different. We turn off RF in that case. We discussed that in lots of detail some months ago. |
Use of reaction field for nonperiodic cutoff simulations is highly nonstandard. I think it violates the idea that the default behavior should not be surprising to the user. I was just trying to simulate a little cluster of particles or molecules in the gas phase, and having RF on by default for
This is also an argument for turning it off by default, since it could be surprising to the user that this is surprisingly that RF is turned off whenever a specific implicit solvent forces are added. If there was a way to keep the RF functionality for An example use case that may apply to the forcefield parameterization work we've been discussing is the computation of potential energies of clusters of water molecules for comparison to QM data. |
But this is completely independent of periodic boundary conditions. GB can be used with or without periodic boundary conditions. RF can be used with or without periodic boundary conditions. Using RF and GB together is wrong, independent of whether or not you have periodic boundary conditions. Using the switching function would be equally wrong in that case. For explicit solvent, RF is a better approximation than the switching function, independent of whether or not you have periodic boundary conditions. |
I think we're confusing the switching function (which is applied to Lennard-Jones interactions only) with various electrostatics models (e.g. RF and GB). |
Isn't that exactly what you're proposing? That for CutoffNonPeriodic we should turn off RF and instead use the switching function for Coulomb? Or were you proposing just using a sharp cutoff with no sort of smoothing at all? If that's not what you're proposing, then yes, I'm confused about what we're discussing. |
This is my fault for having started this thread while still in a confused state! Now that I think I've got my head on right, here's the suggestion:
Does that make more sense? Again, apologies about having things mixed up earlier! |
I don't think we should default to using a sharp cutoff for Coulomb. That's just a really, really bad thing to do, and no one should ever do it. It produces all sorts of errors. The switching function is a little better, but still pretty bad: it tends to produce artifacts, such as artificially creating local minima in the potential. If someone really really wants a sharp cutoff, they can do it by setting the reaction field dielectric to 1, or by using a CustomNonbondedForce. But we shouldn't make it easy for them, because they almost certainly will get a bad result. |
I agree that a sharp cutoff is bad, which is why a switching function is a good idea. I'd be happy with switching functions to always be on by default, actually, and the user switching them off if they think they can live with the consequences. For a correctly-chosen cutoff, the artifacts introduced by switching should not introduce any big problems for the potential. If the switch is creating problematic artificial minima, then the cutoff is way too short. I still think that a reaction field form for cutoff electrostatics is very, very weird. Have you seen anyone publish this method anywhere? |
Of course. Reaction field is one of the standard methods used for this, and is generally preferred over all other cutoff methods when you aren't using PME. In contrast, switching functions are well known to produce serious artifacts. I can dig up some references for you if you really want. But let me just quote what the Gromacs manual says for the option coulombtype=switch: "Analogous to Switch for vdwtype. Switching the Coulomb potential can lead to serious artifacts, advice: use Reaction-Field-zero instead." |
I sorry! I was specifically referring to the use of reaction field without periodic boundary conditions. |
So was I. Or rather, I was nonspecifically referring to RF with or without periodic boundary conditions. :) The switching function is a bad choice either way. I'm not clear exactly what problem you're trying to solve. Is it just that you want C2 continuity at the cutoff? If so, that's easy to do by setting the reaction field dielectric to infinity. |
There are few points here:
Given these four points, I am arguing that it violates good software principles that the default behavior for
I think this is a good alternative to support in addition to switching, especially if you can actually set the dielectric to infinity. But I don't believe it should be the main or default choice, since there is very little literature support for the use of reaction field in a If we had time to assemble a paper characterizing the use of reaction-field in a |
I really don't understand what you're getting at. The reaction field approximation is based on one simple assumption: that everything beyond the cutoff is filled with a uniform dielectric. Whether that's a good assumption depends on what physical system you're trying to model. But in many cases (including many non-periodic cases), it is. In contrast, the switching function is not derived from any physical approximation, and is not a reasonable model of any physical system. Furthermore, every paper I've seen on the subject has concluded it's a terrible way to treat Coulomb interactions and no one should ever use it. Yes, some programs support it anyway, but that's mostly for historical reasons. They now advise people not to use it. Like the bit I quoted from the Gromacs manual. It recommends using reaction field instead, without reference to whether or not you have periodic boundary conditions.
That's a completely different issue. We turn off reaction field when using GB because GB was not designed to work with reaction field. This is true independent of whether or not you have periodic boundary conditions. (Yes, GB is sometimes used with periodic boundary conditions: think of crystals, membranes, etc.) And as I said, we already turn it off in that case. |
How is this a good assumption in non-periodic cases? Using the reaction-field approximation in this case will effectively assume there is a layer of empty vacuum the width of the cutoff surrounding your entire molecule, with uniform dielectric outside. What kind of physical situation does that correspond to?
Unless we can point to a paper showing the deficiencies in the switching function and superiority of the reaction-field for non-periodic cases, we really can't defensibly use this scheme! Also, there is plenty of literature showing why C2 continuity is important for Verlet-style integrators. Reaction field does not provide that, unless we support infinite dielectric, but then the deviation from the desired Coulomb potential grows rapidly with decreasing cutoff.
I'm just saying it is surprising behavior that adding some Force objects will affect the NonbondedForce objects, while other Force objects will not. |
I'll add that I would be very happy to work on such a paper together, if there was interest! We could come up with some tests to compare the various commonly-used switching and truncation schemes and compare with the RF scheme with infinite dielectric for a few systems in our |
See, for example, http://www.unc.edu/~perera/PAPERS/JChemPhys_1995_102_450.pdf http://www.ncbi.nlm.nih.gov/pmc/articles/PMC1301047/pdf/10969015.pdf I'm sure I can dig up some others if you really want. The switching function is just a really bad way to treat Coulomb interactions, and no one should ever use it. We absolutely should not add it as an option, and we certainly shouldn't make it the default! If someone really really wants it, they can always implement it with a custom force. But I'm not going to make it easy for them, because like I said, no one should ever use it.
That's not correct. When simulating explicit solvent without periodic boundary conditions, you typically embed the molecule of interest inside a droplet of water. You don't expect the behavior at the surface of the droplet to be accurate, but that's not the point of the simulation. The atoms in your molecule of interest do not "see" any sort of vacuum anywhere. They see explicit solvent out to the cutoff distance, and a constant dielectric beyond that. This is a good approximation. Contrast that with the switching function, which assumes everything outside your explicit system is vacuum, and throws in some weird cutoff artifacts to boot. By the way, here's a recent article that discusses several of the more modern methods for cutting off Coulomb interactions, including reaction field: |
Just so I know what to look for, are these supposed to be examples of non-periodic systems using reaction-field, or examples of deficiencies in switching functions? (Just not sure what to be looking for specifically!) |
I've been lurking on this thread, and learning a lot. (From that perspective, it's really awesome to have this conversation happen on github where I can lurk, as opposed to on email or something where it would be private). With that said, the Berkowitz paper doesn't make any sense to me. They say:
This makes absolutely no sense to me. |
@rmcgibbo, the statement you quoted is basically a paraphrasing of a description of the Ewald technique taken from either Allen and Tildesley or the Tuckerman book (both are great resources, IMO). I agree that in the given context they are rather opaque, so I would definitely suggest looking at the Ewald derivations in one of (or both of) those texts.
As I understand it, the Ewald sum is only conditionally convergent. Since the net charge is formally 0, you have a sum that is more or less like 1 - 1/r + 1/r^2 - 1/r^3 + 1/r^4 --- an alternating harmonic series in the energy. We know that the harmonic series diverges (slowly, but it diverges), but the convergence criteria for alternating series is significantly less restrictive. Basically, your terms have to tend toward 0 in the infinite limit, which the alternating harmonic series does. One of the weird properties of an infinite, conditionally convergent sum like the one above is that its value actually depends on the order in which the summation is performed. Hence the term "roughly spherical layers" is defining the summation order by adding in particles in an order defined by their distance from the central particle (more or less -- closer periodic images are added before farther ones). The boundary conditions (what is outside this infinitely periodic system that really has no boundary) adds a constant term to the Ewald sum based on the dielectric of this (non-existent) surrounding medium. If the dielectric is infinite (i.e., "tin-foil boundary"), no correction term need be added to the computed energy. If the dielectric is 1 (i.e., an infinite system embedded in a vacuum), there is some constant energy term you need to add to 'correct' for these boundary conditions. It does not affect forces at all, just the total energy (and not even the pressure tensor since it's not volume-dependent, to my understanding). It definitely helps to see the explanation in Allen and Tildesley. |
As a clarification, this convention is used in the derivation of the Ewald summations. The Ewald summation itself is a set of two quickly converging series -- one in direct space using the minimum image convention with every charge damped by a neutralizing charge distribution and the other in reciprocal space computing the convolution of the cancelling charge distributions. This formulation is only possible, however, because an 'order' was defined for summing up the original conditionally convergent series. Basically, the Ewald sum only matches a specific choice for the order of summation of the direct particle-particle interactions over all periodic cells. I can't do full justice to the Ewald sum in a Github post, though. Allen and Tildesley is to date the most helpful resource I've found (closely followed by Tuckerman). I have a somewhat more relaxed discussion of electrostatic summation methods (including Ewald, PME, cutoffs, switches, shifting, GRF, and IPS) in my dissertation ~p 55 [http://jswails.wikidot.com/about at the bottom] |
Back to the original discussion: I agree with both @peastman and @jchodera. Coulomb switching functions just plain suck. Between two oppositely charged particles I believe the switching region introduces a repulsive force, whereas two particles of the same charge introduces an attractive force where the switch is turned on. Yes the switch may be (twice!) differentiable, but this is just physically wrong. The use cases for a RF approach in a non-periodic system seem far-fetched to me. There's an easy solution, though: use Unless somebody has a good reason for wanting to use a cutoff in a non-periodic system, they should use |
Well, I can confess to having played around with simulating a few copies of GroEL in a non-perodic system using implicit solvent models. NoCutoff really isn't an option there.
This is highly dependent on system size |
But I certainly see with your point, @swails. Doesn't this argue for simply disabling the |
Of course, I wasn't that clear in my statement, I don't think. At some point as the size of the system/solute increases, there's a "crossing point" where even omitting the solvent particles in a GB calculation isn't enough to make up for the O(N^2) scaling of the GB/gas-phase algorithm with no cutoff, and biting the bullet to add solvent molecules and run with PME where you can use a small cutoff with a O(N logN) method for long-range electrostatics is actually faster than the corresponding GB or gas-phase calculation. If you use a cutoff with non-periodic systems this isn't true, I suppose (unless you're not using a neighbor list, but those can get huge for a very big cutoff). |
To quote Doug Gwyn: UNIX was not designed to stop its users from doing stupid things, as that would also stop them from doing clever things. Substitute in OpenMM and I think that's a strong argument for keeping |
Perhaps so, but think of this from a Bayesian standpoint. :) The user is using a cutoff, they are not using periodic boundary conditions, and they are not using implicit solvent. How frequently that combination occurs is not the question. Consider all of those as givens, and our job is to figure out the best thing to do. There are two main possibilities:
|
Indeed -- I was arguing for as much. I don't have any use-cases for cutoffs and RF in a non-periodic system, but we ought not to punish people that want to do something clever with this functionality just because somebody else might do something foolish :). My summary from this thread: Relating to
The average user should avoid all 3, but the clever user should not be unnecessarily blocked. Addressing @jchodera's concerns, it would probably be best if the defaults in the application layer steered people away from |
@swails: Thanks for the info in Ewald! |
I believe the conclusion of this discussion was not to change the behavior, so I'm closing it. |
I don't think this is quite settled. There have also been numerous reports that GBSA with a cutoff behaves very, very oddly, and part of that problem may be that |
If we were picking the defaults today, I think that RF with The main reason IMO for keeping the current default is that it's been this way for a long time already. And of all nonbonded schemes to use, |
Ah! I had forgotten about that line: I'll keep looking for the origin of the issues with GB cutoffs then... |
ForceField also disables RF if you add a GBSAOBCForce to the system: |
I think all |
Not to resurrect a dead issue, but I just wanted to add a potential use case where this (having the automatic RF correction) leads to very confusing results. I wanted to calculate the pairwise energy of a particular pair of atoms and I found that setting As OpenMM is a library, it should not, in my opinion as a user, do this sort of decisions under the hood. I agree with @jchodera that there should be a way to absolutely disable the RF correction, even if it's the stupidest thing in the universe. I can use a Sorry if this sounds a bit like a rant, but I spent two days figuring out why the NonbondedForce of a two atom system was not matching what I had on paper and what I wrote from a CustomNonbondedForce. Edit. This also leads to this slightly mind-boggling effect: change the cutoff and see your energy change ... If you want the code I was using, which is the simplest I could come up with, here it is.
|
@JoaoRodrigues I'm literally debugging this right now and ran into the same behavior. I'm +1 on disabling the rf correction. |
What's more insane is that we do turn off the crf offset when computing the 1-4 exceptions |
It's not just the offset. Reaction field isn't applied to 1-4 interactions. Nor are cutoffs, nor periodic boundary conditions. That's because they're fundamentally bonded interactions, not nonbonded. Likewise, if you use PME, the exception is only applied to the two particular bonded atoms. The interactions of each one with all the infinite periodic images of the other are computed with the standard parameter values. |
When a cutoff is used in a non-periodic system, reaction-field electrostatics should not be used.
I may be reading the code wrong, but this seems to suggest that reaction-field electrostatics are used whenever a cutoff is employed:
https://github.com/SimTk/openmm/blob/master/platforms/reference/src/SimTKReference/ReferenceLJCoulombIxn.cpp#L590-L591
Also, the tests (specifically,
testCutoff()
inTestReferenceNonbondedForce
) test theCutoffNonPeriodic
condition against reaction-field electrostatics:https://github.com/SimTk/openmm/blob/master/platforms/reference/src/SimTKReference/ReferenceLJCoulombIxn.cpp#L590-L591
The text was updated successfully, but these errors were encountered: