Skip to main content

Add your description here

Project description

RWA Tools

PyPI - Python Version PyPI - Package Version

A Python package for working with quantum Hamiltonians in the Rotating Wave Approximation (RWA) frame.

Overview

RWA Tools provides a symbolic framework for representing, manipulating, and transforming quantum Hamiltonians to simplify their analysis using the rotating wave approximation. The package leverages symbolic mathematics (via SymPy) and graph theory (via NetworkX) to automate the often tedious process of applying the RWA to complex quantum systems.

Features

  • Symbolic Hamiltonian representation: Create symbolic Hamiltonians with arbitrary energy levels and couplings
  • Graph-based coupling analysis: Visualize and analyze quantum state couplings as graph networks
  • Automated RWA transformations: Transform Hamiltonians into rotating frames and apply the RWA
  • Flexible coupling parameterization: Control coupling strengths with configurable identifiers (a0, a1, etc.)
  • System decomposition: Split composite systems into independent subsystems for separate analysis

Installation

pip install rwa-tools

Or install from source:

git clone https://github.com/ograsdijk/rwa-tools.git
cd rwa-tools
pip install -e .

Dependencies

  • sympy: For symbolic mathematics
  • networkx: For graph representation and analysis
  • numpy: For numerical operations
  • matplotlib: For visualization (optional)

Basic Usage

Here's a simple example demonstrating how to create and transform a three-level quantum system with two driving fields:

import sympy as smp
from rwa_tools import (
    create_hamiltonian_symbolic,
    create_coupling_graph,
    create_hamiltonian_rwa
)
from rwa_tools.graph_transform import create_transform_matrix

# Define a 3-level system with two driving fields
nstates = 3
couplings = [[(0, 1)], [(1, 2)]]  # Two fields: one coupling states 0-1, another coupling 1-2

# Create the symbolic Hamiltonian
hamiltonian = create_hamiltonian_symbolic(couplings, nstates)

# Create the coupling graph
coupling_graph = create_coupling_graph(couplings, nstates)

# Generate the transformation matrix
transform = create_transform_matrix(coupling_graph)

# Apply the RWA transformation
hamiltonian_rwa = create_hamiltonian_rwa(hamiltonian, transform)

# Display the RWA Hamiltonian
print("RWA Hamiltonian:")
smp.pprint(hamiltonian_rwa.hamiltonian)

Advanced Example: Lambda System

Here's an example of analyzing a Lambda-type three-level system:

import matplotlib.pyplot as plt
import networkx as nx
import sympy as smp

from rwa_tools import (
    create_coupling_graph,
    create_hamiltonian_symbolic,
    create_hamiltonian_rwa
)
from rwa_tools.graph_transform import create_transform_matrix

# Lambda system: two ground states (0,1) coupled to one excited state (2)
nstates = 3
couplings = [[(0, 2)], [(1, 2)]]  # Two fields coupling to the excited state

# Create the symbolic Hamiltonian and coupling graph
hamiltonian = create_hamiltonian_symbolic(couplings, nstates)
coupling_graph = create_coupling_graph(couplings, nstates)

# Visualize the coupling graph
plt.figure(figsize=(8, 6))
pos = nx.spring_layout(coupling_graph)
nx.draw(coupling_graph, pos, with_labels=True, node_size=800, node_color='lightblue',
        font_size=12, font_weight='bold')
plt.title("Lambda System Coupling Graph")
plt.show()

# Generate the transformation matrix and apply RWA
transform = create_transform_matrix(coupling_graph)
hamiltonian_rwa = create_hamiltonian_rwa(hamiltonian, transform)

# Show the RWA Hamiltonian
print("RWA Hamiltonian for Lambda System:")
smp.pprint(hamiltonian_rwa.hamiltonian)

Coupling Identifiers

For systems with multiple couplings sharing the same frequency, RWA Tools uses a coefficient system with identifiers in the format a{number} (a0, a1, etc.):

# A system where multiple transitions share the same driving frequency
nstates = 5
couplings = [[(0, 4), (1, 4), (2, 4)]]  # Three states coupled to state 4 by the same field

hamiltonian = create_hamiltonian_symbolic(couplings, nstates)
coupling_graph = create_coupling_graph(couplings, nstates)

# The coupling terms will use identifiers a0, a1, a2 to allow independent control
# of the coupling strengths while sharing the same frequency
print("Coupling Matrix with Identifiers:")
smp.pprint(hamiltonian.coupling_matrix)

License

MIT License

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

rwa_tools-0.1.3.tar.gz (35.2 kB view details)

Uploaded Source

Built Distribution

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

rwa_tools-0.1.3-py3-none-any.whl (14.0 kB view details)

Uploaded Python 3

File details

Details for the file rwa_tools-0.1.3.tar.gz.

File metadata

  • Download URL: rwa_tools-0.1.3.tar.gz
  • Upload date:
  • Size: 35.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.20

File hashes

Hashes for rwa_tools-0.1.3.tar.gz
Algorithm Hash digest
SHA256 c722c55649b2a9ff4d47dfbe267c95ca28b3a29757c4170d68ec08a0b061bc89
MD5 ac64ea50746ac6cf6b3e45bb4dc2bc71
BLAKE2b-256 79b3f75197ad9aa5c4e04f8aaf743e4953aad85a95b134508116aaf18a91e873

See more details on using hashes here.

File details

Details for the file rwa_tools-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: rwa_tools-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 14.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.20

File hashes

Hashes for rwa_tools-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 923013e91106d827f167129b66fb3f0116c35d02511eaaa78edc633fb1bfc64d
MD5 5c0ee9e9202076e7fcc9beefb374bfd9
BLAKE2b-256 15409ee709db3e9e21ef53ef81fd12ae6566920fef665c88a78e229b10d56b9c

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