group_by_operators(expr)
The group_by_operators
function groups terms in a symbolic Expr
with common Operator
factors. The function aggregates the coefficients for terms that share the same Operator
factors, returning a dictionary where each key is a Mul
of Operator
objects and each value is the corresponding summed coefficient.
Parameters
Returns
A dictionary mapping Mul
of Operator
objects to their aggregated coefficients. Each key represents a unique combination of operators (simplified as necessary), and each value is the total coefficient associated with that operator term after grouping.
Example Usage
Below is an example demonstrating how to use the group_by_operators
function:
from sympy import symbols
from sympt import group_by_operators, BosonOp
omega = symbols("omega", real=True)
omega_z = symbols("omega_z", real=True)
a = BosonOp("a")
ad = Dagger(a)
spin = RDBasis("sigma", 2)
s0, sx, sy, sz = spin.basis
H = omega * ad * a + omega * sz + omega_z * sz
# Group the expression by its quantum operator terms
grouped_terms = group_by_operators(H)
display_dict(grouped_terms)
\(\sigma_{z} : \omega + \omega_z\)
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.