MMFFOptimizeMoleculesConfs#
- nvmolkit.mmffOptimization.MMFFOptimizeMoleculesConfs(
- molecules: list['Mol'],
- maxIters: int = 200,
- properties: MMFFMolProperties | Sequence[MMFFMolProperties | None] | None = None,
- nonBondedThreshold: float | Sequence[float] = 100.0,
- ignoreInterfragInteractions: bool | Sequence[bool] = True,
- hardwareOptions: HardwareOptions | None = None,
- output: Literal[CoordinateOutput.RDKIT_CONFORMERS] = CoordinateOutput.RDKIT_CONFORMERS,
- targetGpu: int = -1,
- nvmolkit.mmffOptimization.MMFFOptimizeMoleculesConfs(
- molecules: list['Mol'],
- maxIters: int = 200,
- properties: MMFFMolProperties | Sequence[MMFFMolProperties | None] | None = None,
- nonBondedThreshold: float | Sequence[float] = 100.0,
- ignoreInterfragInteractions: bool | Sequence[bool] = True,
- hardwareOptions: HardwareOptions | None = None,
- *,
- output: Literal[CoordinateOutput.DEVICE],
- targetGpu: int = -1,
Optimize conformers for multiple molecules using MMFF force field with BFGS minimization.
This function performs GPU-accelerated MMFF optimization on multiple molecules with multiple conformers each. It uses CUDA for GPU acceleration and OpenMP for CPU parallelization to achieve high performance.
- Parameters:
molecules – List of RDKit molecules to optimize. Each molecule should have conformers already generated.
maxIters – Maximum number of BFGS optimization iterations (default: 200)
properties – RDKit
MMFFMolPropertiesobject, a per-molecule sequence of those objects, orNoneto use default MMFF94 settings.nonBondedThreshold – Radius threshold used to exclude long-range non-bonded interactions, either as a scalar or per-molecule sequence.
ignoreInterfragInteractions – If
True, omit non-bonded terms between fragments. May also be provided as a per-molecule sequence.hardwareOptions – Configures CPU and GPU batching, threading, and device selection. Will attempt to use reasonable defaults if not set.
output –
RDKIT_CONFORMERS(default) writes optimized coordinates back into each input molecule’s RDKit conformers and returns nested host-side energy lists.DEVICEkeeps optimized coordinates and energies on GPU and returns aDevice3DResult.targetGpu – In DEVICE mode, the GPU to consolidate the result onto.
-1selects the first configured execution GPU.
- Returns:
list of lists of energies, where each inner list contains the optimized energies for all conformers of the corresponding molecule. The order matches the input molecule order and conformer iteration order. For
DEVICE: aDevice3DResultwhosevaluesfield carries optimized coordinates(total_atoms, 3), plusenergies,converged, and CSR indices.- Return type:
For
RDKIT_CONFORMERS- Raises:
ValueError – If any molecules in the input list are None or lack MMFF atom types.
e.args[0]is a summary message,e.args[1]is a dict with keys"none"(indices of None molecules) and"no_params"(indices of molecules lacking MMFF atom types). Example:: try: MMFFOptimizeMoleculesConfs(mols, …) except ValueError as e: failed = e.args[1] none_idx = failed[“none”] no_params_idx = failed[“no_params”]RuntimeError – If CUDA operations fail or optimization encounters errors
Example
>>> from rdkit import Chem >>> from rdkit.Chem import rdDistGeom >>> from nvmolkit.mmffOptimization import MMFFOptimizeMoleculesConfs >>> from nvmolkit.types import HardwareOptions >>> >>> # Load molecules and generate conformers >>> mol1 = Chem.AddHs(Chem.MolFromSmiles('CCO')) >>> mol2 = Chem.AddHs(Chem.MolFromSmiles('CCC')) >>> rdDistGeom.EmbedMultipleConfs(mol1, numConfs=5) >>> rdDistGeom.EmbedMultipleConfs(mol2, numConfs=3) >>> >>> # Set custom runtime performance options (optional) >>> hardware_options = HardwareOptions(batchSize=200, batchesPerGpu=4) >>> energies = MMFFOptimizeMoleculesConfs( ... [mol1, mol2], ... maxIters=500, ... hardwareOptions=hardware_options ... ) >>> >>> # energies[0] contains 5 energies for mol1's conformers >>> # energies[1] contains 3 energies for mol2's conformers
Note
Input molecules are modified in-place with optimized conformer coordinates