From d07dd403e0c208a32ba4865d8aa91cea762d173b Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 25 Jan 2026 16:51:50 +0000 Subject: [PATCH] Fix integrator context warning in energy breakdown computation Create a new LangevinIntegrator when recreating the simulation for force group energy breakdown, since the original integrator is already bound to the first simulation's context. --- src/graphrelax/relaxer.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/graphrelax/relaxer.py b/src/graphrelax/relaxer.py index 3407ef3..6bb4357 100644 --- a/src/graphrelax/relaxer.py +++ b/src/graphrelax/relaxer.py @@ -449,7 +449,9 @@ def get_energy_breakdown(self, pdb_string: str) -> dict: # Set this force to group i force.setForceGroup(i) - # Recreate simulation with force groups + # Recreate simulation with force groups (need new integrator since + # the previous one is already bound to a context) + integrator = openmm.LangevinIntegrator(0, 0.01, 0.0) simulation = openmm_app.Simulation( pdb.topology, system, integrator, platform )