-
Notifications
You must be signed in to change notification settings - Fork 89
Add D3 Dispersion Model #531
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
Merged
+270
−108
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
dc8fab7
fea: add sum model interface
CompRhys 38e3163
lint
CompRhys cd5b0be
fea: add alchemiops d3
CompRhys 7cae397
use less constants [skip-ci]
CompRhys ce38dc6
fix dispersion naming
CompRhys d528ef2
fea: tests with r2scan defaults
CompRhys 73e5b92
Merge remote-tracking branch 'origin/main' into dispersion
CompRhys beed8b2
Merge branch 'main' into dispersion
CompRhys 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
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,72 @@ | ||
| """Tests for the D3DispersionModel wrapper.""" | ||
|
|
||
| import traceback # noqa: I001 | ||
|
|
||
| import pytest | ||
| import torch | ||
|
|
||
| from tests.conftest import DEVICE, DTYPE | ||
| from tests.models.conftest import make_validate_model_outputs_test | ||
|
|
||
| try: | ||
| from nvalchemiops.torch.interactions.dispersion import D3Parameters | ||
|
|
||
| from torch_sim.models.dispersion import D3DispersionModel | ||
| except (ImportError, OSError, RuntimeError): | ||
| pytest.skip( | ||
| f"nvalchemiops not installed: {traceback.format_exc()}", | ||
| allow_module_level=True, | ||
| ) | ||
|
|
||
|
|
||
| def _make_d3_params(device: torch.device = DEVICE) -> D3Parameters: | ||
| """Build minimal D3 reference parameters for testing (elements up to Fe=26).""" | ||
| max_z = 26 | ||
| mesh = 5 | ||
| return D3Parameters( | ||
| rcov=torch.rand(max_z + 1, device=device), | ||
| r4r2=torch.rand(max_z + 1, device=device), | ||
| c6ab=torch.rand(max_z + 1, max_z + 1, mesh, mesh, device=device), | ||
| cn_ref=torch.rand(max_z + 1, max_z + 1, mesh, mesh, device=device), | ||
| ) | ||
|
|
||
|
|
||
| # BJ damping parameters from | ||
| # https://github.com/dftd3/simple-dftd3/blob/main/assets/parameters.toml | ||
| PBE_BJ = {"a1": 0.4289, "s8": 0.7875, "a2": 4.4407, "s6": 1.0} | ||
| R2SCAN_BJ = {"a1": 0.49484001, "s8": 0.78981345, "a2": 5.73083694, "s6": 1.0} | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def d3_model_pbe() -> D3DispersionModel: | ||
| return D3DispersionModel( | ||
| **PBE_BJ, | ||
| d3_params=_make_d3_params(), | ||
| cutoff=12.0, | ||
| device=DEVICE, | ||
| dtype=DTYPE, | ||
| compute_forces=True, | ||
| compute_stress=True, | ||
| ) | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def d3_model_r2scan() -> D3DispersionModel: | ||
| return D3DispersionModel( | ||
| **R2SCAN_BJ, | ||
| d3_params=_make_d3_params(), | ||
| cutoff=12.0, | ||
| device=DEVICE, | ||
| dtype=DTYPE, | ||
| compute_forces=True, | ||
| compute_stress=True, | ||
| ) | ||
|
|
||
|
|
||
| test_d3_pbe_outputs = make_validate_model_outputs_test( | ||
| model_fixture_name="d3_model_pbe", device=DEVICE, dtype=DTYPE | ||
| ) | ||
|
|
||
| test_d3_r2scan_outputs = make_validate_model_outputs_test( | ||
| model_fixture_name="d3_model_r2scan", device=DEVICE, dtype=DTYPE | ||
| ) | ||
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.