View on QuantumAI
|
Run in Google Colab
|
View source on GitHub
|
|
Special routines are available for evolving under a diagonal Coulomb operator. This notebook describes how to use these built in routines and how they work.
try:
import fqe
except ImportError:
!pip install fqe --quiet
from itertools import product
import fqe
from fqe.hamiltonians.diagonal_coulomb import DiagonalCoulomb
import numpy as np
import openfermion as of
from scipy.linalg import expm
#Utility function
def uncompress_tei(tei_mat, notation='chemistry'):
"""
uncompress chemist notation integrals
tei_tensor[i, k, j, l] = tei_mat[(i, j), (k, l)]
[1, 1, 2, 2] = [1, 1, 2, 2] = [1, 1, 2, 2] = [1, 1, 2, 2]
[i, j, k, l] = [k, l, i, j] = [j, i, l, k]* = [l, k, j, i]*
For real we also have swap of i <> j and k <> l
[j, i, k, l] = [l, k, i, j] = [i, j, l, k] = [k, l, j, i]
tei_mat[(i, j), (k, l)] = int dr1 int dr2 phi_i(dr1) phi_j(dr1) O(r12) phi_k(dr1) phi_l(dr1)
Physics notation is the notation that is used in FQE.
Args:
tei_mat: compressed two electron integral matrix
Returns:
uncompressed 4-electron integral tensor. No antisymmetry.
"""
if notation not in ['chemistry', 'physics']:
return ValueError("notation can be [chemistry, physics]")
norbs = int(0.5 * (np.sqrt(8 * tei_mat.shape[0] + 1) - 1))
basis = {}
cnt = 0
for i, j in product(range(norbs), repeat=2):
if i >= j:
basis[(i, j)] = cnt
cnt += 1
tei_tensor = np.zeros((norbs, norbs, norbs, norbs))
for i, j, k, l in product(range(norbs), repeat=4):
if i >= j and k >= l:
tei_tensor[i, j, k, l] = tei_mat[basis[(i, j)], basis[(k, l)]]
tei_tensor[k, l, i, j] = tei_mat[basis[(i, j)], basis[(k, l)]]
tei_tensor[j, i, l, k] = tei_mat[basis[(i, j)], basis[(k, l)]]
tei_tensor[l, k, j, i] = tei_mat[basis[(i, j)], basis[(k, l)]]
tei_tensor[j, i, k, l] = tei_mat[basis[(i, j)], basis[(k, l)]]
tei_tensor[l, k, i, j] = tei_mat[basis[(i, j)], basis[(k, l)]]
tei_tensor[i, j, l, k] = tei_mat[basis[(i, j)], basis[(k, l)]]
tei_tensor[k, l, j, i] = tei_mat[basis[(i, j)], basis[(k, l)]]
if notation == 'chemistry':
return tei_tensor
elif notation == 'physics':
return np.asarray(tei_tensor.transpose(0, 2, 1, 3), order='C')
return tei_tensor
The first example we will perform is diagonal Coulomb evolution on the Hartree-Fock state. The diagonal Coulomb operator is defined as
\begin{align} V = \sum{\alpha, \beta \in {\uparrow, \downarrow} }\sum{p,q} V{pq,pq}n{p,\alpha}n_{q,\beta} \end{align}
The number of free parpameters are \(\mathcal{O}(N^{2})\) where \(N\) is the rank of the spatial basis. The DiagonalCoulomb Hamiltonian takes either a generic 4-index tensor or the \(N \times N\) matrix defining \(V\). If the 4-index tensor is given the \(N \times N\) matrix is constructed along with the diagonal correction. If the goal is to just evolve under \(V\) it is recommended the user input the \(N \times N\) matrix directly.
All the terms in \(V\) commute and thus we can evolve under \(V\) exactly by counting the accumulated phase on each bitstring.
To start out let's define a Hartree-Fock wavefunction for 4-orbitals and 2-electrons \(S_{z} =0\).
norbs = 4
tedim = norbs * (norbs + 1) // 2
if (norbs // 2) % 2 == 0:
n_elec = norbs // 2
else:
n_elec = (norbs // 2) + 1
sz = 0
fqe_wfn = fqe.Wavefunction([[n_elec, sz, norbs]])
fci_data = fqe_wfn.sector((n_elec, sz))
fci_graph = fci_data.get_fcigraph()
hf_wf = np.zeros((fci_data.lena(), fci_data.lenb()), dtype=np.complex128)
hf_wf[0, 0] = 1 # right most bit is zero orbital.
fqe_wfn.set_wfn(strategy='from_data',
raw_data={(n_elec, sz): hf_wf})
fqe_wfn.print_wfn()
Sector N = 2 : S_z = 0 a'0001'b'0001' (1+0j)
Now we can define a random 2-electron operator \(V\). To define \(V\) we need a \(4 \times 4\) matrix. We will generate this matrix by making a full random two-electron integral matrix and then just take the diagonal elements
tei_compressed = np.random.randn(tedim**2).reshape((tedim, tedim))
tei_compressed = 0.5 * (tei_compressed + tei_compressed.T)
tei_tensor = uncompress_tei(tei_compressed, notation='physics')
diagonal_coulomb = of.FermionOperator()
diagonal_coulomb_mat = np.zeros((norbs, norbs))
for i, j in product(range(norbs), repeat=2):
diagonal_coulomb_mat[i, j] = tei_tensor[i, j, i, j]
for sigma, tau in product(range(2), repeat=2):
diagonal_coulomb += of.FermionOperator(
((2 * i + sigma, 1), (2 * i + sigma, 0), (2 * j + tau, 1),
(2 * j + tau, 0)), coefficient=diagonal_coulomb_mat[i, j])
dc_ham = DiagonalCoulomb(diagonal_coulomb_mat)
Evolution under \(V\) can be computed by looking at each bitstring, seeing if \(n_{p\alpha}n_{q\beta}\) is non-zero and then phasing that string by \(V_{pq}\). For the Hartree-Fock state we can easily calculate this phase accumulation. The alpha and beta bitstrings are "0001" and "0001".
alpha_occs = [list(range(fci_graph.nalpha()))]
beta_occs = [list(range(fci_graph.nbeta()))]
occs = alpha_occs[0] + beta_occs[0]
diag_ele = 0.
for ind in occs:
for jnd in occs:
diag_ele += diagonal_coulomb_mat[ind, jnd]
evolved_phase = np.exp(-1j * diag_ele)
print(evolved_phase)
# evolve FQE wavefunction
evolved_hf_wfn = fqe_wfn.time_evolve(1, dc_ham)
# check they the accumulated phase is equivalent!
assert np.isclose(evolved_hf_wfn.get_coeff((n_elec, sz))[0, 0], evolved_phase)
(0.2960575921983606+0.9551700906653795j)
We can now try this out for more than 2 electrons. Let's reinitialize a wavefunction on 6-orbitals with 4-electrons \(S_{z} = 0\) to a random state.
norbs = 6
tedim = norbs * (norbs + 1) // 2
if (norbs // 2) % 2 == 0:
n_elec = norbs // 2
else:
n_elec = (norbs // 2) + 1
sz = 0
fqe_wfn = fqe.Wavefunction([[n_elec, sz, norbs]])
fqe_wfn.set_wfn(strategy='random')
initial_coeffs = fqe_wfn.get_coeff((n_elec, sz)).copy()
print("Random initial wavefunction")
fqe_wfn.print_wfn()
Random initial wavefunction Sector N = 4 : S_z = 0 a'000011'b'000011' (0.017656626602542927-0.08116882382783819j) a'000011'b'000101' (-0.031581167871894855-0.04787289946851157j) a'000011'b'001001' (-0.010460029268995138+0.01195116500035903j) a'000011'b'010001' (0.004111075796690221+0.027236101058541757j) a'000011'b'100001' (0.016247067441198474-0.0010024588422296694j) a'000011'b'000110' (0.027063366645658372-0.057112193960268225j) a'000011'b'001010' (-0.1143327068409404+0.13816335227137472j) a'000011'b'010010' (-0.01279541124405426+0.005368399447970729j) a'000011'b'100010' (-0.021433820731529465+0.051153861441103655j) a'000011'b'001100' (0.014238573804080178+0.06254576974574425j) a'000011'b'010100' (0.06291758364074705-0.020777078558758055j) a'000011'b'100100' (0.07585383651978779+0.052344265255912466j) a'000011'b'011000' (0.028372891560242565-0.014864524556869601j) a'000011'b'101000' (-0.021944456989160355+0.002361299209008652j) a'000011'b'110000' (0.02084439828092195-0.06539673516836216j) a'000101'b'000011' (0.018169601596670814-0.03874307365895082j) a'000101'b'000101' (-0.09355374980617978+0.04014071700917356j) a'000101'b'001001' (-0.05871790507234355+0.00966257298058167j) a'000101'b'010001' (0.07733471751653075+0.034087314396747434j) a'000101'b'100001' (-0.02640732876877089+0.007763996411556342j) a'000101'b'000110' (0.0014717196555145183-0.05373965356763086j) a'000101'b'001010' (-0.020940639567092904+0.01517974265298539j) a'000101'b'010010' (-0.06769634154312726-0.0016560344740813699j) a'000101'b'100010' (0.03059558068299615+0.024602922778167027j) a'000101'b'001100' (-0.022535895637915776-0.03980912461279316j) a'000101'b'010100' (-0.008363108002117632-0.03239346162751463j) a'000101'b'100100' (0.001968733486859684-0.038354113593108724j) a'000101'b'011000' (0.08318208512382895+0.018649448479773543j) a'000101'b'101000' (-0.07145766093542258+0.00944015022524821j) a'000101'b'110000' (0.03624283503757985-0.027760649271809688j) a'001001'b'000011' (0.046118001390944775-0.02100950117142712j) a'001001'b'000101' (0.054594211941151424+0.015784061480760347j) a'001001'b'001001' (-0.03976596871788717-0.05017703211269722j) a'001001'b'010001' (-0.01921767673228372+0.025778133902723422j) a'001001'b'100001' (-0.032457156670863116-0.02947112418024945j) a'001001'b'000110' (0.020551933140643068+0.007852126401170001j) a'001001'b'001010' (-0.02428341326220512-0.06960342586271814j) a'001001'b'010010' (-0.03662259438230194-0.03588609785869362j) a'001001'b'100010' (-0.008078287173187763+0.08412233224619739j) a'001001'b'001100' (-0.04961072661832981+0.039796178394086064j) a'001001'b'010100' (0.029812992083021045-0.04358029427089085j) a'001001'b'100100' (-0.02719196868791014+0.06861278470237296j) a'001001'b'011000' (0.006661973256719772-0.05841645225065785j) a'001001'b'101000' (-0.005303696038148033+0.04556303775751592j) a'001001'b'110000' (0.09775902875250846+0.013742054156587932j) a'010001'b'000011' (-0.08228797989822706-0.04476618425086136j) a'010001'b'000101' (0.020394773032412234-0.011912391547041282j) a'010001'b'001001' (0.03606678116753143+0.055940160289742316j) a'010001'b'010001' (0.01820303865639377+0.003406224090256558j) a'010001'b'100001' (-0.03103699855986659+0.08502811993014367j) a'010001'b'000110' (0.055931648837791115+0.01975742232468761j) a'010001'b'001010' (-0.0016434892451125656+0.010029266292877195j) a'010001'b'010010' (-0.043255035363748896-0.0288100791578157j) a'010001'b'100010' (0.033340866988959564-0.05425558035035836j) a'010001'b'001100' (0.07357532486190807-0.016143464730197385j) a'010001'b'010100' (0.0035370317649382585+0.0867720611222798j) a'010001'b'100100' (0.011759160307443891+0.041573244511711654j) a'010001'b'011000' (0.012933813024078375+0.03480718803192467j) a'010001'b'101000' (-0.06852603624888715+0.10673483100699868j) a'010001'b'110000' (-0.037898077815461687-0.048910918524353184j) a'100001'b'000011' (0.03705669386724966-0.026013397322299955j) a'100001'b'000101' (0.017659105705846+0.06791196252237663j) a'100001'b'001001' (-0.0745911970756123-0.12791050822168595j) a'100001'b'010001' (0.037122914482452925+0.005426058257345579j) a'100001'b'100001' (-0.03805952110002453+0.051415587198182906j) a'100001'b'000110' (-0.005158090404010325-0.012577958123814268j) a'100001'b'001010' (0.055360986255877875-0.10881839078197657j) a'100001'b'010010' (0.053657119391039156+0.07637805442731375j) a'100001'b'100010' (0.012415153854354185+0.043292329239471815j) a'100001'b'001100' (-0.07997046805319102-0.04028269463723104j) a'100001'b'010100' (-0.03613586945057818+0.07352963464753752j) a'100001'b'100100' (-0.001895224648028645-0.005844865462215936j) a'100001'b'011000' (0.06172406231395252-0.02661416073038389j) a'100001'b'101000' (-0.002779949151367893-0.055448086877866114j) a'100001'b'110000' (-0.04872690782871747+0.029971371474381604j) a'000110'b'000011' (-0.05117837286476047+0.007721243414598831j) a'000110'b'000101' (0.06976811948357614+0.023966968879641212j) a'000110'b'001001' (-0.03587318994111617+0.009540363226230005j) a'000110'b'010001' (-0.0002725619214230319+0.005593591983318059j) a'000110'b'100001' (0.0012539427197643975+0.06345427046203153j) a'000110'b'000110' (0.00846524824051545+0.037239894011633384j) a'000110'b'001010' (-0.03452616241316566+0.012420245019683543j) a'000110'b'010010' (0.002498407290039744+0.03839895167847962j) a'000110'b'100010' (-0.02308437140138601-0.0584117506195797j) a'000110'b'001100' (0.10871641801519097-0.008913836739953395j) a'000110'b'010100' (0.04957093892949335-0.05636227252034181j) a'000110'b'100100' (0.009296482689285677-0.08222986174760094j) a'000110'b'011000' (0.01612472122502251-0.042356246205260586j) a'000110'b'101000' (-0.03505807665060782+0.04520975483631336j) a'000110'b'110000' (-0.03148967227091375-0.029216584053721906j) a'001010'b'000011' (0.034806998564266625-0.04175693552692606j) a'001010'b'000101' (0.08113933306310289+0.021290270943623197j) a'001010'b'001001' (-0.0052976196748601035+0.0011535222750080074j) a'001010'b'010001' (-0.01763899797054373-0.06890177132549222j) a'001010'b'100001' (-0.07077369091007922-0.024870266061991796j) a'001010'b'000110' (-0.037694754358608265+0.14641472568950123j) a'001010'b'001010' (-0.11342805122193522-0.02660727773301956j) a'001010'b'010010' (0.033920626105722156-0.021494395851038267j) a'001010'b'100010' (0.004194712150752043-0.04550609958727489j) a'001010'b'001100' (0.00022569352646067148+0.031948142662841766j) a'001010'b'010100' (-0.08524729333984628-0.007927216507086075j) a'001010'b'100100' (0.017726621586248156+0.0025973699985777352j) a'001010'b'011000' (0.040242887492422275-0.01648308419875859j) a'001010'b'101000' (0.0573084716478629-0.023336325593666347j) a'001010'b'110000' (0.019643656817258603+0.03316765606298843j) a'010010'b'000011' (-0.00709056217570483+0.021190238280186832j) a'010010'b'000101' (-0.02173826146357238-0.035561000066718584j) a'010010'b'001001' (-0.09135297546355882-0.01301740364616967j) a'010010'b'010001' (-0.08453648901112325-0.030923946706273058j) a'010010'b'100001' (0.026349522827742233+0.009698238984303961j) a'010010'b'000110' (-0.007029517499487043+0.029455512011129566j) a'010010'b'001010' (0.03176160501395596+0.033004186077249247j) a'010010'b'010010' (-0.09633111215361272-0.019842392917196847j) a'010010'b'100010' (0.0081314454392365+0.05126668463953774j) a'010010'b'001100' (-0.0838996003847131+0.05709776556568332j) a'010010'b'010100' (0.027309727184750342-0.0007130557483545297j) a'010010'b'100100' (0.0828555912179536-0.039617731095649165j) a'010010'b'011000' (0.022346371263405003+0.033031662690904455j) a'010010'b'101000' (0.09449906629432812+0.07286328079457802j) a'010010'b'110000' (-0.03982379307490885+0.055581532811872364j) a'100010'b'000011' (0.00213069156292185-0.043768196162912776j) a'100010'b'000101' (0.005438512673255987-0.02038285097122915j) a'100010'b'001001' (-0.04060332374350854+0.018737369510698532j) a'100010'b'010001' (-0.03804185819736977-0.05486342519303689j) a'100010'b'100001' (-0.04768415375082688-0.04535103827181096j) a'100010'b'000110' (0.07121446408253992+0.057480737214468315j) a'100010'b'001010' (-0.0012483557817228167+0.022301268217808038j) a'100010'b'010010' (-0.013405027504742704-0.08105648587668128j) a'100010'b'100010' (-0.072335655096738-0.013804600531071937j) a'100010'b'001100' (0.05392965725697584+0.006485495656934586j) a'100010'b'010100' (-0.001606679671212793+0.09732096259742382j) a'100010'b'100100' (-0.005923888415342796-0.039913311875996386j) a'100010'b'011000' (0.01648692729368553+0.0333980515490897j) a'100010'b'101000' (-0.022843224800499135+0.012214883381724502j) a'100010'b'110000' (-0.017636492411197847-0.04085503617194243j) a'001100'b'000011' (0.09180868107338602-0.011107039979542531j) a'001100'b'000101' (-0.00905474796370864+0.028276249663811263j) a'001100'b'001001' (0.029505421841278148-0.0049519697687772325j) a'001100'b'010001' (0.03406625386474553+0.03087161211804041j) a'001100'b'100001' (0.07155183463015649-0.04024583617405085j) a'001100'b'000110' (0.02988347285529346+0.009616290923056086j) a'001100'b'001010' (0.0010886440406699836-0.028693474829769725j) a'001100'b'010010' (-0.047867356619548114-0.09619396536164344j) a'001100'b'100010' (0.019079181146261472+0.028608519718578928j) a'001100'b'001100' (0.0403032689650646-0.01808318520869391j) a'001100'b'010100' (0.062443986659592145+0.043056536139728416j) a'001100'b'100100' (-0.0066329222347971265+0.03261660990769644j) a'001100'b'011000' (-0.05185032977823845+0.027297214300545606j) a'001100'b'101000' (-0.003997865633030127-0.0404254296571177j) a'001100'b'110000' (-0.04025139121633284+0.04190858204960061j) a'010100'b'000011' (-0.016504530397402028-0.006508062597865315j) a'010100'b'000101' (-0.05667534138305632-0.02790770751087734j) a'010100'b'001001' (0.003524465168283731-0.005359390102981936j) a'010100'b'010001' (-0.1119269601042622+0.04908149715205941j) a'010100'b'100001' (0.07501676941199628-0.006655250679888167j) a'010100'b'000110' (-0.03001258136084711+0.018345633789582965j) a'010100'b'001010' (-0.06367609440064535-0.08037831707735478j) a'010100'b'010010' (0.06403743580098253-0.01779437524743546j) a'010100'b'100010' (-0.025755770956301268-0.06900778511055278j) a'010100'b'001100' (-0.0274506336024535+0.005743678278826436j) a'010100'b'010100' (-0.06084781246991288+0.03551930803282602j) a'010100'b'100100' (0.039100203708225034+0.11495835389383366j) a'010100'b'011000' (-0.018133366561848805+0.01692832216484911j) a'010100'b'101000' (0.045113982421129045+0.03313896710029312j) a'010100'b'110000' (0.019354112631987382-0.003324456655657544j) a'100100'b'000011' (-0.033971259253365506+0.03273095479072436j) a'100100'b'000101' (0.02887141504401466-0.01848240235109637j) a'100100'b'001001' (0.018547023163483257+0.036924337968956694j) a'100100'b'010001' (0.017261885844749213-0.04858313973849163j) a'100100'b'100001' (-0.07493028581296086+0.0306808119958021j) a'100100'b'000110' (0.03417237239163244-0.019639803867445568j) a'100100'b'001010' (-0.03713850599864453+0.0009965395686135567j) a'100100'b'010010' (-0.08846668566253033-0.008070363190832921j) a'100100'b'100010' (0.0402022058549156+0.07492344766327322j) a'100100'b'001100' (0.06100864981963454-0.0063934658676104384j) a'100100'b'010100' (0.01132826412519526-0.027046573142269586j) a'100100'b'100100' (-0.0026413843133079313+0.07889505892712542j) a'100100'b'011000' (0.10716432179054587+0.04270019768507308j) a'100100'b'101000' (-0.00458805927937421-0.02068342225703758j) a'100100'b'110000' (0.013938393595694357-0.01290931208936786j) a'011000'b'000011' (0.007852667490403207+0.05007880574982735j) a'011000'b'000101' (0.0034130480082481584+0.0017036569067390526j) a'011000'b'001001' (0.04962550362133434+0.07296201272719233j) a'011000'b'010001' (0.038835862484974885-0.016829704339259444j) a'011000'b'100001' (-0.017825708230993675+0.04904262841426505j) a'011000'b'000110' (-0.04367400939303777-0.023976701682822482j) a'011000'b'001010' (0.026986037787573698+0.04026003969620293j) a'011000'b'010010' (0.010851781649206658+0.0131218299707626j) a'011000'b'100010' (0.07024773646230949+0.04599833305023297j) a'011000'b'001100' (-0.08096733648928585-0.044882534972653675j) a'011000'b'010100' (-0.02036316818898779-0.08433973182977202j) a'011000'b'100100' (-0.0007467579157987163-0.04828816589143922j) a'011000'b'011000' (0.07868517013050366-0.0013575342223799242j) a'011000'b'101000' (0.05836983996297182-0.08948396739914898j) a'011000'b'110000' (-0.09267854762454834-0.03343959294371225j) a'101000'b'000011' (0.011861070832542465-0.026101462014574636j) a'101000'b'000101' (-0.04514501922351779+0.0105991241467303j) a'101000'b'001001' (-0.010460178571382905-0.008705188166514593j) a'101000'b'010001' (0.03429471054388203-0.09417626986457854j) a'101000'b'100001' (0.07148909700142411-0.10916486605726419j) a'101000'b'000110' (-0.005032808502107317+0.06144882564751299j) a'101000'b'001010' (-0.07738967216703145-0.0050218989369943965j) a'101000'b'010010' (-0.09387837644733613+0.009904584761154382j) a'101000'b'100010' (0.06356399014798045-0.010712519937693869j) a'101000'b'001100' (0.04062503293868766-0.07226297208912376j) a'101000'b'010100' (-0.05517642365910856-0.047224373026943836j) a'101000'b'100100' (-0.019579906267778266+0.034075246809214484j) a'101000'b'011000' (0.025942086360190283+0.0031039258542353092j) a'101000'b'101000' (-0.034770712039000624-0.031805920642190164j) a'101000'b'110000' (0.08467717580574635+0.0022209375232759487j) a'110000'b'000011' (0.022851426645775077+0.05185348349215536j) a'110000'b'000101' (-0.044071247408110976+0.029638266622993487j) a'110000'b'001001' (0.016989577312735902-0.030369265524870702j) a'110000'b'010001' (-0.07930177149705142-0.08822705352378722j) a'110000'b'100001' (-0.06268590344253794-0.06411961642806878j) a'110000'b'000110' (0.10290477112725359-0.045134202780493474j) a'110000'b'001010' (-0.037734279692865226+0.060164541209508024j) a'110000'b'010010' (0.0665243753503883-0.010489788604676056j) a'110000'b'100010' (-0.014065382016802066-0.009013046812603323j) a'110000'b'001100' (0.0330414840942064+0.020875647156301885j) a'110000'b'010100' (-0.06234892386695976+0.013349848750161111j) a'110000'b'100100' (-0.04213087233472302-0.05074756748753331j) a'110000'b'011000' (0.05929840786859578-0.03439745548123905j) a'110000'b'101000' (0.07685429851602286-0.03462500317392345j) a'110000'b'110000' (0.01780280472677503+0.04247714347679621j)
We need to build our Diagoanl Coulomb operator For this bigger system.
tei_compressed = np.random.randn(tedim**2).reshape((tedim, tedim))
tei_compressed = 0.5 * (tei_compressed + tei_compressed.T)
tei_tensor = uncompress_tei(tei_compressed, notation='physics')
diagonal_coulomb = of.FermionOperator()
diagonal_coulomb_mat = np.zeros((norbs, norbs))
for i, j in product(range(norbs), repeat=2):
diagonal_coulomb_mat[i, j] = tei_tensor[i, j, i, j]
for sigma, tau in product(range(2), repeat=2):
diagonal_coulomb += of.FermionOperator(
((2 * i + sigma, 1), (2 * i + sigma, 0), (2 * j + tau, 1),
(2 * j + tau, 0)), coefficient=diagonal_coulomb_mat[i, j])
dc_ham = DiagonalCoulomb(diagonal_coulomb_mat)
Now we can convert our wavefunction to a cirq wavefunction, evolve under the diagonal_coulomb operator we constructed and then compare the outputs.
cirq_wfn = fqe.to_cirq(fqe_wfn).reshape((-1, 1))
final_cirq_wfn = expm(-1j * of.get_sparse_operator(diagonal_coulomb).todense()) @ cirq_wfn
# recover a fqe wavefunction
from_cirq_wfn = fqe.from_cirq(final_cirq_wfn.flatten(), 1.0E-8)
fqe_wfn = fqe_wfn.time_evolve(1, dc_ham)
print("Evolved wavefunction")
fqe_wfn.print_wfn()
Evolved wavefunction Sector N = 4 : S_z = 0 a'000011'b'000011' (-0.06369656945822004+0.053318678376629104j) a'000011'b'000101' (-0.026642637033258806-0.050787346451542904j) a'000011'b'001001' (0.015753077225267302+0.00202067194487536j) a'000011'b'010001' (0.019754242826717904-0.019195729614169293j) a'000011'b'100001' (0.009897500907589979-0.01292329679120121j) a'000011'b'000110' (-0.017446553111208317-0.06074410504477305j) a'000011'b'001010' (0.1022369185128597+0.1473386991168148j) a'000011'b'010010' (0.005671837707488691-0.012663827168646615j) a'000011'b'100010' (0.021242869440785947+0.05123345303030723j) a'000011'b'001100' (-0.04740475354048914-0.04321457669383536j) a'000011'b'010100' (0.025654158054339286-0.061091517407494356j) a'000011'b'100100' (0.05518179623030716+0.0738152828670925j) a'000011'b'011000' (-0.010697860785657284+0.030191569028484747j) a'000011'b'101000' (-0.020966441035788486+0.0068951632900445675j) a'000011'b'110000' (0.06720886480265931+0.013935221645616627j) a'000101'b'000011' (0.02194772529762672-0.03673496335896566j) a'000101'b'000101' (-0.062365111624790324-0.08046225274521765j) a'000101'b'001001' (0.026099347701378957+0.053478797127949146j) a'000101'b'010001' (-0.054289720547847475-0.06477059347405224j) a'000101'b'100001' (0.02517114095863555-0.01113733881235165j) a'000101'b'000110' (-0.04249540511404855+0.03292805594787379j) a'000101'b'001010' (0.008522478170231083-0.024419302576603127j) a'000101'b'010010' (-0.04570938634569113+0.049961876550059965j) a'000101'b'100010' (0.021143747660758994+0.03308073913044155j) a'000101'b'001100' (-0.044569748433943984+0.01030390795644423j) a'000101'b'010100' (0.017986038942503654-0.02820957877790961j) a'000101'b'100100' (0.004808275513667711-0.03810242023336621j) a'000101'b'011000' (-0.08297994494882563-0.019529207624415297j) a'000101'b'101000' (-0.00447140269605294+0.07193969905807782j) a'000101'b'110000' (0.018825460413560764-0.04159084971205938j) a'001001'b'000011' (-0.04315277484041129-0.026572677985858904j) a'001001'b'000101' (-0.0005391891790733836-0.0568275800059527j) a'001001'b'001001' (-0.030170799092016923-0.056469369589714574j) a'001001'b'010001' (0.014883404769102932+0.028501149958770823j) a'001001'b'100001' (-0.0019489732234766115-0.04379743922855316j) a'001001'b'000110' (-0.021355434887517254+0.005289919243469144j) a'001001'b'001010' (-0.025785828411700736-0.06906093037754608j) a'001001'b'010010' (0.05125456462150961+0.001412814309753716j) a'001001'b'100010' (0.009680163883398742+0.08395308173844873j) a'001001'b'001100' (-0.04185530733485095-0.04788625333305742j) a'001001'b'010100' (-0.030272786944762476+0.04326216495133751j) a'001001'b'100100' (0.062106487906446906+0.0398735695124582j) a'001001'b'011000' (-0.05786343181612021+0.010425307654349741j) a'001001'b'101000' (-0.0272112139251754-0.036927895121117146j) a'001001'b'110000' (-0.09664255317781564+0.02014667889130704j) a'010001'b'000011' (0.011494071844283573+0.092968861456681j) a'010001'b'000101' (-0.023560058469986444+0.0016659784825892128j) a'010001'b'001001' (0.06605018652397125-0.008215053084263629j) a'010001'b'010001' (-0.0037208223226267182+0.018141346700910957j) a'010001'b'100001' (0.07093642052006344+0.05622366674507075j) a'010001'b'000110' (0.051632923439964895-0.029201820074659244j) a'010001'b'001010' (-0.005614204332054068-0.00847159660218714j) a'010001'b'010010' (0.051964330954037796-0.0008526745557391537j) a'010001'b'100010' (0.05742672349298214+0.027521861121484113j) a'010001'b'001100' (-0.07374214108649041+0.015363479749411562j) a'010001'b'010100' (-0.054499560802402654-0.0676143406198719j) a'010001'b'100100' (0.030006734007336427+0.031083893330464366j) a'010001'b'011000' (-0.007542764679154869-0.03635836298606515j) a'010001'b'101000' (0.02836879104546726-0.12362586092195663j) a'010001'b'110000' (0.016568344726737707-0.05961570435731416j) a'100001'b'000011' (0.004661499910900825-0.04503516203145685j) a'100001'b'000101' (-0.026354017834463353-0.06503340996712166j) a'100001'b'001001' (0.03823340847117693-0.14304947141244162j) a'100001'b'010001' (0.01683543958539248-0.03352791168340522j) a'100001'b'100001' (-0.060536418913587145+0.02067442232363083j) a'100001'b'000110' (-0.0008741746826225941-0.013566382930045522j) a'100001'b'001010' (0.031397467084181806-0.11798508393987849j) a'100001'b'010010' (-0.07038820593889111+0.06130411180459422j) a'100001'b'100010' (0.04482196413418091+0.004399243953261921j) a'100001'b'001100' (-0.05490334206892905+0.07073608893305461j) a'100001'b'010100' (0.002894226076100593+0.0818781514677145j) a'100001'b'100100' (0.00478254921151285-0.0038576614389235616j) a'100001'b'011000' (-0.049078000983790386+0.045929546474513194j) a'100001'b'101000' (0.034060084772380476-0.04384209257092813j) a'100001'b'110000' (-0.05634802088008501+0.00987396564209156j) a'000110'b'000011' (-0.03329759470899496+0.03962465943762102j) a'000110'b'000101' (-0.025690800863550373-0.06915192581947122j) a'000110'b'001001' (0.024001265095652462-0.02831684235305935j) a'000110'b'010001' (0.0040390930608318375+0.003879212358558111j) a'000110'b'100001' (-0.019062679845133646+0.06053619619149383j) a'000110'b'000110' (0.0023063758368534167+0.038120214640927956j) a'000110'b'001010' (-0.03668943010031071-0.000451770122608706j) a'000110'b'010010' (-0.022404279528091993+0.03128529667144385j) a'000110'b'100010' (-0.007229003025656294+0.06239040253673759j) a'000110'b'001100' (0.10907621664825409-0.0010464192197309394j) a'000110'b'010100' (0.024353916467379114-0.07099908804138796j) a'000110'b'100100' (0.05600702097556812-0.06092116508130841j) a'000110'b'011000' (-0.03403906605277479+0.029923238618842347j) a'000110'b'101000' (-0.057150859050921037+0.0026019186269386485j) a'000110'b'110000' (-0.04285852871815955+0.002890460103935982j) a'001010'b'000011' (-0.030830918450545253-0.04477301956701769j) a'001010'b'000101' (-0.07876677568681445+0.028855884229756146j) a'001010'b'001001' (-0.005271382316166917+0.001268036409259313j) a'001010'b'010001' (0.05978328190914807+0.038529826697853126j) a'001010'b'100001' (-0.07440841232162207-0.009530668119558773j) a'001010'b'000110' (-0.08656338694318973+0.12395542120379942j) a'001010'b'001010' (-0.11193915158743165+0.03230319448992627j) a'001010'b'010010' (0.013540864554182908-0.037805593706892154j) a'001010'b'100010' (-0.045085958228469114-0.007460367302980855j) a'001010'b'001100' (0.0315935362177294-0.004752181228888179j) a'001010'b'010100' (0.07167806892649917+0.04682089510344771j) a'001010'b'100100' (0.009510619539456637+0.015183134055499101j) a'001010'b'011000' (0.043313544131156935-0.0038883098165451747j) a'001010'b'101000' (0.0581338631215431-0.021196673639823853j) a'001010'b'110000' (0.017917846012990755-0.03413088712766891j) a'010010'b'000011' (-0.009305968972293452-0.020315048900392617j) a'010010'b'000101' (-0.04109331390425965-0.006962491620804708j) a'010010'b'001001' (0.07583710371245143-0.05256950279620097j) a'010010'b'010001' (0.08714277261924955-0.02255760701958322j) a'010010'b'100001' (-0.0069073698796109865+0.027214728254984014j) a'010010'b'000110' (-0.02410594122310188+0.018328799793269353j) a'010010'b'001010' (0.04534029776123533+0.00650640074132885j) a'010010'b'010010' (0.09504523423662671+0.025294409942457772j) a'010010'b'100010' (0.02915913508552809-0.042943430230071536j) a'010010'b'001100' (0.10085360391946134-0.011307004632735228j) a'010010'b'010100' (0.02530014845206441+0.010306897482232789j) a'010010'b'100100' (0.027969945294653166-0.08747740150151875j) a'010010'b'011000' (-0.0299093936673197-0.026379522725419415j) a'010010'b'101000' (0.012408001657602674-0.11868097030912024j) a'010010'b'110000' (-0.02338348842517126+0.06425304470342469j) a'100010'b'000011' (-0.029585936657622783-0.032324405547243286j) a'100010'b'000101' (0.011659176809025635-0.017581286356475233j) a'100010'b'001001' (-0.035791000569346865+0.026809013287430617j) a'100010'b'010001' (0.05061287864212275-0.04353751157999845j) a'100010'b'100001' (-0.05972348520584818+0.027633322386759637j) a'100010'b'000110' (-0.035638413438592004-0.08429376330940579j) a'100010'b'001010' (0.02215350010398667+0.0028508576644648673j) a'100010'b'010010' (-0.04570280625738265+0.06827226497839142j) a'100010'b'100010' (0.07354990931831899+0.003663991452468927j) a'100010'b'001100' (0.03001285746926795+0.045273590229850474j) a'100010'b'010100' (0.0697421390031227+0.06789687200250222j) a'100010'b'100100' (0.024057447976804782+0.032394507492958115j) a'100010'b'011000' (0.019771091334462598-0.03156505292736357j) a'100010'b'101000' (0.025340186631768777+0.005375056909688923j) a'100010'b'110000' (0.022696980821158542-0.03827566990641607j) a'001100'b'000011' (-0.0690254297170837+0.061544214268392516j) a'001100'b'000101' (0.024541057021444847+0.0167114115503947j) a'001100'b'001001' (0.006193303020775439+0.029270034511689785j) a'001100'b'010001' (-0.03373744834235331-0.031230604644980408j) a'001100'b'100001' (-0.02574171909733055-0.07795355197939301j) a'001100'b'000110' (0.029111742987711377+0.011747400615768134j) a'001100'b'001010' (-0.02855804632976054+0.002989754752678864j) a'001100'b'010010' (-0.0025965854265776016+0.10741424740630337j) a'001100'b'100010' (-0.009421670692670173+0.03307105494324393j) a'001100'b'001100' (-0.00047202624724006535+0.044171622879221696j) a'001100'b'010100' (0.04877747160877488+0.05808506725269605j) a'001100'b'100100' (-0.029293348910890946-0.015803120224452884j) a'001100'b'011000' (0.01460350275472183-0.056747971893053785j) a'001100'b'101000' (0.0008703276653900679-0.04061330843870258j) a'001100'b'110000' (0.05109265737784632-0.02767750180793761j) a'010100'b'000011' (-0.015747295870330868+0.008171724125835476j) a'010100'b'000101' (-0.0182451146505166-0.060481817522195516j) a'010100'b'001001' (-0.0035810174855900206+0.005321769514577319j) a'010100'b'010001' (0.060712141696016055-0.10606919256575671j) a'010100'b'100001' (0.06297041581086488-0.041310226182285026j) a'010100'b'000110' (-0.020757553013036893+0.02839791034555041j) a'010100'b'001010' (0.01876837974535456+0.10081203686089205j) a'010100'b'010010' (0.06579552691297041+0.009401149539077292j) a'010100'b'100010' (-0.06789270290228375-0.028565976896299496j) a'010100'b'001100' (-0.027990582915407555-0.0017476822944993984j) a'010100'b'010100' (0.03040046177206676-0.06356012468167108j) a'010100'b'100100' (0.09776598327040337+0.0720143150712121j) a'010100'b'011000' (0.02425261327670335+0.005215153251244899j) a'010100'b'101000' (-0.03289464674118318-0.0452924360808846j) a'010100'b'110000' (-0.007155715691289186-0.018287411538335248j) a'100100'b'000011' (-0.04264066185906573+0.020177606721131038j) a'100100'b'000101' (0.030162834394323813-0.016289911743535192j) a'100100'b'001001' (0.03980086417449981-0.011103603632854502j) a'100100'b'010001' (-0.007741558584310784-0.050974135014266224j) a'100100'b'100001' (-0.055417917414585675-0.05903146945624782j) a'100100'b'000110' (0.03917939975450838+0.004295062944889684j) a'100100'b'001010' (-0.024828452717592916-0.027637106479756937j) a'100100'b'010010' (-0.06653117955511031+0.058864992832332666j) a'100100'b'100010' (-0.07080007573512147-0.047085981366573666j) a'100100'b'001100' (-0.011566428823475012+0.06024242261800716j) a'100100'b'010100' (-0.006153783659773934-0.028670152310356217j) a'100100'b'100100' (-0.0649257201914692+0.04490053554050594j) a'100100'b'011000' (-0.08909551699147553-0.07327678758784177j) a'100100'b'101000' (0.017703223869680203-0.011638303520442941j) a'100100'b'110000' (-0.018923243145698265+0.0016852369263626887j) a'011000'b'000011' (-0.03980877501104122-0.03138172404703214j) a'011000'b'000101' (-0.003394816850085711-0.0017397017321542552j) a'011000'b'001001' (0.05560090725825356-0.06851777158469999j) a'011000'b'010001' (-0.040927951117380734+0.010787306449344076j) a'011000'b'100001' (0.00017999021268210662-0.05218144190456534j) a'011000'b'000110' (0.02742153062147831+0.04159760784498963j) a'011000'b'001010' (0.01391954223711037+0.04642589122161781j) a'011000'b'010010' (-0.013793213047302313-0.009984531064371093j) a'011000'b'100010' (0.002273402536258451-0.08393701663977803j) a'011000'b'001100' (0.08763475953759453-0.029837902817200466j) a'011000'b'010100' (-0.057596990781083685+0.06488786971980683j) a'011000'b'100100' (-0.013978329718965656+0.046226733724240604j) a'011000'b'011000' (-0.010169720195029354-0.07803701486337139j) a'011000'b'101000' (0.07209877894626239-0.07884278478879901j) a'011000'b'110000' (-0.04571118309073278-0.08728119675212037j) a'101000'b'000011' (0.006144428201457927-0.028003880493067394j) a'101000'b'000101' (0.0017237460696440383+0.046340510278340456j) a'101000'b'001001' (0.013586677061556472-0.0007732031974965789j) a'101000'b'010001' (-0.0004059609778093046+0.10022540682171897j) a'101000'b'100001' (0.12539285586501872-0.03611496461848029j) a'101000'b'000110' (-0.05005835129909283+0.03599234363158289j) a'101000'b'001010' (-0.07715042850425752-0.007886203691474893j) a'101000'b'010010' (0.057712241247927586+0.07470306268031889j) a'101000'b'100010' (-0.055515669818540545-0.03275895803512115j) a'101000'b'001100' (0.048983685874039264-0.06687995928988277j) a'101000'b'010100' (0.03819527426397857+0.06177135387456576j) a'101000'b'100100' (-0.038808931399265625-0.006193707953315094j) a'101000'b'011000' (0.025096247213559287+0.007266675734067008j) a'101000'b'101000' (-0.01881331533913841-0.04320507110914803j) a'101000'b'110000' (-0.07069918449470894+0.04665599616022224j) a'110000'b'000011' (-0.049197889804215786+0.02811652696957271j) a'110000'b'000101' (-0.02483776343035907+0.0469445119721155j) a'110000'b'001001' (-0.005711576816592756+0.03432660653274206j) a'110000'b'010001' (0.023348702772633182-0.1163083058723452j) a'110000'b'100001' (-0.034598930550253974-0.08272703129007201j) a'110000'b'000110' (0.03770084230296177-0.1058543087031906j) a'110000'b'001010' (0.07101664536793516+0.0005328823274484653j) a'110000'b'010010' (0.06124140214019109-0.028018187747132113j) a'110000'b'100010' (-0.0009709095850654742-0.01667714959764965j) a'110000'b'001100' (-0.025124933184174154-0.029937769586809486j) a'110000'b'010100' (0.025638038393384733+0.05838062826280183j) a'110000'b'100100' (0.002283279152408768+0.06591746844273266j) a'110000'b'011000' (0.06695338008861854+0.014721787053314778j) a'110000'b'101000' (-0.04319113506138896+0.07238784357399397j) a'110000'b'110000' (-0.042325050113788266-0.018161434606146266j)
print("From Cirq Evolution")
from_cirq_wfn.print_wfn()
assert np.allclose(from_cirq_wfn.get_coeff((n_elec, sz)),
fqe_wfn.get_coeff((n_elec, sz)))
print("Wavefunctions are equivalent")
From Cirq Evolution Sector N = 4 : S_z = 0 a'000011'b'000011' (-0.06369656945822007+0.053318678376629j) a'000011'b'000101' (-0.02664263703325873-0.050787346451542925j) a'000011'b'001001' (0.015753077225267295+0.0020206719448753767j) a'000011'b'010001' (0.019754242826717908-0.019195729614169287j) a'000011'b'100001' (0.00989750090758999-0.012923296791201204j) a'000011'b'000110' (-0.017446553111208293-0.06074410504477303j) a'000011'b'001010' (0.10223691851285979+0.14733869911681477j) a'000011'b'010010' (0.005671837707488676-0.012663827168646618j) a'000011'b'100010' (0.021242869440785794+0.05123345303030728j) a'000011'b'001100' (-0.04740475354048912-0.043214576693835376j) a'000011'b'010100' (0.02565415805433936-0.06109151740749431j) a'000011'b'100100' (0.055181796230307+0.07381528286709259j) a'000011'b'011000' (-0.010697860785657253+0.030191569028484758j) a'000011'b'101000' (-0.020966441035788486+0.006895163290044571j) a'000011'b'110000' (0.0672088648026593+0.013935221645616627j) a'000101'b'000011' (0.02194772529762675-0.03673496335896561j) a'000101'b'000101' (-0.06236511162479021-0.08046225274521772j) a'000101'b'001001' (0.02609934770137893+0.05347879712794914j) a'000101'b'010001' (-0.0542897205478475-0.06477059347405223j) a'000101'b'100001' (0.02517114095863554-0.011137338812351669j) a'000101'b'000110' (-0.042495405114048555+0.03292805594787374j) a'000101'b'001010' (0.008522478170231095-0.02441930257660311j) a'000101'b'010010' (-0.04570938634569117+0.0499618765500599j) a'000101'b'100010' (0.021143747660758924+0.03308073913044157j) a'000101'b'001100' (-0.04456974843394397+0.010303907956444222j) a'000101'b'010100' (0.017986038942503647-0.028209578777909625j) a'000101'b'100100' (0.004808275513667676-0.0381024202333662j) a'000101'b'011000' (-0.08297994494882566-0.019529207624415183j) a'000101'b'101000' (-0.004471402696052899+0.07193969905807782j) a'000101'b'110000' (0.018825460413560754-0.04159084971205938j) a'001001'b'000011' (-0.043152774840411245-0.026572677985858936j) a'001001'b'000101' (-0.0005391891790733523-0.056827580005952685j) a'001001'b'001001' (-0.03017079909201697-0.05646936958971454j) a'001001'b'010001' (0.014883404769102892+0.028501149958770837j) a'001001'b'100001' (-0.001948973223476598-0.043797439228553184j) a'001001'b'000110' (-0.021355434887517247+0.005289919243469124j) a'001001'b'001010' (-0.025785828411700712-0.0690609303775461j) a'001001'b'010010' (0.0512545646215096+0.001412814309753655j) a'001001'b'100010' (0.009680163883398759+0.08395308173844873j) a'001001'b'001100' (-0.04185530733485096-0.04788625333305741j) a'001001'b'010100' (-0.03027278694476243+0.04326216495133754j) a'001001'b'100100' (0.06210648790644692+0.03987356951245816j) a'001001'b'011000' (-0.05786343181612022+0.010425307654349788j) a'001001'b'101000' (-0.027211213925175358-0.03692789512111719j) a'001001'b'110000' (-0.09664255317781567+0.020146678891307133j) a'010001'b'000011' (0.011494071844283561+0.09296886145668094j) a'010001'b'000101' (-0.023560058469986437+0.001665978482589217j) a'010001'b'001001' (0.06605018652397127-0.008215053084263534j) a'010001'b'010001' (-0.0037208223226267126+0.018141346700910953j) a'010001'b'100001' (0.07093642052006345+0.056223666745070774j) a'010001'b'000110' (0.05163292343996491-0.02920182007465917j) a'010001'b'001010' (-0.005614204332054077-0.008471596602187133j) a'010001'b'010010' (0.05196433095403778-0.0008526745557391573j) a'010001'b'100010' (0.05742672349298214+0.027521861121484102j) a'010001'b'001100' (-0.07374214108649038+0.015363479749411655j) a'010001'b'010100' (-0.05449956080240265-0.06761434061987191j) a'010001'b'100100' (0.030006734007336437+0.031083893330464345j) a'010001'b'011000' (-0.00754276467915491-0.03635836298606515j) a'010001'b'101000' (0.028368791045467155-0.12362586092195671j) a'010001'b'110000' (0.016568344726737707-0.05961570435731417j) a'100001'b'000011' (0.004661499910900847-0.045035162031456855j) a'100001'b'000101' (-0.02635401783446343-0.06503340996712163j) a'100001'b'001001' (0.03823340847117703-0.14304947141244162j) a'100001'b'010001' (0.016835439585392496-0.03352791168340523j) a'100001'b'100001' (-0.0605364189135872+0.02067442232363082j) a'100001'b'000110' (-0.0008741746826225714-0.01356638293004552j) a'100001'b'001010' (0.0313974670841818-0.11798508393987853j) a'100001'b'010010' (-0.07038820593889109+0.061304111804594226j) a'100001'b'100010' (0.0448219641341809+0.004399243953262039j) a'100001'b'001100' (-0.05490334206892899+0.07073608893305468j) a'100001'b'010100' (0.0028942260761006255+0.0818781514677145j) a'100001'b'100100' (0.004782549211512852-0.0038576614389235625j) a'100001'b'011000' (-0.049078000983790365+0.045929546474513264j) a'100001'b'101000' (0.03406008477238047-0.043842092570928165j) a'100001'b'110000' (-0.05634802088008503+0.009873965642091549j) a'000110'b'000011' (-0.03329759470899497+0.039624659437621j) a'000110'b'000101' (-0.025690800863550307-0.06915192581947122j) a'000110'b'001001' (0.024001265095652476-0.028316842353059327j) a'000110'b'010001' (0.004039093060831833+0.003879212358558114j) a'000110'b'100001' (-0.019062679845133764+0.0605361961914938j) a'000110'b'000110' (0.0023063758368533863+0.038120214640927935j) a'000110'b'001010' (-0.036689430100310706-0.0004517701226087103j) a'000110'b'010010' (-0.022404279528092007+0.03128529667144383j) a'000110'b'100010' (-0.007229003025656398+0.062390402536737555j) a'000110'b'001100' (0.10907621664825408-0.001046419219731037j) a'000110'b'010100' (0.024353916467379024-0.07099908804138798j) a'000110'b'100100' (0.05600702097556812-0.06092116508130837j) a'000110'b'011000' (-0.03403906605277479+0.029923238618842347j) a'000110'b'101000' (-0.05715085905092103+0.002601918626938638j) a'000110'b'110000' (-0.04285852871815954+0.0028904601039359615j) a'001010'b'000011' (-0.030830918450545267-0.04477301956701765j) a'001010'b'000101' (-0.07876677568681444+0.02885588422975609j) a'001010'b'001001' (-0.005271382316166915+0.0012680364092593102j) a'001010'b'010001' (0.059783281909148125+0.03852982669785305j) a'001010'b'100001' (-0.07440841232162207-0.009530668119558754j) a'001010'b'000110' (-0.08656338694318973+0.12395542120379939j) a'001010'b'001010' (-0.11193915158743162+0.032303194489926315j) a'001010'b'010010' (0.013540864554182894-0.037805593706892154j) a'001010'b'100010' (-0.0450859582284691-0.00746036730298087j) a'001010'b'001100' (0.031593536217729395-0.004752181228888199j) a'001010'b'010100' (0.07167806892649915+0.04682089510344772j) a'001010'b'100100' (0.009510619539456634+0.015183134055499098j) a'001010'b'011000' (0.04331354413115695-0.0038883098165451956j) a'001010'b'101000' (0.0581338631215431-0.02119667363982388j) a'001010'b'110000' (0.01791784601299075-0.03413088712766891j) a'010010'b'000011' (-0.009305968972293476-0.0203150489003926j) a'010010'b'000101' (-0.04109331390425964-0.0069624916208047526j) a'010010'b'001001' (0.07583710371245136-0.052569502796201026j) a'010010'b'010001' (0.08714277261924955-0.0225576070195832j) a'010010'b'100001' (-0.006907369879610983+0.02721472825498401j) a'010010'b'000110' (-0.02410594122310189+0.018328799793269325j) a'010010'b'001010' (0.045340297761235326+0.006506400741328848j) a'010010'b'010010' (0.09504523423662664+0.02529440994245786j) a'010010'b'100010' (0.029159135085528125-0.04294343023007149j) a'010010'b'001100' (0.10085360391946133-0.011307004632735214j) a'010010'b'010100' (0.0253001484520644+0.010306897482232784j) a'010010'b'100100' (0.027969945294653194-0.0874774015015187j) a'010010'b'011000' (-0.0299093936673197-0.0263795227254194j) a'010010'b'101000' (0.012408001657602669-0.1186809703091202j) a'010010'b'110000' (-0.023383488425171253+0.06425304470342463j) a'100010'b'000011' (-0.029585936657622682-0.03232440554724336j) a'100010'b'000101' (0.011659176809025663-0.017581286356475205j) a'100010'b'001001' (-0.035791000569346865+0.026809013287430634j) a'100010'b'010001' (0.05061287864212275-0.04353751157999845j) a'100010'b'100001' (-0.059723485205848276+0.02763332238675947j) a'100010'b'000110' (-0.03563841343859182-0.0842937633094058j) a'100010'b'001010' (0.02215350010398667+0.0028508576644648816j) a'100010'b'010010' (-0.04570280625738269+0.06827226497839134j) a'100010'b'100010' (0.07354990931831898+0.003663991452468861j) a'100010'b'001100' (0.03001285746926794+0.04527359022985047j) a'100010'b'010100' (0.06974213900312266+0.06789687200250222j) a'100010'b'100100' (0.024057447976804692+0.03239450749295816j) a'100010'b'011000' (0.019771091334462587-0.031565052927363585j) a'100010'b'101000' (0.025340186631768777+0.005375056909688978j) a'100010'b'110000' (0.022696980821158643-0.03827566990641601j) a'001100'b'000011' (-0.06902542971708371+0.06154421426839247j) a'001100'b'000101' (0.024541057021444837+0.016711411550394698j) a'001100'b'001001' (0.006193303020775448+0.029270034511689785j) a'001100'b'010001' (-0.03373744834235334-0.03123060464498036j) a'001100'b'100001' (-0.0257417190973306-0.077953551979393j) a'001100'b'000110' (0.029111742987711384+0.011747400615768108j) a'001100'b'001010' (-0.028558046329760535+0.0029897547526788904j) a'001100'b'010010' (-0.002596585426577598+0.10741424740630333j) a'001100'b'100010' (-0.009421670692670164+0.03307105494324393j) a'001100'b'001100' (-0.00047202624724004133+0.0441716228792217j) a'001100'b'010100' (0.04877747160877501+0.05808506725269592j) a'001100'b'100100' (-0.02929334891089094-0.015803120224452894j) a'001100'b'011000' (0.014603502754721803-0.05674797189305382j) a'001100'b'101000' (0.0008703276653901108-0.040613308438702596j) a'001100'b'110000' (0.05109265737784631-0.027677501807937592j) a'010100'b'000011' (-0.01574729587033087+0.008171724125835455j) a'010100'b'000101' (-0.018245114650516626-0.060481817522195544j) a'010100'b'001001' (-0.0035810174855900132+0.005321769514577325j) a'010100'b'010001' (0.06071214169601609-0.10606919256575673j) a'010100'b'100001' (0.0629704158108649-0.041310226182285054j) a'010100'b'000110' (-0.020757553013036865+0.028397910345550424j) a'010100'b'001010' (0.018768379745354558+0.100812036860892j) a'010100'b'010010' (0.06579552691297039+0.009401149539077273j) a'010100'b'100010' (-0.06789270290228372-0.028565976896299517j) a'010100'b'001100' (-0.027990582915407555-0.0017476822944993316j) a'010100'b'010100' (0.030400461772066616-0.06356012468167115j) a'010100'b'100100' (0.09776598327040333+0.07201431507121213j) a'010100'b'011000' (0.024252613276703354+0.00521515325124489j) a'010100'b'101000' (-0.032894646741183156-0.04529243608088461j) a'010100'b'110000' (-0.007155715691289178-0.018287411538335248j) a'100100'b'000011' (-0.042640661859065745+0.020177606721130947j) a'100100'b'000101' (0.03016283439432379-0.016289911743535213j) a'100100'b'001001' (0.039800864174499795-0.011103603632854522j) a'100100'b'010001' (-0.007741558584310793-0.050974135014266224j) a'100100'b'100001' (-0.055417917414585655-0.05903146945624785j) a'100100'b'000110' (0.03917939975450835+0.004295062944889686j) a'100100'b'001010' (-0.024828452717592896-0.027637106479756927j) a'100100'b'010010' (-0.06653117955511031+0.05886499283233264j) a'100100'b'100010' (-0.07080007573512132-0.04708598136657384j) a'100100'b'001100' (-0.011566428823475035+0.06024242261800714j) a'100100'b'010100' (-0.006153783659773917-0.028670152310356217j) a'100100'b'100100' (-0.06492572019146928+0.044900535540505764j) a'100100'b'011000' (-0.08909551699147551-0.07327678758784179j) a'100100'b'101000' (0.017703223869680224-0.0116383035204429j) a'100100'b'110000' (-0.018923243145698265+0.0016852369263626668j) a'011000'b'000011' (-0.03980877501104127-0.0313817240470321j) a'011000'b'000101' (-0.003394816850085715-0.0017397017321542506j) a'011000'b'001001' (0.055600907258253535-0.06851777158470007j) a'011000'b'010001' (-0.04092795111738073+0.010787306449344121j) a'011000'b'100001' (0.00017999021268205392-0.052181441904565376j) a'011000'b'000110' (0.0274215306214783+0.041597607844989615j) a'011000'b'001010' (0.013919542237110396+0.046425891221617825j) a'011000'b'010010' (-0.013793213047302313-0.009984531064371088j) a'011000'b'100010' (0.0022734025362584342-0.08393701663977804j) a'011000'b'001100' (0.08763475953759453-0.029837902817200522j) a'011000'b'010100' (-0.057596990781083664+0.06488786971980684j) a'011000'b'100100' (-0.013978329718965662+0.046226733724240604j) a'011000'b'011000' (-0.01016972019502944-0.0780370148633714j) a'011000'b'101000' (0.07209877894626242-0.07884278478879907j) a'011000'b'110000' (-0.045711183090732806-0.08728119675212037j) a'101000'b'000011' (0.006144428201457921-0.0280038804930674j) a'101000'b'000101' (0.0017237460696440717+0.04634051027834047j) a'101000'b'001001' (0.013586677061556477-0.0007732031974965617j) a'101000'b'010001' (-0.00040596097780919854+0.10022540682171897j) a'101000'b'100001' (0.12539285586501875-0.03611496461848036j) a'101000'b'000110' (-0.050058351299092835+0.035992343631582886j) a'101000'b'001010' (-0.07715042850425756-0.007886203691474861j) a'101000'b'010010' (0.057712241247927606+0.07470306268031887j) a'101000'b'100010' (-0.055515669818540496-0.03275895803512127j) a'101000'b'001100' (0.04898368587403937-0.06687995928988275j) a'101000'b'010100' (0.038195274263978556+0.06177135387456578j) a'101000'b'100100' (-0.03880893139926562-0.006193707953315178j) a'101000'b'011000' (0.025096247213559297+0.007266675734067002j) a'101000'b'101000' (-0.018813315339138402-0.04320507110914807j) a'101000'b'110000' (-0.07069918449470895+0.04665599616022227j) a'110000'b'000011' (-0.04919788980421577+0.0281165269695727j) a'110000'b'000101' (-0.02483776343035906+0.04694451197211551j) a'110000'b'001001' (-0.005711576816592729+0.034326606532742075j) a'110000'b'010001' (0.0233487027726332-0.11630830587234517j) a'110000'b'100001' (-0.03459893055025397-0.08272703129007206j) a'110000'b'000110' (0.037700842302961834-0.1058543087031905j) a'110000'b'001010' (0.07101664536793514+0.0005328823274484695j) a'110000'b'010010' (0.061241402140191074-0.02801818774713207j) a'110000'b'100010' (-0.0009709095850654317-0.016677149597649654j) a'110000'b'001100' (-0.025124933184174136-0.029937769586809486j) a'110000'b'010100' (0.025638038393384712+0.05838062826280182j) a'110000'b'100100' (0.002283279152408696+0.06591746844273264j) a'110000'b'011000' (0.06695338008861851+0.014721787053314749j) a'110000'b'101000' (-0.043191135061388955+0.07238784357399397j) a'110000'b'110000' (-0.042325050113788246-0.018161434606146276j) Wavefunctions are equivalent
Finally, we can compare against evolving each term of \(V\) individually.
fqe_wfn = fqe.Wavefunction([[n_elec, sz, norbs]])
fqe_wfn.set_wfn(strategy='from_data',
raw_data={(n_elec, sz): initial_coeffs})
for term, coeff in diagonal_coulomb.terms.items():
op = of.FermionOperator(term, coefficient=coeff)
fqe_wfn = fqe_wfn.time_evolve(1, op)
assert np.allclose(from_cirq_wfn.get_coeff((n_elec, sz)),
fqe_wfn.get_coeff((n_elec, sz)))
print("Individual term evolution is equivalent")
Individual term evolution is equivalent
View on QuantumAI
Run in Google Colab
View source on GitHub