Block
The Block
class is essential in performing transformations in which the user would like to eliminate arbitrary couplings. Each block object can thus be thought of as a mask that SymPT will use to determine which finite and infinite parts of a given Hamiltonian to eliminate. A block is characterized by its finite part (typically a boolean matrix) and its infinite part (a symbolic expression comprised of BosonOp
terms). This class provides methods to obtain the Hermitian conjugate of the block, to add structural alignment information, and to apply the block’s mask to a given expression. It also includes operator overloading (e.g., addition) to facilitate combining blocks.
Parameters
-
fin (
MutableDenseMatrix
,ndarray
,Expr
,RDOperator
, optional):-
The finite part of the block, which must be provided as a boolean matrix (i.e., containing only
0
/False
or1
/True
). -
Note: If both
fin
andinf
areNone
, the constructor raises aValueError
. Whenfin
is given as a symbolic expression or as an instance ofRDOperator
, thesubspaces
parameter must be provided (as to ensure the correct tensorial ordering desired by the user).
-
-
inf (
Expr
, optional):- The infinite part of the block. This is a symbolic expression (usually a product of
BosonOp
objects) that specify (given a specific element within the finite subspace) which elements of the infinite susbapce to eliminate.
- The infinite part of the block. This is a symbolic expression (usually a product of
-
deltas (
dict
, optional):-
A dictionary representing the shift from the main diagonal subspace from a given bosonic subspace.
-
Note: If not provided but an infinite part (
inf
) is given, the deltas are automatically computed from the factors ininf
.
-
-
subspaces (
list[RDBasis]
, optional):- Specifies the subspaces on which the block acts. This is required when
fin
is anExpr
or anRDOperator
.
- Specifies the subspaces on which the block acts. This is required when
Attributes
-
fin (
ndarray
ofbool
):- The finite part of the block stored as a boolean NumPy array. It represents the selected elements within the finite subspace to eliminate.
-
fin_not (
ndarray
ofbool
):- The logical negation of the
fin
matrix, used for operations that require the inverse mask.
- The logical negation of the
-
inf (
Expr
):- The infinite part of the block, maintained as an expanded symbolic expression.
-
deltas (
dict
):- A dictionary of shifts from the main diagonal of a given bosonic subspace. The keys correspond to number operators of the given bosonic subspace.
-
subspaces (
list[RDBasis]
):- A list of finite dimensional
RDBasis
that the block operates on.
- A list of finite dimensional
Methods
hermitian()
Returns a new Block
object that represents the Hermitian conjugate of the current block.
- If
inf
isNone
, the method returns a new block with the transposed finite part (fin.T
). - Otherwise, it applies the conjugate transpose (using
Dagger
) to the infinite part as well.
has_diagonal()
Checks whether the block contains a fully diagonal component.
- It verifies if the infinite part (via
deltas
) is diagonal (i.e., all values are zero) and if the finite part's diagonal elements sum to a nonzero value. - Returns
True
if both conditions are met; otherwise, returnsFalse
.
add_structure(structure)
Adds a structure to the block to align it with other blocks.
- The
structure
parameter is a dictionary mapping specific operators (typically of the formDagger[BosonOp] * BosonOp
) to structural positions. - This method initializes a new delta array (
new_deltas
) based on the provided structure and updates the finite part accordingly.
apply_mask(expr)
Applies a mask to a given expression based on the block’s finite part.
- The method expects the input
expr
to be of typeMulGroup
orExpression
. - It returns a tuple of two new expressions: one where the block's mask is applied (
fin_true
) and another where the negation (fin_not
) is applied.
Usage Example
Below is an example that demonstrates how to create a Block
instance, compute its Hermitian conjugate, and access its attributes. In this example, we use a simple 2×2 boolean matrix for the finite part and do not provide an infinite part.
from sympt import Block
import numpy as np
# Define a simple 2x2 boolean matrix as the finite part
fin_matrix = np.array([[False, True],
[False, False]])
# Create a Block instance with the finite part and a default subspace
block = Block(fin=fin_matrix, inf=None, subspaces=['default'])
# Access and print the finite part of the block
print("Finite part of Block:\n", block.fin)
# Compute the Hermitian conjugate of the block (which transposes the finite part)
herm_block = block.hermitian()
print("Hermitian conjugate (finite part):\n", herm_block.fin)
Finite part of Block:
[[False False]
[True False]]
Hermitian conjugate (finite part):
[[False False]
[True False]]
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.