Hi,
I'm developing a force field which has "standard" Coulomb forces (like in OPLS) and a custom dispersion/repulsion term. I'd like the Coulombic forces and CustomNonbondedForce to be scaled by 0.5 for 1-4 interactions.
Initially, I tried to use <NonbondedForce> with epsilon=sigma=0 and the charges from my model, <CustomNonbondedForce bondCutoff=4> and <CustomBondForce> for all 1-3 interactions, but I got this error Exception: All Forces must have identical exceptions.
To get rid of this exception, I set bondCutoff for the custom NB to 3, and subtracted half of the non-bonded force using CustomBondForce, but this is a dirty workaround which I really don't like.
I would be very grateful if someone could suggest a better solution. For example, is it possible to change the bondCutoff for Coulomb to 4, and then add the missing 1-3 Coulomb via CustomBondForce?
Thanks,
Michal
CustomNonbondedForce and exceptions/exclusions
- Michal Krompiec
- Posts: 21
- Joined: Tue Jul 02, 2019 1:17 pm
- Peter Eastman
- Posts: 2593
- Joined: Thu Aug 09, 2007 1:25 pm
Re: CustomNonbondedForce and exceptions/exclusions
Code: Select all
<CustomNonbondedForce bondCutoff=4>
- Michal Krompiec
- Posts: 21
- Joined: Tue Jul 02, 2019 1:17 pm
Re: CustomNonbondedForce and exceptions/exclusions
Thank you very much for your reply. Oh yes, you are right. Indeed, bondCutoff should be set to 3, and I will add scaled 1-4s via CustomBondForce. Do I understand correctly that NonbondedForce with zeroed epsilons includes scaled 1-4 Coulomb? (assuming the scaling parameter is set correctly)
Thanks,
Michal
Thanks,
Michal
- Peter Eastman
- Posts: 2593
- Joined: Thu Aug 09, 2007 1:25 pm
Re: CustomNonbondedForce and exceptions/exclusions
Correct. Also, if you set all the epsilons to 0 then it ifdefs out the parts of the kernels that compute LJ interactions, so there's no performance cost from them.
- Michal Krompiec
- Posts: 21
- Joined: Tue Jul 02, 2019 1:17 pm
Re: CustomNonbondedForce and exceptions/exclusions
I still can't get this right. At the moment, I have a CustomNonbondedForce with bondCutoff=3 and a NonbondedForce which handles Coulomb interactions (1-4 interactions are scaled by 0.5). Now, I would like to add 1-4 interactions to the CustomNonbondedForce (scaled by 0.5, or unscaled). Is it possible to do it in the xml (without modifying anything in python)? Such a solution would be preferred because I'd like to keep my FF compatible with ForceBalance.
If I do it by adding 1-4 interactions as bonds (in <Residue>) with a CustomBondForce, these interactions will become "bonded" in the topology and will disappear from NonbondedForce, and any neighboring atoms will become 1-3 interactions (instead of 1-5). So using this https://github.com/jmcdaniel43/Thermody ... ionpol.xml as an example won't help.
If I do it by adding 1-4 interactions as bonds (in <Residue>) with a CustomBondForce, these interactions will become "bonded" in the topology and will disappear from NonbondedForce, and any neighboring atoms will become 1-3 interactions (instead of 1-5). So using this https://github.com/jmcdaniel43/Thermody ... ionpol.xml as an example won't help.
- Peter Eastman
- Posts: 2593
- Joined: Thu Aug 09, 2007 1:25 pm
Re: CustomNonbondedForce and exceptions/exclusions
You actually can put Python code right in the XML file. It goes in a <Script> tag. That gives you a chance to post-process the System in whatever way you need, such as by adding a CustomBondForce. For an example of a force field that uses this mechanism, take a look at https://raw.githubusercontent.com/openm ... r_2013.xml. Within the script, the variable "sys" refers to the System that was just created and "data" is a ForceField._SystemData object containing lots of useful information about bonds, angles, dihedrals, atom types, etc.
- Michal Krompiec
- Posts: 21
- Joined: Tue Jul 02, 2019 1:17 pm
Re: CustomNonbondedForce and exceptions/exclusions
Thank you, this is great! When exactly is this code executed?
- Peter Eastman
- Posts: 2593
- Joined: Thu Aug 09, 2007 1:25 pm
Re: CustomNonbondedForce and exceptions/exclusions
It's the very last step, after all standard processing has been done and just before the System gets returned:
https://github.com/openmm/openmm/blob/m ... 1331-L1334
https://github.com/openmm/openmm/blob/m ... 1331-L1334