-
Notifications
You must be signed in to change notification settings - Fork 2
Bugfix: Add ECP Contributions #447
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
Merged
Changes from all commits
Commits
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| """Verify that ECP contributions are included in Hamiltonian one-electron integrals. | ||
|
|
||
| Bug: HamiltonianConstructor.run() computes h_core = T + V_nuc but omits V_ecp. | ||
| This causes incorrect one-electron integrals for any atom using an ECP basis | ||
| (e.g., Mo with def2-svp). | ||
| """ | ||
|
|
||
| # -------------------------------------------------------------------------------------------- | ||
| # Copyright (c) Microsoft Corporation. All rights reserved. | ||
| # Licensed under the MIT License. See LICENSE.txt in the project root for license information. | ||
| # -------------------------------------------------------------------------------------------- | ||
|
|
||
| import numpy as np | ||
| import pytest | ||
|
|
||
| from qdk_chemistry.algorithms import create | ||
| from qdk_chemistry.data import Structure | ||
|
|
||
| from .reference_tolerances import scf_energy_tolerance | ||
|
|
||
| # Mo ROHF/def2-svp reference: trace of h1e (alpha = beta for ROHF). | ||
| # Trace is unitarily invariant, so it does not depend on the MO rotation | ||
| # within degenerate subspaces (d-shell degeneracy causes different rotations | ||
| # across thread counts / platforms). | ||
| # Without ECP (bare Z=42), the trace is ~ -1800. With ECP (Z_eff=14), ~ -134. | ||
| _MO_ROHF_H1E_TRACE = -133.9900221637 | ||
|
|
||
|
|
||
| @pytest.fixture(scope="module") | ||
| def mo_rohf_orbitals(): | ||
| """ROHF orbitals for Mo atom with def2-svp (shared across both parameterized tests).""" | ||
| structure = Structure(np.array([[0.0, 0.0, 0.0]]), ["Mo"]) | ||
| scf = create("scf_solver", "qdk") | ||
| scf.settings()["method"] = "hf" | ||
| scf.settings()["scf_type"] = "restricted" | ||
| scf.settings()["enable_gdm"] = False | ||
| _, wfn = scf.run(structure, 0, 7, "def2-svp") | ||
| return wfn.get_orbitals() | ||
|
|
||
|
|
||
| @pytest.mark.parametrize("constructor_name", ["qdk", "qdk_cholesky"]) | ||
| def test_ecp_included_in_hamiltonian_h1e(mo_rohf_orbitals, constructor_name): | ||
| """h1e from HamiltonianConstructor must include ECP terms for Mo/def2-svp.""" | ||
| ham = create("hamiltonian_constructor", constructor_name).run(mo_rohf_orbitals) | ||
| h1e_a, h1e_b = ham.get_one_body_integrals() | ||
|
|
||
| np.testing.assert_allclose(np.trace(h1e_a), _MO_ROHF_H1E_TRACE, atol=scf_energy_tolerance) | ||
| np.testing.assert_allclose(np.trace(h1e_b), _MO_ROHF_H1E_TRACE, atol=scf_energy_tolerance) |
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.