1313import numpy as np
1414from scipy .optimize import minimize
1515from noisyopt import minimizeSPSA
16-
16+ from pyscf . gto . mole import Mole
1717from openfermion import (
1818 hermitian_conjugated ,
1919 jordan_wigner ,
@@ -186,6 +186,36 @@ class HEA:
186186 For a comprehensive tutorial see :doc:`/tutorial_jupyter/noisy_simulation`.
187187 """
188188
189+ @classmethod
190+ def from_molecule (cls , m : Mole , n_layers = 3 , mapping = "parity" , ** kwargs ):
191+ """
192+ Construct the HEA class from the given molecule.
193+ The :math:`R_y` ansatz is employed.
194+
195+
196+ Parameters
197+ ----------
198+ m: Mole
199+ The molecule object.
200+ n_layers: int
201+ The number of layers in the :math:`R_y` ansatz.
202+ mapping: str
203+ The fermion to qubit mapping. Supported mappings are ``"parity"``,
204+ and ``"bravyi-kitaev"``.
205+
206+ kwargs:
207+ Other arguments to be passed to the :func:`__init__` function such as ``engine``.
208+
209+ Returns
210+ -------
211+ hea: :class:`HEA`
212+ An HEA instance
213+ """
214+ from tencirchem import UCC
215+
216+ ucc = UCC (m )
217+ return cls .ry (ucc .int1e , ucc .int2e , ucc .n_elec , ucc .e_core , n_layers = n_layers , mapping = mapping , ** kwargs )
218+
189219 @classmethod
190220 def ry (
191221 cls ,
@@ -198,10 +228,24 @@ def ry(
198228 mapping : str = "parity" ,
199229 ** kwargs ,
200230 ):
201- """
202- Construct the HEA class from electron integrals and custom quantum circuit.
231+ r"""
232+ Construct the HEA class from electron integrals and the :math:`R_y` ansatz.
233+ The circuit consists of interleaved layers of $R_y$ and CNOT gates
234+
235+ .. math::
236+
237+ |\Psi(\theta)\rangle=\prod_{l=k}^1\left [ L_{R_y}^{(l)}(\theta) L_{CNOT}^{(l)} \right ] L_{R_y}^{(0)}(\theta) |{\phi}\rangle
238+
239+ where $k$ is the total number of layers, and the layers are defined as
240+
241+ .. math::
242+ L_{CNOT}^{(l)}=\prod_{j=N/2-1}^1 CNOT_{2j, 2j+1} \prod_{j=N/2}^{1} CNOT_{2j-1, 2j}
243+
244+ .. math::
245+ L_{R_y}^{(l)}(\theta)=\prod_{j=N}^{1} RY_{j}(\theta_{lj})
246+
203247 Overlap integral is assumed to be identity.
204- Parity transformation is used to transform from fermion operators to qubit operators.
248+ Parity transformation is used to transform from fermion operators to qubit operators by default .
205249
206250 Parameters
207251 ----------
@@ -216,8 +260,7 @@ def ry(
216260 n_layers: int
217261 The number of layers in the ansatz.
218262 init_circuit: Circuit
219- The initial circuit before the :math:`R_y` ansatz. Defaults to None,
220- which creates an HF initial state.
263+ The initial circuit before the :math:`R_y` ansatz. Defaults to None.
221264 mapping: str
222265 The fermion to qubit mapping. Supported mappings are ``"parity"``,
223266 and ``"bravyi-kitaev"``.
0 commit comments