from qiskit.opflow import I, X, Y, Z

h2_op = (
    -1.052373245772859 * (I ^ I)
    + 0.39793742484318045 * (I ^ Z)
    - 0.39793742484318045 * (Z ^ I)
    - 0.01128010425623538 * (Z ^ Z)
    + 0.18093119978423156 * (X ^ X)
)

list_aux_ops = [
    2.0 * (I ^ I),
    0.5 * (
        (I ^ I) + (Z ^ Z) + (Y ^ Y) - (X ^ X)
    ),
]

dict_aux_ops = {
    "AuxOp1": 2.0 * (I ^ I),
    "AuxOp2": 0.5 * (
        (I ^ I) + (Z ^ Z) + (Y ^ Y) - (X ^ X)
    ),
}

from qiskit.algorithms import NumPyMinimumEigensolver

solver = NumPyMinimumEigensolver()

list_result = solver.compute_minimum_eigenvalue(h2_op, aux_operators=list_aux_ops)
print(list_result)

dict_result = solver.compute_minimum_eigenvalue(h2_op, aux_operators=dict_aux_ops)
print(dict_result)

from qiskit_nature.drivers import Molecule
from qiskit_nature.drivers.second_quantization import (
    ElectronicStructureMoleculeDriver,
    ElectronicStructureDriverType,
)

molecule = Molecule(geometry=[("H", (0.0, 0.0, 0.0)), ("H", (0.0, 0.0, 0.735))])
driver = ElectronicStructureMoleculeDriver(molecule, "sto3g", driver_type=ElectronicStructureDriverType.PYSCF)

from qiskit_nature.problems.second_quantization import ElectronicStructureProblem

problem = ElectronicStructureProblem(driver)

problem.second_q_ops()

from qiskit_nature import settings
settings.dict_aux_operators = True

problem.second_q_ops()

from qiskit_nature.converters.second_quantization import QubitConverter
from qiskit_nature.mappers.second_quantization import JordanWignerMapper

converter = QubitConverter(JordanWignerMapper())

from qiskit_nature.algorithms.ground_state_solvers import GroundStateEigensolver
from qiskit_nature.algorithms.ground_state_solvers.minimum_eigensolver_factories import NumPyMinimumEigensolverFactory

solver = GroundStateEigensolver(converter, NumPyMinimumEigensolverFactory(use_default_filter_criterion=True))

result = solver.solve(problem)
print(result)

import qiskit.tools.jupyter
%qiskit_version_table
%qiskit_copyright