UFFBatchedForcefield#
- class nvmolkit.batchedForcefield.UFFBatchedForcefield(
- molecules: list[Mol],
- vdwThreshold: float | Sequence[float] = 10.0,
- ignoreInterfragInteractions: bool | Sequence[bool] = True,
- hardwareOptions: HardwareOptions | None = None,
Evaluate UFF energies and gradients, or run BFGS minimization, for a batch of molecules with all their conformers.
Constraints are per-molecule and are shared across all conformers of that molecule. Results are nested as
list[list[...]]— outer per-molecule, inner per-conformer.Examples:
ff = UFFBatchedForcefield([mol_a, mol_b]) energies = ff.compute_energy() # [[...], [...]]
ff = UFFBatchedForcefield([mol_a, mol_b]) ff[0].add_position_constraint(0, 0.1, 50.0) opt_energies, converged = ff.minimize()
- __init__(
- molecules: list[Mol],
- vdwThreshold: float | Sequence[float] = 10.0,
- ignoreInterfragInteractions: bool | Sequence[bool] = True,
- hardwareOptions: HardwareOptions | None = None,
Create a batched UFF forcefield wrapper.
All conformers of each molecule are included in the batch automatically.
- Parameters:
molecules – RDKit molecules to evaluate.
vdwThreshold – Van der Waals threshold, scalar or per-molecule.
ignoreInterfragInteractions – Whether to omit interfragment non-bonded interactions, as a scalar or per-molecule list.
hardwareOptions – GPU device and batching configuration. Uses reasonable defaults when
None.
- compute_energy() list[list[float]]#
Return forcefield energies for all conformers of all molecules.
- Returns:
result[mol_idx][conf_idx]– one energy per conformer.
- compute_gradients() list[list[list[float]]]#
Return forcefield gradients for all conformers of all molecules.
- Returns:
result[mol_idx][conf_idx]– one flattened[x0, y0, z0, ...]gradient vector per conformer.
- minimize(
- maxIters: int = 1000,
- forceTol: float = 0.0001,
- output: Literal[CoordinateOutput.RDKIT_CONFORMERS] = CoordinateOutput.RDKIT_CONFORMERS,
- target_gpu: int | None = None,
- minimize(
- maxIters: int = 1000,
- forceTol: float = 0.0001,
- *,
- output: Literal[CoordinateOutput.DEVICE],
- target_gpu: int | None = None,
Run BFGS minimization on all conformers of all molecules.
In
RDKIT_CONFORMERSmode, optimized coordinates are written back into the RDKit conformers in-place. InDEVICEmode, optimized coordinates and energies stay on the GPU, the wrapper’s persistent on-device positions buffer is updated in-place (no host roundtrip), and aDevice3DResultis returned.- Parameters:
maxIters – Maximum number of BFGS iterations.
forceTol – Gradient convergence tolerance.
output –
RDKIT_CONFORMERS(default) orDEVICE.target_gpu – In DEVICE mode, the GPU to consolidate the result on.
None(the default) selects the wrapper’s own GPU. The wrapper is single-GPU - the only supported value is the wrapper’s GPU id; passing a different GPU raisesinvalid_argument. For cross-GPU consolidation use the standaloneUFFOptimizeMoleculesConfs(output=DEVICE, targetGpu=...)API.
- Returns:
(energies, converged)nested host lists. For DEVICE mode: aDevice3DResultwhosevaluesfield holds the optimized coordinates,energiesholds final energies, andconvergedholds per-conformer convergence flags.- Return type:
For RDKit mode