torchref.refinement.targets.forcefield_target module
Force Field Target for Molecular Dynamics Energy Calculations.
This module provides a target that computes molecular energy using TorchMD-Net neural network potentials for crystallographic refinement.
- class torchref.refinement.targets.forcefield_target.ForceFieldTarget(model=None, model_path=None, cutoff=5.0, normalize_by_atoms=True, verbose=0)[source]
Bases:
ModelTargetForce field energy target using TorchMD-Net ML potentials.
Computes molecular energy from atomic coordinates using a pre-trained neural network potential. Returns energy as a differentiable tensor suitable for gradient-based refinement.
- Parameters:
model (Model, optional) – Reference to the Model object. Must have hydrogens (load with strip_H=False).
model_path (str, optional) – Path to TorchMD-Net checkpoint file (.ckpt).
cutoff (float, optional) – Interaction cutoff distance in Angstroms. Default is 5.0.
normalize_by_atoms (bool, optional) – If True, return energy per atom. Default is True.
verbose (int, optional) – Verbosity level. Default is 0.
Examples
>>> from torchref.model import Model >>> from torchref.refinement.targets import ForceFieldTarget >>> >>> # Load model WITH hydrogens >>> model = Model(strip_H=False) >>> model.load_pdb('structure_with_H.pdb') >>> >>> # Create force field target >>> ff_target = ForceFieldTarget( ... model=model, ... model_path='path/to/torchmdnet.ckpt', ... ) >>> >>> # Get energy >>> energy = ff_target()
Notes
Requires torchmd-net package: pip install torchmd-net
Pre-trained models available at: https://github.com/torchmd/torchmd-net/tree/main/examples
- __init__(model=None, model_path=None, cutoff=5.0, normalize_by_atoms=True, verbose=0)[source]
Initialize model target.