Skip to content

Commit

Permalink
Fix bugs in optimize_orbitals related to open-shell workflows (#71)
Browse files Browse the repository at this point in the history
* Fix OO bug

* Fix bug in RDM creation

* Update release note

* Fix spin-down occs

* Fix bugs in orbital optimization affecting open-shell

* typo
  • Loading branch information
caleb-johnson authored Oct 7, 2024
1 parent 466ac78 commit 45c89c2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 3 additions & 2 deletions qiskit_addon_sqd/fermion.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,16 +231,17 @@ def optimize_orbitals(
)

# Generate the one and two-body reduced density matrices from latest wavefunction amplitudes
dm1, dm2_chem = myci.make_rdm12(amplitudes, num_orbitals, (num_up, num_up))
dm1, dm2_chem = myci.make_rdm12(amplitudes, num_orbitals, (num_up, num_dn))
dm2 = np.asarray(dm2_chem.transpose(0, 2, 3, 1), order="C")
dm1a, dm1b = myci.make_rdm1s(amplitudes, num_orbitals, (num_up, num_dn))

# TODO: Expose the momentum parameter as an input option
# Optimize the basis rotations
_optimize_orbitals_sci(
k_flat, learning_rate, 0.9, num_steps_grad, dm1, dm2, hcore, eri_phys
)

return e_qsci, k_flat, [np.diagonal(dm1), np.diagonal(dm1)]
return e_qsci, k_flat, [np.diagonal(dm1a), np.diagonal(dm1b)]


def rotate_integrals(
Expand Down
4 changes: 4 additions & 0 deletions releasenotes/notes/oo-bug-occs-3c348b86ee03857f.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
fixes:
- |
Fixed a bug in open-shell workflows which would cause :func:`qiskit_addon_sqd.fermion.optimize_orbitals` to crash with a ``malloc`` error.

0 comments on commit 45c89c2

Please sign in to comment.