# 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
>>> print(spin2(electrons, orbitals))
(0.75) [I0]
+ (0.375) [Z1]
+ (-0.375) [Z0 Z1]
+ (0.125) [Z0 Z2]
+ (0.375) [Z0]
+ (-0.125) [Z0 Z3]
+ (-0.125) [Z1 Z2]
+ (0.125) [Z1 Z3]
+ (0.375) [Z2]
+ (0.375) [Z3]
+ (-0.375) [Z2 Z3]
+ (0.125) [Y0 X1 Y2 X3]
+ (0.125) [Y0 Y1 X2 X3]
+ (0.125) [Y0 Y1 Y2 Y3]
+ (-0.125) [Y0 X1 X2 Y3]
+ (-0.125) [X0 Y1 Y2 X3]
+ (0.125) [X0 X1 X2 X3]
+ (0.125) [X0 X1 Y2 Y3]
+ (0.125) [X0 Y1 X2 Y3]


Using PennyLane

Development

API

Internals