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([(h.wires) for h in dipole_obs])
[<Wires = [0, 1, 2, 3, 4, 5]>, <Wires = [0, 1, 2, 3, 4, 5]>, <Wires = [0]>]
>>> dipole_obs[0] # x-component of D
(
    0.4781123173263876 * Z(0)
  + 0.4781123173263876 * Z(1)
  + -0.3913638489489803 * (Y(0) @ Z(1) @ Y(2))
  + -0.3913638489489803 * (X(0) @ Z(1) @ X(2))
  + -0.3913638489489803 * (Y(1) @ Z(2) @ Y(3))
  + -0.3913638489489803 * (X(1) @ Z(2) @ X(3))
  + 0.2661114704527088 * (Y(0) @ Z(1) @ Z(2) @ Z(3) @ Y(4))
  + 0.2661114704527088 * (X(0) @ Z(1) @ Z(2) @ Z(3) @ X(4))
  + 0.2661114704527088 * (Y(1) @ Z(2) @ Z(3) @ Z(4) @ Y(5))
  + 0.2661114704527088 * (X(1) @ Z(2) @ Z(3) @ Z(4) @ X(5))
  + 0.7144779061810713 * Z(2)
  + 0.7144779061810713 * Z(3)
  + -0.11734958781031017 * (Y(2) @ Z(3) @ Y(4))
  + -0.11734958781031017 * (X(2) @ Z(3) @ X(4))
  + -0.11734958781031017 * (Y(3) @ Z(4) @ Y(5))
  + -0.11734958781031017 * (X(3) @ Z(4) @ X(5))
  + 0.24190977644645698 * Z(4)
  + 0.24190977644645698 * Z(5)
)