Skip to content

Commit

Permalink
Revert to 8a827e6
Browse files Browse the repository at this point in the history
  • Loading branch information
loeflerm committed Aug 22, 2024
1 parent 6dab962 commit 1e1f3e7
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 100 deletions.
141 changes: 68 additions & 73 deletions transformato/bin/drude_openmm_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -105,7 +104,6 @@
print("Drude Hard Wall set to {}".format(integrator.getMaxDrudeDistance()))

# TEST: HELLO 2!
# another test

# Set platform
platform = Platform.getPlatformByName("CUDA")
Expand Down Expand Up @@ -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))
14 changes: 0 additions & 14 deletions transformato/bin/init_energies.sh

This file was deleted.

2 changes: 1 addition & 1 deletion transformato/bin/simulation-rsfe.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
12 changes: 0 additions & 12 deletions transformato/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down

0 comments on commit 1e1f3e7

Please sign in to comment.