hqs_quantum_solver.bosons#
Operators for bosons.
Functions
|
Bosonic annihilation operator. |
|
Bosonic creation operator. |
|
The bosonic hopping term. |
|
The identity operator. |
|
The bosonic interaction term. |
|
The bosonic number operators. |
|
The photon click detector operators. |
|
Photon coincidence operator. |
Classes
Operator acting on a space representing spinless fermions. |
|
VectorSpace for representing Boson systems. |
- class Operator#
Operator acting on a space representing spinless fermions.
- property H#
Hermitian adjoint.
Returns the Hermitian adjoint of self, aka the Hermitian conjugate or Hermitian transpose. For a complex matrix, the Hermitian adjoint is equal to the conjugate transpose.
Can be abbreviated self.H instead of self.adjoint().
- Returns:
A_H – Hermitian adjoint of self.
- Return type:
LinearOperator
- property T#
Transpose this linear operator.
Returns a LinearOperator that represents the transpose of this one. Can be abbreviated self.T instead of self.transpose().
- __init__(expression: Expression, *, domain: VectorSpace, codomain: VectorSpace | None = None, dtype: DTypeLike | None = None, operator_type: SparseMatrixFactory | None = None) None #
Creates the operator.
- Parameters:
expression (Expression) – The bosonic operator expression.
domain (VectorSpace) – The domain of the operator.
codomain (VectorSpace | None) – The codomain of the operator.
dtype (DTypeLike | None) – When given, forces the dtype of the operator.
operator_type (OperatorFactory | None) – The operator backend.
- static __new__(cls, *args, **kwargs)#
- adjoint()#
Hermitian adjoint.
Returns the Hermitian adjoint of self, aka the Hermitian conjugate or Hermitian transpose. For a complex matrix, the Hermitian adjoint is equal to the conjugate transpose.
Can be abbreviated self.H instead of self.adjoint().
- Returns:
A_H – Hermitian adjoint of self.
- Return type:
LinearOperator
- property codomain: VectorSpace#
The codomain of the operator.
- property domain: VectorSpace#
The domain of the operator.
- dot(x: ndarray, out: ndarray | None = None) ndarray #
Compute the dot product of operator with array; optional
out
to avoid reallocation.When represented by NumPy this operation would be
A @ x
.- Parameters:
x (np.ndarray) – The vector/array to dot product with.
out (Optional[np.ndarray]) – Optional array to store results and avoid reallocation.
- Returns:
The result of the dot product,
A @ x
.- Return type:
np.ndarray
- dot_add(x: ndarray, out: ndarray, z: float | complex = 1.0) None #
Compute the dot product of operator with array and add it to
out
array.When represented by NumPy this operation would be
out += z * (A @ x)
.- Parameters:
x (np.ndarray) – The vector/array to dot product with.
out (np.ndarray) – The array to which the outcome will be added.
z (complex) – scalar prefactor before addition, defaults to unity.
- dot_h(x: ndarray, out: ndarray | None = None) ndarray #
Compute the dot product of operator adjoint with array, allows optional
out
.When represented by NumPy this operation would be
A.conj().T @ x
. Though transpose returns only a view of a matrix, conjugate returns a copy, hence this method.- Parameters:
x (np.ndarray) – The vector/array to dot product with.
out (Optional[np.ndarray]) – Optional array to store results and avoid reallocation.
- Returns:
The result of the dot product,
A.conj().T @ x
.- Return type:
np.ndarray
- property dtype: OperatorDType#
The NumPy dtype.
- matmat(X)#
Matrix-matrix multiplication.
Performs the operation y=A@X where A is an MxN linear operator and X dense N*K matrix or ndarray.
- Parameters:
X ({matrix, ndarray}) – An array with shape (N,K).
- Returns:
Y – A matrix or ndarray with shape (M,K) depending on the type of the X argument.
- Return type:
{matrix, ndarray}
Notes
This matmat wraps any user-specified matmat routine or overridden _matmat method to ensure that y has the correct type.
- matvec(x)#
Matrix-vector multiplication.
Performs the operation y=A@x where A is an MxN linear operator and x is a column vector or 1-d array.
- Parameters:
x ({matrix, ndarray}) – An array with shape (N,) or (N,1).
- Returns:
y – A matrix or ndarray with shape (M,) or (M,1) depending on the type and shape of the x argument.
- Return type:
{matrix, ndarray}
Notes
This matvec wraps the user-specified matvec routine or overridden _matvec method to ensure that y has the correct shape and type.
- rdot(x: ndarray) ndarray #
Compute the dot product of array with operator.
When represented by NumPy this operation would be
x @ A
.- Parameters:
x (np.ndarray) – The vector/array to dot product with.
- Returns:
The result of the dot product,
x @ A
.- Return type:
np.ndarray
- rdot_h(x: ndarray) ndarray #
Compute the dot product of array with operator adjoint.
When represented by NumPy this operation would be
x @ A.conj().T
.- Parameters:
x (np.ndarray) – The vector/array to dot product with.
- Returns:
The result of the dot product,
x @ A.conj().T
.- Return type:
np.ndarray
- rmatmat(X)#
Adjoint matrix-matrix multiplication.
Performs the operation y = A^H @ x where A is an MxN linear operator and x is a column vector or 1-d array, or 2-d array. The default implementation defers to the adjoint.
- Parameters:
X ({matrix, ndarray}) – A matrix or 2D array.
- Returns:
Y – A matrix or 2D array depending on the type of the input.
- Return type:
{matrix, ndarray}
Notes
This rmatmat wraps the user-specified rmatmat routine.
- rmatvec(x)#
Adjoint matrix-vector multiplication.
Performs the operation y = A^H @ x where A is an MxN linear operator and x is a column vector or 1-d array.
- Parameters:
x ({matrix, ndarray}) – An array with shape (M,) or (M,1).
- Returns:
y – A matrix or ndarray with shape (N,) or (N,1) depending on the type and shape of the x argument.
- Return type:
{matrix, ndarray}
Notes
This rmatvec wraps the user-specified rmatvec routine or overridden _rmatvec method to ensure that y has the correct shape and type.
- property shape: tuple[int, int]#
Returns the shape tuple of the class.
- Returns:
The tuple containing the dimensions of the class.
- Return type:
Tuple[int, …]
- todense() ndarray #
Return the operator as a dense matrix.
- Returns:
The operator as a dense matrix.
- Return type:
np.ndarray
- transpose()#
Transpose this linear operator.
Returns a LinearOperator that represents the transpose of this one. Can be abbreviated self.T instead of self.transpose().
- class VectorSpace#
VectorSpace for representing Boson systems.
The space is spanned by vectors of the form
\[\prod_{j=0}^{M-1} \sqrt{n_j!} \, (b_j^\dagger)^{n_j} \ket{0} \quad\text{where}\quad n_j \in \{ 0, 1, \dots, N_j \} ,\]and \(b_j^\dagger\) is the creation operator for site \(j\). The variable \(N_j\) is the maximal occupation of site \(j\).
The vector space contains all vectors from the set above where the total particle number is equal to
\[\left( \texttt{particle_number_offset} + k \cdot \texttt{particle_number_stride} \right)\]for some \(k \in \mathbb{Z}\).
- max_occupations#
The maximal occupation per site.
- Type:
list[int]
- particle_number_offset#
The particle number offset.
- Type:
int
- particle_number_stride#
The particle number stride.
- Type:
int
- __init__(*, max_occupations: list[int], particle_numbers: Literal['even', 'odd'] | int | tuple[int, int]) None #
Constructor.
- Parameters:
max_occupations (list[int]) – Specifies the maximal number of bosons for each site.
particle_numbers ("even" | "odd" | int | tuple[int, int]) –
Restricts the states of the system.
"even"
Restricts to states having an even number of particles.
"odd"
Restricts to states having an odd number of particle.
int
Restricts to states that have the the given number of particles.
tuple[int, int]
Given the tuple
(offset, stride)
restricts to states that have a particle number equal tooffset
plus an integer multiple ofstride
.
- all_occupations() Iterator[list[int]] #
Iterator over all possible occupation configurations.
- Returns:
The iterator.
- Return type:
Iterator[list[int]]
- copy(*, particle_number_change: int) VectorSpace #
Returns a new vector space with a different value for particles.
- Parameters:
particle_number_change (int) – The value to be added to the number of particles. Allowed to be negative.
- Returns:
The modified copy of the vector space.
- Return type:
- property dim: int#
The dimension of the vector space.
- fock_state(occupation: list[int]) ndarray #
Returns an element of the occupancy number basis.
- Parameters:
occupation (list[int]) – The occupation number per site.
- Returns:
The state vector.
- Return type:
ndarray
- property sites: int#
The number of sites represented in the vector space.
- annihilation(*, site: int | None = None, coef: ArrayLike | None = None) Expression #
Bosonic annihilation operator.
Adds the term
\[\sum_{j=0}^{M-1} v_j \, \hat{b}_j\]to the operator, where \(\hat{b}_j\) is the annihilation operator for site \(j\).
- Parameters:
site (int | None) – Set \(v\) to the cannonical unit vector with index
site
.coef (ndarray | None) – Set \(v\).
- Returns:
The operator expression.
- Return type:
Expression
- creation(*, site: int | None = None, coef: ArrayLike | None = None) Expression #
Bosonic creation operator.
Adds the term
\[\sum_{j=0}^{M-1} v_j \, \hat{b}_j^\dagger\]to the operator, where \(\hat{b}_j^\dagger\) is the creation operator for site \(j\).
- Parameters:
site (int | None) – Set \(v\) to the cannonical unit vector with index
site
.coef (ndarray | None) – Set \(v\).
- Returns:
The operator expression.
- Return type:
Expression
- hopping(coef: ndarray) Expression[MatrixEntryGenerator] #
The bosonic hopping term.
Adds the term
\[\sum_{j,k=0}^{M-1} h_{jk} \, \hat{b}_j^\dagger \hat{b}_k\]to the operator.
- Parameters:
coef (ndarray) – The coefficient matrix \(h\).
- identity() Expression[MatrixEntryGenerator] #
The identity operator.
- Returns:
Term describing the identity operator.
- Return type:
Expression
- interaction(coef: ndarray) Expression[MatrixEntryGenerator] #
The bosonic interaction term.
Adds the term
\[\sum_{j,k=0}^{M-1} V_{jk} \, \hat{n}_j \hat{n}_k\]to the operator, where \(\hat{n}_\ell = \hat{b}^\dagger_\ell \hat{b}_\ell\).
- Parameters:
coef (ndarray) – The coefficient matrix \(V\).
- number(site: int | None = None, coef: ndarray | None = None) Expression[MatrixEntryGenerator] #
The bosonic number operators.
Adds the term
\[\sum_{j=0}^{M-1} \varepsilon_j \, \hat{b}_j^\dagger \hat{b}_j = \sum_{j=0}^{M-1} \varepsilon_j \, \hat{n}_j\]to the operator, where \(\varepsilon\) is the coefficient vector.
- Parameters:
site (int | None) – Sets \(\varepsilon\) to be the unit vector with index site.
coef (ndarray | None) – Sets the coefficient vector \(\varepsilon\).
- Returns:
The term.
- Return type:
Expression
- photon_click(site: int | None = None, coef: ndarray | None = None) Expression[MatrixEntryGenerator] #
The photon click detector operators.
Adds the term
\[\sum_{j=0}^{M-1} \varepsilon_j \, d(\hat{n}_j) \,,\]where the function \(d\) is defined by
\[\begin{split}d(n) = \begin{cases} 0 & \text{if } n = 0 \\ 1 & \text{if } n = 1, 2, 3, \dots \end{cases}\end{split}\]- Parameters:
site (int | None) – Sets \(\varepsilon\) to be the unit vector with index site.
coef (ndarray | None) – Sets the coefficient vector \(\varepsilon\).
- Returns:
The term.
- Return type:
Expression
- photon_coincidence(sites: Sequence[int]) Expression #
Photon coincidence operator.
Adds the term
\[\prod d(\hat{n}_{j_k})\]to the operator, where \(d(\hat{n}_\ell)\) is the photon click detector for site \(\ell\).
- Parameters:
sites (Sequence[int]) – The site indices at which to measure the coincidence between.
- Returns:
The term.
- Return type:
Expression