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.
-
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_system_coords
–Generate coordinates for a system of molecules using PACKMOL.
-
simulate
–Simulate a SMEE system of molecules or topology.
-
compute_ensemble_averages
–Compute ensemble average of the potential energy, volume, density,
-
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.
MinimizationConfig
pydantic-model
#
Bases: BaseModel
Configure how a system should be energy minimized.
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_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
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 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 |
|
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_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
.