xnn.ffnn.models.dreiding.DreidingForceField#

class xnn.ffnn.models.dreiding.DreidingForceField(library='dreiding', trainable=())[source]#

Bases: Module

The trainable generator tensors of a DREIDING parameter set.

Assembles the library’s per-type generators and global rule constants into tensors (eV / Angstrom / radians) exposed as a torch.nn.ParameterDict, so any group can be refit by gradient descent. One instance can be shared by several Dreiding models (different molecules) to train transferable parameters jointly.

Parameters:
  • library (DreidingLibrary, str or Path) – The parameter library (or a spec for read_dreiding(); default specs are "dreiding" and "dreiding/X6").

  • trainable (sequence of str or "all", optional) – Parameter groups to expose to the optimizer: any of "radius", "theta0", "bond_k", "bond_d", "angle_k", "torsion_v", "oop_k", "oop_psi0", "vdw_r0", "vdw_d0", "x6_zeta", "hbond_d0", "hbond_r0"; "all" unfreezes every group. Default: none (the fixed classical force field).

Variables:
  • params (torch.nn.ParameterDict) – radius (T,) A, theta0 (T,) rad, bond_k eV/A^2, bond_d eV, angle_k eV/rad^2, torsion_v (9,) eV (one total barrier per rule, in TORSION_RULES order), oop_k (T,) eV/rad^2, oop_psi0 (T,) rad, vdw_r0 (T,) A, vdw_d0 (T,) eV, x6_zeta (T,), hbond_d0 eV and hbond_r0 A.

  • type_names (list of str) – Row labels of the per-type tensors.

  • form (str) – "lj" or "x6".

  • combination (str) – The LJ R0 combination rule ("arithmetic" or "geometric").

type_index(name)[source]#

Row index of atom type name.

Parameters:

name (str) – The DREIDING atom type (e.g. "C_3").

Returns:

Index into the per-type parameter tensors.

Return type:

int

Raises:

KeyError – If the library has no such atom type.

check_generators(name)[source]#

Raise if a type lacks the per-type generators terms need.

Parameters:

name (str)

Return type:

None

export_library()[source]#

Write the current (possibly trained) parameters back to a library.

Returns:

A new library in DREIDING units (kcal/mol, Angstrom, degrees), round-trippable through DreidingLibrary.save() / read_dreiding().

Return type:

DreidingLibrary