diff --git a/tyff/compute/_equilibrate.py b/tyff/compute/_equilibrate.py index 36fac51..c61e273 100644 --- a/tyff/compute/_equilibrate.py +++ b/tyff/compute/_equilibrate.py @@ -5,6 +5,7 @@ from parsl import File +import tyff.mm from tyff.compute._files import ( EquilibrationFiles, MinimizationFiles, @@ -122,18 +123,27 @@ def _run_equilibration( ) ) - dcd_reporter = openmm.app.DCDReporter( - file=files["dcd_trajectory"].filepath, - reportInterval=1000, + simulation.reporters.append( + openmm.app.DCDReporter( + file=files["dcd_trajectory"].filepath, + reportInterval=1000, + ) ) - simulation.reporters.append(dcd_reporter) - simulation.context.setVelocitiesToTemperature( compute_config["temperature"], # kelvin, but as float compute_config["replicate_index"] + 1, ) + simulation.reporters.append( + tyff.mm.TensorReporter( + output_file=files["msgpack_trajectory"].filepath, + report_interval=1000, + beta=1.0 / (openmm.unit.MOLAR_GAS_CONSTANT_R * compute_config["temperature"] * openmm.unit.kelvin), + pressure=pressure * openmm.unit.kilopascal, + ) + ) + logger.info("Running 10,000 steps of MD") detected_platform = simulation.context.getPlatform().getName() diff --git a/tyff/compute/_produce.py b/tyff/compute/_produce.py index 78caec1..12f5bd9 100644 --- a/tyff/compute/_produce.py +++ b/tyff/compute/_produce.py @@ -7,6 +7,7 @@ import openmm.app from parsl import File +import tyff.mm from tyff.compute._files import ( EquilibrationFiles, ProductionFiles, @@ -97,6 +98,11 @@ def _run_production( assert barostat.getDefaultPressure() is not None + pressure = compute_config.get("pressure", None) + + if pressure is None: + raise PressureNotDefinedError("Trying to set up NPT simulation but no pressure defined.") + simulation.context.setVelocitiesToTemperature( compute_config["temperature"], # kelvin, but as float compute_config["replicate_index"] + 1, @@ -117,17 +123,21 @@ def _run_production( ) ) - dcd_reporter = openmm.app.DCDReporter( - file=files["dcd_trajectory"].filepath, - reportInterval=1000, + simulation.reporters.append( + openmm.app.DCDReporter( + file=files["dcd_trajectory"].filepath, + reportInterval=1000, + ) ) - simulation.reporters.append(dcd_reporter) - - pressure = compute_config.get("pressure", None) - - if pressure is None: - raise PressureNotDefinedError("Trying to set up NPT simulation but no pressure defined.") + simulation.reporters.append( + tyff.mm.TensorReporter( + output_file=files["msgpack_trajectory"].filepath, + report_interval=1000, + beta=1.0 / (openmm.unit.MOLAR_GAS_CONSTANT_R * compute_config["temperature"] * openmm.unit.kelvin), + pressure=pressure * openmm.unit.kilopascal, + ) + ) logger.info("Running 100,000 steps of MD")