From 1e1f3e7e0641debc1bfdb06c48c6eedb14aa7b4c Mon Sep 17 00:00:00 2001 From: loeflerm Date: Thu, 22 Aug 2024 16:13:46 +0200 Subject: [PATCH] Revert to 8a827e6 --- transformato/bin/drude_openmm_run.py | 141 +++++++++++++-------------- transformato/bin/init_energies.sh | 14 --- transformato/bin/simulation-rsfe.sh | 2 +- transformato/state.py | 12 --- 4 files changed, 69 insertions(+), 100 deletions(-) delete mode 100644 transformato/bin/init_energies.sh diff --git a/transformato/bin/drude_openmm_run.py b/transformato/bin/drude_openmm_run.py index c114469d..836e7b22 100644 --- a/transformato/bin/drude_openmm_run.py +++ b/transformato/bin/drude_openmm_run.py @@ -20,7 +20,6 @@ parser = argparse.ArgumentParser() parser.add_argument("-odcd", metavar="DCDFILE", dest="odcd") parser.add_argument("-env", metavar="ENVIRONMENT", dest="env") -parser.add_argument("-sim", metavar="SIMULATION", dest="sim", default=True) args = parser.parse_args() # Load parameters @@ -105,7 +104,6 @@ print("Drude Hard Wall set to {}".format(integrator.getMaxDrudeDistance())) # TEST: HELLO 2! -# another test # Set platform platform = Platform.getPlatformByName("CUDA") @@ -154,76 +152,73 @@ print("\nInitial system energy") print(simulation.context.getState(getEnergy=True).getPotentialEnergy()) - -if args.sim.lower() == 'true': - - # Drude VirtualSites - simulation.context.computeVirtualSites() - - # Energy minimization - if inputs.mini_nstep > 0: - print("\nEnergy minimization:") - simulation.minimizeEnergy() - print(simulation.context.getState(getEnergy=True).getPotentialEnergy()) - - # Generate initial velocities - if inputs.gen_vel == "yes": - print("\nGenerate initial velocities") - if inputs.gen_seed: - simulation.context.setVelocitiesToTemperature(inputs.gen_temp, inputs.gen_seed) - else: - simulation.context.setVelocitiesToTemperature(inputs.gen_temp) - - ## Do some additional pre-equilibration when using Drude particles - print("Doing a first equilibration run") - simulation.step(100_000) - - print("Doing a second equilibration run") - simulation.integrator.setStepSize(0.0002 * unit.picoseconds) - simulation.context.reinitialize(preserveState=True) - simulation.step(100_000) - - print("Doing a third equilibration run") - simulation.integrator.setStepSize(0.0003 * unit.picoseconds) - simulation.context.reinitialize(preserveState=True) - simulation.step(100_000) - - print("Doing a fourth equilibration run") - simulation.integrator.setStepSize(0.0004 * unit.picoseconds) - simulation.context.reinitialize(preserveState=True) - simulation.step(100_000) - - print("Starting the actual simulation") - simulation.integrator.setStepSize(inputs.dt * unit.picoseconds) - simulation.context.reinitialize(preserveState=True) - - # Production - print("\nMD run: %s steps" % inputs.nstep) - simulation.reporters.append(DCDReporter(args.odcd, inputs.nstdcd)) - simulation.reporters.append( - StateDataReporter( - sys.stdout, - inputs.nstout, - step=True, - time=True, - potentialEnergy=True, - temperature=True, - progress=True, - remainingTime=True, - speed=True, - totalSteps=inputs.nstep, - separator="\t", - ) +# Drude VirtualSites +simulation.context.computeVirtualSites() + +# Energy minimization +if inputs.mini_nstep > 0: + print("\nEnergy minimization:") + simulation.minimizeEnergy() + print(simulation.context.getState(getEnergy=True).getPotentialEnergy()) + +# Generate initial velocities +if inputs.gen_vel == "yes": + print("\nGenerate initial velocities") + if inputs.gen_seed: + simulation.context.setVelocitiesToTemperature(inputs.gen_temp, inputs.gen_seed) + else: + simulation.context.setVelocitiesToTemperature(inputs.gen_temp) + +## Do some additional pre-equilibration when using Drude particles +print("Doing a first equilibration run") +simulation.step(100_000) + +print("Doing a second equilibration run") +simulation.integrator.setStepSize(0.0002 * unit.picoseconds) +simulation.context.reinitialize(preserveState=True) +simulation.step(100_000) + +print("Doing a third equilibration run") +simulation.integrator.setStepSize(0.0003 * unit.picoseconds) +simulation.context.reinitialize(preserveState=True) +simulation.step(100_000) + +print("Doing a fourth equilibration run") +simulation.integrator.setStepSize(0.0004 * unit.picoseconds) +simulation.context.reinitialize(preserveState=True) +simulation.step(100_000) + +print("Starting the actual simulation") +simulation.integrator.setStepSize(inputs.dt * unit.picoseconds) +simulation.context.reinitialize(preserveState=True) + +# Production +print("\nMD run: %s steps" % inputs.nstep) +simulation.reporters.append(DCDReporter(args.odcd, inputs.nstdcd)) +simulation.reporters.append( + StateDataReporter( + sys.stdout, + inputs.nstout, + step=True, + time=True, + potentialEnergy=True, + temperature=True, + progress=True, + remainingTime=True, + speed=True, + totalSteps=inputs.nstep, + separator="\t", ) +) - simulation.step(inputs.nstep) - - # needed for later analysis - file_name = f"lig_in_{env}" - state = simulation.context.getState(getPositions=True, getVelocities=True) - with open(file_name + ".rst", "w") as f: - f.write(XmlSerializer.serialize(state)) - with open(file_name + "_integrator.xml", "w") as outfile: - outfile.write(XmlSerializer.serialize(integrator)) - with open(file_name + "_system.xml", "w") as outfile: - outfile.write(XmlSerializer.serialize(system)) +simulation.step(inputs.nstep) + +# needed for later analysis +file_name = f"lig_in_{env}" +state = simulation.context.getState(getPositions=True, getVelocities=True) +with open(file_name + ".rst", "w") as f: + f.write(XmlSerializer.serialize(state)) +with open(file_name + "_integrator.xml", "w") as outfile: + outfile.write(XmlSerializer.serialize(integrator)) +with open(file_name + "_system.xml", "w") as outfile: + outfile.write(XmlSerializer.serialize(system)) diff --git a/transformato/bin/init_energies.sh b/transformato/bin/init_energies.sh deleted file mode 100644 index 027e3115..00000000 --- a/transformato/bin/init_energies.sh +++ /dev/null @@ -1,14 +0,0 @@ -path=$1 - -cd ${path} -pwd -hostname - - -istep=lig_in_vacuum -python openmm_run.py -env vacuum -odcd ${istep}.dcd -sim False &> vacuum_init_energies_out.log - -# test - -istep=lig_in_waterbox -python openmm_run.py -env waterbox -odcd ${istep}.dcd -sim False &> waterbox_init_energies_out.log diff --git a/transformato/bin/simulation-rsfe.sh b/transformato/bin/simulation-rsfe.sh index bf03e17f..e799e08f 100644 --- a/transformato/bin/simulation-rsfe.sh +++ b/transformato/bin/simulation-rsfe.sh @@ -12,7 +12,7 @@ hostname istep=lig_in_vacuum python openmm_run.py -env vacuum -odcd ${istep}.dcd &> vacuum_out.log -# test + istep=lig_in_waterbox python openmm_run.py -env waterbox -odcd ${istep}.dcd &> waterbox_out.log diff --git a/transformato/state.py b/transformato/state.py index a82551b7..0026ba40 100644 --- a/transformato/state.py +++ b/transformato/state.py @@ -488,17 +488,6 @@ def _copy_omm_files(self, intermediate_state_file_path: str): shutil.copyfile( omm_simulation_submit_script_source, omm_simulation_submit_script_target ) - omm_init_energies_submit_script_source = ( - f"{self.configuration['bin_dir']}/init_energies.sh" - ) - omm_init_energies_submit_script_target = ( - f"{intermediate_state_file_path}/init_energies.sh" - ) - shutil.copyfile( - omm_init_energies_submit_script_source, - omm_init_energies_submit_script_target, - ) - self._write_workload_preamble(omm_init_energies_submit_script_target) elif self.configuration["simulation"]["free-energy-type"] == "rbfe": # parse omm simulation paramter @@ -524,7 +513,6 @@ def _copy_omm_files(self, intermediate_state_file_path: str): if self.multiple_runs: self._modify_submit_script(omm_simulation_submit_script_target) - self._modify_submit_script(omm_init_energies_submit_script_target) # Prepend workload manager instructions self._write_workload_preamble(omm_simulation_submit_script_target)