Skip to main content

Faster simulations of fermionic quantum circuits.

Project description

ffsim

ffsim is a software library for simulating fermionic quantum circuits that conserve particle number and the Z component of spin. This category includes many quantum circuits used for quantum chemistry simulations. By exploiting the symmetries and using specialized algorithms, ffsim can simulate these circuits much faster than a generic quantum circuit simulator.

Documentation

Documentation is located at the project website.

Installation

We recommend installing ffsim using pip, when possible:

pip install ffsim

This method won't work natively on Windows, however. Refer to the installation instructions for information about using ffsim on Windows, as well as instructions for installing from source and running ffsim in a container.

Code example

import numpy as np
import pyscf

import ffsim

# Build an N2 molecule
mol = pyscf.gto.Mole()
mol.build(atom=[["N", (0, 0, 0)], ["N", (1.0, 0, 0)]], basis="6-31g", symmetry="Dooh")

# Get molecular data
scf = pyscf.scf.RHF(mol).run()
mol_data = ffsim.MolecularData.from_scf(scf, active_space=range(4, mol.nao_nr()))
norb, nelec = mol_data.norb, mol_data.nelec

# Generate a random orbital rotation
orbital_rotation = ffsim.random.random_unitary(norb, seed=1234)

# Create the Hartree-Fock state and apply the orbital rotation to it
vec = ffsim.hartree_fock_state(norb, nelec)
vec = ffsim.apply_orbital_rotation(vec, orbital_rotation, norb=norb, nelec=nelec)

# Convert the Hamiltonian to a Scipy LinearOperator
linop = ffsim.linear_operator(mol_data.hamiltonian, norb=norb, nelec=nelec)

# Compute the energy of the state
energy = np.vdot(vec, linop @ vec).real
print(energy)  # prints -104.17181289596

Citing ffsim

You can cite ffsim using the following BibTeX:

@software{ffsim,
  author = {{The ffsim developers}},
  title = {{ffsim: Faster simulations of fermionic quantum circuits.}},
  url = {https://github.com/qiskit-community/ffsim}
}

Developer guide

See the developer guide for instructions on contributing code to ffsim.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ffsim-0.0.41.tar.gz (547.7 kB view details)

Uploaded Source

Built Distributions

ffsim-0.0.41-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (13.1 MB view details)

Uploaded CPython 3.9+ manylinux: glibc 2.17+ x86-64

ffsim-0.0.41-cp39-abi3-macosx_11_0_arm64.whl (567.4 kB view details)

Uploaded CPython 3.9+ macOS 11.0+ ARM64

ffsim-0.0.41-cp39-abi3-macosx_10_9_x86_64.whl (574.2 kB view details)

Uploaded CPython 3.9+ macOS 10.9+ x86-64

File details

Details for the file ffsim-0.0.41.tar.gz.

File metadata

  • Download URL: ffsim-0.0.41.tar.gz
  • Upload date:
  • Size: 547.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.0 CPython/3.12.4

File hashes

Hashes for ffsim-0.0.41.tar.gz
Algorithm Hash digest
SHA256 0c9671223a8936ec9912f14d98e0cbe3f096dc964efe0365645d29fe8755b7bd
MD5 cc6f9e7903695816e0bb15d1efc69036
BLAKE2b-256 04d02f86c131a51e397eb54ddda07c48820509dcd4570965841ff1f67ee111da

See more details on using hashes here.

Provenance

File details

Details for the file ffsim-0.0.41-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for ffsim-0.0.41-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 1161ee1c86a37efb0a8ca97bcb19b0296a01584ec0e7f229f32d6fb757963d8f
MD5 3983071de11bd50b9ec2a0bbed104390
BLAKE2b-256 31831098b2fbeda4401a4e5fb1f98f975e0d33312f8761747e50cc959bacb48e

See more details on using hashes here.

Provenance

File details

Details for the file ffsim-0.0.41-cp39-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for ffsim-0.0.41-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 3786306ab0621eb7226251771031adddcc58b5a28487630ef9098fc9331fe98b
MD5 7cc0b17c84626980a478047b315dd1bc
BLAKE2b-256 ccbd4d3bddb15d0510499e3370bf5408af4386356324bae09dcfaf5b0c679334

See more details on using hashes here.

Provenance

File details

Details for the file ffsim-0.0.41-cp39-abi3-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for ffsim-0.0.41-cp39-abi3-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 5b1479550c204c8c58f9bd55b02e372e93f1d3002fdb12d554744c94f043a58f
MD5 6c8e212e60675071baad3e107a0c08ad
BLAKE2b-256 cf342e51e00a27666be00fc3b2b9123c148a8ac809089a928f811f562e49b35a

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page