Count Bosons Documentation
Overview
The "Count Bosons" utilities provide a set functions to compute the shift from the main diagonal in a bosonic subspace (e.g. an expression proportional to \(\hat a ^{\Delta}\) represents a shift of \(-\Delta\) from the main diagonal). These functions are essential for quantifying the contributions of bosonic operators within a Hamiltonian or any composite operator expression. The utilities leverage multimethod overloading to handle various types of inputs, including single bosonic operators, power expressions, conjugate expressions, and trivial numeric factors. Additionally, functions are provided to aggregate boson counts across factors and to determine the distinct bosonic subspaces present in a Hamiltonian.
get_count_boson(factor)
Determines the difference in the number of \(\hat{a}\) and \(\hat{a}^\dagger\) bosonic operators for a given factor.
Parameters
factor
: The input to evaluate, which can be:
Returns
An integer representing the shift from the main diagonal in the bosonic subspace.
count_bosons(factors, structure={})
Aggregates boson counts for a set of operator factors grouped by subspace.
Parameters
factors
: Dictionary mapping the bosonic subspaces to lists of operators. This is theinfinite
entry in the output ofgroup_by_order
.structure
: (Optional) A dictionary that maps bosonic subspaces to a positional index. This contains the ordering structure in case of multiple bosonic subspaces are present. This is the result ofcount_bosonic_subspaces
.
Returns
A ndarray
with the total shift from the main diagonal for each subspace.
count_bosonic_subspaces(H:Expr)
This function identifies and counts the distinct bosonic subspaces within a Hamiltonian expression.
Parameters
H
(Expr
): The Hamiltonian expression.
Returns
A structure
dictionary mapping each bosonic subspace (identified via a key constructed from its number operator) to a unique index.
Example Usage
Below is an example demonstrating how to use the "Count Bosons" utilities:
from sympy import Pow
from sympt import BosonOp, RDSymbol, get_count_boson, count_bosons, count_bosonic_subspaces, Dagger, group_by_order
# Define bosonic creation and annihilation operators
b = BosonOp("b") # Annihilation operator
bd = Dagger(b) # Creation operator
a = RDSymbol("a") # Trivial symbolic factor
# Get boson count for individual operators
print("Single Operator Counts:")
print(f"Boson count for b: {get_count_boson(b)}") # Expected: -1 (annihilation)
print(f"Boson count for bd: {get_count_boson(bd)}") # Expected: +1 (creation)
# Get boson count for powered bosonic operators
print("\nPowered Operator Counts:")
print(f"Boson count for b^3: {get_count_boson(Pow(b, 3))}") # Expected: -3
print(f"Boson count for bd^3: {get_count_boson(Pow(bd, 3))}") # Expected: +3
# Get boson count for a trivial factor (numbers have zero boson count)
print("\nTrivial Factor Counts:")
print(f"Boson count for 3.14: {get_count_boson(3.14)}") # Expected: 0
# Define multiple bosonic operators for a composite system
a_1 = BosonOp("a_1")
ad_1 = Dagger(a_1)
a_2 = BosonOp("a_2")
ad_2 = Dagger(a_2)
# Construct a Hamiltonian-like expression
H = ad_1 * a_1 + ad_2 * a_2 + ad_1 # Includes creation/annihilation terms
# Determine the structure of the bosonic subspaces
subspace_structure = count_bosonic_subspaces(H)
print("\nBosonic Subspace Structure:")
print(subspace_structure)
# Group terms in H by perturbative order and extract bosonic factors
grouped_terms = group_by_order(H)
first_term = grouped_terms[0][0] # Extract a term dictionary
print("\nExample Term from Order 0:")
print(first_term)
# Compute boson count in the infinite category
boson_count = count_bosons(first_term['infinite'], structure=subspace_structure)
print("\nBoson Count in Infinite Category:")
print(boson_count)
Single Operator Counts:
Boson count for b: -1
Boson count for bd: 1
Powered Operator Counts:
Boson count for b^3: -3
Boson count for bd^3: 3
Trivial Factor Counts:
Boson count for 3.14: 0
Bosonic Subspace Structure:
{Dagger(a_2)*a_2: 0, Dagger(a_1)*a_1: 1}
Example Term from Order 0:
{'other': [], 'finite': [], 'infinite': {Dagger(a_1)*a_1: [Dagger(a_1)]}}
Boson Count in Infinite Category:
[0. 1.]
License
SymPT is licensed under the MIT License. See the LICENSE
file for details.
Citation
If you use SymPT in your research, please cite the following paper:
BibTeX Entry:
@misc{diotallevi2024symptcomprehensivetoolautomating,
title={SymPT: a comprehensive tool for automating effective Hamiltonian derivations},
author={Giovanni Francesco Diotallevi and Leander Reascos and Mónica Benito},
year={2024},
eprint={2412.10240},
archivePrefix={arXiv},
primaryClass={quant-ph},
url={https://arxiv.org/abs/2412.10240},
}
APA Citation:
Diotallevi, G. F., Reascos, L., & Benito, M. (2024). SymPT: a comprehensive tool for automating effective Hamiltonian derivations. arXiv preprint arXiv:2412.10240.
IEEE Citation:
G. F. Diotallevi, L. Reascos, and M. Benito, "SymPT: a comprehensive tool for automating effective Hamiltonian derivations," arXiv preprint arXiv:2412.10240, 2024.