Skip to content

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 named global_variables to manage reserved symbol names like hbar (reduced Planck's constant) and t (time variable). If a reserved name is used without the overwrite 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.
  • 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, a ValueError is raised.

    Note: The Hamiltonian must contain only integer non-negative orders.

  • overwrite (bool, optional):

    • When set to True, this flag allows the creation of an RDSymbol even if the given name already exists in global_variables. The default value is False.
  • *args : tuple

    • Additional positional arguments that are forwarded to the base Symbol class.
  • **kwargs : dict

    • Additional keyword arguments that are forwarded to the base Symbol class. This also includes the order and overwrite parameters which are handled separately.

Attributes

  • order (float):

    • The order of the symbol, which is stored internally as _order. This attribute can be accessed via the read-only property order.
  • other attributes

    • The RDSymbol class inherits all attributes from the base Symbol class, including the name attribute.

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)
The order of omega is: 0

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)
The order of g is: 1

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)
ValueError: hbar is a reserved name. Import "hbar" from SymPT instead.

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)
The order of hbar is: 0

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.


References