xnn.ffnn.models.opls.OPLSForceField#
- class xnn.ffnn.models.opls.OPLSForceField(library, trainable=())[source]#
Bases:
ModuleThe trainable parameter tensors of an OPLS parameter library.
Assembles the library’s per-atom-type nonbonded parameters and per-class bonded parameter tables into dense tensors (eV / Angstrom / radians), exposed as a
torch.nn.ParameterDictso any group can be refit by gradient descent. One instance can be shared by severalOPLSmodels (different molecules) to train transferable parameters jointly.- Parameters:
library (OPLSLibrary, str or Path) – The parameter library (or a built-in set name / file path, see
read_opls()).trainable (sequence of str or "all", optional) – Parameter groups to expose to the optimizer: any of
"charge","sigma","epsilon","bond_k","bond_r0","angle_k","angle_theta0","dihedral_v","improper_v2";"all"unfreezes every group. Default: none (a fixed classical force field).
- Variables:
params (torch.nn.ParameterDict) –
charge(T,)in e,sigma(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_v(ND, 5)in eV andimproper_v2(NI,)in eV.improper_keys (type_names, bond_keys, angle_keys, dihedral_keys,) – Row labels of the parameter tensors, in assembly order.
fudge_qq (fudge_lj,) – The library’s 1,4 scaling factors.
- resolve_dihedral(a, b, c, d)[source]#
Dihedral-type row for the class quadruple (wildcards allowed).
- Parameters:
- Returns:
Row index into
dihedral_v.- Return type:
- Raises:
KeyError – If no library entry (exact or wildcard) matches.
- resolve_improper(*args)[source]#
Improper-type row, by exact key or by class quadruple.
- Parameters:
*args (str) – Either one opaque key (
"Z-CM-X-Y", from a topology’simproper_keys), or four atom classesi, j, k, lwithkthe trigonal center, matched against the library’s"I-J-K-L"patterns (Xwildcards) in SEAMM’s precedence order (resolve_improper_type()).- Returns:
Row index into
improper_v2.- Return type:
- Raises:
KeyError – If nothing in the library matches.
- export_library()[source]#
Write the current (possibly trained) parameters back to a library.
- Returns:
A new library in OPLS units (kcal/mol, Angstrom, degrees), round-trippable through
OPLSLibrary.save()/read_opls().- Return type: