qml.qchem.spin2

spin2(electrons, orbitals)[source]

Compute the total spin observable \(\hat{S}^2\).

The total spin observable \(\hat{S}^2\) is given by

\[\hat{S}^2 = \frac{3}{4}N + \sum_{ \bm{\alpha}, \bm{\beta}, \bm{\gamma}, \bm{\delta} } \langle \bm{\alpha}, \bm{\beta} \vert \hat{s}_1 \cdot \hat{s}_2 \vert \bm{\gamma}, \bm{\delta} \rangle ~ \hat{c}_\bm{\alpha}^\dagger \hat{c}_\bm{\beta}^\dagger \hat{c}_\bm{\gamma} \hat{c}_\bm{\delta},\]

where the two-particle matrix elements are computed as,

\[\begin{split}\langle \bm{\alpha}, \bm{\beta} \vert \hat{s}_1 \cdot \hat{s}_2 \vert \bm{\gamma}, \bm{\delta} \rangle = && \delta_{\alpha,\delta} \delta_{\beta,\gamma} \\ && \times \left( \frac{1}{2} \delta_{s_{z_\alpha}, s_{z_\delta}+1} \delta_{s_{z_\beta}, s_{z_\gamma}-1} + \frac{1}{2} \delta_{s_{z_\alpha}, s_{z_\delta}-1} \delta_{s_{z_\beta}, s_{z_\gamma}+1} + s_{z_\alpha} s_{z_\beta} \delta_{s_{z_\alpha}, s_{z_\delta}} \delta_{s_{z_\beta}, s_{z_\gamma}} \right).\end{split}\]

In the equations above \(N\) is the number of electrons, \(\alpha\) refer to the quantum numbers of the spatial wave function and \(s_{z_\alpha}\) is the spin projection of the single-particle state \(\vert \bm{\alpha} \rangle \equiv \vert \alpha, s_{z_\alpha} \rangle\). The operators \(\hat{c}^\dagger\) and \(\hat{c}\) are the particle creation and annihilation operators, respectively.

Parameters
  • electrons (int) – Number of electrons. If an active space is defined, this is the number of active electrons.

  • orbitals (int) – Number of spin orbitals. If an active space is defined, this is the number of active spin-orbitals.

Returns

the total spin observable \(\hat{S}^2\)

Return type

pennylane.Hamiltonian

Raises

ValueError – If electrons or orbitals is less than or equal to 0

Example

>>> electrons = 2
>>> orbitals = 4
>>> spin2(electrons, orbitals)
(
    0.75 * I(0)
  + 0.375 * Z(0)
  + 0.375 * Z(1)
  + -0.375 * (Z(0) @ Z(1))
  + 0.375 * Z(2)
  + 0.125 * (Z(0) @ Z(2))
  + 0.375 * Z(3)
  + -0.125 * (Z(0) @ Z(3))
  + -0.125 * (Z(1) @ Z(2))
  + 0.125 * (Z(1) @ Z(3))
  + -0.375 * (Z(2) @ Z(3))
  + 0.125 * (Y(0) @ Y(2) @ X(3) @ X(1))
  + 0.125 * (Y(0) @ X(2) @ X(3) @ Y(1))
  + 0.125 * (Y(0) @ Y(2) @ Y(3) @ Y(1))
  + -0.125 * (Y(0) @ X(2) @ Y(3) @ X(1))
  + -0.125 * (X(0) @ Y(2) @ X(3) @ Y(1))
  + 0.125 * (X(0) @ X(2) @ X(3) @ X(1))
  + 0.125 * (X(0) @ Y(2) @ Y(3) @ X(1))
  + 0.125 * (X(0) @ X(2) @ Y(3) @ Y(1))
)