Hi Peter,
Oh, I see thank you very much for pointing that out for me! Fixing that bit of business
Another question on using
scripts in force field xml files, as must be done for pair-specific LJ interactions:
*How do I add particles to the force based on their type as interpreted by templating?
*How do I ensure that the force's parameters will be set to a particular nonbonded method and nonbonded cutoff specified when using the loaded force field to create a simulation (to set the method to CutoffPeriodic and the cutoff to 1.0 nm when doing forcefield.createSystem(pdb.topology, nonbondedMethod=app.CutoffPeriodic, nonbondedCutoff=1.0*unit.nanometers)?
As of right now, trying something like the following:
Code: Select all
<ForceField>
<AtomTypes>
<Type name="0" class="LJA" element="Ar" mass="39.948"/>
<Type name="1" class="LJB" element="Ar" mass="39.948"/>
</AtomTypes>
<Residues>
<Residue name="AYY">
<Atom name="A" type="0"/>
</Residue>
<Residue name="BEE">
<Atom name="B" type="1"/>
</Residue>
</Residues>
<Script>
import simtk.openmm as mm
import simtk.openmm.app as app
import simtk.unit as u
cutoff = 2.5 * u.nanometers
# making self-interaction well 4x deeper
epsilon = [
3.9832, 0.9958, # A-A, A-B
0.9958, 3.9832] # B-A, B-B
sigma = [
0.3405, 0.3405, # A-A, A-B
0.3405, 0.3405] # B-A, B-B
# Create a CustomNonbondedForce to compute Lennard-Jones interactions.
customNonbondedForce = mm.CustomNonbondedForce('4*eps*((sig/r)^12-(sig/r)^6); eps=epsilon(type1, type2); sig=sigma(type1, type2)')
customNonbondedForce.setNonbondedMethod(mm.NonbondedForce.CutoffNonPeriodic)
customNonbondedForce.setCutoffDistance(cutoff)
customNonbondedForce.addTabulatedFunction('epsilon', mm.Discrete2DFunction(2, 2, epsilon))
customNonbondedForce.addTabulatedFunction('sigma', mm.Discrete2DFunction(2, 2, sigma))
customNonbondedForce.addPerParticleParameter('type')
for atom in data.atoms:
customNonbondedForce.addParticle([data.atomType[atom]])
sys.addForce(customNonbondedForce)
</Script>
</ForceField>
Gives the following error:
Traceback (most recent call last):
File "teststruct.py", line 7, in <module>
forcefield.createSystem(pdb.topology, nonbondedMethod=app.CutoffNonPeriodic, nonbondedCutoff=1.0*u.nanometers)
File "/Users/gpantel/miniconda2/lib/python2.7/site-packages/simtk/openmm/app/forcefield.py", line 956, in createSystem
exec(script, locals())
File "<string>", line 25, in <module>
File "/Users/gpantel/miniconda2/lib/python2.7/site-packages/simtk/openmm/openmm.py", line 11554, in addParticle
return _openmm.CustomNonbondedForce_addParticle(self, *args)
NotImplementedError: Wrong number or type of arguments for overloaded function 'CustomNonbondedForce_addParticle'.
Possible C/C++ prototypes are:
OpenMM::CustomNonbondedForce::addParticle(std::vector< double,std::allocator< double > > const &)
OpenMM::CustomNonbondedForce::addParticle(