-
Notifications
You must be signed in to change notification settings - Fork 2
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
sanity check all pickled non-interacting Hamiltonians in h0 directory #52
Merged
Merged
Changes from all commits
Commits
Show all changes
37 commits
Select commit
Hold shift + click to select a range
cd98d68
sanity check all non-interacting Hamiltonians in pickled files in the…
JohanSchott 99eae10
projected angular momentum should be between -L and L
JohanSchott 84bb9cd
use pickle.load
JohanSchott 279ec77
Use default values for stdout and stderr. Want to see where the unit-…
JohanSchott c17494f
another attempt to see the error traceback from the subprocess
JohanSchott a41d0db
debug printing and removing mpirun. Do not understand why python comm…
JohanSchott ceb574b
try mpiexec
JohanSchott 78dd4a1
edit github action script
JohanSchott e164afb
install python3-mpi4py. Remove openmpi-bin and libopenmpi-dev
JohanSchott fd120a1
correctly remove libs in requirements-ubuntu.txt
JohanSchott 32621f2
add back openmpi-bin and libopenmpi-dev
JohanSchott 812f632
try echo in parallel
JohanSchott 90fcb49
can not reproduce mpi issue locally. Another commit to investigate fa…
JohanSchott a733919
install some more stuff
JohanSchott 0fce41d
run mpiexec not in subprocess
JohanSchott 93f07d0
narrow down what is causing the MPI problem.
JohanSchott be2e228
skip comparison
JohanSchott efdb6ca
black fix.
JohanSchott da733ba
ruff fix.
JohanSchott d58bd68
try also pytest
JohanSchott 7c426dc
try to run real script again.
JohanSchott 4b04f57
add back comparison
JohanSchott d1f7e9f
ruff fix.
JohanSchott e52300b
use $ranks processes
JohanSchott 3ec341e
only pytest
JohanSchott e794715
run all pytests
JohanSchott 80e2bdd
do not treat warnings as errors
JohanSchott bc383c1
remove mpi stuff and checks
JohanSchott eaac5bf
use mpiexec when run all unit-tests
JohanSchott 8b8109f
ignore test_comparison_with_reference.py in pytest.ini since it start…
fcda47f
run subprocess as a separate pytest job.
fcd732d
add documentation
185cd51
clean up scripts/run_Ni_NiO_Xbath.sh
114a836
remove mpi libs in requirements-ubuntu.txt
86d2d2f
use subprocess.run with check=True
JohanSchott 0d5b4d6
remove extra white spacing
JohanSchott 9ef052d
remove unneccecary print statement and unused variable.
JohanSchott 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 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 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 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 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 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,58 @@ | ||
import os | ||
from glob import glob | ||
|
||
from impurityModel.ed.get_spectra import read_pickled_file | ||
|
||
DIR_PATH = os.path.dirname(os.path.realpath(__file__)) | ||
|
||
|
||
def test_read_all_h0_pickle_files(): | ||
for h0_filename in glob(os.path.join(DIR_PATH, "../../h0/h0*.pickle")): | ||
h0 = read_pickled_file(h0_filename) | ||
|
||
string = os.path.basename(h0_filename).split(".")[0].split("_")[-1].split("bath")[0] | ||
nBaths_tot = sum([int(nbath) for nbath in string.split("p")]) | ||
# So far, in all the non-interacting Hamiltonians the angular momentum is equal to two | ||
# for the correlated orbitals that are coupled to the bath states. | ||
nBaths = {2: nBaths_tot} | ||
|
||
sanity_check_non_interacting_hamiltonian(h0, nBaths) | ||
|
||
|
||
def sanity_check_non_interacting_hamiltonian(h0: dict[tuple, complex], nBaths: dict[int, int]): | ||
""" | ||
Sanity check non-interacting Hamiltonian operator. | ||
|
||
Parameters | ||
------- | ||
h0: | ||
Non-interacting Hamiltonian operator. | ||
Describes impurity orbitals and bath orbitals. | ||
Each tuple key describes a process of two steps: annihilation followed by creation. | ||
Each step is described by a tuple of the form: | ||
(spin_orb, 'c') for creation, and | ||
(spin_orb, 'a') for annihilation, | ||
where spin_orb is a tuple of the form (l, s, m) or (l, b) or ((l_a, l_b), b). | ||
nBaths: | ||
angular momentum: number of bath states coupled to the correlated orbitals with this angular momentum. | ||
""" | ||
for process, value in h0.items(): | ||
assert isinstance(value, complex) | ||
assert len(process) == 2 # two events in non-interacting Hamiltonian | ||
assert process[1][1] == "a" # First event is annihilation | ||
assert process[0][1] == "c" # Second event is creation | ||
for event in process[::-1]: | ||
assert len(event) == 2 # spin-orbit and create or remove | ||
spin_orbit_info = event[0] | ||
if len(spin_orbit_info) == 2: | ||
l, bath_index = spin_orbit_info | ||
assert 0 <= l <= 3 | ||
assert 0 <= bath_index < nBaths[l] | ||
elif len(spin_orbit_info) == 3: | ||
l, s, m = spin_orbit_info | ||
assert l in nBaths | ||
assert 0 <= l <= 3 | ||
assert s in (0, 1) | ||
assert m in range(-l, l + 1) | ||
else: | ||
raise ValueError(f"{spin_orbit_info}") |
This file contains 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 |
---|---|---|
@@ -1,6 +1,8 @@ | ||
[pytest] | ||
testpaths = impurityModel | ||
|
||
# Test test_comparison_with_reference.py in a separate pytest call since it starts MPI processes in a subprocess.run, and | ||
# MPI can't handle that both the parent and the child process use MPI. | ||
addopts = --ignore impurityModel/test/test_comparison_with_reference.py | ||
|
||
filterwarnings = | ||
error | ||
filterwarnings = error |
This file contains 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 |
---|---|---|
@@ -1,7 +1,8 @@ | ||
build-essential | ||
gfortran | ||
openmpi-bin | ||
libopenmpi-dev | ||
python3 | ||
python3-dev | ||
python3-venv | ||
python3-mpi4py | ||
openmpi-bin | ||
libopenmpi-dev |
This file contains 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.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no need to check events in any particular order.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The order does not matter in this for-loop. But when a process is used for real, i.e. applied on a product state, the order matters.
The order is chosen such that$c_i^\dagger c_j \ket{\Psi}$ is implemented as process $\ket{\Psi}$ (with
((i, 'c'), (j, 'a'))
operating on the state'c'
denoting creation and'a'
annihilation). So the right-most "event" is first applied, and finally the left-most "event", just like the math expression.Relevant documentation e.g. https://github.com/JohanSchott/impurityModel/blob/master/impurityModel/ed/finite.py#L1320
https://github.com/JohanSchott/impurityModel/blob/master/impurityModel/ed/finite.py#L1395
And in the same way is the Coulomb interaction process between two electrons:
$c_i^\dagger c_j^\dagger c_k c_l$ implemented as
((i, 'c'), (j, 'c'), (k, 'a'), (l, 'a'))
https://github.com/JohanSchott/impurityModel/blob/master/impurityModel/ed/finite.py#L1322
Because of this I think it might be good to consistently loop over events "from right to left" in this repo.