Skip to content

docs: add mathematical formulas to atomic model classes#5257

Merged
iProzd merged 5 commits intodeepmodeling:masterfrom
njzjz-bot:add-atomic-model-formulas
Feb 26, 2026
Merged

docs: add mathematical formulas to atomic model classes#5257
iProzd merged 5 commits intodeepmodeling:masterfrom
njzjz-bot:add-atomic-model-formulas

Conversation

@njzjz-bot
Copy link
Contributor

@njzjz-bot njzjz-bot commented Feb 23, 2026

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)

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.

Add mathematical formulas to atomic model class docstrings:
- DPAtomicModel: descriptor + fitting pipeline
- LinearEnergyAtomicModel: linear combination of models
- PairTabAtomicModel: pairwise tabulated energy

Follow numpydoc convention: parameters in class docstring.
@dosubot
Copy link

dosubot bot commented Feb 23, 2026

Related Documentation

Checked 0 published document(s) in 1 knowledge base(s). No updates required.

How did I do? Any feedback?  Join Discord

@dosubot dosubot bot added the Docs label Feb 23, 2026
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 23, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between da653ad and f51f587.

📒 Files selected for processing (2)
  • deepmd/dpmodel/atomic_model/dp_atomic_model.py
  • deepmd/dpmodel/atomic_model/linear_atomic_model.py
✅ Files skipped from review due to trivial changes (1)
  • deepmd/dpmodel/atomic_model/linear_atomic_model.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • deepmd/dpmodel/atomic_model/dp_atomic_model.py

📝 Walkthrough

Walkthrough

Expanded and reformatted class docstrings for three atomic-model classes to include mathematical descriptions and notation for descriptor/energy workflows; no code, signatures, or runtime behavior were changed.

Changes

Cohort / File(s) Summary
Atomic model docstrings
deepmd/dpmodel/atomic_model/dp_atomic_model.py, deepmd/dpmodel/atomic_model/linear_atomic_model.py, deepmd/dpmodel/atomic_model/pairtab_atomic_model.py
Expanded/reformatted class docstrings: DPAtomicModel now describes two-stage descriptor extraction and neural-network fitting with notation for D^i and y^i; LinearEnergyAtomicModel documents E^i = sum_k w_k * E_k^i and example combinations; PairTabAtomicModel documents pairwise table lookup and cubic-spline interpolation with E^i = (1/2) sum_j E_{t_i,t_j}(r_{ij}). No functional or signature changes.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Possibly related PRs

Suggested reviewers

  • njzjz
  • iProzd
🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and accurately describes the main change: adding mathematical formulas to the docstrings of atomic model classes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@deepmd/dpmodel/atomic_model/pairtab_atomic_model.py`:
- Around line 48-55: The docstring formula for per-atom pairwise energy omits
the 1/2 prefactor used in the implementation; update the displayed equation for
E^i to E^i = 1/2 \sum_{j \in \mathcal{N}(i)} E_{t_i,t_j}(r_{ij}) so it matches
the code that multiplies the neighbor sum by 0.5 (the neighbor-sum energy
accumulation in this module). Ensure the LaTeX/formatted text and any
accompanying explanation mention the 1/2 factor to indicate pairwise
double-counting is corrected.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
deepmd/dpmodel/atomic_model/dp_atomic_model.py (1)

29-41: Formula inputs left undefined in the "where" clause

The where clause on lines 40–41 only explains \mathcal{D}^i and \mathbf{y}^i, but three inputs introduced in the first equation — \mathbf{R}^i, \mathbf{R}_j, and \mathrm{types} — are never described. A reader unfamiliar with the codebase won't know that j indexes over the neighbours of atom i or what \mathrm{types} represents.

📝 Suggested clarification
-    where :math:`\mathcal{D}^i` is the descriptor for atom :math:`i`, and
-    :math:`\mathbf{y}^i` is the predicted atomic property (energy, dipole, etc.).
+    where :math:`\mathbf{R}^i` is the position of atom :math:`i`,
+    :math:`\mathbf{R}_j` are the positions of its neighbours :math:`j`,
+    :math:`\mathrm{types}` are the atomic-type indices,
+    :math:`\mathcal{D}^i` is the resulting descriptor for atom :math:`i`, and
+    :math:`\mathbf{y}^i` is the predicted atomic property (energy, dipole, etc.).
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@deepmd/dpmodel/atomic_model/dp_atomic_model.py` around lines 29 - 41, The
docstring's math block defines Descriptor(R^i, R_j, types) but the "where"
clause omits explanations for the inputs; update the docstring in
dp_atomic_model.py to document that R^i is the position of atom i, R_j denotes
positions of neighbor atoms (j indexes neighbors of i), and types denotes atomic
species or type identifiers used by Descriptor; also briefly state that
Descriptor(...) computes the environment descriptor D^i from those inputs and
that Fitting(...) maps D^i to the atomic prediction y^i so readers can map R^i,
R_j, and types to Descriptor and Fitting.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@deepmd/dpmodel/atomic_model/dp_atomic_model.py`:
- Around line 29-41: The docstring's math block defines Descriptor(R^i, R_j,
types) but the "where" clause omits explanations for the inputs; update the
docstring in dp_atomic_model.py to document that R^i is the position of atom i,
R_j denotes positions of neighbor atoms (j indexes neighbors of i), and types
denotes atomic species or type identifiers used by Descriptor; also briefly
state that Descriptor(...) computes the environment descriptor D^i from those
inputs and that Fitting(...) maps D^i to the atomic prediction y^i so readers
can map R^i, R_j, and types to Descriptor and Fitting.

@codecov
Copy link

codecov bot commented Feb 23, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.00%. Comparing base (352a2b5) to head (f51f587).
⚠️ Report is 7 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #5257   +/-   ##
=======================================
  Coverage   82.00%   82.00%           
=======================================
  Files         750      750           
  Lines       75082    75081    -1     
  Branches     3615     3615           
=======================================
  Hits        61572    61572           
+ Misses      12347    12346    -1     
  Partials     1163     1163           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

The implementation applies 0.5 factor to avoid double-counting
pairs. Update formula to E^i = 1/2 * sum E_{t_i,t_j}(r_ij).
@njzjz njzjz requested a review from Copilot February 23, 2026 04:20
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds mathematical formulas to the docstrings of three atomic model classes following the numpydoc convention. The additions provide precise mathematical descriptions of how each model computes atomic properties.

Changes:

  • Added mathematical notation for the descriptor-fitting pipeline in DPAtomicModel
  • Documented the linear combination formula for LinearEnergyAtomicModel with use case examples
  • Explained the pairwise energy computation formula for PairTabAtomicModel with table lookup details

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
deepmd/dpmodel/atomic_model/dp_atomic_model.py Added mathematical formulas describing descriptor extraction and fitting network pipeline
deepmd/dpmodel/atomic_model/linear_atomic_model.py Added weighted sum formula for linear model combinations with practical use cases
deepmd/dpmodel/atomic_model/pairtab_atomic_model.py Added pairwise energy formula with table lookup and double-counting explanation

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Fix subject-verb agreement: 'Linear model makes'
@njzjz-bot
Copy link
Contributor Author

Fixed:

  • pairtab: added 1/2 factor to avoid double-counting
  • linear: fixed grammar 'make' → 'makes'

Commit: da653ad

- dp_atomic_model: use α_j for atom types, D for descriptor, F for fitting
- linear_atomic_model: remove incorrect statement about learnable weights
@iProzd iProzd added this pull request to the merge queue Feb 25, 2026
Merged via the queue into deepmodeling:master with commit 8eb2943 Feb 26, 2026
70 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants