# Quantum Chemistry: Simulation of Lithium Cations

Written by Bikash's Quantum for the Strangeworks Platform

Molecular simulation, one of the promising applications of a quantum computer, is performed mostly on neutral species to calculate their ground state energies. The available algorithms are not suitable for the charged species as they usually tend to converge the energy to one of the neutral systems. Here, we show the quantum simulation of both dilithium and lithium cations on the quantum simulators. $Li_{2}$ can be simulated using 12, 14 and 20 qubits and $Li_{+}$ using 10, 8 and 4 qubits. Simulations are performed in Qiskit using the variational quantum eigensolver algorithm. Different variational forms can be used including UCCSD, RYRZ and Swap RZ optimization techniques. Considering the active space of the system, we can reduce the number of molecular orbitals and simulate the system using 12 and 14 qubits, thus obtaining a good approximation to the energy value.

## Introduction

Following Feynman's idea, a number of works have been proposed in the field of quantum computation. Quantum simulation has become a field of great interest catching the eyes of researchers working in the field of condensed matter, nuclear physics, chemistry, biology, cosmology and so on. Quantum chemistry being an area for the rigorous application of quantum computation, algorithms for the efficient simulation of molecular systems have been proposed. These are limited to the neutral molecules as the optimization routines tend to converge the energy to the ground state of the nearest neutral molecular configuration. Charged atomic or molecular configurations are yet to be addressed. It brings a great zeal of interest to see how we can approximate the ground and excited state energies for the charged systems with the available algorithms, different encoding methods, and quantum chemistry programs. Variational Quantum Eigensolver (VQE) is best suited for creating wavefunctions for molecules. For a large number of qubit requirement and a charged molecule or atom, the algorithm does not provide good approximations to the energy. We attempt simulating a lesser-known charged molecular system dilithium cation and the well known lithium cation. $Li_{2}$being a 20 qubit system which can be further reduced to 12 and 14 qubits by considering only the active space of the molecule. The 20-qubit circuit optimization is found to give poor approximations and thus the qubits are reduced. $Li_{+}$ finds its applications particularly in medicine and batteries, and thus remains an important system.

Structure of the $Li_{2}$ and $Li_{+}$. Red dots in the center are nucleus, holes depict the vacant positions and black dots are electrons.

The dilithium cation ($Li_{2}$) is a seven-body system with 5 electrons and two nuclei and lithium ion ($Li_{+}$) is a three-body system with 2 electrons and 1 nucleus. The structure of $Li_{2}$ and $Li_{+}$ ion is shown in Fig. 1.

The trial guess wavefunction for these systems is generated by VQE algorithm. To get a good approximation for $Li_{2}$, we reduce the active space. The importance of VQE lies on the fact that it is able to prepare the ansatz by varying the parameters of the circuit. Due to it's high fidelity, robustness to errors and less resource requirement, it is best suited for molecular simulations. The backbone of VQE is the variational principle,

$∣⟨ψ∣ψ⟩∣∣⟨ψ∣H∣ψ⟩∣ ≥E$

where E is the minimum possible energy eigenvalue. The variational principle ensures that this expectation value is always greater than the smallest eigenvalue of H. Here, we show the calculation of the ground state energy of $Li_{2}$ and $Li_{+}$ ion using VQE.

## Tools

## The Second-Quantization

We know the Schrodinger equation,

$H^∣ψ⟩=E∣ψ⟩$

Where $H^$ is Hamiltonian of the system and $E$ is the energy eigenvalue. This Hamiltonian consists of two parts, the kinetic energy term $T^$ and the potential energy term $U^$.

$H^=T^+U^$

For the calculation of ground state or excited state energy of any system, we need to solve the Eq. 2. Here we deal with ions. In this case, the Hamiltonian describes a system of electrons and nuclei in an amalgamation of potential comprised by the Coulombic potential of each particle. To reduce the complexity of the calculation, we consider the Born-Oppenheimer (BO) approximation. As the mass of nucleus is much greater than the electron, the nucleus is treated as a stationary particle in BO approximation. Our reduced Hamiltonian is given by

