Skip to content

Commit 806fea2

Browse files
njzjz-botJinzhe Zeng
authored andcommitted
docs: add formulas to fitting classes
Add mathematical formulas to fitting class docstrings: - DipoleFitting: dipole computation from rotation matrix - PolarFitting: polarizability tensor with diagonal/full fitting Follow numpydoc convention: parameters in class docstring.
1 parent 352a2b5 commit 806fea2

2 files changed

Lines changed: 41 additions & 1 deletion

File tree

deepmd/dpmodel/fitting/dipole_fitting.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,23 @@
3434
@BaseFitting.register("dipole")
3535
@fitting_check_output
3636
class DipoleFitting(GeneralFitting):
37-
r"""Fitting rotationally equivariant diploe of the system.
37+
r"""Fitting rotationally equivariant dipole of the system.
38+
39+
The dipole :math:`\boldsymbol{\mu}` is computed from the fitting network output
40+
and the rotation matrix:
41+
42+
.. math::
43+
\boldsymbol{\mu}^i = \mathbf{M}^i \cdot \mathbf{R}^i,
44+
45+
where :math:`\mathbf{M}^i \in \mathbb{R}^{1 \times m_1}` is the output of the fitting
46+
network for atom :math:`i`, and :math:`\mathbf{R}^i \in \mathbb{R}^{m_1 \times 3}` is
47+
the rotation matrix from the descriptor. The fitting network is:
48+
49+
.. math::
50+
\mathbf{M}^i = \mathcal{L}^{(n)} \circ \mathcal{L}^{(n-1)} \circ \cdots \circ \mathcal{L}^{(0)}(\mathcal{D}^i),
51+
52+
where :math:`\mathcal{D}^i` is the descriptor and each layer :math:`\mathcal{L}^{(k)}`
53+
is a fully connected layer with activation function.
3854
3955
Parameters
4056
----------

deepmd/dpmodel/fitting/polarizability_fitting.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,30 @@
4444
class PolarFitting(GeneralFitting):
4545
r"""Fitting rotationally equivariant polarizability of the system.
4646
47+
The polarizability tensor :math:`\boldsymbol{\alpha} \in \mathbb{R}^{3 \times 3}` is
48+
computed from the fitting network output and the rotation matrix:
49+
50+
**Diagonal fitting** (when `fit_diag=True`):
51+
52+
.. math::
53+
\boldsymbol{\alpha}^i = \mathbf{R}^{i,T} \cdot \mathrm{diag}(\mathbf{p}^i) \cdot \mathbf{R}^i,
54+
55+
where :math:`\mathbf{p}^i \in \mathbb{R}^{m_1}` is the diagonal elements predicted by
56+
the fitting network.
57+
58+
**Full matrix fitting** (when `fit_diag=False`):
59+
60+
.. math::
61+
\boldsymbol{\alpha}^i = \mathbf{R}^{i,T} \cdot \mathbf{P}^i \cdot \mathbf{R}^i,
62+
63+
where :math:`\mathbf{P}^i \in \mathbb{R}^{m_1 \times m_1}` is the full matrix predicted
64+
by the fitting network.
65+
66+
The fitting network is:
67+
68+
.. math::
69+
\mathbf{p}^i \text{ (or } \mathbf{P}^i) = \mathcal{L}^{(n)} \circ \cdots \circ \mathcal{L}^{(0)}(\mathcal{D}^i).
70+
4771
Parameters
4872
----------
4973
ntypes

0 commit comments

Comments
 (0)