Skip to content

dq.thermal_dm

thermal_dm(dim: int | tuple[int, ...], nth: ArrayLike) -> QArray

Returns the density matrix of a thermal state or a tensor product of thermal states.

For a single mode, it is defined for a thermal photon number \(n_{th}\) by:

\[ \rho = \sum_k \frac{(n_{th})^k}{(1+n_{th})^{1+k}} \ket{k}\bra{k}. \]

Parameters

  • dim –

    Hilbert space dimension of each mode.

  • nth (array-like of shape (...) or (..., len(dim))) –

    Thermal photon number for each mode. If dim is a tuple, the last dimension of nth should match the length of dim.

Returns

(qarray of shape (..., n, n)) Density matrix of the thermal state or tensor product of thermal states, with n = prod(dims).

Examples

Single-mode thermal state with thermal photon number \(n_{th}=0.1\):

>>> dq.thermal_dm(4, 0.1)
QArray: shape=(4, 4), dims=(4,), dtype=complex64, layout=dense
[[0.909+0.j 0.   +0.j 0.   +0.j 0.   +0.j]
 [0.   +0.j 0.083+0.j 0.   +0.j 0.   +0.j]
 [0.   +0.j 0.   +0.j 0.008+0.j 0.   +0.j]
 [0.   +0.j 0.   +0.j 0.   +0.j 0.001+0.j]]

Batched single-mode thermal states:

>>> dq.thermal_dm(4, [0.1, 0.2, 0.3]).shape
(3, 4, 4)

Multi-mode thermal state:

>>> dq.thermal_dm((4, 3), (0.1, 0.2)).shape
(12, 12)

Batched multi-mode thermal states:

>>> nth = [(0.1, 0.2), (0.2, 0.1), (0.2, 0.2)]
>>> dq.thermal_dm((4, 3), nth).shape
(3, 12, 12)