-
Notifications
You must be signed in to change notification settings - Fork 612
feat(pt): Add DPA4/SeZM descriptor & model 🎉🎉🎉 #5448
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
OutisLi
wants to merge
7
commits into
deepmodeling:master
Choose a base branch
from
OutisLi:dpa4
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 4 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
1c09b27
feat(pt): add DPA4 model components
OutisLi df41e4c
feat(pt): support DPA4 training and export
OutisLi c190e05
docs: add DPA4 guide and examples
OutisLi eae375e
test(pt): add DPA4 coverage
OutisLi 733ee8d
fix(pt): multiple DPA4 bugs fix
OutisLi 39d6c66
add torch to ci
OutisLi 37cdf46
add atom_modify map yes
OutisLi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| # SPDX-License-Identifier: LGPL-3.0-or-later | ||
| """Minimum pairwise distance check for frame validity filtering.""" | ||
|
|
||
| from __future__ import ( | ||
| annotations, | ||
| ) | ||
|
|
||
| import numpy as np | ||
|
|
||
|
|
||
| def compute_min_pair_dist_single( | ||
| coord: np.ndarray, | ||
| box: np.ndarray | None, | ||
| atype: np.ndarray, | ||
| ) -> float: | ||
| """Compute the minimum pairwise atomic distance for a single frame. | ||
|
|
||
| Parameters | ||
| ---------- | ||
| coord : np.ndarray | ||
| Atomic coordinates, flattened with shape (natoms * 3,) | ||
| or reshaped as (natoms, 3). | ||
| box : np.ndarray or None | ||
| Box vectors with shape (9,) for PBC, or None for non-PBC. | ||
| atype : np.ndarray | ||
| Atom types with shape (natoms,). Virtual atoms (type < 0) | ||
| are excluded from the distance check. | ||
|
|
||
| Returns | ||
| ------- | ||
| float | ||
| Minimum pairwise distance. Returns inf if fewer than 2 | ||
| real atoms exist. | ||
| """ | ||
| coord = coord.reshape(-1, 3) | ||
|
|
||
| # === Step 1. Filter out virtual atoms === | ||
| real_mask = atype.ravel() >= 0 | ||
| real_coord = coord[real_mask] | ||
| n_real = real_coord.shape[0] | ||
| if n_real < 2: | ||
| return float("inf") | ||
|
|
||
| # === Step 2. Compute pairwise displacement vectors === | ||
| diff = real_coord[np.newaxis, :, :] - real_coord[:, np.newaxis, :] | ||
|
|
||
| # === Step 3. Apply minimum image convention for PBC === | ||
| if box is not None: | ||
| cell = box.reshape(3, 3) | ||
| inv_cell = np.linalg.inv(cell) | ||
| frac_diff = diff @ inv_cell | ||
| frac_diff -= np.round(frac_diff) | ||
| diff = frac_diff @ cell | ||
|
|
||
| # === Step 4. Compute distances and exclude self-pairs === | ||
| dist_sq = np.sum(diff * diff, axis=-1) | ||
| np.fill_diagonal(dist_sq, np.inf) | ||
|
|
||
| return float(np.sqrt(dist_sq.min())) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.