xnn.ffnn.models.amber.AmberForceField#

class xnn.ffnn.models.amber.AmberForceField(library, trainable=())[source]#

Bases: Module

The trainable parameter tensors of an AMBER parameter library.

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

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

Variables:
  • params (torch.nn.ParameterDict) – rstar (T,) in Angstrom, epsilon (T,) in eV, bond_k (NB,) in eV/A^2, bond_r0 (NB,), angle_k (NA,) in eV/rad^2, angle_theta0 (NA,) in rad, dihedral_k (ND, 4) and improper_k (NI, 2) in eV (one column per Fourier term, zero where a row has fewer terms).

  • 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; a trained dihedral_k never grows a term in an unused slot); likewise improper_n / improper_cos / improper_sin / improper_mask.

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

  • fudge_qq (fudge_lj,) – The library’s 1,4 scaling factors.

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 class pair (KeyError if missing).

Parameters:
Return type:

int

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

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

Parameters:
Return type:

int

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 classes in evaluation order (center third, distinguished atom last).

Return type:

int

export_library()[source]#

The current (possibly trained) parameters as an AmberLibrary.

Returns:

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

Return type:

AmberLibrary