Skip to main content

A framework for fermionic quantum simulation based on variational quantum algorithms.

Project description

Carcará logo

License: MIT PyPI

Carcará

Carcará is a framework for fermionic quantum simulation based on variational quantum algorithms, engineered from the ground up for deployment on real quantum hardware.

Overview

Carcará connects theoretical condensed matter physics with NISQ-era quantum hardware. Engineered around variational workflows, the framework streamlines the pipeline from mapping complex fermionic Hamiltonians onto qubit operators to optimizing ansatz states and executing error-mitigated circuits on real quantum backends.

Key Features

  • Fermion-to-Qubit Mapping: Built-in, optimized transformations including Jordan-Wigner, Bravyi-Kitaev, and parity mappings to translate fermionic creation/annihilation operators into Pauli strings.

  • Hardware-Efficient & Physics-Inspired Ansatzes: Ready-to-use ansatz generation, including Unitary Coupled Cluster (UCCSD) and hardware-efficient templates designed to minimize circuit depth and gate errors on real QPUs.

  • Hybrid Variational Solvers: Robust implementation of the Variational Quantum Eigensolver (VQE) and its time-dependent variants, coupled with state-of-the-art classical optimizers (e.g., SPSA, COBYLA, SLSQP).

  • Real Hardware Deployment: Seamless integration with major quantum cloud providers (IBM Quantum Platform) with native support.

  • Advanced Error Mitigation: Built-in noise-resilient pipelines featuring Zero-Noise Extrapolation (ZNE) and symmetry verification.

Installation

From pip

The easiest way to install Carcará is with pip:

pip install carcara

From github

To install Carcará directly from the GitHub repository, run the following commands:

git clone https://github.com/seixas-research/carcara.git
cd carcara
pip install -e .

Getting started

One- and two-body integrals for H2

The carcara.integrals module computes real-space one- and two-body integrals over any localized basis. The example below builds a minimal basis of one hydrogen 1s orbital on each proton and evaluates the core Hamiltonian and the electron-repulsion tensor. The full script lives in examples/h2_integrals.py.

import numpy as np

from carcara.basis import HydrogenicOrbital
from carcara.integrals import Grid, IntegralEngine

# Geometry (atomic units): two protons at the H2 equilibrium bond length.
Z, R = 1.0, 1.4
nuclei = np.array([[0.0, 0.0, -R / 2], [0.0, 0.0, +R / 2]])

def nuclear_potential(x, y, z):
    v = np.zeros_like(x, dtype=float)
    for Rx, Ry, Rz in nuclei:
        r = np.sqrt((x - Rx) ** 2 + (y - Ry) ** 2 + (z - Rz) ** 2)
        v -= Z / np.maximum(r, 1e-12)
    return v

grid = Grid(center=[0.0, 0.0, 0.0], box_size=10.0, points=64)
basis = [HydrogenicOrbital(1, 0, 0, Z=Z, center=nuclei[0]),
         HydrogenicOrbital(1, 0, 0, Z=Z, center=nuclei[1])]

engine = IntegralEngine(basis, grid)

# One-body: kinetic T and nuclear attraction V -> core Hamiltonian.
T, V = engine.one_body(nuclear_potential)
h_core = T + V

# Two-body electron-repulsion tensor (ab|cd) in chemists' notation.
eri = engine.two_body(method="fft")

print("Core Hamiltonian h = T + V (Ha):")
print(h_core.real)
print(f"(00|00) on-site repulsion = {eri[0, 0, 0, 0].real:.4f} Ha")

Running it prints the 2 x 2 core Hamiltonian and the on-site repulsion (00|00) ~ 0.62 Ha, in agreement with the exact hydrogen 1s value of 5/8 Ha.

License

This is an open source code under MIT License.

Acknowledgements

We thank financial support from INCT Materials Informatics (Grant No. 406447/2022-5).

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

carcara-26.7.2.tar.gz (2.2 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

carcara-26.7.2-py3-none-any.whl (28.4 kB view details)

Uploaded Python 3

File details

Details for the file carcara-26.7.2.tar.gz.

File metadata

  • Download URL: carcara-26.7.2.tar.gz
  • Upload date:
  • Size: 2.2 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.7

File hashes

Hashes for carcara-26.7.2.tar.gz
Algorithm Hash digest
SHA256 577667e3f103daf9e9c31926a68dfea2cf0f945788a23d71be500f5d86c88610
MD5 c00d56240363d3eba6d12afea6680236
BLAKE2b-256 4f5c252357df881b372c7700ffb332277bb74fb5f9870f9287a9b3f2847e04c0

See more details on using hashes here.

File details

Details for the file carcara-26.7.2-py3-none-any.whl.

File metadata

  • Download URL: carcara-26.7.2-py3-none-any.whl
  • Upload date:
  • Size: 28.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.7

File hashes

Hashes for carcara-26.7.2-py3-none-any.whl
Algorithm Hash digest
SHA256 9065b2f43fb70e135c81fd4f078fa60617406b88236944e83644c1208721c908
MD5 2e9b606cdee29ed1176f1b53f5f3f3a7
BLAKE2b-256 8ded158f1f937a2ad6dd6f844c07fa88f2c9c6457462224ac65b4ce4132de2da

See more details on using hashes here.

Supported by

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