$H^=−∑_{i}2∇_{i} −∑_{i,I}∣r_{i}−R_{I}∣Z_{I} +∑_{i=I}2∣r_{i}−R_{I}∣1 $

Where indices $i$ and $j$ are used for electrons, index $I$ is used for nucleus, $R_{I}$ is the location of $I_{th}$ nucleus,$Z_{I}$ is the atomic number of $I_{th}$ nucleus, $r_{i}$ denotes the position of $i_{th}$ electron.

The first term in Eq. 4 denotes the total kinetic energy of the electrons, the second term denotes the Coulomb interaction between electrons and fixed nuclei and the third term represents the Coulomb interaction between the two different electrons.

The mapping of the Hamiltonian to Pauli matrices is done using the second quantization, introduced by Paul Dirac in 1927. The concept of the second quantization is useful to describe and analyz quantum many-body system. The most import thing about this formalism is the introduction of anti-commuting creation ($a_{†}$) and annihilation ($a$) operators. Here, $a_{i}$ and $a_{j}$ follow the anti-commutation relations given by,

${a_{i},a_{j}}=δ_{ij},{a_{i},a_{j}}=0,{a_{i},a_{j}}=0$

The fermionic creation operator increases the occupational number of an orbital by one and the annihilation operator decreases it by one. Using the Jordan-Wigner or Bravyi-Kitaev or parity transform, the fermionic Hamiltonian can be mapped onto the spin operators. The second quantized form of the Hamiltonian for fermions is given by,

$H=∑_{i,j}h_{ij}a_{i}a_{j}+21 ∑_{i,j,k,l}h_{ijkl}a_{i}a_{j}a_{k}a_{l}$

where $h_{ij}$ and $h_{ijkl}$ are one and two electron integrals are given by

$h_{ij} = \int d\vec{r_1} \chi_i^*(\vec{r_1}) (\frac{- \nabla_1^{2}}{2} -{\sum_ \sigma\frac{Z}{|\vec{r_1}\ -R_o|}})\chi_j(\vec{r_1})$

and

$h_{ijkl} = \int \frac{ d\vec{r_1} d\vec{r_2} \chi_i^*(\vec{r_1}) \chi_j^*(\vec{r_2})}{|(r_1-r_2)|} \frac {{\chi_{k}(\vec{r_2})}{\chi_l(\vec{r_1})}}{2}$

where $χ_{i}(r_{1} )$ is the $i$th spin orbital of the electron 1, $r_{i} $ is the position of the $i^{\text {th}}$ electron, $r_{12}$ is the distance between the two points $r_{1}$ and $r_{2}$, Z is the total charge on the nucleus, and $R_{o}$ is the position of the nucleus.

The Hamiltonians of the $Li_{+}$ and $Li_{2}$ are determined using the PyQuante on QISKit. Then it is converted into Pauli's spin operators form using the Jordan-Wigner transformation. The calculated Hamiltonian in Pauli form of $Li_{+}$ for four qubits is

$H_{Li_{+}}=−4.391IIII+1.588IIIZ+0.1648IIZI+1.588IZII+0.165ZIII+0.097IIZZ+0.4155IZIZ+0.00243XXYY+0.00243YYYY+0.00243XXXX+0.00243YYXX+0.099ZIIZ+0.099IZZI+0.078ZIZI+0.0967ZZII$

The Hamiltonian of $Li_{2}$ contains nearly 3000 terms and all the other Hamiltonian used here also contains hundreds of terms.

## Jordan-Wigner transformation

Jordan-Wigner transformation is a method for encoding second quantized Hamiltonian, in the form of fermionic creation and annihilation operator, into spin operators. Then, it can be easily mapped on qubits. This method requires n qubits to store the occupation number of n spin-orbitals. An occupied orbital is equivalent to the qubit in state $∣1⟩$ and an unoccupied orbital is equivalent to the qubit in state $∣0⟩$. This new kind of basis is known as the occupation basis. The process of mapping is,

$a_{j}=Q⊗Z_{j−1}⊗Z_{j−2}....⊗Z_{0},a_{j}=Q_{†}⊗Z_{j−1}⊗Z_{j−2}....⊗Z_{0}$

