Model: D4S#

This module contains the definition of the D4 dispersion model for the evaluation of C6 coefficients.

Upon instantiation, the reference polarizabilities are calculated for the all atoms of the molecule(s) and stored in the model class.

Example

>>> import torch
>>> import tad_dftd4 as d4
>>>
>>> numbers = torch.tensor([14, 1, 1, 1, 1]) # SiH4
>>> model = d4.D4Model(numbers)
>>>
>>> # calculate Gaussian weights, optionally pass CN and partial charges
>>> gw = model.weight_references()
>>> c6 = model.get_atomic_c6(gw)
class tad_dftd4.model.d4.D4Model(numbers, ga=3.0, gc=2.0, wf=None, ref_charges='eeq', rc6=None, device=None, dtype=None)[source]#

The D4 dispersion model.

Instantiate D4Model.

Parameters:
  • numbers (Tensor) – Atomic numbers of all atoms in the system.

  • ga (float, optional) – Maximum charge scaling height for partial charge extrapolation. Defaults to GA_DEFAULT.

  • gc (float, optional) – Charge scaling steepness for partial charge extrapolation. Defaults to GC_DEFAULT.

  • wf (float, optional) – Weighting factor for coordination number interpolation. Defaults to WF_DEFAULT.

  • ref_charges (Literal[“eeq”, “gfn2”], optional) – Reference charges to use for the model. Defaults to “eeq”.

  • rc6 (Tensor | None, optional) – Reference C6 coefficients of all atoms. Defaults to None.

  • device (torch.device | None, optional) – Pytorch device for calculations. Defaults to None.

  • dtype (torch.dtype | None, optional) – Pytorch dtype for calculations. Defaults to None.

Parameters:
get_atomic_c6(gw)[source]#

Calculate atomic C6 dispersion coefficients.

Parameters:

gw (Tensor) – Weights for the atomic reference systems of shape (…, nat, nref).

Returns:

C6 coefficients for all atom pairs of shape (…, nat, nat).

Return type:

Tensor

Parameters:

gw (Tensor)

get_weighted_pols(gw)[source]#

Calculate the weighted polarizabilities for each atom and frequency.

Parameters:

gw (Tensor) – Weights for the atomic reference systems of shape (..., nat, nref).

Returns:

Weighted polarizabilities of shape (..., nat, 23).

Return type:

Tensor

Parameters:

gw (Tensor)

weight_references(cn=None, q=None, *, with_dgwdq=False, with_dgwdcn=False)[source]#

Calculate the weights of the reference system (shape: (..., nat, nref)).

Parameters:
  • cn (Tensor | None, optional) – Coordination number of every atom. Defaults to None (0).

  • q (Tensor | None, optional) – Partial charge of every atom. Defaults to None (0).

  • with_dgwdq (bool, optional) – Whether to also calculate the derivative of the weights with respect to the partial charges. Defaults to False.

  • with_dgwdcn (bool, optional) – Whether to also calculate the derivative of the weights with respect to the coordination numbers. Defaults to False.

Returns:

Weights for the atomic reference systems (shape: (..., nat, ref)). If with_dgwdq is True, also returns the derivative of the weights with respect to the partial charges. If with_dgwdcn is True, also returns the derivative of the weights with respect to the coordination numbers.

Return type:

Tensor | tuple[Tensor, Tensor] | tuple[Tensor, Tensor, Tensor]

Parameters:
ga: float#

Maximum charge scaling height for partial charge extrapolation.

Default:

GA_DEFAULT

gc: float#

Charge scaling steepness for partial charge extrapolation.

Default:

GC_DEFAULT

numbers: Tensor#

Atomic numbers of all atoms in the system.

rc6: Tensor#

Reference C6 coefficients of all atoms.

Default:

None (calculated upon instantiation)

ref_charges: Literal['eeq', 'gfn2']#

Reference charges to use for the model.

Default:

"eeq"

wf: Tensor#

Weighting factor for coordination number interpolation.

Default:

None (model-dependent, set upon instantiation)