Skip to content

Potential

Numerical potential energy functions for bonds, angles, dihedrals, and pairs.

Quick reference

The numerical kernels live in the molrs Rust extension; molpy.potential exposes the thin Style classes that name them plus the Potentials evaluator.

Symbol Summary Preferred for
BondHarmonicStyle Harmonic bond style: E = k(r - r₀)² Standard bonded interactions
AngleHarmonicStyle Harmonic angle style: E = k(θ - θ₀)² Standard angle terms
LJ126Style Lennard-Jones 12-6 pair style Standard nonbonded interactions
Potentials Deferred evaluator over a typed Frame Energy / force computation

Canonical example

Define styles and types on a ForceField, then evaluate against a typed Frame via ff.to_potentials(). There is no per-style to_potential() and no parameter-array lookup; the math runs in molrs.

import molpy as mp
import numpy as np

ff = mp.ForceField(name="demo", units="real")
astyle = ff.def_atomstyle("full")
ct = astyle.def_type("CT", mass=12.011, charge=-0.18, element="C")
hc = astyle.def_type("HC", mass=1.008,  charge=0.06,  element="H")

bond_style = ff.def_bondstyle("harmonic")
bond_style.def_type(ct, hc, k=340.0, r0=1.09)   # param name is "k", not "k0"

# Build a typed frame (atoms block + bonds block carrying a "type" column).
frame = mp.Frame()
atoms = mp.Block()
atoms.insert("x", np.array([0.0, 1.2]))
atoms.insert("y", np.array([0.0, 0.0]))
atoms.insert("z", np.array([0.0, 0.0]))
frame["atoms"] = atoms
bonds = mp.Block()
bonds.insert("atomi", np.array([0], dtype=np.uint32))
bonds.insert("atomj", np.array([1], dtype=np.uint32))
bonds.insert("type", np.array(["CT-HC"], dtype=str))
frame["bonds"] = bonds

pots = ff.to_potentials()
energy = pots.calc_energy(frame)
forces = pots.calc_forces(frame)

Full API

Bond

bond

Bond potential styles (facade over molrs).

BondClass2Style

Bases: BondStyle

Bond class2 style.

BondMorseStyle

Bases: BondStyle

Bond morse style (LAMMPS bond_style morse).

Angle

angle

Angle potential styles (facade over molrs).

AngleClass2BondAngleStyle

Bases: AngleStyle

Angle class2/ba cross term.

AngleClass2BondBondStyle

Bases: AngleStyle

Angle class2/bb cross term.

AngleClass2Style

Bases: AngleStyle

Angle class2 style.

Dihedral

dihedral

Dihedral potential styles (facade over molrs).

DihedralCharmmStyle

Bases: DihedralStyle

Dihedral charmm style.

DihedralClass2Style

Bases: DihedralStyle

Dihedral class2 style.

DihedralFourierStyle

Bases: DihedralStyle

Dihedral fourier style (AMBER multi-term).

DihedralMultiHarmonicStyle

Bases: DihedralStyle

Dihedral multi/harmonic style.

DihedralPeriodicStyle

Bases: DihedralStyle

Dihedral periodic (CHARMM-style charmm/periodic) style.

Pair

pair

Pair (non-bonded) potential styles (facade over molrs).

PairBuckStyle

Bases: PairStyle

Pair buck (Buckingham) style.

PairCoulTTStyle

Bases: PairStyle

Pair coul/tt — Tang−Toennies damped charge−dipole Coulomb style.

Style-level parameters: b (1/Å, default 4.5), n (default 4), c (default 1.0). Per-atom-type parameter: charge (e). Damping: f_n(r) = 1 − c·exp(−b·r)·Σ_{k=0}^n (b·r)^k/k!.

Reference: Tang & Toennies, J. Chem. Phys. 80 (1984) 3726, :doi:10.1063/1.447150.

PairLJClass2Style

Bases: PairStyle

Pair lj/class2 style.

PairMorseStyle

Bases: PairStyle

Pair morse style.

PairTholeStyle

Bases: PairStyle

Pair thole — Thole damped dipole-dipole / core-shell Coulomb style.

Per-atom-type parameters: charge (e), alpha (ų), a_thole (dimensionless Thole damping width, default 2.6). Damping: T(r) = 1 − (1 + s·r/2)·exp(−s·r) where s = a_ij / (α_i·α_j)^(1/6), a_ij = (a_i + a_j)/2.

Reference: Thole, Chem. Phys. 59 (1981) 341, :doi:10.1016/0301-0104(81)85176-2.