xnn.ffnn.models.amoeba.AmoebaForceField#
- class xnn.ffnn.models.amoeba.AmoebaForceField(library, trainable=(), symmetry_mask=True)[source]#
Bases:
ModuleThe trainable parameter tensors of an AMOEBA / HIPPO library.
- Parameters:
library (AmoebaLibrary, str or Path) – The library (a shipped set such as
"amoeba-water-2003", a.frc/.prm/ JSON path, seeread_amoeba()).trainable (sequence of str or "all", optional) – Groups to expose to the optimizer:
"vdw","bond","angle","strbnd","urey","opbend","torsion","pitors","tortor","charge","dipole","quadrupole","polarizability","thole","chgpen","chgtrn","repulsion","dispersion","exchpol","cflux","ionct","mbct","ionpair";"all"unfreezes every group.symmetry_mask (bool, optional) – Keep the dipole and quadrupole components that the library leaves zero (by the symmetry of the local frame) at zero while they train, by default
True.
- Variables:
params (torch.nn.ParameterDict) – The parameter tensors in eV / Angstrom / radian / e (see the source for each group’s layout).
settings (dict) – The force-field definition settings.
library (AmoebaLibrary) – The library the tensors were built from (names and keys).
- constrain_charges(counts, total)[source]#
Fix a molecule’s total charge across refits of
charge.Adds the linear constraint
counts . q == totalon the multipole row chargesq;chargesis then thempole_qparameter projected onto every constraint registered so far, so the molecule keeps its net charge whatever the optimizer does to the row values.Amoebaregisters every molecule of its topology at construction; a force field shared by several models accumulates their constraints, identical molecules once.- Parameters:
counts (Tensor) –
(R,), how many atoms of the molecule use each multipole row.total (float) – The molecule’s total charge in e.
- Return type:
None
- property charges: Tensor#
The row charges satisfying the registered constraints.
The minimum-norm correction
A^+ (A q - b)is removed from thempole_qparameterq, withAthe constraint rows andbtheir totals; without constraints this isqitself.- Type:
Tensor
- effective_multipoles()[source]#
The multipoles the model uses.
The constrained charges, the masked dipoles and the quadrupoles made symmetric, masked and traceless.
- Returns:
(R,)charges in e,(R, 3)dipoles in e Angstrom and(R, 3, 3)quadrupoles in e Angstrom^2 / 3, one row per(type, frame)entry, in the local frames.- Return type:
tuple of Tensor
- export_library()[source]#
The current (possibly trained) parameters as an
AmoebaLibrary.The multipoles are the ones the model uses (see
effective_multipoles()), so a program reading the exported file evaluates the same model.- Returns:
In the library’s units (kcal/mol, Angstrom, degrees).
- Return type: