MetaCVWriter¶
- class cvpack.reporting.MetaCVWriter(metaCV, values=(), emasses=(), parameters=(), derivatives=(), allowReinitialization=False)[source]¶
A custom writer for reporting meta-collective variable data.
- Parameters:
metaCV (MetaCollectiveVariable) – The meta-collective variable whose associated values will be reported.
values (Sequence[str]) – The names of the inner variables whose values will be reported.
emasses (Sequence[str]) – The names of the inner variables whose effective masses will be reported.
parameters (Sequence[str]) – The names of the parameters whose values will be reported.
derivatives (Sequence[str]) – The names of the parameters with respect to which the derivatives of the meta-collective variable will be reported.
allowReinitialization (bool) – Whether to allow context reinitialization when the meta-collective variable shares its force group with other forces (needed for derivatives only).
- Raises:
ValueError – If any name does not match an inner variable or a parameter
Examples
>>> import cvpack >>> import openmm >>> from math import pi >>> from cvpack.reporting import StateDataReporter, MetaCVWriter >>> from openmm import app, unit >>> from sys import stdout >>> from openmmtools import testsystems >>> model = testsystems.AlanineDipeptideVacuum() >>> phi = cvpack.Torsion(4, 6, 8, 14, name="phi") >>> psi = cvpack.Torsion(6, 8, 14, 16, name="psi") >>> umbrella = cvpack.MetaCollectiveVariable( ... f"0.5*kappa*(min(dphi,{2*pi}-dphi)^2+min(dpsi,{2*pi}-dpsi)^2)" ... "; dphi=abs(phi-phi0); dpsi=abs(psi-psi0)", ... [phi, psi], ... unit.kilojoules_per_mole, ... name="umbrella", ... kappa=100 * unit.kilojoules_per_mole/unit.radian**2, ... phi0=5*pi/6 * unit.radian, ... psi0=-5*pi/6 * unit.radian, ... ) >>> reporter = StateDataReporter( ... stdout, ... 100, ... writers=[ ... MetaCVWriter( ... umbrella, ... values=["phi", "psi"], ... emasses=["phi", "psi"], ... parameters=["phi0", "psi0"], ... derivatives=["phi0", "psi0"], ... ), ... ], ... step=True, ... ) >>> integrator = openmm.LangevinIntegrator( ... 300 * unit.kelvin, ... 1 / unit.picosecond, ... 2 * unit.femtosecond, ... ) >>> integrator.setRandomNumberSeed(1234) >>> umbrella.addToSystem(model.system) >>> simulation = app.Simulation(model.topology, model.system, integrator) >>> simulation.context.setPositions(model.positions) >>> simulation.context.setVelocitiesToTemperature(300 * unit.kelvin, 5678) >>> simulation.reporters.append(reporter) >>> simulation.step(1000) #"Step","phi (rad)",...,"d[umbrella]/d[psi0] (kJ/(mol rad))" 100,2.6766...,-20.519... 200,2.3694...,0.7804... 300,3.1342...,49.272... 400,2.8179...,-10.012... 500,2.7565...,-8.9529... 600,2.6956...,23.049... 700,2.9331...,25.068... 800,2.6988...,-0.4481... 900,2.7477...,9.5528... 1000,2.7744...,21.986...
Methods
- getValues(simulation)[source]¶
Gets a list of floats containing the values to be added to the report.
- Parameters:
simulation (Simulation) – The simulation object.
- Return type: