QiskitSolver#
- class QiskitSolver(solver)[source]#
Bases:
object
A Qiskit-based FCI solver for PySCF.
This class bridges the APIs of PySCF and Qiskit Nature. You can use an instance of it to overwrite the
fcisolver
attribute of apyscf.mcscf.casci.CASCI
object, in order to use a Quantum algorithm as provided by Qiskit for the CI solution step. Depending on the algorithm and its configuration, this may not result in the true FCI result, so care must be taken when using this class.Here is an example use case:
from pyscf import gto, scf, mcscf from qiskit_algorithms import VQE from qiskit_algorithms.optimizers import SLSQP from qiskit.primitives import Estimator from qiskit_nature.second_q.algorithms import GroundStateEigensolver from qiskit_nature.second_q.circuit.library import HartreeFock, UCCSD from qiskit_nature.second_q.mappers import ParityMapper from qiskit_nature_pyscf import QiskitSolver mol = gto.M(atom="Li 0 0 0; H 0 0 1.51", basis="631g*") h_f = scf.RHF(mol).run() norb = 2 nalpha, nbeta = 1, 1 nelec = nalpha + nbeta cas = mcscf.CASCI(h_f, norb, nelec) mapper = ParityMapper(num_particles=(nalpha, nbeta)) ansatz = UCCSD( norb, (nalpha, nbeta), mapper, initial_state=HartreeFock( norb, (nalpha, nbeta), mapper, ), ) vqe = VQE(Estimator(), ansatz, SLSQP()) vqe.initial_point = np.zeros(ansatz.num_parameters) algorithm = GroundStateEigensolver(mapper, vqe) cas.fcisolver = QiskitSolver(algorithm) cas.run()
For more details please to the documentation of PySCF and Qiskit Nature.
An instance of this class has the following attributes:
- solver#
a ground-state solver provided by Qiskit Nature. This must be supplied by the user prior to running the algorithm.
- density#
an ElectronicDensity provided by Qiskit Nature. This is only available after the first iteration of the algorithm.
- result#
an ElectronicStructureResult provided by Qiskit Nature. This is only available after the first iteration of the algorithm.
- Parameters:
solver (GroundStateSolver) – a ground-state solver provided by Qiskit Nature.
Methods
approx_kernel
(h1, h2, norb, nelec[, ci0, ecore])Finds the ground-state of the provided Hamiltonian.
kernel
(h1, h2, norb, nelec[, ci0, ecore])Finds the ground-state of the provided Hamiltonian.
make_rdm1
(fake_ci_vec, norb, nelec)Constructs the spin-traced 1-RDM.
make_rdm12
(fake_ci_vec, norb, nelec)Constructs the spin-traced 1- and 2-RDMs.
make_rdm12s
(fake_ci_vec, norb, nelec)Constructs the alpha- and beta-spin 1- and 2-RDMs.
make_rdm1s
(fake_ci_vec, norb, nelec)Constructs the alpha- and beta-spin 1-RDMs.