nvalchemi.models.lj.LennardJonesModelWrapper#
- class nvalchemi.models.lj.LennardJonesModelWrapper(epsilon, sigma, cutoff, switch_width=0.0, half_list=False)[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.
- model_config#
Mutable configuration controlling which outputs are computed. Include
"stress"inmodel_config.active_outputsto 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.
- 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
- extra_repr()#
Format the model config for
nn.Module.__repr__.- Parameters:
self (Any)
- Return type:
str
- 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_matrix_shifts(populated byNeighborListHook).kwargs (Any)
- Returns:
OrderedDict with keys
"energy"(shape[B, 1]),"forces"(shape[N, 3]), and optionally"stress"(shape[B, 3, 3]) — Cauchy stressW/Vin energy units.- Return type:
ModelOutputs