mm
#
Compute differentiable ensemble averages using OpenMM and SMEE.
Classes:
-
GenerateCoordsConfig
–Configure how coordinates should be generated for a system using PACKMOL.
-
MinimizationConfig
–Configure how a system should be energy minimized.
-
SimulationConfig
– -
NotEnoughSamplesError
–An error raised when an ensemble average is attempted with too few samples.
-
TensorReporter
–A reporter which stores coords, box vectors, reduced potentials and kinetic
Functions:
-
generate_dg_solv_data
–Run a solvation free energy calculation using
absolv
, and saves the output -
generate_system_coords
–Generate coordinates for a system of molecules using PACKMOL.
-
simulate
–Simulate a SMEE system of molecules or topology.
-
compute_dg_solv
–Computes ∆G_solv from existing FEP data.
-
compute_ensemble_averages
–Compute ensemble average of the potential energy, volume, density,
-
reweight_dg_solv
–Computes ∆G_solv by re-weighting existing FEP data.
-
reweight_ensemble_averages
–Compute the ensemble average of the potential energy, volume, density,
-
tensor_reporter
–Create a
TensorReporter
capable of writing frames to a file. -
unpack_frames
–Unpack frames saved by a
TensorReporter
.
GenerateCoordsConfig
pydantic-model
#
Bases: BaseModel
Configure how coordinates should be generated for a system using PACKMOL.
Fields:
-
target_density
(OpenMMQuantity[_GRAMS_PER_ML]
) -
scale_factor
(float
) -
padding
(OpenMMQuantity[angstrom]
) -
tolerance
(OpenMMQuantity[angstrom]
) -
seed
(int | None
)
target_density
pydantic-field
#
Target mass density for final system with units compatible with g / mL.
scale_factor
pydantic-field
#
The amount to scale the approximate box size by to help alleviate issues with packing larger molecules.
padding
pydantic-field
#
The amount of padding to add to the final box size to help alleviate PBC issues.
tolerance
pydantic-field
#
The minimum spacing between molecules during packing.
seed
pydantic-field
#
The random seed to use when generating the coordinates.
MinimizationConfig
pydantic-model
#
Bases: BaseModel
Configure how a system should be energy minimized.
Fields:
-
tolerance
(OpenMMQuantity[_KCAL_PER_MOL / _ANGSTROM]
) -
max_iterations
(int
)
SimulationConfig
pydantic-model
#
Bases: BaseModel
Fields:
-
temperature
(OpenMMQuantity[kelvin]
) -
pressure
(OpenMMQuantity[atmospheres] | None
) -
n_steps
(int
) -
timestep
(OpenMMQuantity[femtoseconds]
) -
friction_coeff
(OpenMMQuantity[1.0 / picoseconds]
)
NotEnoughSamplesError
#
Bases: ValueError
An error raised when an ensemble average is attempted with too few samples.
TensorReporter
#
TensorReporter(
output_file: BinaryIO,
report_interval: int,
beta: Quantity,
pressure: Quantity | None,
)
A reporter which stores coords, box vectors, reduced potentials and kinetic energy using msgpack.
report_interval: The interval (in steps) at which to write frames.
beta: The inverse temperature the simulation is being run at.
pressure: The pressure the simulation is being run at, or None if NVT /
vacuum.
Source code in smee/mm/_reporters.py
generate_dg_solv_data
#
generate_dg_solv_data(
solute: TensorTopology,
solvent_a: TensorTopology | None,
solvent_b: TensorTopology | None,
force_field: TensorForceField,
temperature: Quantity = 298.15 * kelvin,
pressure: Quantity = 1.0 * atmosphere,
solvent_a_protocol: Optional[
EquilibriumProtocol
] = None,
solvent_b_protocol: Optional[
EquilibriumProtocol
] = None,
n_solvent_a: int = 216,
n_solvent_b: int = 216,
output_dir: Path | None = None,
)
Run a solvation free energy calculation using absolv
, and saves the output
such that a differentiable free energy can be computed.
The free energy will correspond to the free energy of transferring a solute from solvent A to solvent B.
Parameters:
-
solute
(TensorTopology
) –The solute topology.
-
solvent_a
(TensorTopology | None
) –The topology of solvent A, or
None
if solvent A is vacuum. -
solvent_b
(TensorTopology | None
) –The topology of solvent B, or
None
if solvent B is vacuum. -
force_field
(TensorForceField
) –The force field to parameterize the system with.
-
temperature
(Quantity
, default:298.15 * kelvin
) –The temperature to simulate at.
-
pressure
(Quantity
, default:1.0 * atmosphere
) –The pressure to simulate at.
-
solvent_a_protocol
(Optional[EquilibriumProtocol]
, default:None
) –The protocol to use to decouple the solute in solvent A.
-
solvent_b_protocol
(Optional[EquilibriumProtocol]
, default:None
) –The protocol to use to decouple the solute in solvent B.
-
n_solvent_a
(int
, default:216
) –The number of solvent A molecules to use.
-
n_solvent_b
(int
, default:216
) –The number of solvent B molecules to use.
-
output_dir
(Path | None
, default:None
) –The directory to write the output FEP data to.
Source code in smee/mm/_fe.py
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 |
|
generate_system_coords
#
generate_system_coords(
system: TensorSystem,
force_field: TensorForceField | None,
config: Optional[GenerateCoordsConfig] = None,
) -> tuple[Quantity, Quantity]
Generate coordinates for a system of molecules using PACKMOL.
Parameters:
-
system
(TensorSystem
) –The system to generate coordinates for.
-
force_field
(TensorForceField | None
) –The force field that describes the geometry of any virtual sites.
-
config
(Optional[GenerateCoordsConfig]
, default:None
) –Configuration of how to generate the system coordinates.
Returns:
-
tuple[Quantity, Quantity]
–The coordinates with
shape=(n_atoms, 3)
and box vectors withshape=(3, 3)
Source code in smee/mm/_mm.py
simulate
#
simulate(
system: TensorSystem | TensorTopology,
force_field: TensorForceField,
coords: Quantity,
box_vectors: Quantity | None,
equilibrate_configs: list[
Union[MinimizationConfig, SimulationConfig]
],
production_config: SimulationConfig,
production_reporters: list[Any] | None = None,
apply_hmr: bool = False,
) -> State
Simulate a SMEE system of molecules or topology.
Parameters:
-
system
(TensorSystem | TensorTopology
) –The system / topology to simulate.
-
force_field
(TensorForceField
) –The force field to simulate with.
-
coords
(Quantity
) –The coordinates [Å] to use for the simulation. This should be a unit wrapped numpy array with
shape=(n_atoms, 3)
. -
box_vectors
(Quantity | None
) –The box vectors [Å] to use for the simulation if periodic. This should be a unit wrapped numpy array with
shape=(3, 3)
. -
equilibrate_configs
(list[Union[MinimizationConfig, SimulationConfig]]
) –A list of configurations defining the steps to run for equilibration. No data will be stored from these simulations.
-
production_config
(SimulationConfig
) –The configuration defining the production simulation to run.
-
production_reporters
(list[Any] | None
, default:None
) –A list of additional OpenMM reporters to use for the production simulation.
-
apply_hmr
(bool
, default:False
) –Whether to apply Hydrogen Mass Repartitioning to the system prior to simulation.
Source code in smee/mm/_mm.py
327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 |
|
compute_dg_solv
#
compute_dg_solv(
force_field: TensorForceField, fep_dir: Path
) -> Tensor
Computes ∆G_solv from existing FEP data.
Notes
It is assumed that FEP data was generated using the same force field as
force_field
, and using generate_dg_solv_data
Parameters:
-
force_field
(TensorForceField
) –The force field used to generate the FEP data.
-
fep_dir
(Path
) –The directory containing the FEP data.
Returns:
-
Tensor
–∆G_solv [kcal/mol].
Source code in smee/mm/_ops.py
compute_ensemble_averages
#
compute_ensemble_averages(
system: TensorSystem,
force_field: TensorForceField,
frames_path: Path,
temperature: Quantity,
pressure: Quantity | None,
) -> tuple[dict[str, Tensor], dict[str, Tensor]]
Compute ensemble average of the potential energy, volume, density, and enthalpy (if running NPT) over an MD trajectory.
Parameters:
-
system
(TensorSystem
) –The system to simulate.
-
force_field
(TensorForceField
) –The force field to use.
-
frames_path
(Path
) –The path to the trajectory to compute the average over.
-
temperature
(Quantity
) –The temperature that the trajectory was simulated at.
-
pressure
(Quantity | None
) –The pressure that the trajectory was simulated at.
Returns:
-
tuple[dict[str, Tensor], dict[str, Tensor]]
–A dictionary containing the ensemble averages of the potential energy [kcal/mol], volume [Å^3], density [g/mL], and enthalpy [kcal/mol], and a dictionary containing their standard deviations.
Source code in smee/mm/_ops.py
reweight_dg_solv
#
reweight_dg_solv(
force_field: TensorForceField,
fep_dir: Path,
dg_0: Tensor,
min_samples: int = 50,
) -> tuple[Tensor, float]
Computes ∆G_solv by re-weighting existing FEP data.
Notes
It is assumed that FEP data was generated using generate_dg_solv_data
.
Parameters:
-
force_field
(TensorForceField
) –The force field to reweight to.
-
fep_dir
(Path
) –The directory containing the FEP data.
-
dg_0
(Tensor
) –∆G_solv [kcal/mol] computed with the force field used to generate the FEP data.
-
min_samples
(int
, default:50
) –The minimum number of effective samples required to re-weight.
Raises:
-
NotEnoughSamplesError
–If the number of effective samples is less than
min_samples
.
Returns:
-
tuple[Tensor, float]
–The re-weighted ∆G_solv [kcal/mol], and the minimum number of effective samples between the two phases.
Source code in smee/mm/_ops.py
reweight_ensemble_averages
#
reweight_ensemble_averages(
system: TensorSystem,
force_field: TensorForceField,
frames_path: Path,
temperature: Quantity,
pressure: Quantity | None,
min_samples: int = 50,
) -> dict[str, Tensor]
Compute the ensemble average of the potential energy, volume, density, and enthalpy (if running NPT) by re-weighting an existing MD trajectory.
Parameters:
-
system
(TensorSystem
) –The system that was simulated.
-
force_field
(TensorForceField
) –The new force field to use.
-
frames_path
(Path
) –The path to the trajectory to compute the average over.
-
temperature
(Quantity
) –The temperature that the trajectory was simulated at.
-
pressure
(Quantity | None
) –The pressure that the trajectory was simulated at.
-
min_samples
(int
, default:50
) –The minimum number of samples required to compute the average.
Raises:
-
NotEnoughSamplesError
–If the number of effective samples is less than
min_samples
.
Returns:
-
dict[str, Tensor]
–A dictionary containing the ensemble averages of the potential energy [kcal/mol], volume [Å^3], density [g/mL], and enthalpy [kcal/mol].
Source code in smee/mm/_ops.py
tensor_reporter
#
tensor_reporter(
output_path: PathLike,
report_interval: int,
beta: Quantity,
pressure: Quantity | None,
) -> TensorReporter
Create a TensorReporter
capable of writing frames to a file.
Parameters:
-
output_path
(PathLike
) –The path to write the frames to.
-
report_interval
(int
) –The interval (in steps) at which to write frames.
-
beta
(Quantity
) –The inverse temperature the simulation is being run at.
-
pressure
(Quantity | None
) –The pressure the simulation is being run at, or
None
if NVT / vacuum.
Source code in smee/mm/_reporters.py
unpack_frames
#
Unpack frames saved by a TensorReporter
.