From bcd1dd0508c65361143d43e3df1718721661ebb3 Mon Sep 17 00:00:00 2001 From: Caleb Johnson Date: Mon, 28 Oct 2024 15:20:56 -0500 Subject: [PATCH] rearrange --- qiskit_addon_sqd/fermion.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/qiskit_addon_sqd/fermion.py b/qiskit_addon_sqd/fermion.py index 1145d70..6a5d382 100644 --- a/qiskit_addon_sqd/fermion.py +++ b/qiskit_addon_sqd/fermion.py @@ -127,17 +127,18 @@ def solve_fermion( verbose=verbose, max_cycle=max_davidson, ) - # Convert the PySCF SCIVector to internal format - sci_state = SCIState( - amplitudes=np.array(sci_vec), ci_strs_a=sci_vec._strs[0], ci_strs_b=sci_vec._strs[1] - ) # Calculate the avg occupancy of each orbital - dm1 = myci.make_rdm1s(sci_state, norb, (num_up, num_dn)) + dm1 = myci.make_rdm1s(sci_vec, norb, (num_up, num_dn)) avg_occupancy = [np.diagonal(dm1[0]), np.diagonal(dm1[1])] # Compute total spin - spin_squared = myci.spin_square(sci_state, norb, (num_up, num_dn))[0] + spin_squared = myci.spin_square(sci_vec, norb, (num_up, num_dn))[0] + + # Convert the PySCF SCIVector to internal format + sci_state = SCIState( + amplitudes=np.array(sci_vec), ci_strs_a=sci_vec._strs[0], ci_strs_b=sci_vec._strs[1] + ) return e_sci, sci_state, avg_occupancy, spin_squared