deepmd.dpmodel.fitting.polarizability_fitting

Module Contents

Classes

PolarFitting

Fitting rotationally equivariant polarizability of the system.

class deepmd.dpmodel.fitting.polarizability_fitting.PolarFitting(ntypes: int, dim_descrpt: int, embedding_width: int, neuron: List[int] = [120, 120, 120], resnet_dt: bool = True, numb_fparam: int = 0, numb_aparam: int = 0, rcond: float | None = None, tot_ener_zero: bool = False, trainable: List[bool] | None = None, activation_function: str = 'tanh', precision: str = DEFAULT_PRECISION, layer_name: List[str | None] | None = None, use_aparam_as_mask: bool = False, spin: Any = None, mixed_types: bool = False, exclude_types: List[int] = [], old_impl: bool = False, fit_diag: bool = True, scale: List[float] | None = None, shift_diag: bool = True, seed: int | None = None)[source]

Bases: deepmd.dpmodel.fitting.general_fitting.GeneralFitting

Fitting rotationally equivariant polarizability of the system.

Parameters:
ntypes

The number of atom types.

dim_descrpt

The dimension of the input descriptor.

embedding_widthint

The dimension of rotation matrix, m1.

neuron

Number of neurons \(N\) in each hidden layer of the fitting net

resnet_dt

Time-step dt in the resnet construction: \(y = x + dt * \phi (Wx + b)\)

numb_fparam

Number of frame parameter

numb_aparam

Number of atomic parameter

rcond

The condition number for the regression of atomic energy.

tot_ener_zero

Force the total energy to zero. Useful for the charge fitting.

trainable

If the weights of fitting net are trainable. Suppose that we have \(N_l\) hidden layers in the fitting net, this list is of length \(N_l + 1\), specifying if the hidden layers and the output layer are trainable.

activation_function

The activation function \(\boldsymbol{\phi}\) in the embedding net. Supported options are “relu”, “tanh”, “none”, “linear”, “softplus”, “sigmoid”, “relu6”, “gelu”, “gelu_tf”.

precision

The precision of the embedding net parameters. Supported options are “float32”, “default”, “float16”, “float64”.

layer_namelist[Optional[str]], optional

The name of the each layer. If two layers, either in the same fitting or different fittings, have the same name, they will share the same neural network parameters.

use_aparam_as_mask: bool, optional

If True, the atomic parameters will be used as a mask that determines the atom is real/virtual. And the aparam will not be used as the atomic parameters for embedding.

mixed_types

If true, use a uniform fitting net for all atom types, otherwise use different fitting nets for different atom types.

fit_diagbool

Fit the diagonal part of the rotational invariant polarizability matrix, which will be converted to normal polarizability matrix by contracting with the rotation matrix.

scaleList[float]

The output of the fitting net (polarizability matrix) for type i atom will be scaled by scale[i]

shift_diagbool

Whether to shift the diagonal part of the polarizability matrix. The shift operation is carried out after scale.

_net_out_dim()[source]

Set the FittingNet output dim.

__setitem__(key, value)[source]
__getitem__(key)[source]
serialize() dict[source]

Serialize the fitting to dict.

classmethod deserialize(data: dict) deepmd.dpmodel.fitting.general_fitting.GeneralFitting[source]

Deserialize the fitting.

Parameters:
datadict

The serialized data

Returns:
BF

The deserialized fitting

output_def()[source]

Returns the output def of the fitting net.

call(descriptor: numpy.ndarray, atype: numpy.ndarray, gr: numpy.ndarray | None = None, g2: numpy.ndarray | None = None, h2: numpy.ndarray | None = None, fparam: numpy.ndarray | None = None, aparam: numpy.ndarray | None = None) Dict[str, numpy.ndarray][source]

Calculate the fitting.

Parameters:
descriptor

input descriptor. shape: nf x nloc x nd

atype

the atom type. shape: nf x nloc

gr

The rotationally equivariant and permutationally invariant single particle representation. shape: nf x nloc x ng x 3

g2

The rotationally invariant pair-partical representation. shape: nf x nloc x nnei x ng

h2

The rotationally equivariant pair-partical representation. shape: nf x nloc x nnei x 3

fparam

The frame parameter. shape: nf x nfp. nfp being numb_fparam

aparam

The atomic parameter. shape: nf x nloc x nap. nap being numb_aparam