Skip to content
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

Fix bugs in optimize_orbitals related to open-shell workflows #71

Merged
merged 7 commits into from
Oct 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.