diff --git a/.pylintdict b/.pylintdict index 98f03d9..ee37094 100644 --- a/.pylintdict +++ b/.pylintdict @@ -1,3 +1,4 @@ +ansatz args autosummary bool @@ -18,6 +19,8 @@ kwargs makefile mcscf mol +nalpha +nbeta ndarray nelec norb diff --git a/README.md b/README.md index 3bf42d2..9660760 100644 --- a/README.md +++ b/README.md @@ -35,11 +35,14 @@ Below we show a simple example of how to do this. ```python from pyscf import gto, scf, mcscf +import numpy as np + +from qiskit.algorithms.minimum_eigensolvers import VQE from qiskit.algorithms.optimizers import SLSQP from qiskit.primitives import Estimator -from qiskit_nature.second_q.algorithms import GroundStateEigensolver, VQEUCCFactory -from qiskit_nature.second_q.circuit.library import UCCSD -from qiskit_nature.second_q.mappers import ParityMapper, QubitConverter +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 @@ -47,15 +50,29 @@ mol = gto.M(atom="Li 0 0 0; H 0 0 1.6", basis="sto-3g") h_f = scf.RHF(mol).run() -norb, nelec = 2, 2 +norb = 2 +nalpha, nbeta = 1, 1 +nelec = nalpha + nbeta cas = mcscf.CASCI(h_f, norb, nelec) -converter = QubitConverter(ParityMapper(), two_qubit_reduction=True) +mapper = ParityMapper(num_particles=(nalpha, nbeta)) + +ansatz = UCCSD( + norb, + (nalpha, nbeta), + mapper, + initial_state=HartreeFock( + norb, + (nalpha, nbeta), + mapper, + ), +) -vqe = VQEUCCFactory(Estimator(), UCCSD(), SLSQP()) +vqe = VQE(Estimator(), ansatz, SLSQP()) +vqe.initial_point = np.zeros(ansatz.num_parameters) -algorithm = GroundStateEigensolver(converter, vqe) +algorithm = GroundStateEigensolver(mapper, vqe) cas.fcisolver = QiskitSolver(algorithm) @@ -66,3 +83,12 @@ More detailed documentation can be found at [Documentation](https://qiskit-community.github.io/qiskit-nature-pyscf/). For more detailed explanations we recommend to check out the documentation of [PySCF](https://pyscf.org/) and [Qiskit Nature](https://qiskit.org/documentation/nature/). + + +## Citation + +If you use this plugin, please cite the following references: + +- PySCF, as per [these instructions](https://github.com/pyscf/pyscf#citing-pyscf). +- Qiskit, as per the provided [BibTeX file](https://github.com/Qiskit/qiskit/blob/master/Qiskit.bib). +- Qiskit Nature, as per https://doi.org/10.5281/zenodo.7828767 diff --git a/docs/conf.py b/docs/conf.py index faddaa4..da64a4b 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -1,6 +1,6 @@ # This code is part of Qiskit. # -# (C) Copyright IBM 2022. +# (C) Copyright IBM 2022, 2023. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory @@ -210,7 +210,7 @@ "python": ("https://docs.python.org/3", None), "numpy": ("https://numpy.org/doc/stable", None), "scipy": ("https://docs.scipy.org/doc/scipy", None), - "qiskit_nature": ("https://qiskit.org/documentation/nature", None), + "qiskit_nature": ("https://qiskit.org/ecosystem/nature", None), "qiskit": ("https://qiskit.org/documentation", None), } diff --git a/docs/index.rst b/docs/index.rst index faa96a2..9aa737e 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -9,6 +9,16 @@ Overview To get started we suggest looking at the README on Github ``_. +Citation +======== + +If you use this plugin, please cite the following references: + +- PySCF, as per `these instructions `_. +- Qiskit, as per the provided `BibTeX file `_. +- Qiskit Nature, as per https://doi.org/10.5281/zenodo.7828767 + + Next Steps ================================= diff --git a/qiskit_nature_pyscf/qiskit_solver.py b/qiskit_nature_pyscf/qiskit_solver.py index 044433e..a1d6605 100644 --- a/qiskit_nature_pyscf/qiskit_solver.py +++ b/qiskit_nature_pyscf/qiskit_solver.py @@ -1,6 +1,6 @@ # This code is part of Qiskit. # -# (C) Copyright IBM 2022. +# (C) Copyright IBM 2022, 2023. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory @@ -49,11 +49,12 @@ class QiskitSolver: from pyscf import gto, scf, mcscf + from qiskit.algorithms.minimum_eigensolvers import VQE from qiskit.algorithms.optimizers import SLSQP from qiskit.primitives import Estimator - from qiskit_nature.second_q.algorithms import GroundStateEigensolver, VQEUCCFactory - from qiskit_nature.second_q.circuit.library import UCCSD - from qiskit_nature.second_q.mappers import ParityMapper, QubitConverter + 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 @@ -61,15 +62,29 @@ class QiskitSolver: h_f = scf.RHF(mol).run() - norb, nelec = 2, 2 + norb = 2 + nalpha, nbeta = 1, 1 + nelec = nalpha + nbeta cas = mcscf.CASCI(h_f, norb, nelec) - converter = QubitConverter(ParityMapper(), two_qubit_reduction=True) + mapper = ParityMapper(num_particles=(nalpha, nbeta)) + + ansatz = UCCSD( + norb, + (nalpha, nbeta), + mapper, + initial_state=HartreeFock( + norb, + (nalpha, nbeta), + mapper, + ), + ) - vqe = VQEUCCFactory(Estimator(), UCCSD(), SLSQP()) + vqe = VQE(Estimator(), ansatz, SLSQP()) + vqe.initial_point = np.zeros(ansatz.num_parameters) - algorithm = GroundStateEigensolver(converter, vqe) + algorithm = GroundStateEigensolver(mapper, vqe) cas.fcisolver = QiskitSolver(algorithm) diff --git a/releasenotes/notes/compatibility-with-qiskit-nature-0.6-7f1189fe41833678.yaml b/releasenotes/notes/compatibility-with-qiskit-nature-0.6-7f1189fe41833678.yaml new file mode 100644 index 0000000..c0af57e --- /dev/null +++ b/releasenotes/notes/compatibility-with-qiskit-nature-0.6-7f1189fe41833678.yaml @@ -0,0 +1,6 @@ +--- +fixes: + - | + Ensures compatibility of this plugin with Qiskit Nature 0.6. + The examples are updated in order to avoid triggering deprecation warnings. + Using Qiskit Nature 0.5 is still supported. diff --git a/requirements.txt b/requirements.txt index 5f1a8e5..b0afc69 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,3 @@ -qiskit-nature>=0.5.* -pyscf>=2.0.* -setuptools>=40.1.0,<=65.5.1 +qiskit-nature>=0.6 +pyscf>=2.0 +setuptools>=40.1.0 diff --git a/test/test_qiskit_solver.py b/test/test_qiskit_solver.py index 7ad321b..d3e16de 100644 --- a/test/test_qiskit_solver.py +++ b/test/test_qiskit_solver.py @@ -1,6 +1,6 @@ # This code is part of Qiskit. # -# (C) Copyright IBM 2022. +# (C) Copyright IBM 2022, 2023. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory @@ -16,8 +16,9 @@ from pyscf import gto, scf, mcscf -from qiskit_nature.second_q.algorithms import GroundStateEigensolver, NumPyMinimumEigensolverFactory -from qiskit_nature.second_q.mappers import JordanWignerMapper, QubitConverter +from qiskit.algorithms.minimum_eigensolvers import NumPyMinimumEigensolver +from qiskit_nature.second_q.algorithms import GroundStateEigensolver +from qiskit_nature.second_q.mappers import JordanWignerMapper from qiskit_nature_pyscf.qiskit_solver import QiskitSolver @@ -37,8 +38,8 @@ def test_rhf_casci_h2(self): qcas = mcscf.CASCI(h_f, norb, nelec) ground_state_solver = GroundStateEigensolver( - QubitConverter(JordanWignerMapper()), - NumPyMinimumEigensolverFactory(), + JordanWignerMapper(), + NumPyMinimumEigensolver(), ) qcas.fcisolver = QiskitSolver(ground_state_solver) @@ -60,8 +61,8 @@ def test_uhf_ucasci_h2(self): qcas = mcscf.UCASCI(h_f, norb, nelec) ground_state_solver = GroundStateEigensolver( - QubitConverter(JordanWignerMapper()), - NumPyMinimumEigensolverFactory(), + JordanWignerMapper(), + NumPyMinimumEigensolver(), ) qcas.fcisolver = QiskitSolver(ground_state_solver) @@ -83,8 +84,8 @@ def test_rhf_casscf_h2(self): qcas = mcscf.CASSCF(h_f, norb, nelec) ground_state_solver = GroundStateEigensolver( - QubitConverter(JordanWignerMapper()), - NumPyMinimumEigensolverFactory(), + JordanWignerMapper(), + NumPyMinimumEigensolver(), ) qcas.fcisolver = QiskitSolver(ground_state_solver) @@ -106,8 +107,8 @@ def test_uhf_ucasscf_h2(self): qcas = mcscf.UCASSCF(h_f, norb, nelec) ground_state_solver = GroundStateEigensolver( - QubitConverter(JordanWignerMapper()), - NumPyMinimumEigensolverFactory(), + JordanWignerMapper(), + NumPyMinimumEigensolver(), ) qcas.fcisolver = QiskitSolver(ground_state_solver)