where,

$Q=2X+iY $

$Q_{†}=2X−iY $

Where X, Y and Z are Pauli's spin operators. Each qubit stores the occupation number of the orbital in Fock space. Other encoding methods like Bravyi-Kitaev encoding and parity encoding also could be used for the Hamiltonian transformation. In Bravyi-Kitaev model, the qubit with even index stores the occupation number of orbitals, as in Jordan-Wigner transformation, and the qubits with odd index stores the parity of a particular set of occupation numbers corresponding to that set of orbitals.

## Variational Quantum Eigensolver

VQE is a semi Quantum/Classical and the most efficient hybrid quantum computing algorithm till date. We run a quantum subroutine and then optimize the eigenvalues using a classical optimization loop. VQE, first demonstrated in 2014 is widely used for molecular simulations. The VQE algorithm consists of two parts:

Quantum:

We prepare the initial state of the system $ψ$, also known as the ansatz and measure the expectation value $∣⟨ψ∣H∣ψ⟩∣$ using the quantum simulators. The variational principle ensures that the calculated expectation value is always greater than the smallest eigenvalue of H. The ansatz is prepared by entangling all the qubits with various single-qubit rotation gates. This ansatz preparation could be done by using different combination of entangler and rotation gates. The complexity of initial state increases as the size of the system (i.e. the number of qubits required for simulation) increases. For dilithium cation, we use pre-specified QISKit variational forms.

Classical:

Each time after the calculation of expectation value, the classical optimizer automatically feeds it back to an optimization loop to obtain the minimum possible eigenvalue. Some easily available classical optimizers are Nelder-Mead, Powell, Coybala and gradient descent methods. These optimizers iterate until the energy converges. VQE is based on the Rayleigh-Ritz variational principle,

$∣⟨ψ(θ_{i})∣H∣ψ(θ_{i})⟩∣≥E_{0}$

where $E_{0}$ is the ground state energy. The wave function $∣ψ(θ_{i})⟩$ is a trial wave function. The quantum circuit consists of 3 parts:

## Initial state preparation (ansatz)

This part creates the initial wave-function ($ψ$). In QISKit, the state preparation is done using different variational forms like RyRz, UCCSD, and SwapRz with a given initial state like HF (Hartree - Fock) state. These variational forms provide a different combination of entangled qubits with different unitary rotation gates. The circuit depth can be increased to produce more complex state as required. For an n-qubit system, the number of parameters for initial rotations would be $3n(n−1)$ and the number of unitary gates required is given by $n(n−1)$.

## The Hamiltonian

As our Hamiltonian is in the form of Pauli X, Y and Z gates, we put each Hamiltonian term after ansatz circuit one by one.

## Measurement

Finally, we measure the expectation values of each term in the Hamiltonian one by one.

Schematic of quantum circuit used for VQE. Ansatz is created by using different combination of rotation gates with entanglement.

## Optimization Methods

The main classical part of the VQE algorithm is the optimization of the obtained result and it is also the last step for finding the minimum (ground state) energy. We choose the best-suited optimizer for our system. Different classical optimizers like particle swarm optimization, Nelder-Mead, Powell, L-BFGS-B, and Coybala, etc are used. These optimizers mainly come in two categories. The L-BFGS-B follows the gradient-based method, in which the optimization is done using the gradient of the objective function. Some other optimizers use direct search methods. For example, COYBALA optimizes by using the linear approximation not by using the gradient of the function and so on.

The gradient-based methods converge the function at a local minima, which is no use for us as we need global minima of the function. The direct search method is derivative free and good for the systems where we use noisy and discontinuous functions. However, these optimizers are system dependent, means the accuracy of the result will vary with the different number of qubits used (i.e. complexity of the system). Here we use COYBALA (Constrained Optimization BY Linear Approximation) optimizer for our energy calculation. Powell or Nelder-Mead can also be used.

## Methodology

The Variational Quantum Eigensolver is used for the simulation, which is a semi-quantum algorithm, with the quantum chemistry package PyQuante. All the calculations are done using the QISKit package.

