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 the inputs the LJ kernel needs from data.
Unlike the base implementation this does not enable gradients on
positions: forces come analytically from the Warp kernel, not from autograd.- Parameters:
data (Batch) – The input batch.
AtomicDatais rejected; wrap it first withBatch.from_data_list([data]).**kwargs – Unused; accepted for interface compatibility.
- Returns:
Kernel inputs: the configured input fields plus
batch_idx,ptr,num_graphs,fill_value, and optionalcells[B, 3, 3]/neighbor_matrix_shifts[N, K, 3].- Return type:
dict[str, Any]
- Raises:
KeyError – If a required input field is missing from data.
TypeError – If data is an
AtomicDatarather than aBatch.
- adapt_output(model_output, data)[source]#
Map the LJ kernel output to the framework
ModelOutputsformat.- Parameters:
model_output (dict) – Raw kernel output with
energy/forcesand, when stress is active,virial(converted here to tensile-positive Cauchy stress-W / V).data (AtomicData | Batch) – Original input batch; its
cellprovides the volume for stress.
- Returns:
OrderedDict with the active output keys.
- Return type:
ModelOutputs
- compute_embeddings(data, **kwargs)[source]#
Not implemented — the Lennard-Jones potential produces no embeddings.
- Parameters:
data (AtomicData | Batch) – The input system.
**kwargs – Unused; accepted for interface compatibility.
- Returns:
Never returns.
- Return type:
- Raises:
NotImplementedError – Always; the LJ potential has no learned embeddings.
- distribution_spec(strategy=None)[source]#
MLIPSpec for the Lennard-Jones wrapper under domain decomposition.
Halo-only; the
strategyargument is accepted for the framework contract and ignored (LJ ships no graph-parallel spec).The LJ Warp kernels are opaque to sharded tensors, so each is wrapped in an
OpAdapterthat unwraps to local tensors for the kernel and re-wraps the per-atom outputs.- Returns:
The halo spec plus one
OpAdapterper LJ kernel.- Return type:
- Parameters:
strategy (Any)
- 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]#
Not implemented for the Lennard-Jones wrapper.
- Parameters:
path (Path) – Output path (unused).
as_state_dict (bool, optional) – Unused. Defaults to
False.
- Returns:
Never returns.
- Return type:
None
- Raises:
NotImplementedError – Always; the LJ wrapper carries no learned weights to export.
- 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 – Forwarded to
adapt_input().
- Returns:
OrderedDict with keys
"energy"(shape[B, 1]),"forces"(shape[N, 3]), and optionally"stress"(shape[B, 3, 3]) — Cauchy stress-W/Vin energy units.- Return type:
ModelOutputs