Skip to content

Commit 8eb2943

Browse files
docs: add mathematical formulas to atomic model classes (#5257)
## Summary Add detailed mathematical formulas to atomic model class docstrings following numpydoc convention. ## Changes Added formulas to the following classes: - **DPAtomicModel**: Descriptor + fitting pipeline - D = Descriptor(R, types) - y = Fitting(D) - **LinearEnergyAtomicModel**: Linear combination of models - E = Σ w_k · E_k - **PairTabAtomicModel**: Pairwise tabulated energy - E = Σ E_{t_i,t_j}(r_ij) via table lookup ## Convention Following numpydoc convention, parameters are documented in class docstrings, not in `__init__` docstrings. ## Statistics - 3 files changed - 33 insertions(+) Authored by OpenClaw (model: GLM-5) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Documentation** * Clarified atomic-model workflow: descriptor extraction followed by neural-network fitting, with mathematical notation for descriptors and predictions. * Documented linear-model energy as a weighted sum of sub-model contributions; weights may be learned or specified and example use cases provided. * Explained pairwise energy evaluation via table lookup and cubic-spline interpolation, including cutoff behavior and double-counting convention. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent bf982ab commit 8eb2943

3 files changed

Lines changed: 38 additions & 3 deletions

File tree

deepmd/dpmodel/atomic_model/dp_atomic_model.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,21 @@
2626

2727
@BaseAtomicModel.register("standard")
2828
class DPAtomicModel(BaseAtomicModel):
29-
"""Model give atomic prediction of some physical property.
29+
r"""Model give atomic prediction of some physical property.
30+
31+
The atomic model computes atomic properties by first extracting a descriptor
32+
from the atomic environment, then passing it through a fitting network:
33+
34+
.. math::
35+
\mathcal{D}^i = \mathcal{D}(\mathbf{R}^i, \mathbf{R}_j, \alpha_j),
36+
37+
.. math::
38+
\mathbf{y}^i = \mathcal{F}(\mathcal{D}^i),
39+
40+
where :math:`\mathcal{D}^i` is the descriptor for atom :math:`i`,
41+
:math:`\alpha_j` is the atom type of neighbor :math:`j`,
42+
:math:`\mathcal{F}` is the fitting network, and
43+
:math:`\mathbf{y}^i` is the predicted atomic property (energy, dipole, etc.).
3044
3145
Parameters
3246
----------

deepmd/dpmodel/atomic_model/linear_atomic_model.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,18 @@
3838

3939
@BaseAtomicModel.register("linear")
4040
class LinearEnergyAtomicModel(BaseAtomicModel):
41-
"""Linear model make linear combinations of several existing models.
41+
r"""Linear model makes linear combinations of several existing models.
42+
43+
The linear model combines predictions from multiple atomic models:
44+
45+
.. math::
46+
E^i = \sum_{k=1}^{K} w_k \cdot E_k^i,
47+
48+
where :math:`E_k^i` is the energy predicted by the :math:`k`-th sub-model
49+
for atom :math:`i`, and :math:`w_k` is the corresponding weight.
50+
51+
This is useful for combining different interaction types, e.g., DP + ZBL
52+
for short-range repulsion, or DP + D3 for dispersion corrections.
4253
4354
Parameters
4455
----------

deepmd/dpmodel/atomic_model/pairtab_atomic_model.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232

3333
@BaseAtomicModel.register("pairtab")
3434
class PairTabAtomicModel(BaseAtomicModel):
35-
"""Pairwise tabulation energy model.
35+
r"""Pairwise tabulation energy model.
3636
3737
This model can be used to tabulate the pairwise energy between atoms for either
3838
short-range or long-range interactions, such as D3, LJ, ZBL, etc. It should not
@@ -45,6 +45,16 @@ class PairTabAtomicModel(BaseAtomicModel):
4545
At this moment, the model does not smooth the energy at the cutoff radius, so
4646
one needs to make sure the energy has been smoothed to zero.
4747
48+
The pairwise energy is computed by table lookup and interpolation:
49+
50+
.. math::
51+
E^i = \frac{1}{2} \sum_{j \in \mathcal{N}(i)} E_{t_i, t_j}(r_{ij}),
52+
53+
where :math:`E_{t_i, t_j}(r)` is the tabulated pairwise energy between atom types
54+
:math:`t_i` and :math:`t_j` at distance :math:`r`, obtained via cubic spline
55+
interpolation from the table data. The factor of :math:`\frac{1}{2}` avoids
56+
double-counting of pairwise interactions.
57+
4858
Parameters
4959
----------
5060
tab_file : str

0 commit comments

Comments
 (0)