Skip to content

Commit

Permalink
Add restart flag to equilibration protocols.
Browse files Browse the repository at this point in the history
  • Loading branch information
lohedges committed Nov 15, 2024
1 parent f7e8208 commit 26bd4ec
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 1 deletion.
38 changes: 37 additions & 1 deletion python/BioSimSpace/Protocol/_equilibration.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ def __init__(
thermostat_time_constant=_Types.Time(1, "picosecond"),
report_interval=200,
restart_interval=1000,
restart=False,
restraint=None,
force_constant=10 * _Units.Energy.kcal_per_mol / _Units.Area.angstrom2,
):
Expand Down Expand Up @@ -89,6 +90,9 @@ def __init__(
The frequency at which restart configurations and trajectory
frames are saved. (In integration steps.)
restart : bool
Whether this is a continuation of a previous simulation.
restraint : str, [int]
The type of restraint to perform. This should be one of the
following options:
Expand Down Expand Up @@ -155,6 +159,9 @@ def __init__(
# Set the restart interval.
self.setRestartInterval(restart_interval)

# Set the restart flag.
self.setRestart(restart)

# Set the posistion restraint.
_PositionRestraintMixin.__init__(self, restraint, force_constant)

Expand All @@ -169,7 +176,7 @@ def _get_parm(self):
f"thermostat_time_constant={self._thermostat_time_constant}, "
f"report_interval={self._report_interval}, "
f"restart_interval={self._restart_interval}, "
+ _PositionRestraintMixin._get_parm(self)
f"restart={self._restart}, " + _PositionRestraintMixin._get_parm(self)
)

def __str__(self):
Expand Down Expand Up @@ -204,6 +211,7 @@ def __eq__(self, other):
and self._thermostat_time_constant == other._thermostat_time_constant
and self._report_interval == other._report_interval
and self._restart_interval == other._restart_interval
and self._restart == other._restart
and _PositionRestraintMixin.__eq__(self, other)
)

Expand Down Expand Up @@ -484,6 +492,34 @@ def setRestartInterval(self, restart_interval):

self._restart_interval = restart_interval

def isRestart(self):
"""
Return whether this restart simulation.
Returns
-------
is_restart : bool
Whether this is a restart simulation.
"""
return self._restart

def setRestart(self, restart):
"""
Set the restart flag.
Parameters
----------
restart : bool
Whether this is a restart simulation.
"""
if isinstance(restart, bool):
self._restart = restart
else:
_warnings.warn("Non-boolean restart flag. Defaulting to False!")
self._restart = False

def isConstantTemp(self):
"""
Return whether the protocol has a constant temperature.
Expand Down
5 changes: 5 additions & 0 deletions python/BioSimSpace/Protocol/_free_energy_equilibration.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ def __init__(
thermostat_time_constant=_Types.Time(1, "picosecond"),
report_interval=200,
restart_interval=1000,
restart=False,
restraint=None,
force_constant=10 * _Units.Energy.kcal_per_mol / _Units.Area.angstrom2,
perturbation_type="full",
Expand Down Expand Up @@ -106,6 +107,9 @@ def __init__(
The frequency at which restart configurations and trajectory
frames are saved. (In integration steps.)
restart : bool
Whether this is a continuation of a previous simulation.
restraint : str, [int]
The type of restraint to perform. This should be one of the
following options:
Expand Down Expand Up @@ -217,4 +221,5 @@ def _to_regular_protocol(self):
restart_interval=self.getRestartInterval(),
restraint=self.getRestraint(),
force_constant=self.getForceConstant(),
restart=self.isRestart(),
)

0 comments on commit 26bd4ec

Please sign in to comment.