Find ground state energy using the NumPyMinimumEigensolver#

In order to ensure a physically meaningful ground state of a hamiltonian is found when using the NumPyMinimumEigensolver one needs to set the filter_criterion attribute of the solver.

Subclasses of BaseProblem in Qiskit Nature provide the get_default_filter_criterion() method which provides a default implementation of such a filter criterion for commonly encountered cases.

Below we show how you can use this setting.

  1. We obtain an ElectronicStructureProblem which we want to solve:

from qiskit_nature.second_q.drivers import PySCFDriver
driver = PySCFDriver(atom="H 0 0 0; H 0 0 0.735", basis="sto-3g")
problem =
  1. We setup our QubitMapper:

from qiskit_nature.second_q.mappers import JordanWignerMapper
mapper = JordanWignerMapper()
  1. We setup our NumPyMinimumEigensolver:

from qiskit_algorithms import NumPyMinimumEigensolver
algo = NumPyMinimumEigensolver()
algo.filter_criterion = problem.get_default_filter_criterion()
  1. We wrap everything in a GroundStateEigensolver:

from qiskit_nature.second_q.algorithms import GroundStateEigensolver
solver = GroundStateEigensolver(mapper, algo)
  1. We solve the problem:

result = solver.solve(problem)

print(f"Total ground state energy = {result.total_energies[0]:.4f}")
Total ground state energy = -1.1373