MulGroup
The MulGroup
class represents a multiplicative group designed for symbolic matrix multiplication within the SymPT framework. It extends Sympy’s Expr
and is used throughout SymPT source code to perform operations whilst keeping products of finite and infinite operators separate. This class supports algebraic operations such as addition, subtraction, and multiplication, as well as advanced operations like differentiation, taking the Hermitian conjugate (dagger), and substitutions.
Parameters
-
fn (
Expr
):- The matrix of functions of bosonic number operators associated with the group (note that this may include constant terms w.r.t. any bosonic number operator).
-
inf (
ndarray[Mul[BosonOp]]
, optional):- A product of
BosonOp
objects for the group. - Default is
[1]
, representing the multiplicative identity.Note: Each element in the array represents the contribution to a different bosonic subspace.
- A product of
-
delta (
ndarray[int]
, optional):- Represents a shift or offset from the diagonal of each bosonic subspace.
- Default is
[0]
.Note: Each element in the array represents the offset of the group for different bosonic subspaces.
-
Ns (
ndarray
, optional):- A NumPy array representing the number operators for each bosonic subspace.
- This is used to facilitate substitutions in the function matrix when bosonic operators are present.
Attributes
-
fn (
Expr
):- The matrix of functions of number operators.
-
inf (
ndarray[Mul[BosonOp]]
):- A product of
BosonOp
objects for the group.
- A product of
-
delta (
ndarray[int]
):- Represents a shift or offset from the diagonal of each bosonic subspace.
- Default is
[0]
.
-
Ns (
ndarray
):- The elements corresponding to the number operators.
- These elements are essential for managing substitutions and ensuring proper operator alignment.
Methods
diff(self, theta)
Differentiates the group with respect to time using the sympy function diff
.
-
Parameters:
-
Returns:
- A new
MulGroup
instance representing the derivative of the original group. - If the group is not time-dependent (i.e., does not contain the symbol
t
), the method returns a group with a zero function matrix.
- A new
dagger(self)
Computes and returns the Hermitian conjugate (dagger) of the group.
-
Returns:
- A new
MulGroup
instance that is the Hermitian conjugate of the original.
- A new
subs(self, substitutions)
Substitutes variables within the group according to a given mapping.
-
Parameters:
- substitutions (
dict
):- A dictionary where keys are symbols to be replaced and the values are their corresponding replacement expressions.
- substitutions (
-
Returns:
- A new
MulGroup
instance with the substitutions applied to the function matrix (fn
).
- A new
is_diagonal(self)
Checks if the group is diagonal by verifying that the shift (delta
) for all the bosonic subspaces is zero and the function matrix consists solely of its diagonal elements.
-
Returns:
True
if:- The
delta
shift is zero, and - The function matrix consists solely of its diagonal elements (i.e., all off-diagonal elements are zero).
- The
False
otherwise.
is_t_periodic(self)
Determines whether the group exhibits time-periodic behavior by checking for the presence of the symbol t
within its function matrix.
-
Returns:
Usage Example
Below is an example that demonstrates how to create a MulGroup
instance and utilize its methods for symbolic matrix operations.
from sympt import MulGroup, BosonOp, t
import numpy as np
from sympy import Matrix, cos, sin, exp, I
# Define a 2x2 function matrix with symbolic expressions involving t
fn = Matrix([
[cos(t), sin(t)],
[exp(I*t), cos(t)]
])
a = BosonOp('a')
ad = Dagger(a)
# Define the multiplicative bosonic operator (using the default identity)
inf = np.array([a], dtype=object)
# Define the shift (delta) and the number operators (Ns)
delta = np.array([1])
Ns = np.array([ad*a], dtype=object)
# Create a MulGroup instance
group = MulGroup(fn, inf, delta, Ns)
display(group)
# Access and print the function matrix of the group
print("Function matrix (fn):")
display(group.fn)
# Compute the Hermitian conjugate of the group
group_dagger = group.dagger()
print("Hermitian conjugate of the group:")
display(group_dagger)
# Differentiate the group with respect to t
group_diff = group.diff(t)
print("Derivative of the group with respect to t:")
display(group_diff.fn)
# Substitute t with 0 in the group
group_subs = group.subs({t: 0})
print("Group after substituting t=0 (fn):")
display(group_subs.fn)
# Check if the group is diagonal
print("Is the group diagonal?", group.is_diagonal())
# Check if the group is time-periodic
print("Is the group t-periodic?", group.is_t_periodic())
\(\displaystyle \left[\begin{matrix}\cos{\left(t \right)} & \sin{\left(t \right)}\\e^{i t} & \cos{\left(t \right)}\end{matrix}\right] \cdot {a}\)
\(\displaystyle \left[\begin{matrix}\cos{\left(t \right)} & \sin{\left(t \right)}\\e^{i t} & \cos{\left(t \right)}\end{matrix}\right]\)
\(\displaystyle \left[\begin{matrix}\cos{\left(t \right)} & e^{- i t}\\\sin{\left(t \right)} & \cos{\left(t \right)}\end{matrix}\right] \cdot {a^\dagger}\)\(\displaystyle \left[\begin{matrix}- \sin{\left(t \right)} & \cos{\left(t \right)}\\i e^{i t} & - \sin{\left(t \right)}\end{matrix}\right]\)
\(\displaystyle \left[\begin{matrix}1 & 0\\1 & 1\end{matrix}\right]\)
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.