Skip to content

Commit

Permalink
Fix use of totalSteps in OpenMM StateDataReporter.
Browse files Browse the repository at this point in the history
[closes #144] [closes #145]
  • Loading branch information
lohedges committed Aug 1, 2023
1 parent 10d39ec commit 86244be
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
7 changes: 6 additions & 1 deletion python/BioSimSpace/Process/_openmm.py
Original file line number Diff line number Diff line change
Expand Up @@ -2083,6 +2083,11 @@ def _add_config_reporters(
is_time = True
is_temperature = True

# Work out the total number of steps.
total_steps = _math.ceil(
self._protocol.getRunTime() / self._protocol.getTimeStep()
)

# Write state information to file every 100 steps.
self.addToConfig(f"log_file = open('{self._name}.log', 'a')")
self.addToConfig(f"simulation.reporters.append(StateDataReporter(log_file,")
Expand All @@ -2109,7 +2114,7 @@ def _add_config_reporters(
)
self.addToConfig(" volume=True,")
self.addToConfig(
" totalSteps=True,"
f" totalSteps={total_steps},"
)
self.addToConfig(" speed=True,")
self.addToConfig(
Expand Down
7 changes: 6 additions & 1 deletion python/BioSimSpace/Sandpit/Exscientia/Process/_openmm.py
Original file line number Diff line number Diff line change
Expand Up @@ -2123,6 +2123,11 @@ def _add_config_reporters(
is_time = True
is_temperature = True

# Work out the total number of steps.
total_steps = _math.ceil(
self._protocol.getRunTime() / self._protocol.getTimeStep()
)

# Write state information to file every 100 steps.
self.addToConfig(f"log_file = open('{self._name}.log', 'a')")
self.addToConfig(f"simulation.reporters.append(StateDataReporter(log_file,")
Expand All @@ -2149,7 +2154,7 @@ def _add_config_reporters(
)
self.addToConfig(" volume=True,")
self.addToConfig(
" totalSteps=True,"
f" totalSteps={total_steps},"
)
self.addToConfig(" speed=True,")
self.addToConfig(
Expand Down

0 comments on commit 86244be

Please sign in to comment.