Back to News
quantum-computing

Converting qubit eigenstate to pyscf eigenstate

GreenPhi
Loading...
5 min read
0 likes
⚡ Quantum Brief
I want to convert a PySCF wavefunction in terms of CIstrings to a representation of a qubit state after Jordan-Wigner transformation of the Hamiltonian. Qiskit-nature keeps the molecular ordering of the driver it uses, PySCF in this case. With a Jordan-Wigner mapping, a qubit (at position x in the ordering of the qubits) being in state 1 means the respective orbital (x) is occupied. The first n qubits encode the occupation of the alpha spin orbitals, the last n qubits those of the beta spin orbitals. The wavefuction is a superposition of these basis states.
AI Audio Summary
0:00 / 0:00
Click to play
Quantum computing technology
Unsplash · Validated Fallback

I want to convert a PySCF wavefunction in terms of CIstrings to a representation of a qubit state after Jordan-Wigner transformation of the Hamiltonian. Qiskit-nature keeps the molecular ordering of the driver it uses, PySCF in this case. With a Jordan-Wigner mapping, a qubit (at position x in the ordering of the qubits) being in state 1 means the respective orbital (x) is occupied. The first n qubits encode the occupation of the alpha spin orbitals, the last n qubits those of the beta spin orbitals. The wavefuction is a superposition of these basis states. A PySCF SCIvector c encodes the coeffients of the CI components. $c[i,j] = |\alpha= \text{strs}_a[i], \beta = \text{strs}_b[j] \rangle$. CI space is strs_a x strs_ab. Example: $\text{strs} [1,2] = [\text{occupation of orbital 0}, \text{occupation of orbital 1}] = [01, 10]$; ie. ci space $[[1,2],[1,2]]= (0101, 0110, 1001,1010)$ BUT this does not give consistent results: Take the example of the H2 molecule. If I obtain the Hamiltonian with Jordan-Wigner-mapping and diagonalize it, I obtain as the eigenvector for the ground state: $0.75 |5\rangle + -0.67 |10\rangle$* If I use the PySCF CI method for diagonalization I obtain SCIvector([[-0.05180278, -0.70520669],[-0.70520669, -0.05180278]]). Converting it according to the logic outlined above, this would be the qubit state $-0.05 |5\rangle + -0.7 |6\rangle + -0.7 |9\rangle + -0.05 |10\rangle$** However, both give approx. the same energy, -1.12Ha as expected*** Where is my misinterpretation? Does it have something to do with an incorrect use of the electronic integrals and thus I actually construct different Hamiltonians? But then why does the energy match? What is the correct conversion? *to be precise, I get: [ 0.+0.j 0.+0.j 0.+0.j 0.+0.j 0.+0.j 0.74599217+0.j 0.+0.j 0.+0.j 0.+0.j 0.+0.j -0.66595472+0.j 0.+0.j 0.+0.j 0.+0.j 0.+0.j 0.+0.j] **: $\begin{align} & -0.05 (1,1) + -0.7 (1,2) + -0.7 (2,1) + -0.05 (2,2) \\ &= -0.05 (0101) + -0.7 (0110) + -0.7 (1001) + -0.05 (1010) \\ &= -0.05 |5\rangle + -0.7 |6\rangle + -0.7 |9\rangle + -0.05 |10\rangle \end{align}$ *** The precise energies do not align perfectly, but are: Result from JW Hamiltonian matrix diagonalization: energy: (-1.1242851621047738+0j) Result from subspsce diagonalization: energy: -1.1260549831212638 However, the next higher eigenvalue when diagonalizing the JW Hamiltonian is -1.1227Ha, so noticeable different. Note: I use PySCFs selected CI here for the diagonalization, which in principle diagonalizes only in a subspace. But for this example the subspace is the full space, as it is so small. Minimal code example: from qiskit_nature.second_q.drivers import PySCFDriver from qiskit_nature.second_q.mappers import JordanWignerMapper from qiskit_nature.units import DistanceUnit from qiskit_nature.second_q.drivers.electronic_structure_driver import MethodType import numpy as np from pyscf import fci driver = PySCFDriver( atom= 'H -1.392024723099 0.0 0.0; H 1.392024723099 0.0 0.0', basis = 'sto_3G', charge = 0, spin = 0, unit = DistanceUnit.ANGSTROM, method = MethodType.RHF, ) driver._build_molecule() pyscf_molecule = driver._mol hf = driver.run() hamil = hf.hamiltonian.second_q_op() mapper = JordanWignerMapper() q_hamil = mapper.map(hamil) # diagonalization of qubit Hamiltonian mat = q_hamil.to_matrix() eigenvalues, eigenvectors = np.linalg.eig(mat) gs_eigenval = np.min(eigenvalues) gs_eigenvec = eigenvectors[:,np.argmin(eigenvalues)] # diagonalization using pyscf sci h1= pyscf_molecule.intor('int1e_kin')+ pyscf_molecule.intor('int1e_nuc') # one-body integrals h2 = pyscf_molecule.intor('int2e') # two-body integrals nelec=pyscf_molecule.nelectron norb = hf.num_spatial_orbitals sci_result = fci.selected_ci.kernel(h1, h2, norb, nelec) # alternatively the fci result: # sci_result = fci.FCI(pyscf_molecule).kernel(h1, h2, norb, nelec) print(f'Result from JW Hamiltonian matrix diagonalization: \n \ energy: {gs_eigenval}\n \ eigenvector: {gs_eigenvec}\n \ \n\ Result from subspsce diagonalization:\n \ energy: {sci_result[0]} \n \ eigenvector: {sci_result[1]}') Before writing an answer to your question, I would like to be able to read it, and your formatting makes it hard for me to do that. Please put computer I/O in code blocks, and use $\LaTeX$ for your bras and kets, and use $\textrm{}$ for things like $\textrm{strs}$.Also, to make things simpler, please use CISD or FCI instead of selected CI, and show us the resulting wavefunction. Also, if you're going to say that the two energies are the same (-1.12 Ha), please show that they agree within 1 pico-hartree, or 1 nano-hartree, by showing the numbers on top of each other in a code block. Expressing energies at the 10 mHa level does not prove anything [valuable].Using selected CI or FCI does not make a difference for this example. But I added the respective line to the minimal example. They give exactly the same wavefunctions.Interesting that you you're quick to tell me that selcted CI and FCI gave you the same wavefuntions but neglect to report that after telling you to look at more digits, the "JW" energy is miles away from the true energy based on the variatonal principle. I told you to make sure they are in agreement at the pico-hartree level, and they turn out to be 2 milli-hartree apart which is absolutely unacceptable for H2 in STO-3G or any other electronic structure calculation, and yet you say "the energies don't align perfectly". The JW energy is simply wrong. It also has only 2 determinants.Ok, thanks for figuring out which of the two results is faulty. Do you have any idea, why it is faulty? The qiskit nature driver uses PySCF as basis, and numpy linalg.eig should do an exact diagonalization

Read Original

Tags

energy-climate
government-funding
quantum-hardware
quantum-investment
quantum-programming

Source Information

Source: Quantum Computing Stack Exchange

Discussion

0 professional contributions

Sign in to join this professional discussion.

Be the first to add a constructive contribution.