Closed frankharkins closed 1 year ago
The (minimum_)eigen_solvers
in Terra were refactored to support primitives and are in (minimum_)eigensolvers
folders (no underscore between eigen and solvers). The pre-existing algorithms are still there, currently pending_deprecation but are planned to be deprecated soon. Nature 0.5.0 in the refactored second_q
code supports only the new primitive based algorithms. The new folder has the new algorithms and the new results. There is a Numpy classical solver there too compatible with this. So the import, for a compatible solver, should be
from qiskit.algorithms.minimum_eigensolvers import NumPyMinimumEigensolver
where they need to be imported from the new folder. (The import from qiskit.algorithms are the pre-existing algorithms - this has to stay that way because of compatibility).
from qiskit_nature.second_q.mappers import QubitConverter, ParityMapper
qubit_converter = QubitConverter(ParityMapper())
from qiskit_nature.second_q.drivers import PySCFDriver
driver = PySCFDriver(
atom="H 0 0 0; H 0 0 0.72"
)
problem = driver.run()
hamiltonian = qubit_converter.convert(problem.second_q_ops()[0])
from qiskit.algorithms.minimum_eigensolvers import NumPyMinimumEigensolver
sol = NumPyMinimumEigensolver().compute_minimum_eigenvalue(hamiltonian)
real_solution = problem.interpret(sol)
@woodsp-ibm ok that makes sense. I've got it working now, thank you!
Environment
0.5.2
0.39.2
3.8.13
Linux-4.15.0-202-generic-x86_64-with-glibc2.10
What is happening?
From the docs, it seems
Should accept a Qiskit
MinimumEigensolverResult
, but this is not the case.How can we reproduce the issue?
Here's a minimal code example that shows the issue in context
Output:
What should happen?
I expect the code to run without error.
Any suggestions?
I'm a bit confused, but it seems there are two
MinimumEigensolverResult
s. It looks like the class accepted in the code iswhereas
driver.run()
NumPyMinimumEigensolver.compute_minimum_eigenvalue
returns