RDSymbol
The RDSymbol
class is an extension of the base Symbol
that adds an ordering property to symbols. This feature is particularly useful in performing perturbative expansions as it allows SymPT to automatically track the perturbative order of terms in any given expression.
Note: The
RDSymbol
class relies on a global variable namedglobal_variables
to manage reserved symbol names likehbar
(reduced Planck's constant) andt
(time variable). If a reserved name is used without theoverwrite
flag, the constructor will raise an error.
Parameters
-
name (
str
):- The name of the symbol. This is the primary identifier used for the symbol. The
name
parameter can accept LaTeX style strings for mathematical symbols.
- The name of the symbol. This is the primary identifier used for the symbol. The
-
order (
float
, optional):- The perturbative order associated with the symbol. Defaults to
0
. The order must be a real number; if a complex number is passed, aValueError
is raised.
Note: The Hamiltonian must contain only integer non-negative orders.
- The perturbative order associated with the symbol. Defaults to
-
overwrite (
bool
, optional):- When set to
True
, this flag allows the creation of anRDSymbol
even if the givenname
already exists inglobal_variables
. The default value isFalse
.
- When set to
-
*args : tuple
- Additional positional arguments that are forwarded to the base
Symbol
class.
- Additional positional arguments that are forwarded to the base
-
**kwargs : dict
- Additional keyword arguments that are forwarded to the base
Symbol
class. This also includes theorder
andoverwrite
parameters which are handled separately.
- Additional keyword arguments that are forwarded to the base
Attributes
-
order (
float
):- The order of the symbol, which is stored internally as
_order
. This attribute can be accessed via the read-only propertyorder
.
- The order of the symbol, which is stored internally as
-
other attributes
Usage Examples
Creating Symbols with Default Order
from sympt import RDSymbol
# Create an RDSymbol with the default order (0)
omega = RDSymbol('omega')
print("The order of omega is:", omega.order)
Creating Symbols with a Specified Order
from sympt import RDSymbol
# Create an RDSymbol with a specified order
g = RDSymbol('g', order=1)
print('The order of g is:', g.order)
Handling Reserved Names
If you attempt to create a symbol with a name that is reserved (hbar
or t
) without the overwrite
flag, the constructor will raise an error.
from sympt import RDSymbol
try:
hbar = RDSymbol('hbar', overwrite=False)
except ValueError as e:
print(e)
Overwriting a Reserved Name
from sympt import RDSymbol
# Force creation of a symbol even if the name is reserved by using the overwrite flag
hbar = RDSymbol('hbar', overwrite=True, order=0)
print('The order of hbar is:', hbar.order)
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.