ExtendedSpaceMetadynamics¶
- class openxps.ExtendedSpaceMetadynamics(system, variables, temperature, biasFactor, height, frequency, saveFrequency=None, biasDir=None)[source]¶
Performs Extended Phase-Space (XPS) Metadynamics simulations, in which a bias potential is applied to dynamical variables (DVs) to enhance sampling of the physical coordinates.
- Parameters:
system (ExtendedSpaceSystem) – The
ExtendedSpaceSystemto be used in the XPS simulation.variables (Sequence[ExtendedSpaceBiasVariable]) – A sequence of
ExtendedSpaceBiasVariableobjects to specify the biased dynamical variables and their corresponding Gaussian kernels.temperature (Quantity) – The temperature at which the simulation is being run. This is used in computing the free energy.
biasFactor (float) – Used in scaling the height of the Gaussians added to the bias. The dynamical variables are sampled as if the effective temperature of the simulation were temperature*biasFactor.
height (Quantity) – The initial height of the Gaussians to add (in units of energy).
frequency (int) – The interval in time steps at which Gaussians should be added to the bias potential.
saveFrequency (int | None) – The interval in time steps at which to write out the current biases to disk. At the same time it writes biases, it also checks for updated biases written by other processes and loads them in. This must be a multiple of frequency.
biasDir (str | None) – The directory to which biases should be written, and from which biases written by other processes should be loaded.
note:: (..) – The bias is stored on a grid spanning the bounds of each dynamical variable, so variables with
NoBoundsare rejected. UseReflectiveBoundsover the range the variable may explore instead. If the variable never reaches the walls, the reflections never act, and if it does, the coupling turns them into soft walls on the physical system.note:: – Periodic and reflective variables can be mixed. A reflective variable is tabulated as a periodic one of twice its range, holding the bias and its mirror image, which makes the interpolated bias exactly flat at the walls. This doubles the table along each reflective axis.
note:: – The bias force is added to the extension system of
systemwhen this object is created, so it must be created before theExtendedSpaceSimulationorExtendedSpaceContextthat uses the system.
Example
>>> import openxps as xps >>> from openmm import unit >>> import cvpack >>> from math import pi >>> import openmm >>> from openmmtools import testsystems >>> model = testsystems.AlanineDipeptideVacuum() >>> phi = cvpack.Torsion(6, 8, 14, 16, name="phi") >>> mass = 3 * unit.dalton*(unit.nanometer/unit.radian)**2 >>> phi0 = xps.DynamicalVariable("phi0", unit.radian, mass, xps.CircularBounds()) >>> phi = cvpack.Torsion(6, 8, 14, 16, name="phi") >>> kappa = 1000 * unit.kilojoules_per_mole / unit.radian**2 >>> harmonic_force = xps.HarmonicCoupling(phi, phi0, kappa) >>> system = xps.ExtendedSpaceSystem(model.system, harmonic_force) >>> bias_variable = xps.ExtendedSpaceBiasVariable(phi0, 18 * unit.degrees) >>> temperature = 300 * unit.kelvin >>> metadynamics = xps.ExtendedSpaceMetadynamics( ... system=system, ... variables=[bias_variable], ... temperature=temperature, ... biasFactor=5, ... height=2 * unit.kilojoule_per_mole, ... frequency=100, ... ) >>> simulation = xps.ExtendedSpaceSimulation( ... model.topology, ... system, ... xps.LockstepIntegrator( ... openmm.LangevinMiddleIntegrator( ... temperature, 1 / unit.picosecond, 4 * unit.femtosecond ... ) ... ), ... openmm.Platform.getPlatformByName("Reference"), ... ) >>> context = simulation.context >>> context.setPositions(model.positions) >>> context.setVelocitiesToTemperature(temperature, 1234) >>> context.setDynamicalVariableValues([180 * unit.degree]) >>> context.setDynamicalVariableVelocitiesToTemperature(temperature, 1234) >>> metadynamics.step(simulation, 100) >>> print(metadynamics.getFreeEnergy()) [...] kJ/mol
Methods