diff --git a/qiskit_addon_sqd/fermion.py b/qiskit_addon_sqd/fermion.py index 92a6f87..1c7f13b 100644 --- a/qiskit_addon_sqd/fermion.py +++ b/qiskit_addon_sqd/fermion.py @@ -231,8 +231,9 @@ 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 @@ -240,7 +241,7 @@ def optimize_orbitals( 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( diff --git a/releasenotes/notes/oo-bug-occs-3c348b86ee03857f.yaml b/releasenotes/notes/oo-bug-occs-3c348b86ee03857f.yaml new file mode 100644 index 0000000..e848bce --- /dev/null +++ b/releasenotes/notes/oo-bug-occs-3c348b86ee03857f.yaml @@ -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.