Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP -- intuitive handling of minimization steps kwarg #1141

Draft
wants to merge 1 commit into
base: 0.10.x
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion perses/dispersed/feptasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,6 @@ def check_EquilibriumFEPTask(task):

def minimize(thermodynamic_state: states.ThermodynamicState, sampler_state: states.SamplerState,
max_iterations: int=100) -> states.SamplerState:
# TODO: set max iterations to 1000 and check tyk2 benchmarks
"""
Minimize the given system and state, up to a maximum number of steps.
This does not return a copy of the samplerstate; it is an update-in-place.
Expand Down Expand Up @@ -687,6 +686,9 @@ def minimize(thermodynamic_state: states.ThermodynamicState, sampler_state: stat
context, integrator = cache.global_context_cache.get_context(thermodynamic_state)
sampler_state.apply_to_context(context, ignore_velocities = True)
# TODO: Set logging for minimization
# If max_iterations = None, it means run as many iterations as needed to reach tolerance.
if max_iterations is None:
max_iterations = 0
openmm.LocalEnergyMinimizer.minimize(context, maxIterations = max_iterations)
sampler_state.update_from_context(context)

Expand Down
5 changes: 3 additions & 2 deletions perses/samplers/multistate.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def setup(self, n_states, temperature, storage_file, minimisation_steps=100,
sampler_state = SamplerState(positions, box_vectors=hybrid_system.getDefaultPeriodicBoxVectors())

for lambda_val in lambda_schedule:
# Create a compound thermodynamic for lambda_val and set alchemical parameters
# Create a compound thermodynamic for lambda_val and set alchemical parameters
compound_thermodynamic_state_copy = copy.deepcopy(compound_thermodynamic_state)
if factory_name == 'HybridTopologyFactory':
compound_thermodynamic_state_copy.set_alchemical_parameters(lambda_val,lambda_protocol)
Expand All @@ -93,7 +93,8 @@ def setup(self, n_states, temperature, storage_file, minimisation_steps=100,
thermodynamic_state_list.append(compound_thermodynamic_state_copy)

# Generate a sampler_state for each thermodynamic state
feptasks.minimize(compound_thermodynamic_state_copy, sampler_state, max_iterations=minimisation_steps)
if minimisation_steps != 0: # only minimize if there are specified steps != 0
feptasks.minimize(compound_thermodynamic_state_copy, sampler_state, max_iterations=minimisation_steps)
sampler_state_list.append(copy.deepcopy(sampler_state))

reporter = storage_file
Expand Down