View on GitHub
Open this notebook in GitHub to run it yourself
Generating a Qubit Hamiltonian
Define the molecule to simulate, declaring theMolecularData class and inserting a list of atoms and their spatial positions (the distances are received in Å =). In addition, provide basis, multiplicity, and charge.
As mentioned above, this tutorial demonstrates how to define and find the ground state and energies for these molecules:
FermionHamiltonianProblem) and the mapper (FermionToQubitMapper) between Fermionic Hamiltonian and qubit Hamiltonians (Jordan Wigner or Bravyi Kitaev). If you want to use Z2-symmteries for reducing the problem size you can use Z2SymTaperMapper (see below).
Output:
Constructing and Synthesizing a Ground State Solver
A ground state solver model consists of a parameterized eigenfunction (“the ansatz”), on which to run a VQE. Start with a Hardware (HW) efficient ansatz:HW Efficient Ansatz
The suggested HW efficient ansatz solution is generated to fit a specific hardware [1]. The ansatz creates a state with a given number of parameters according to your choice of the number of qubits that fits the Hamiltonian, and creates entanglement between the qubits using the inputed connectivity map. This example uses a four qubit map, which is specifically made for without using qubit tapering. After constructing the model, synthesize it and view the output circuit. For groundstate solvers, it is typical to initialize the ansatz with the Hartree-Fock state. Use theget_hf_state and the prepare_basis_state qfunc.
Output:
Unitary Coupled Cluster (UCC) Ansatz
Create the commonly used chemistry-inspired UCC ansatz, which is a unitary version of the classical coupled cluster (CC) method [2]. The parameter that defines the UCC ansatz:excitations (List[int] or List[str]): list of desired excitations, e.g.,
- 1 for singles
- 2 for doubles
- 3 for triples
- 4 for quadruples
Z2SymTaperMapper that exploits Z2-symmetries of the molecule Hamiltonian to reduce the problem size.
You can confirm that using Z2SymTaperMapper.from_problem compared to FermionToQubitMapper, the number of qubits is reduced as:
- for - from 4 to 1
- for from 12 to 8 (together with freezing the core orbital
first_active_index=1) - for from 14 to 10 (together with freezing the core orbital
first_active_index=1)
Output:
Executing to Find the Ground State
After synthesizing the model you can execute it: After you specified a Hamiltonian and an ansatz, send the resulting quantum program to the VQE algorithm to find the Hamiltonian’s ground state. In the process, the algorithm sends requests to a classical server, whose task is to minimize the energy expectation value and return the optimized parameters. The simulator and optimizing parameters are defined as part of the VQE part of the model. You can control themax_iteration value so the solution reaches a stable convergence. In addition, the num_shots value sets the number of measurements performed after each iteration, thus influencing the accuracy of the solutions.
Output:
Output: