11"""Module that defines the AlchemicalState dataclass."""
22
33from dataclasses import dataclass , field
4- from typing import Dict , Optional , Union
4+ from typing import Any , Callable , Dict , List , Optional , Union
55
66import openmm as _mm
77import openmm .app as _app
@@ -29,6 +29,13 @@ class AlchemicalState:
2929 applied to the system to the λ value.
3030 work_dir : str, optional
3131 Directory with the files the creation strategy wrote for this state (None if removed).
32+ parameters : dict, optional
33+ Global-parameter values that define this window when it shares its Context with other
34+ windows (``FES.create_alchemical_states(..., shared_context=True)``).
35+ shared : fes_ml.sampling.SharedContext, optional
36+ The shared Context, or None if the state has a Context of its own.
37+ levers : dict, optional
38+ Callbacks that change lambdas held outside OpenMM (EMLE's calculator), by parameter name.
3239 """
3340
3441 # OpenMM objects
@@ -44,6 +51,16 @@ class AlchemicalState:
4451 # Files written by the creation strategy
4552 work_dir : Optional [str ] = field (repr = False , default = None )
4653
54+ # Windows that share one Context (R3)
55+ parameters : Optional [Dict [str , float ]] = field (repr = False , default = None )
56+ shared : Optional [Any ] = field (repr = False , default = None )
57+ levers : Optional [Dict [str , List [Callable [[float ], None ]]]] = field (repr = False , default = None )
58+
59+ def activate (self ) -> None :
60+ """Make the Context simulate this window (a no-op unless the Context is shared)."""
61+ if self .shared is not None :
62+ self .shared .activate (self )
63+
4764 def check_integrity (self ):
4865 """Check that the state holds OpenMM objects and a modifications dict; raise ``TypeError`` if not."""
4966 if not isinstance (self .system , _mm .System ):
0 commit comments