nonbonded
#
Non-bonded potential energy functions.
Modules:
-
smee
–Differentiably evaluate energies of molecules using SMIRNOFF force fields
Classes:
-
PairwiseDistances
–A container for the pairwise distances between all particles, possibly within
Functions:
-
compute_pairwise_scales
–Returns the scale factor for each pair of particles in the system by
-
compute_pairwise
–Computes all pairwise distances between particles in the system.
-
prepare_lrc_types
–Finds the unique vdW interactions present in a system, ready to use
-
lorentz_berthelot
–Computes the Lorentz-Berthelot combination rules for the given parameters.
-
compute_lj_energy
–Computes the potential energy [kcal / mol] of the vdW interactions using the
-
compute_dexp_energy
–Compute the potential energy [kcal / mol] of the vdW interactions using the
-
compute_coulomb_energy
–Computes the potential energy [kcal / mol] of the electrostatic interactions
PairwiseDistances
#
Bases: NamedTuple
A container for the pairwise distances between all particles, possibly within a given cutoff.
Attributes:
compute_pairwise_scales
#
compute_pairwise_scales(
system: TensorSystem, potential: TensorPotential
) -> Tensor
Returns the scale factor for each pair of particles in the system by broadcasting and stacking the exclusions of each topology.
Parameters:
-
system
(TensorSystem
) –The system.
-
potential
(TensorPotential
) –The potential containing the scale factors to broadcast.
Returns:
-
Tensor
–The scales for each pair of particles as a flattened upper triangular matrix with
shape=(n_particles * (n_particles - 1) / 2,)
.
Source code in smee/potentials/nonbonded.py
compute_pairwise
#
compute_pairwise(
system: TensorSystem,
conformer: Tensor,
box_vectors: Tensor | None,
cutoff: Tensor,
) -> PairwiseDistances
Computes all pairwise distances between particles in the system.
Notes
If the system is not periodic, no cutoff and no PBC will be applied.
Parameters:
-
system
(TensorSystem
) –The system to compute the distances for.
-
conformer
(Tensor
) –The conformer [Å] to evaluate the potential at with
shape=(n_confs, n_particles, 3)
orshape=(n_particles, 3)
. -
box_vectors
(Tensor | None
) –The box vectors [Å] of the system with
shape=(n_confs3, 3)
orshape=(3, 3)
if the system is periodic, orNone
otherwise. -
cutoff
(Tensor
) –The cutoff [Å] to apply for periodic systems.
Returns:
-
PairwiseDistances
–The pairwise distances between each pair of particles within the cutoff.
Source code in smee/potentials/nonbonded.py
prepare_lrc_types
#
prepare_lrc_types(
system: TensorSystem, potential: TensorPotential
) -> tuple[Tensor, Tensor, Tensor]
Finds the unique vdW interactions present in a system, ready to use for computing the long range dispersion correction.
Parameters:
-
system
(TensorSystem
) –The system to prepare the types for.
-
potential
(TensorPotential
) –The potential to prepare the types for.
Returns:
-
tuple[Tensor, Tensor, Tensor]
–Two tensors containing the i and j indices into
potential.paramaters
of each unique interaction parameter excludingi==j
, the number ofii
interactions withshape=(n_params,)
, and the numbers ofij
interactions withshape=(len(idxs_i),)
.
Source code in smee/potentials/nonbonded.py
lorentz_berthelot
#
lorentz_berthelot(
epsilon_a: Tensor,
epsilon_b: Tensor,
sigma_a: Tensor,
sigma_b: Tensor,
) -> tuple[Tensor, Tensor]
Computes the Lorentz-Berthelot combination rules for the given parameters.
Notes
A 'safe' geometric mean is used to avoid NaNs when the parameters are zero. This will yield non-analytic gradients in some cases.
Parameters:
-
epsilon_a
(Tensor
) –The epsilon [kcal / mol] values of the first particle in each pair with
shape=(n_pairs, 1)
. -
epsilon_b
(Tensor
) –The epsilon [kcal / mol] values of the second particle in each pair with
shape=(n_pairs, 1)
. -
sigma_a
(Tensor
) –The sigma [kcal / mol] values of the first particle in each pair with
shape=(n_pairs, 1)
. -
sigma_b
(Tensor
) –The sigma [kcal / mol] values of the second particle in each pair with
shape=(n_pairs, 1)
.
Returns:
-
tuple[Tensor, Tensor]
–The epsilon [kcal / mol] and sigma [Å] values of each pair, each with
shape=(n_pairs, 1)
.
Source code in smee/potentials/nonbonded.py
compute_lj_energy
#
compute_lj_energy(
system: TensorSystem,
potential: TensorPotential,
conformer: Tensor,
box_vectors: Tensor | None = None,
pairwise: PairwiseDistances | None = None,
) -> Tensor
Computes the potential energy [kcal / mol] of the vdW interactions using the standard Lennard-Jones potential.
Notes
- No cutoff / switching function will be applied if the system is not periodic.
- A switching function will only be applied if the potential has a
switch_width
attribute.
Parameters:
-
system
(TensorSystem
) –The system to compute the energy for.
-
potential
(TensorPotential
) –The potential energy function to evaluate.
-
conformer
(Tensor
) –The conformer [Å] to evaluate the potential at with
shape=(n_confs, n_particles, 3)
orshape=(n_particles, 3)
. -
box_vectors
(Tensor | None
, default:None
) –The box vectors [Å] of the system with
shape=(n_confs, 3, 3)
orshape=(3, 3)
if the system is periodic, orNone
otherwise. -
pairwise
(PairwiseDistances | None
, default:None
) –The pre-computed pairwise distances between each pair of particles in the system. If none, these will be computed within the function.
Returns:
-
Tensor
–The computed potential energy [kcal / mol] with
shape=(n_confs,)
if the input conformer has a batch dimension, orshape=()
otherwise.
Source code in smee/potentials/nonbonded.py
423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 |
|
compute_dexp_energy
#
compute_dexp_energy(
system: TensorSystem,
potential: TensorPotential,
conformer: Tensor,
box_vectors: Tensor | None = None,
pairwise: PairwiseDistances | None = None,
) -> Tensor
Compute the potential energy [kcal / mol] of the vdW interactions using the double-exponential potential.
Notes
- No cutoff function will be applied if the system is not periodic.
Parameters:
-
system
(TensorSystem
) –The system to compute the energy for.
-
potential
(TensorPotential
) –The potential energy function to evaluate.
-
conformer
(Tensor
) –The conformer [Å] to evaluate the potential at with
shape=(n_confs, n_particles, 3)
orshape=(n_particles, 3)
. -
box_vectors
(Tensor | None
, default:None
) –The box vectors [Å] of the system with
shape=(n_confs, 3, 3)
orshape=(3, 3)
if the system is periodic, orNone
otherwise. -
pairwise
(PairwiseDistances | None
, default:None
) –Pre-computed distances between each pair of particles in the system.
Returns:
-
Tensor
–The evaluated potential energy [kcal / mol].
Source code in smee/potentials/nonbonded.py
702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 |
|
compute_coulomb_energy
#
compute_coulomb_energy(
system: TensorSystem,
potential: TensorPotential,
conformer: Tensor,
box_vectors: Tensor | None = None,
pairwise: PairwiseDistances | None = None,
) -> Tensor
Computes the potential energy [kcal / mol] of the electrostatic interactions using the Coulomb potential.
Notes
- No cutoff will be applied if the system is not periodic.
- PME will be used to compute the energy if the system is periodic.
Parameters:
-
system
(TensorSystem
) –The system to compute the energy for.
-
potential
(TensorPotential
) –The potential energy function to evaluate.
-
conformer
(Tensor
) –The conformer [Å] to evaluate the potential at with
shape=(n_confs, n_particles, 3)
orshape=(n_particles, 3)
. -
box_vectors
(Tensor | None
, default:None
) –The box vectors [Å] of the system with
shape=(n_confs, 3, 3)
orshape=(3, 3)
if the system is periodic, orNone
otherwise. -
pairwise
(PairwiseDistances | None
, default:None
) –The pre-computed pairwise distances between each pair of particles in the system. If none, these will be computed within the function.
Returns:
-
Tensor
–The computed potential energy [kcal / mol] with
shape=(n_confs,)
if the input conformer has a batch dimension, orshape=()
otherwise.