Skip to content

Commit

Permalink
Merge pull request #45 from mrossinek/proper-qiskit-density
Browse files Browse the repository at this point in the history
fix: ensure the `ElectronicDensity` is always unrestricted-spin
  • Loading branch information
mrossinek authored Sep 27, 2023
2 parents 7ccd80e + 5605d5d commit e22b7c0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
15 changes: 4 additions & 11 deletions qiskit_nature_pyscf/pyscf_ground_state_solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,17 +166,10 @@ def solve(
nelec=problem.num_particles,
)

density: ElectronicDensity
if restricted_spin:
raw_density = self.solver.make_rdm1(
ci_vec, norb=problem.num_spatial_orbitals, nelec=problem.num_particles
)
density = ElectronicDensity.from_raw_integrals(raw_density)
else:
raw_density = self.solver.make_rdm1s(
ci_vec, norb=problem.num_spatial_orbitals, nelec=problem.num_particles
)
density = ElectronicDensity.from_raw_integrals(raw_density[0], h1_b=raw_density[1])
raw_density = self.solver.make_rdm1s(
ci_vec, norb=problem.num_spatial_orbitals, nelec=problem.num_particles
)
density = ElectronicDensity.from_raw_integrals(raw_density[0], h1_b=raw_density[1])

result = ElectronicStructureResult()
result.computed_energies = np.asarray([energy])
Expand Down
10 changes: 10 additions & 0 deletions releasenotes/notes/proper-qiskit-density-0582f26cc9a669d9.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
fixes:
- |
The :class:`~qiskit_nature.second_q.properties.ElectronicDensity` object that was returned as part of the
:class:`~qiskit_nature.second_q.problems.ElectronicStructureResult` from the :class:`.PySCFGroundStateSolver`
was faultily storing restricted-spin information within the alpha-spin register even though the object is
documented as storing unrestricted spin-data. This has been fixed and the
:class:`~qiskit_nature.second_q.properties.ElectronicDensity` object is now guaranteed to store
unrestricted-spin information. If a restricted-spin density is required it may be obtained from the
:meth:`~qiskit_nature.second_q.properties.ElectronicDensity.trace_spin` method.

0 comments on commit e22b7c0

Please sign in to comment.