qml.qchem.particle_number

particle_number(orbitals)[source]

Compute the particle number observable \(\hat{N}=\sum_\alpha \hat{n}_\alpha\) in the Pauli basis.

The particle number operator is given by

\[\hat{N} = \sum_\alpha \hat{c}_\alpha^\dagger \hat{c}_\alpha,\]

where the index \(\alpha\) runs over the basis of single-particle states \(\vert \alpha \rangle\), and the operators \(\hat{c}^\dagger\) and \(\hat{c}\) are the particle creation and annihilation operators, respectively.

Parameters

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

Returns

the particle number observable

Return type

pennylane.Hamiltonian

Raises

ValueError – If orbitals is less than or equal to 0

Example

>>> orbitals = 4
>>> print(particle_number(orbitals))
(2.0) [I0]
+ (-0.5) [Z0]
+ (-0.5) [Z1]
+ (-0.5) [Z2]
+ (-0.5) [Z3]