To determine the ground state energy, we need the h values, which is calculated by PyQuante. Manually the h values can be calculated by solving the one and two-electron integrals. The expectation value of the Hamiltonian is therefore,

$⟨ψ∣H∣ψ⟩=Σ_{0}h_{i}⟨ψ∣H_{i}∣ψ⟩$

Where H is the Hamiltonian of the system, $i$ is the index running from 0 to the maximum number of Hamiltonian terms, $H_{i}$ denotes each Hamiltonian terms, $h_{i}$ is the $h$ values for each $H_{i}$ respectively.

For initial geometry optimization of the ions, we perform Restricted Open-Shell Hartree-Fock (ROHF) calculation in STO-3G basis using the PyQuante package and obtain the Hamiltonian of the system. We use the Jordan-Wigner transformation to convert the Hamiltonian in spin operators form. Then we use the optimized initial HF state as the ansatz ($∣ψ(θ)⟩$) for the system.

We reduce the active space of the ions by manually selecting the active orbitals and calculate the Hamiltonian for the different number of qubits. Which we further fed into the quantum system.

We use different variational forms with the initial HF state and Hamiltonian of the system and start our quantum machine.

We calculate the expectation value of the Hamiltonian (i.e. $⟨ψ∣H^∣ψ⟩$) by using statevector simulator.

Now we use a classical optimizer (like Coybala, Powell, etc.) to find the minimum ground state energy of the system by iterating the process multiple times.

Manually, the expectation value of each Hamiltonian terms (in Pauli form) can be calculated by placing each term one by one in the circuit after ansatz circuit and measuring all the qubits. All the gates are to be placed at their respected qubits. But for obtaining the ground state energy, we have to run the circuit multiple times by changing the parameters, which we can do using QISKit and Python programming language. For further calculations, the Ref. can be followed. The initial parameters may be chosen at random. It can be adjusted according to the measured expectation value.

## Quantum circuit for calculating average of XXXX term in the Hamiltonian

from qiskit import QuantumCircuit, execute from strangeworks.qiskit import get_backend from math import pi #taking 4 quantum and 4 classical registers qc = QuantumCircuit(4, 4) #preparing the ansatz qc.u3(pi/2,0,0,(0)) qc.cx(0,1) qc.cx(1,0) qc.cx(0,2) qc.cx(2,0) qc.cx(0,3) qc.cx(3,0) qc.u3(pi/2,0,0,(1)) qc.cx(1,2) qc.cx(2,1) qc.cx(1,3) qc.cx(3,1) qc.u3(pi/2,0,0,(2)) qc.cx(2,3) qc.cx(3,2) #applying XXXX terms of the Hamiltonian qc.x(0), qc.x(1), qc.x(2), qc.x(3), #measuring the qubits qc.measure([0,1,2,3], [0,1,2,3]) # get a Strangeworks backend backend = get_backend("qasm_simulator") # execute circuit execute(qc, backend, shots=1024)

In the circuit, u3 operators, are used where the parameters $θ$, $ϕ$ and $λ$ can be taken in a range, and average of XXXX term can be calculated from the probabilities. Similarly, the total Hamiltonian can be calculated in a range of parameters and using the above mentioned optimized techniques, it can be used and thus ground state energy values can be evaluated.

## Conclusion

To conclude, we have shown that the VQE is good for small ionic systems but as the complexity of the system increases the error margin increases. We have demonstrated that the UCCSD variational forms are much better than any other forms for chemistry related calculations. It is observed that the energy calculation is affected by limiting our system by considering Slater type basis set and by reducing the active space. In future, more complex molecules/ions can be simulated on the Noisy Intermediate-Scale Quantum (NISQ) era quantum systems. Still, we need to develop more advanced quantum machines to simulate them.

## Reference

Utkarsh Singh, Shubham Kumar, Bikash K. Behera, and Prasanta K. Panigrahi, Efficient Simulation of Charged Systems Using Variational Quantum Eigensolver, [DOI: 10.13140/RG.2.2.29794.48328]