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.38.tar.gz (513.1 kB view details)

Uploaded Source

Built Distributions

ffsim-0.0.38-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.38-cp39-abi3-macosx_11_0_arm64.whl (554.8 kB view details)

Uploaded CPython 3.9+ macOS 11.0+ ARM64

ffsim-0.0.38-cp39-abi3-macosx_10_12_x86_64.whl (561.6 kB view details)

Uploaded CPython 3.9+ macOS 10.12+ x86-64

File details

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

File metadata

  • Download URL: ffsim-0.0.38.tar.gz
  • Upload date:
  • Size: 513.1 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.38.tar.gz
Algorithm Hash digest
SHA256 35475187709b3766b6bfb3c04ad1f0bda7268e07bd1f9bf15e8f6e25b30fa142
MD5 92b4b6eff4d132240aad8535acaffca4
BLAKE2b-256 0630056573696fd05c8912a846fff494d1e5871e56f1580d2f046d2821678d04

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for ffsim-0.0.38-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 7444aeadb223d49e356431039e11adc47b2a0abc839c6509e44fa24fe584c28e
MD5 b2960b6f7724b1e3bf31706e7054f714
BLAKE2b-256 6d2f0a25df84c3d84320a563e883a45054d4f524a6af6976a0482b93b3de9173

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for ffsim-0.0.38-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 90db3f215729d8bd8b9b7a5b397e746ec260ad691afd65c4e246e40bc969d3b9
MD5 b1c32d48c86d6e19e12a1bada06045e1
BLAKE2b-256 1e15320688a2bb6d3a1c04acfb83ed4b17fb98b64f6880cfb0c6de700f2040e6

See more details on using hashes here.

Provenance

File details

Details for the file ffsim-0.0.38-cp39-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for ffsim-0.0.38-cp39-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 b36b12615b6310f81599cd998213c7614f72aeca31c53856fa58d37743779ea4
MD5 fa896e94df4d3f075866e7b2e6d256c4
BLAKE2b-256 6f1941b8e575dc8bdae63e6ccffeeae62f8f69557096e99e4e4b27ed5ebfcacd

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