qml.qchem.dipole_of

dipole_of(symbols, coordinates, name='molecule', charge=0, mult=1, basis='sto-3g', package='pyscf', core=None, active=None, mapping='jordan_wigner', cutoff=1e-12, outpath='.', wires=None)[source]

Computes the electric dipole moment operator in the Pauli basis.

The second quantized dipole moment operator \(\hat{D}\) of a molecule is given by

\[\hat{D} = -\sum_{\alpha, \beta} \langle \alpha \vert \hat{{\bf r}} \vert \beta \rangle [\hat{c}_{\alpha\uparrow}^\dagger \hat{c}_{\beta\uparrow} + \hat{c}_{\alpha\downarrow}^\dagger \hat{c}_{\beta\downarrow}] + \hat{D}_\mathrm{n}.\]

In the equation above, the indices \(\alpha, \beta\) run over the basis of Hartree-Fock molecular orbitals and the operators \(\hat{c}^\dagger\) and \(\hat{c}\) are the electron creation and annihilation operators, respectively. The matrix elements of the position operator \(\hat{{\bf r}}\) are computed as

\[\langle \alpha \vert \hat{{\bf r}} \vert \beta \rangle = \sum_{i, j} C_{\alpha i}^*C_{\beta j} \langle i \vert \hat{{\bf r}} \vert j \rangle,\]

where \(\vert i \rangle\) is the wave function of the atomic orbital, \(C_{\alpha i}\) are the coefficients defining the molecular orbitals, and \(\langle i \vert \hat{{\bf r}} \vert j \rangle\) is the representation of operator \(\hat{{\bf r}}\) in the atomic basis.

The contribution of the nuclei to the dipole operator is given by

\[\hat{D}_\mathrm{n} = \sum_{i=1}^{N_\mathrm{atoms}} Z_i {\bf R}_i \hat{I},\]

where \(Z_i\) and \({\bf R}_i\) denote, respectively, the atomic number and the nuclear coordinates of the \(i\)-th atom of the molecule.

Parameters
  • symbols (list[str]) – symbols of the atomic species in the molecule

  • coordinates (array[float]) – 1D array with the atomic positions in Cartesian coordinates. The coordinates must be given in atomic units and the size of the array should be 3*N where N is the number of atoms.

  • name (str) – name of the molecule

  • charge (int) – charge of the molecule

  • mult (int) – spin multiplicity \(\mathrm{mult}=N_\mathrm{unpaired} + 1\) of the Hartree-Fock (HF) state based on the number of unpaired electrons occupying the HF orbitals

  • basis (str) – Atomic basis set used to represent the molecular orbitals. Basis set availability per element can be found here

  • package (str) – quantum chemistry package (pyscf) used to solve the mean field electronic structure problem

  • core (list) – indices of core orbitals

  • active (list) – indices of active orbitals

  • mapping (str) – transformation ('jordan_wigner' or 'bravyi_kitaev') used to map the fermionic operator to the Pauli basis

  • cutoff (float) – Cutoff value for including the matrix elements \(\langle \alpha \vert \hat{{\bf r}} \vert \beta \rangle\). The matrix elements with absolute value less than cutoff are neglected.

  • outpath (str) – path to the directory containing output files

  • wires (Wires, list, tuple, dict) – Custom wire mapping used to convert the qubit operator to an observable measurable in a PennyLane ansatz. For types Wires/list/tuple, each item in the iterable represents a wire label corresponding to the qubit number equal to its index. For type dict, only int-keyed dict (for qubit-to-wire conversion) is accepted. If None, will use identity map (e.g. 0->0, 1->1, …).

Returns

the qubit observables corresponding to the components \(\hat{D}_x\), \(\hat{D}_y\) and \(\hat{D}_z\) of the dipole operator in atomic units.

Return type

list[pennylane.Hamiltonian]

Example

>>> symbols = ["H", "H", "H"]
>>> coordinates = np.array([0.028, 0.054, 0.0, 0.986, 1.610, 0.0, 1.855, 0.002, 0.0])
>>> dipole_obs = dipole_of(symbols, coordinates, charge=1)
>>> print(dipole_obs)
[<Hamiltonian: terms=18, wires=[0, 1, 2, 3, 4, 5]>,
<Hamiltonian: terms=18, wires=[0, 1, 2, 3, 4, 5]>,
<Hamiltonian: terms=1, wires=[0]>]
>>> print(dipole_obs[0]) # x-component of D
(0.24190977644628117) [Z4]
+ (0.24190977644628117) [Z5]
+ (0.4781123173263878) [Z0]
+ (0.4781123173263878) [Z1]
+ (0.714477906181248) [Z2]
+ (0.714477906181248) [Z3]
+ (-0.3913638489487808) [Y0 Z1 Y2]
+ (-0.3913638489487808) [X0 Z1 X2]
+ (-0.3913638489487808) [Y1 Z2 Y3]
+ (-0.3913638489487808) [X1 Z2 X3]
+ (-0.1173495878099553) [Y2 Z3 Y4]
+ (-0.1173495878099553) [X2 Z3 X4]
+ (-0.1173495878099553) [Y3 Z4 Y5]
+ (-0.1173495878099553) [X3 Z4 X5]
+ (0.26611147045300276) [Y0 Z1 Z2 Z3 Y4]
+ (0.26611147045300276) [X0 Z1 Z2 Z3 X4]
+ (0.26611147045300276) [Y1 Z2 Z3 Z4 Y5]
+ (0.26611147045300276) [X1 Z2 Z3 Z4 X5]