Skip to content

Commit

Permalink
Fix bugs in fermion module affecting open shell systems (#74)
Browse files Browse the repository at this point in the history
* Fix bugs in fermion module causing open-shell systems to have their spin-up/down determinants flipped before solving

* Clean up comment
  • Loading branch information
caleb-johnson authored Oct 7, 2024
1 parent 45c89c2 commit 8c5948d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
3 changes: 0 additions & 3 deletions qiskit_addon_sqd/fermion.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ def solve_fermion(
else:
# This will become the default code path after the deprecation period.
ci_strs = bitstring_matrix_to_ci_strs(bitstring_matrix, open_shell=open_shell)
ci_strs = ci_strs[::-1]
ci_strs = _check_ci_strs(ci_strs)

num_up = format(ci_strs[0][0], "b").count("1")
Expand Down Expand Up @@ -199,9 +198,7 @@ def optimize_orbitals(
)
ci_strs = bitstring_matrix
else:
# Flip the output so the alpha CI strs are on the left with [::-1]
ci_strs = bitstring_matrix_to_ci_strs(bitstring_matrix, open_shell=open_shell)
ci_strs = ci_strs[::-1]
ci_strs = _check_ci_strs(ci_strs)

num_up = format(ci_strs[0][0], "b").count("1")
Expand Down
3 changes: 3 additions & 0 deletions releasenotes/notes/fermion-bug-2b2ed34f979b1321.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fixes:
- |
Fixes a bug in :func:`qiskit_addon_sqd.fermion.solve_fermion` and :func:`qiskit_addon_sqd.fermion.optimize_orbitals` which causes the determinants for spin-up and spin-down to be incorrectly flipped before solving.

0 comments on commit 8c5948d

Please sign in to comment.