Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

https://github.com/qiskit-community/qiskit-nature-pyscf

Documentation at https://qiskit-community.github.io/qiskit-nature-pyscf/
https://github.com/qiskit-community/qiskit-nature-pyscf

Last synced: 17 days ago
JSON representation

Documentation at https://qiskit-community.github.io/qiskit-nature-pyscf/

Lists

README

        

# Qiskit Nature PySCF

[![License](https://img.shields.io/github/license/qiskit-community/qiskit-nature-pyscf.svg?style=popout-square)](https://opensource.org/licenses/Apache-2.0)[![Build Status](https://github.com/qiskit-community/qiskit-nature-pyscf/workflows/Nature%20PySCF%20Unit%20Tests/badge.svg?branch=main)](https://github.com/qiskit-community/qiskit-nature-pyscf/actions?query=workflow%3A"Nature%20PySCF%20Unit%20Tests"+branch%3Amain+event%3Apush)[![](https://img.shields.io/github/release/qiskit-community/qiskit-nature-pyscf.svg?style=popout-square)](https://github.com/qiskit-community/qiskit-nature-pyscf/releases)[![](https://img.shields.io/pypi/dm/qiskit-nature-pyscf.svg?style=popout-square)](https://pypi.org/project/qiskit-nature-pyscf/)[![Coverage Status](https://coveralls.io/repos/github/qiskit-community/qiskit-nature-pyscf/badge.svg?branch=main)](https://coveralls.io/github/qiskit-community/qiskit-nature-pyscf?branch=main)

**Qiskit Nature PySCF** is a third-party integration plugin of Qiskit Nature + PySCF.

## Installation

We encourage installing Qiskit Nature PySCF via the pip tool (a python package manager).

```bash
pip install qiskit-nature-pyscf
```

**pip** will handle all dependencies automatically and you will always install the latest
(and well-tested) version. It will also install Qiskit Nature if needed.

If you want to work on the very latest work-in-progress versions, either to try features ahead of
their official release or if you want to contribute to Qiskit Nature PySCF, then you can install from source.

## Usage

This plugin couples the APIs of PySCF and Qiskit Nature, enabling a user of PySCF to leverage
Quantum-based algorithms implemented in Qiskit to be used in-place of their classical counterparts.

### Active Space Calculations

One very common approach is to use a Quantum algorithm to find the ground state in an active space
calculation. To this extent, this plugin provides the `QiskitSolver` class, which you can inject
directly into your `CASCI` or `CASSCF` simulation objects of PySCF.

Below we show a simple example of how to do this.

```python
from pyscf import gto, scf, mcscf

import numpy as np

from qiskit.primitives import Estimator
from qiskit_algorithms import VQE
from qiskit_algorithms.optimizers import SLSQP
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.6", basis="sto-3g")

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()
```

More detailed information for this plugin can be found in its
[Documentation](https://qiskit-community.github.io/qiskit-nature-pyscf/). For further
information and explanations we recommend to check out the documentation of
[PySCF](https://pyscf.org/) and [Qiskit Nature](https://qiskit-community.github.io/qiskit-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