metadynamics

The functionality of OpenMM will (eventually) include everything that one would need to run modern molecular simulation.
POST REPLY
User avatar
Daniel Konstantinovsky
Posts: 77
Joined: Tue Jun 11, 2019 12:21 pm

metadynamics

Post by Daniel Konstantinovsky » Fri Oct 16, 2020 2:19 pm

Hi!

I want to do some metadynamics where the collective variable is the distance between two specific particles. I am not sure how to implement the collective variable. Below is the code I have now, which I adapted from https://github.com/openmm/openmm/issues/2126. I am particularly unsure about what to put for the custom force, considering that I don't want to introduce any actual forces, just to define a degree of freedom. Is the following code on the right track or am I missing something? How can I implement this collective variable?


force = CustomBondForce("k") # k is a placeholder, there is no actual force (is this the right thing to do here?)
force.addBond(particleIdx1, particleIdx2)

distance = BiasVariable(force, minDistance, maxDistance, biasWidth=0.5, periodic=True)
enhancedSampling = Metadynamics(system, [distance], temperature=298 * kelvin, biasFactor=2, height=1.0 * kilojoules_per_mole, frequency=100)

User avatar
lewis martin
Posts: 63
Joined: Tue Mar 06, 2018 8:56 pm

Re: metadynamics

Post by lewis martin » Mon Oct 19, 2020 5:12 pm

The custom force in this case never gets added to the system directly, it's just used by the metadynamics module to calculate the value of the collective variable. So you want the energy expression to evaluate to the the value of the collective variable. To do this, change

Code: Select all

force = CustomBondForce("k") # k is a placeholder, there is no actual force (is this the right thing to do here?)
to

Code: Select all

force = CustomBondForce("r") 
since r is the code for the distance between the two particles in a custombondforce. You might want to call setUsesPeriodicBoundaryConditions(True) on the custombondforce as well, since (if using PBC) the bond distance should be calculated to the nearest image. Confusingly, I would then set periodic=False within the metadynamics call

Code: Select all

distance = BiasVariable(force, minDistance, maxDistance, biasWidth=0.5, periodic=False)
since you don't expect the maximum bond distance to be equivalent to the minimum bond distance.

POST REPLY