D3DispersionModel

class torch_sim.models.dispersion.D3DispersionModel(a1, a2, s8, *, s6=1.0, d3_params=None, cutoff=95.0 * UnitConversion.Bohr_to_Ang, device=None, dtype=torch.float64, compute_forces=True, compute_stress=True, neighbor_list_fn=torchsim_nl)[source]

Bases: ModelInterface

DFT-D3(BJ) dispersion correction as a ModelInterface.

Computes DFT-D3 energies, forces, and (optionally) stresses via the nvalchemiops Warp GPU/CPU kernels. All user-facing quantities are in metal units (Angstrom / eV); unit conversion to and from atomic units (Bohr / Hartree) is handled internally.

Functional-dependent BJ damping parameters (a1, a2, s8, s6) can be looked up from the canonical parameter table: https://github.com/dftd3/simple-dftd3/blob/main/assets/parameters.toml

Parameters:
  • a1 (float) – BJ damping parameter (dimensionless, functional-dependent).

  • a2 (float) – BJ damping parameter (in Bohr, functional-dependent).

  • s8 (float) – C8 scaling factor (dimensionless, functional-dependent).

  • s6 (float) – C6 scaling factor. Defaults to 1.0.

  • d3_params (D3Parameters | None) – Reference D3 parameters (rcov, r4r2, c6ab, cn_ref).

  • cutoff (float) – Neighbor-list cutoff in Angstrom.

  • device (device | None) – Compute device. Defaults to CUDA if available, else CPU.

  • dtype (dtype) – Floating-point dtype. Defaults to torch.float64.

  • compute_forces (bool) – Whether to return forces. Defaults to True.

  • compute_stress (bool) – Whether to return stress. Defaults to True.

  • neighbor_list_fn (Callable) – Neighbor-list constructor. Defaults to torchsim_nl.

Example:

model = D3DispersionModel(
    a1=0.4289,
    a2=4.4407,
    s8=0.7875,
    d3_params=params,
    cutoff=50.0,
)
results = model(sim_state)
forward(state, **_kwargs)[source]

Compute D3 dispersion energy, forces, and stress.

Parameters:
  • state (SimState) – Simulation state (positions in Angstrom, cell in Angstrom).

  • **_kwargs (object) – Unused; accepted for interface compatibility.

Returns:

dict with "energy" [n_systems], "forces" [n_atoms, 3], and (if compute_stress) "stress" [n_systems, 3, 3].

Return type:

dict[str, Tensor]