openmmforcefields icon indicating copy to clipboard operation
openmmforcefields copied to clipboard

Add NBFIX to Amber forcefield to the xml

Open DanielWicz opened this issue 3 months ago • 4 comments

I wanted to add NBFIXes to the Amber force field XML files. Is adding them within <LennardJonesForce> is sufficient (since there is no <LennardJonesForce> by default in the Amber XMLs)? Or the parser for the Amber XMLs will ignore them?

DanielWicz avatar Sep 29 '25 08:09 DanielWicz

If you want to modify a force field XML file that uses <NonbondedForce> for both Lennard-Jones and Coulomb interactions, and doesn't use <LennardJonesForce>, adding a <LennardJonesForce> with <NBFixPair> entries alone won't work. You'll need to edit the file so that the <NonbondedForce> handles Coulomb interactions only (i.e., all epsilon values set to 0), and then add a <LennardJonesForce> with all of the sigma and epsilon values that used to be set in the <NonbondedForce>. Then you could add <NBFixPair> entries to the <LennardJonesForce>. See the documentation for <LennardJonesForce>.

epretti avatar Sep 29 '25 22:09 epretti

So I edit the XML: for the atoms I want to modify with NBFIX, I set epsilon to zero (as in this example: waters_ions_spc_e.xml#L374) in the <NonbondedForce> section.

Then I copy (with the correct epsilon and sigma) them to the <LennardJonesForce> section and define the NBFIX parameters pair in <NBFixPair> ?

Will this work with the Amber force field by only modifying the XML, without changing the OpenMM parser? Does it use the same XML force field parser both for CHARMM and Amber ?

DanielWicz avatar Sep 30 '25 09:09 DanielWicz

The CHARMM force fields like the one you linked, with both <NonbondedForce> and <LennardJonesForce>, demonstrate what you'd need to do. The XML parser always interprets the files in the same way; there's no special distinction between an "Amber" and a "CHARMM" XML file besides the file contents.

The basic idea you have is right, except that it won't work to just switch the atom types that you want to add NBFIXes to over to <LennardJonesForce>, since it will try to assign parameters for every atom. If an atom type is missing, you will get an exception when trying to create a System from the force field.

epretti avatar Sep 30 '25 16:09 epretti

The documentation at https://docs.openmm.org/latest/userguide/application/06_creating_ffs.html may be helpful.

peastman avatar Sep 30 '25 17:09 peastman