xnn.hybnn.models.byteff.ByteFFPol#
- class xnn.hybnn.models.byteff.ByteFFPol(structure=None, *, graph=None, bonded=None, nonbonded=None, members=1, supported_elements=(1, 3, 6, 7, 8, 9, 15, 16, 17), coulomb_constant=332.0637141491396, charge14=0.5, vdw14=0.5, induction14=0.5, induction15=1.0, thole=0.39, dispersion_damping=120.0, wall=1.5, repulsion_prefactor=6.0, charge=0, use_fast='auto', cutoff=None, ewald_tolerance=5e-05, ewald_alpha=None, pme_grid=None, pme_order=5, polar_eps=1e-05, max_iter=100, long_range_correction=True, predictor=None, predictor_history=6)[source]#
Bases:
_GraphParameterizedFFByteFF-Pol: a polarizable force field whose parameters a graph transformer predicts.
- Parameters:
structure (rdkit.Chem.Mol, str, ase.Atoms or list, optional) – The system to bind (see
bind()).graph (dict, optional) – As for
ByteFF(the bonded head defaults to the two-well form).bonded (dict, optional) – As for
ByteFF(the bonded head defaults to the two-well form).nonbonded (dict, optional) – Options of
PolarizableHead.members (int, optional) – Networks of the ensemble. Default 1.
supported_elements (sequence of int, optional) – Elements an evaluation outside training accepts.
coulomb_constant (float, optional) – In kcal Angstrom / (mol e^2).
charge14 (float, optional) – Scale factors of the 1,4 electrostatic and repulsion/dispersion terms.
vdw14 (float, optional) – Scale factors of the 1,4 electrostatic and repulsion/dispersion terms.
induction14 (float, optional) – Scale factors of the charges’ polarizing field at 1,4 and 1,5 pairs (1,2 and 1,3 pairs do not polarize each other).
induction15 (float, optional) – Scale factors of the charges’ polarizing field at 1,4 and 1,5 pairs (1,2 and 1,3 pairs do not polarize each other).
thole (float, optional) – Thole damping strength.
dispersion_damping (float, optional) –
sof the damped C6 term.wall (float, optional) –
s12of the short-range repulsive wall, in Angstrom (kcal/mol)^(1/12).repulsion_prefactor (float, optional) – Prefactor of the Born-Mayer term (
aofa eps exp[lam (1 - r/r0)]).charge (int, optional) – Total charge for bond perception when binding an
ase.Atoms.use_fast (bool or "auto", optional) – Evaluate the energy block compiled on a CUDA device (the same numbers to round-off, its first and second derivatives compiled for force training; the dipoles are solved outside it). Compiling takes tens of seconds per batch shape:
"auto"(default) compiles aftercompile_afterevaluations of one shape,Trueat once (molecular dynamics, training),Falsenever. In cells,Trueand"auto"solve the dipoles and run the mesh on fused GPU kernels when evaluating (the same numbers to round-off), training stays on the reference.cutoff (float, optional) –
None(default): every pair of a structure interacts (molecules and clusters, no cell). A cutoff in Angstrom evaluates periodic cells: the repulsion, dispersion and charge transfer of the neighbor pairs truncated there, the charges and induced dipoles as Ewald sums.ewald_tolerance (float, optional) – Sets the Ewald coefficient
sqrt(-ln(2 tol)) / cutoffand the mesh,ceil(2 alpha L / (3 tol^(1/5)))points (at least six) along a cell sideL, rounded up to a size whose prime factors are at most 7 (as OpenMM’s GPU platforms do). Default5e-5.ewald_alpha (float, optional) – The Ewald coefficient in 1/Angstrom instead.
pme_grid (sequence of int, optional) – The mesh instead.
pme_order (int, optional) – B-spline order of the mesh. Default 5.
polar_eps (float, optional) – Convergence of the iterative dipole solve of cells, the rms change per iteration in Debye. Default
1e-5.max_iter (int, optional) – Iterations of that solve at most. Default 100.
long_range_correction (bool, optional) – Add the uniform-density estimate of the short-range terms beyond the cutoff. Default
True.predictor (str, optional) – Extrapolate the dipoles of the next step from the last ones as the start of the iterative solve in cells (molecular dynamics):
"aspc","gear"or"previous"(seeDipolePredictor);None(default) starts from the direct dipoles. The converged dipoles do not change.predictor_history (int, optional) – Dipole sets the predictor uses. Default 6.
Notes
forwardreturnse_repulsion,e_dispersion,e_electrostatics,e_polarizationande_charge_transferbesides the bonded terms, and theinduced_dipoles(N, 3)in e Angstrom. A cell’s sides must be at least twice the cutoff long (its perpendicular widths), so that every pair interacts with one image at most; the 1,2 to 1,5 pairs of a molecule take their nearest images. In cells,plan_step()records the host decisions of an evaluation forStepGraph, which replays molecular dynamics steps as CUDA graphs.- plan_step(data, skin=0.0, capacity=None)[source]#
Record the host decisions of an evaluation of a periodic structure for later evaluations of it as it moves (see
StepPlan): the neighbor pairs as a Verlet list ofcutoff + skin, the image shifts of the bonded vectors, the meshes and the Ewald coefficient. Evaluations on the plan read nothing from the device but the convergence of the dipole solve, and with fixed solve lengths not even that. The recording evaluation runs without gradients and leaves the dipole predictor alone.- Parameters:
data (AtomicGraph) – The batched graph, its neighbor list built with
cutoff + skin.skin (float, optional) – The margin of the neighbor list beyond the cutoff in Angstrom. Default 0.
capacity (int, optional) – The number of pairs the plan holds, padded beyond the unique pairs of the neighbor list; by default exactly those.
- Returns:
The plan, for
forward(data, plan).- Return type:
- plan_pairs(data, plan)[source]#
Refresh the pair list of
planfrom the neighbor list ofdatain place.- Parameters:
data (AtomicGraph) – The graph at the current positions, its neighbor list built with
cutoff + skin.plan (StepPlan) – The plan to refresh.
- Returns:
Whether the pairs fitted the plan’s capacity and were copied.
- Return type:
- refresh_pairs(data, plan, cutoff)[source]#
Refresh the pair list of
planin place at the positions and cell ofdata, one structure, from a half neighbor list ofcutoff(the cutoff plus the skin) found on the device, without building a graph.- Parameters:
data (AtomicGraph) – The plan’s graph at the current step.
plan (StepPlan) – The plan to refresh.
cutoff (float) – The radius of the pair list.
- Returns:
Whether the pairs fitted the plan’s capacity and were copied.
- Return type:
- stage_pairs(data, plan, pairs, single_image=False)[source]#
The unique pairs
(i, k, shift)ofdata, one structure, sorted byi, recorded as the pair list of a new plan forplan.update(fresh, bonded=False);planis not touched, so a step can still run on it meanwhile.- Parameters:
data (AtomicGraph) – The plan’s graph, its positions and cell where the pairs were found.
plan (StepPlan) – The plan whose capacity and skin the new one takes.
pairs (tuple of Tensor) – The pairs and their integer image shifts, or those in buffers of the plan’s capacity followed by their number on the device.
single_image (bool, optional) – Every pair has one image within the list’s cutoff. Unused: every image of an excluded pair is excluded, its far images lying beyond the cutoff anyway.
- Returns:
The new pair list, or
Nonewhen the pairs exceed the capacity.- Return type:
StepPlan or None
- export_core()[source]#
The scriptable core of
export_torchscript_potential(): the parameters of the bound system with the reference’s terms, for molecules and clusters (ByteFFPolExport) or, with a cutoff, periodic cells (ByteFFPolCellExport).- Return type:
- set_dipole_predictor(kind, history=6)[source]#
Switch the dipole predictor of the iterative solve in cells on (
"aspc","gear","previous") or off (None).
- rewind_predictors()[source]#
Take the dipoles of the last evaluation back out of the predictor, before a step is evaluated again.
- Return type:
None