xnn.ffnn.models.charmm.CharmmForceField#

class xnn.ffnn.models.charmm.CharmmForceField(library, trainable=())[source]#

Bases: Module

The trainable parameter tensors of a CHARMM parameter library.

Parameters:
  • library (CharmmLibrary, str or Path) – The parameter library (or a shipped set such as "charmm22", a .frc path or a native JSON path, see read_charmm()).

  • trainable (sequence of str or "all", optional) – Groups to expose to the optimizer: "rstar", "epsilon", "rstar14", "epsilon14", "nbfix_rmin", "nbfix_eps", "bond_k", "bond_r0", "angle_k", "angle_theta0", "ub_k", "ub_s0", "dihedral_k", "improper_k"; "all" unfreezes every group.

Variables:
  • params (torch.nn.ParameterDict) – rstar (T,) (Rmin/2) in Angstrom and epsilon (T,) in eV, rstar14 / epsilon14 (T,) the 1,4 values (equal to the regular ones where a type has none; own14 marks the types whose values count), nbfix_rmin / nbfix_eps and nbfix_rmin14 / nbfix_eps14 (M,) the pair overrides, bond_k (NB,) in eV/A^2, bond_r0 (NB,), angle_k (NA,) in eV/rad^2, angle_theta0 (NA,) in rad, ub_k (NU,) in eV/A^2, ub_s0 (NU,), dihedral_k (ND, 6) in eV (one column per Fourier term, zero where a row has fewer terms) and improper_k (NI,) in eV/rad^2.

  • dihedral_mask (dihedral_n, dihedral_cos, dihedral_sin,) – Periodicities, the cosine / sine of the phases and a 0/1 mask of the used term slots of the torsion rows (fixed buffers).

  • improper_sin (improper_cos,) – The cosine / sine of the improper reference angles (fixed buffers).

  • nbfix_keys (type_names, bond_keys, angle_keys, ub_keys, dihedral_keys, improper_keys,) – Row labels of the parameter tensors.

  • fudge_qq (coulomb_constant,) – The library’s Coulomb constant (kcal Angstrom / mol / e^2) and its 1,4 electrostatic scaling.

type_index(name)[source]#

Row index of atom type name (KeyError if unknown).

Parameters:

name (str)

Return type:

int

resolve_bond(a, b)[source]#

Bond-type row for the type pair (KeyError if missing).

Parameters:
Return type:

int

resolve_angle(a, b, c)[source]#

Angle-type row for the type triple, center second.

Parameters:
Return type:

int

resolve_urey_bradley(a, b, c)[source]#

Urey-Bradley row for the type triple, or None when the angle has no such term.

Parameters:
Return type:

int | None

resolve_dihedral(a, b, c, d)[source]#

Dihedral-type row: the exact quadruple (either direction) wins over the X-B-C-X generic entry.

Parameters:
Return type:

int

resolve_improper(*args)[source]#

Improper-type row, by exact key or by the four types in evaluation order (central atom first).

Return type:

int

pair_tables()[source]#

The per-type-pair Lennard-Jones tables (rmin, eps, rmin14, eps14).

Returns:

Four (T, T) tensors: the Lorentz-Berthelot combination of the per-type parameters (the regular ones, and the 1,4 ones for the types that have their own), with the pair overrides written over the listed pairs. rmin is the pair’s minimum distance in Angstrom, eps its well depth in eV.

Return type:

tuple of Tensor

export_library()[source]#

The current (possibly trained) parameters as a CharmmLibrary.

Returns:

In CHARMM units (kcal/mol, Angstrom, degrees); the residue templates keep the library’s charges (trained per-atom charges belong to the models, see Charmm.export_library()).

Return type:

CharmmLibrary