nvalchemi.models.lj.LennardJonesModelWrapper#
- class nvalchemi.models.lj.LennardJonesModelWrapper(epsilon, sigma, cutoff, switch_width=0.0, half_list=False, max_neighbors=128)[source]#
Warp-accelerated Lennard-Jones potential as a model wrapper.
- Parameters:
epsilon (float) – LJ well-depth parameter (energy units, e.g. eV).
sigma (float) – LJ zero-crossing distance (length units, e.g. Å).
cutoff (float) – Interaction cutoff radius (same length units as positions).
switch_width (float, optional) – Width of the C2-continuous switching region;
0.0disables switching (hard cutoff). Defaults to0.0.half_list (bool, optional) – Pass
True(default) if the neighbor matrix contains each pair once (half list). Must match thehalf_fillargument given toNeighborListHook.max_neighbors (int, optional) – Maximum neighbors per atom used when building the neighbor matrix. Passed through to
NeighborConfigand read byNeighborListHook. Defaults to 128.
- model_config#
Mutable configuration controlling which outputs are computed. Set
model.model_config.compute_stresses = Trueto enable virial computation for NPT/NPH simulations.- Type:
- adapt_input(data, **kwargs)[source]#
Collect required inputs from data without enabling gradients.
Unlike the base-class implementation this method deliberately does not call
positions.requires_grad_(True)because forces are computed analytically by the Warp kernel rather than via autograd.- Parameters:
data (AtomicData | Batch)
kwargs (Any)
- Return type:
dict[str, Any]
- adapt_output(model_output, data)[source]#
Adapts the model output to the framework’s expected format.
The super() implementation will provide the initial OrderedDict with keys that are expected to be present in the model output. This method will then map the model outputs to this OrderedDict.
Technically, this is not necessary for the LennardJonesModelWrapper, but it is included to demonstrate how to override the super() implementation.
- Parameters:
model_output (Any)
data (AtomicData | Batch)
- Return type:
OrderedDict[str, Float[Tensor, ‘B 1’] | Float[Tensor, ‘V 3’] | Float[Tensor, ‘V 3 3’] | Float[Tensor, ‘B 3 3’] | Float[Tensor, ‘B 3 3’] | Float[Tensor, ‘B 3’] | None]
- compute_embeddings(data, **kwargs)[source]#
Compute embeddings for the LennardJonesModelWrapper.
This method is not implemented for the LennardJonesModelWrapper, but it is included to demonstrate how to override the super() implementation.
- Parameters:
data (AtomicData | Batch)
kwargs (Any)
- Return type:
- property embedding_shapes: dict[str, tuple[int, ...]]#
Retrieves the expected shapes of the node, edge, and graph embeddings.
- export_model(path, as_state_dict=False)[source]#
Export model is not implemented for LennardJonesModelWrapper.
- Parameters:
path (Path)
as_state_dict (bool)
- Return type:
None
- forward(data, **kwargs)[source]#
Run the LJ kernel and return a
ModelOutputsdict.- Parameters:
data (Batch) – Batch containing
positions,neighbor_matrix,num_neighbors, and optionallycell/neighbor_shifts(populated byNeighborListHook).kwargs (Any)
- Returns:
OrderedDict with keys
"energies"(shape[B, 1]),"forces"(shape[N, 3]), and optionally"stress"(shape[B, 3, 3]) — the physical virial-W_LJin units of eV, ready for NPT/NPH barostat use.- Return type:
ModelOutputs