Skip to content

valence #

Valence potential energy functions.

Functions:

compute_harmonic_bond_energy #

compute_harmonic_bond_energy(
    system: TensorSystem,
    potential: TensorPotential,
    conformer: Tensor,
) -> Tensor

Compute the potential energy [kcal / mol] of a set of bonds for a given conformer using a harmonic potential of the form 1/2 * k * (r - length) ** 2

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) or shape=(n_particles, 3).

Returns:

  • Tensor

    The computed potential energy [kcal / mol].

Source code in smee/potentials/valence.py
@smee.potentials.potential_energy_fn(
    smee.PotentialType.BONDS, smee.EnergyFn.BOND_HARMONIC
)
def compute_harmonic_bond_energy(
    system: smee.TensorSystem,
    potential: smee.TensorPotential,
    conformer: torch.Tensor,
) -> torch.Tensor:
    """Compute the potential energy [kcal / mol] of a set of bonds for a given
    conformer using a harmonic potential of the form ``1/2 * k * (r - length) ** 2``

    Args:
        system: The system to compute the energy for.
        potential: The potential energy function to evaluate.
        conformer: The conformer [Å] to evaluate the potential at with
            ``shape=(n_confs, n_particles, 3)`` or ``shape=(n_particles, 3)``.

    Returns:
        The computed potential energy [kcal / mol].
    """

    parameters = smee.potentials.broadcast_parameters(system, potential)
    particle_idxs = smee.potentials.broadcast_idxs(system, potential)

    _, distances = smee.geometry.compute_bond_vectors(conformer, particle_idxs)

    k = parameters[:, potential.parameter_cols.index("k")]
    length = parameters[:, potential.parameter_cols.index("length")]

    return (0.5 * k * (distances - length) ** 2).sum(-1)

compute_harmonic_angle_energy #

compute_harmonic_angle_energy(
    system: TensorSystem,
    potential: TensorPotential,
    conformer: Tensor,
) -> Tensor

Compute the potential energy [kcal / mol] of a set of valence angles for a given conformer using a harmonic potential of the form 1/2 * k * (theta - angle) ** 2

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) or shape=(n_particles, 3).

Returns:

  • Tensor

    The computed potential energy [kcal / mol].

Source code in smee/potentials/valence.py
@smee.potentials.potential_energy_fn(
    smee.PotentialType.ANGLES, smee.EnergyFn.ANGLE_HARMONIC
)
def compute_harmonic_angle_energy(
    system: smee.TensorSystem,
    potential: smee.TensorPotential,
    conformer: torch.Tensor,
) -> torch.Tensor:
    """Compute the potential energy [kcal / mol] of a set of valence angles for a given
    conformer using a harmonic potential of the form ``1/2 * k * (theta - angle) ** 2``

    Args:
        system: The system to compute the energy for.
        potential: The potential energy function to evaluate.
        conformer: The conformer [Å] to evaluate the potential at with
            ``shape=(n_confs, n_particles, 3)`` or ``shape=(n_particles, 3)``.

    Returns:
        The computed potential energy [kcal / mol].
    """

    parameters = smee.potentials.broadcast_parameters(system, potential)
    particle_idxs = smee.potentials.broadcast_idxs(system, potential)

    theta = smee.geometry.compute_angles(conformer, particle_idxs)

    k = parameters[:, potential.parameter_cols.index("k")]
    angle = parameters[:, potential.parameter_cols.index("angle")]

    return (0.5 * k * (theta - angle) ** 2).sum(-1)

compute_cosine_proper_torsion_energy #

compute_cosine_proper_torsion_energy(
    system: TensorSystem,
    potential: TensorPotential,
    conformer: Tensor,
) -> Tensor

Compute the potential energy [kcal / mol] of a set of proper torsions for a given conformer using a cosine potential of the form:

k*(1+cos(periodicity*theta-phase))

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) or shape=(n_particles, 3).

Returns:

  • Tensor

    The computed potential energy [kcal / mol].

Source code in smee/potentials/valence.py
@smee.potentials.potential_energy_fn(
    smee.PotentialType.PROPER_TORSIONS, smee.EnergyFn.TORSION_COSINE
)
def compute_cosine_proper_torsion_energy(
    system: smee.TensorSystem,
    potential: smee.TensorPotential,
    conformer: torch.Tensor,
) -> torch.Tensor:
    """Compute the potential energy [kcal / mol] of a set of proper torsions
    for a given conformer using a cosine potential of the form:

    `k*(1+cos(periodicity*theta-phase))`

    Args:
        system: The system to compute the energy for.
        potential: The potential energy function to evaluate.
        conformer: The conformer [Å] to evaluate the potential at with
            ``shape=(n_confs, n_particles, 3)`` or ``shape=(n_particles, 3)``.

    Returns:
        The computed potential energy [kcal / mol].
    """
    return _compute_cosine_torsion_energy(system, potential, conformer)

compute_cosine_improper_torsion_energy #

compute_cosine_improper_torsion_energy(
    system: TensorSystem,
    potential: TensorPotential,
    conformer: Tensor,
) -> Tensor

Compute the potential energy [kcal / mol] of a set of improper torsions for a given conformer using a cosine potential of the form:

k*(1+cos(periodicity*theta-phase))

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) or shape=(n_particles, 3).

Returns:

  • Tensor

    The computed potential energy [kcal / mol].

Source code in smee/potentials/valence.py
@smee.potentials.potential_energy_fn(
    smee.PotentialType.IMPROPER_TORSIONS, smee.EnergyFn.TORSION_COSINE
)
def compute_cosine_improper_torsion_energy(
    system: smee.TensorSystem,
    potential: smee.TensorPotential,
    conformer: torch.Tensor,
) -> torch.Tensor:
    """Compute the potential energy [kcal / mol] of a set of improper torsions
    for a given conformer using a cosine potential of the form:

    `k*(1+cos(periodicity*theta-phase))`

    Args:
        system: The system to compute the energy for.
        potential: The potential energy function to evaluate.
        conformer: The conformer [Å] to evaluate the potential at with
            ``shape=(n_confs, n_particles, 3)`` or ``shape=(n_particles, 3)``.

    Returns:
        The computed potential energy [kcal / mol].
    """
    return _compute_cosine_torsion_energy(system, potential, conformer)