Skip to main content

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

Release files for rwa-tools 0.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for rwa-tools 0.1.3
File Size Uploaded
rwa_tools-0.1.3.tar.gz 35.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for rwa-tools 0.1.3
File Interpreter ABI Platform
rwa_tools-0.1.3-py3-none-any.whl Python 3 none any Details

Total release size:49.2 kB

Release files / rwa_tools-0.1.3.tar.gz

Download URL rwa_tools-0.1.3.tar.gz
Size 35.2 kB
Tags Source
SHA-256 checksum
How to use checksums
c722c55649b2a9ff4d47dfbe267c95ca28b3a29757c4170d68ec08a0b061bc89
BLAKE2b-256 checksum
How to use checksums
79b3f75197ad9aa5c4e04f8aaf743e4953aad85a95b134508116aaf18a91e873
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.7.20

Release files / rwa_tools-0.1.3-py3-none-any.whl

Download URL rwa_tools-0.1.3-py3-none-any.whl
Size 14.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
923013e91106d827f167129b66fb3f0116c35d02511eaaa78edc633fb1bfc64d
BLAKE2b-256 checksum
How to use checksums
15409ee709db3e9e21ef53ef81fd12ae6566920fef665c88a78e229b10d56b9c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.7.20

Release history Release notifications | RSS feed

This release

0.1.3 This release

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page