CVWriter¶
- class cvpack.reporting.CVWriter(variable, value=False, emass=False, allowReinitialization=False)[source]¶
A custom writer for reporting collective variable data.
- Parameters:
variable (CollectiveVariable) – The collective variable whose values and/or effective masses will be reported.
value (bool) – If True, report the values of the collective variable.
emass (bool) – If True, report the effective masses of the collective variable.
allowReinitialization (bool) – Whether to allow context reinitialization when the collective variable shares its force group with other forces (see
CollectiveVariable.getValue()).
Examples
>>> import cvpack >>> import openmm >>> from cvpack.reporting import StateDataReporter, CVWriter >>> from math import pi >>> 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") >>> phi.addToSystem(model.system) >>> psi = cvpack.Torsion(6, 8, 14, 16, name="psi") >>> psi.addToSystem(model.system) >>> reporter = StateDataReporter( ... stdout, ... 100, ... writers=[ ... CVWriter(phi, value=True, emass=True), ... CVWriter(psi, value=True, emass=True), ... ], ... step=True, ... ) >>> integrator = openmm.LangevinIntegrator( ... 300 * unit.kelvin, ... 1 / unit.picosecond, ... 2 * unit.femtosecond, ... ) >>> integrator.setRandomNumberSeed(1234) >>> # Integrate only the physical forces, so phi and psi do not bias the dynamics >>> integrator.setIntegrationForceGroups({0}) >>> 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)",...,"emass[psi] (nm**2 Da/(rad**2))" 100,-2.4309...,0.0404...,2.7368...,0.0497... 200,-2.0470...,0.0386...,2.2298...,0.0456... 300,-2.4721...,0.0424...,2.2528...,0.0422... 400,-2.4032...,0.0406...,-3.1341...,0.0546... 500,-2.8165...,0.0460...,-2.5845...,0.0458... 600,-2.6256...,0.0401...,3.1382...,0.0509... 700,-2.4156...,0.0463...,2.1037...,0.0406... 800,-2.3871...,0.0372...,1.8683...,0.0408... 900,-1.8631...,0.0322...,2.0393...,0.0374... 1000,-1.0804...,0.0240...,1.8363...,0.0354...
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: