Model: DFT-D4#
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.
Moreover, the weighting factors wf are gathered from the parameter file.
Example
>>> import torch
>>> import tad_dftd4 as d4
>>>
>>> numbers = torch.tensor([14, 1, 1, 1, 1]) # SiH4
>>> model = d4.D4SModel(numbers)
>>>
>>> # calculate Gaussian weights, optionally pass CN and partial charges
>>> gw = model.weight_references()
>>> c6 = model.get_atomic_c6(gw)
- class tad_dftd4.model.d4s.D4SModel(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:
numbers (Tensor)
ga (float)
gc (float)
wf (Tensor)
ref_charges (Literal['eeq', 'gfn2'])
rc6 (Tensor)
device (torch.device | None)
dtype (torch.dtype | None)
- get_atomic_c6(gw)[source]#
Calculate atomic C6 dispersion coefficients.
- Parameters:
gw (Tensor) – Weights for the atomic reference systems of shape (…, nat, 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.
This is helpful for calculating C6 coefficients between molecules.
- Parameters:
gw (Tensor) – Weights for the atomic reference systems of shape
(..., nat, 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)). Ifwith_dgwdqisTrue, also returns the derivative of the weights with respect to the partial charges. Ifwith_dgwdcnisTrue, also returns the derivative of the weights with respect to the coordination numbers.- Return type:
Tensor | tuple[Tensor, Tensor] | tuple[Tensor, Tensor, Tensor]
- Parameters: