qml.qchem.diff_hamiltonian

diff_hamiltonian(mol, cutoff=1e-12, core=None, active=None, mapping='jordan_wigner')[source]

Return a function that computes the qubit Hamiltonian.

Parameters
  • mol (Molecule) – the molecule object

  • cutoff (float) – cutoff value for discarding the negligible electronic integrals

  • core (list[int]) – indices of the core orbitals

  • active (list[int]) – indices of the active orbitals

  • mapping (str) – Specifies the fermion-to-qubit mapping. Input values can be 'jordan_wigner', 'parity' or 'bravyi_kitaev'.

Returns

function that computes the qubit hamiltonian

Return type

function

Example

>>> from pennylane import numpy as np
>>> symbols  = ['H', 'H']
>>> geometry = np.array([[0.0, 0.0, 0.0], [0.0, 0.0, 1.0]], requires_grad = False)
>>> alpha = np.array([[3.42525091, 0.62391373, 0.1688554],
>>>                   [3.42525091, 0.62391373, 0.1688554]], requires_grad=True)
>>> mol = qml.qchem.Molecule(symbols, geometry, alpha=alpha)
>>> args = [alpha]
>>> h = qml.qchem.diff_hamiltonian(mol)(*args)
>>> h.terms()[0]
[tensor(0.29817878, requires_grad=True),
tensor(0.20813366, requires_grad=True),
tensor(-0.34724872, requires_grad=True),
tensor(0.13290292, requires_grad=True),
tensor(0.20813366, requires_grad=True),
tensor(0.17860977, requires_grad=True),
tensor(0.04256036, requires_grad=True),
tensor(-0.04256036, requires_grad=True),
tensor(-0.04256036, requires_grad=True),
tensor(0.04256036, requires_grad=True),
tensor(-0.34724872, requires_grad=True),
tensor(0.17546328, requires_grad=True),
tensor(0.13290292, requires_grad=True),
tensor(0.17546328, requires_grad=True),
tensor(0.18470917, requires_grad=True)]