Alchemical groups and dependencies¶
Groups¶
A group is a named set of alchemical atoms with its own λ values. Declare the atoms of each group once, as a dictionary, and add the group name after a colon in the schedule keys:
alchemical_atoms = {
"ligand1": [1, 2, 3, 4, 5],
"ligand2": [20, 21, 22, 23, 24],
"cofactor": [40, 41, 42, 43],
}
lambda_schedule = {
"LJSoftCore:ligand1": [1.0, 0.8, 0.6, 0.4, 0.2, 0.0, 0.0, 0.0],
"ChargeScaling:ligand1": [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.5, 0.0],
"LJSoftCore:ligand2": [1.0, 1.0, 0.8, 0.6, 0.4, 0.2, 0.0, 0.0],
"ChargeScaling:ligand2": [1.0, 1.0, 1.0, 1.0, 1.0, 0.5, 0.33, 0.0],
"MLInterpolation:cofactor": [0.0, 0.0, 0.0, 0.2, 0.4, 0.6, 0.8, 1.0],
}
Rules:
- A plain list of atoms is the
defaultgroup; a schedule key without a group ("LJSoftCore") means"LJSoftCore:default". Every group used in the schedule must be declared. - Groups are either identical or disjoint, and one kind of modification cannot act on the same atom in two groups.
- Interactions between two decoupled groups are scaled by the product of their λ values:
ChargeScalinggives this for Coulomb, andLJSoftCoreuses softcore LJ atλ_a · λ_b. Interactions with the rest of the system use each group's own λ. - Each ML group has its own ML forces and its own global parameter,
lambda_interpolate_<group>. modifications_kwargsis looked up byName:groupfirst, then byName.
Dependencies¶
Each modification class declares how it relates to others:
| Attribute | Meaning |
|---|---|
pre_dependencies |
modifications that must be applied before this one; added automatically |
post_dependencies |
modifications that must be applied after this one; added automatically |
excludes |
modifications that must not be applied to this group, even if another one requires them |
phase |
stage used to order modifications that have no dependency between them |
requires_lambda |
the modification needs a λ value; a missing one raises ValueError before anything is applied |
inputs |
keyword arguments the creation strategy provides, such as topology |
A dependency belongs to the group of the modification that requires it and acts on the same atoms
(for example IntraMolecularNonBondedForces:ligand1 for LJSoftCore:ligand1). If several
modifications require it with the same atoms, it is applied once.
Modifications are applied in topological order of this graph. Ties are broken by phase, then by name, so the result does not depend on the order of the schedule keys or on the group names:
| Phase | What happens |
|---|---|
PREPARE |
read the unmodified system (copy the intramolecular nonbonded terms) |
PARAMETERS |
change nonbonded parameters or add nonbonded forces |
POTENTIALS |
add ML or embedding potentials |
INTERPOLATION |
combine forces into collective variables |
CLEANUP |
remove the terms that other modifications replaced |
To see the graph for a schedule:
from fes_ml.alchemical import Alchemist
alchemist = Alchemist()
alchemist.create_alchemical_graph({"LJSoftCore": 0.5, "MLInterpolation": 0.5})
print(alchemist.application_order())