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.9788486914587018+0.20458553035243554j)
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.01585062650994893-0.034708490844681764j) a'000011'b'000101' (-0.0380700422611966+0.032544399768937346j) a'000011'b'001001' (0.025151221885808216-0.07140336050577394j) a'000011'b'010001' (-0.007542725969171134-0.12493505018002488j) a'000011'b'100001' (-0.038343290642187035+0.0378269673532633j) a'000011'b'000110' (-0.036014411559304446+0.012649901443110219j) a'000011'b'001010' (0.03396699581839527+0.06433298328399979j) a'000011'b'010010' (-0.004847469019525289+0.020526900168226354j) a'000011'b'100010' (0.015345264851200713-0.011679961392913139j) a'000011'b'001100' (0.013779116000388841-0.06339478623952742j) a'000011'b'010100' (-0.0007243428681152575+0.045441937826756665j) a'000011'b'100100' (-0.014094653769662206+0.06702855282662347j) a'000011'b'011000' (-0.01865929563513565-0.010682703972655612j) a'000011'b'101000' (-0.006627845860311443-0.028281460943794308j) a'000011'b'110000' (0.07572481983652128+0.06493857055081155j) a'000101'b'000011' (-0.06270172996323597+0.04125121928395652j) a'000101'b'000101' (0.05758341012665508-0.044272721474914206j) a'000101'b'001001' (0.08176027269208384+0.0047751109455614355j) a'000101'b'010001' (0.06918704347542486+0.0034137894602748286j) a'000101'b'100001' (-0.03138947738481408+0.032860264923739446j) a'000101'b'000110' (-0.0770743671764575-0.0034957051182091157j) a'000101'b'001010' (0.03079205828541337-0.002750066703484109j) a'000101'b'010010' (-0.02636355775004886+0.10020935361549818j) a'000101'b'100010' (-0.02279477130852746-0.06001617639496978j) a'000101'b'001100' (-0.039350974691138255-0.061160802836688816j) a'000101'b'010100' (0.018806351414898895+0.01704652007131856j) a'000101'b'100100' (-0.03779026842493533+0.04440627832442074j) a'000101'b'011000' (-0.018037807536203543+0.06710869317166919j) a'000101'b'101000' (0.018305695468315394+0.13978242038341412j) a'000101'b'110000' (-0.025541040374963957+0.019866895371218826j) a'001001'b'000011' (-0.020338229389199432-0.0027630746015678384j) a'001001'b'000101' (0.005254236639860807-0.02304476410737329j) a'001001'b'001001' (0.05255665417546423-0.0029716374594987555j) a'001001'b'010001' (-0.03498652915061242-0.018449401666097803j) a'001001'b'100001' (0.0025751017156936+0.026356970093419602j) a'001001'b'000110' (-0.04766029479400932+0.08595085529908973j) a'001001'b'001010' (-0.020657517306887047+0.02219332500631699j) a'001001'b'010010' (-0.001068672733754501+0.044773068878868984j) a'001001'b'100010' (-0.010862894033822625+0.033389792665397794j) a'001001'b'001100' (-0.045349373107392635-0.07390214137639758j) a'001001'b'010100' (-0.09481539055307162+0.01103450741794712j) a'001001'b'100100' (0.07574440099127898+0.006688599763689842j) a'001001'b'011000' (0.05290762957478644-0.03491071497712068j) a'001001'b'101000' (0.06432111325891292-0.025966043167239203j) a'001001'b'110000' (0.032101643356022044+0.03225446656977694j) a'010001'b'000011' (-0.004703308385561974+0.09025779359622423j) a'010001'b'000101' (0.10219892079565161-0.02684867071086991j) a'010001'b'001001' (0.011246199137808093+0.03551966760844435j) a'010001'b'010001' (-0.07512284333017986-0.017639621141262534j) a'010001'b'100001' (0.061968458498656356+0.007393211280941739j) a'010001'b'000110' (-0.010311357468012445+0.03503375072255832j) a'010001'b'001010' (-0.034540146535540744+0.04248166601224615j) a'010001'b'010010' (-0.11612180160986108+0.01314968948923992j) a'010001'b'100010' (0.04122457379367362-0.025194311602581235j) a'010001'b'001100' (-0.00042930564184876305-0.011608257709654301j) a'010001'b'010100' (-0.1203262412428368+0.02830825266545257j) a'010001'b'100100' (-0.0440036043735315+0.05395941626289004j) a'010001'b'011000' (-0.017019259510820638+0.03108185757654393j) a'010001'b'101000' (-0.008245348127195552-0.07295145359977072j) a'010001'b'110000' (-0.034089952038709743-0.023929116074562027j) a'100001'b'000011' (0.023560865514852817-0.0883509763236787j) a'100001'b'000101' (-0.047388015144768474-0.0004574783551368615j) a'100001'b'001001' (-0.08524128967307444-0.03149494121653801j) a'100001'b'010001' (-0.08256888868832313-0.04288233637692152j) a'100001'b'100001' (0.012618283490042495-0.014701741168766108j) a'100001'b'000110' (0.04055425841501832-0.050488982654488576j) a'100001'b'001010' (-0.013850688164050348+0.022141159053089075j) a'100001'b'010010' (-0.03414766335573516-0.04141351670961205j) a'100001'b'100010' (0.02757526665531763-0.007951525934289416j) a'100001'b'001100' (0.022088526103842047+0.08309450373723559j) a'100001'b'010100' (0.04311886009323413-0.039745504360446014j) a'100001'b'100100' (-0.0342737972293315+0.045723206695511054j) a'100001'b'011000' (-0.01583084163212871-0.07497344503294182j) a'100001'b'101000' (0.02820817406277079-0.04513951062307267j) a'100001'b'110000' (0.050195592196378244-0.041256681681006525j) a'000110'b'000011' (-0.014895899787891676-0.031851909335314045j) a'000110'b'000101' (-0.007305089464935711+0.030126026667570964j) a'000110'b'001001' (0.01901384586318285+0.02135001394841135j) a'000110'b'010001' (-0.12456808684686471-0.11012564716694863j) a'000110'b'100001' (0.02633437438022609+0.061382760019667804j) a'000110'b'000110' (-0.008160041557416151-0.05783817518744872j) a'000110'b'001010' (0.011957833468601891-0.06008332896035046j) a'000110'b'010010' (-0.017227750704283718+0.07165955155175857j) a'000110'b'100010' (0.05687586822754646-0.039841018806035314j) a'000110'b'001100' (-0.09482804179484548+0.05464277244742047j) a'000110'b'010100' (-0.02238219089631644-0.018055604226584473j) a'000110'b'100100' (0.005720911575357659+0.022925566904047977j) a'000110'b'011000' (0.026411258980321674+0.0498387126616405j) a'000110'b'101000' (-0.11946841843250942+0.0102586749908297j) a'000110'b'110000' (0.0270721108201238-0.02318085368035384j) a'001010'b'000011' (0.031186686000931794-0.007132491683273941j) a'001010'b'000101' (-0.008982264060599805-0.005784005985190718j) a'001010'b'001001' (-0.04265483144952225+0.025948748459509213j) a'001010'b'010001' (-0.014484240380008138-0.0637072283939424j) a'001010'b'100001' (-0.0042795515733881975+0.024142497555323182j) a'001010'b'000110' (0.009410356319258791+0.04077499977651289j) a'001010'b'001010' (0.015589618858282878+0.010299231125103683j) a'001010'b'010010' (-0.04677084996428073+0.04682832381111885j) a'001010'b'100010' (0.07468359439565686+0.006857866716653623j) a'001010'b'001100' (0.010859925368071427+0.03255741900862283j) a'001010'b'010100' (0.03187161497228468-0.013630476591488278j) a'001010'b'100100' (0.08542004863166437+0.07323919872806117j) a'001010'b'011000' (-0.02410313274028142-0.08028520756683778j) a'001010'b'101000' (0.03423653566879913-0.04017023127260907j) a'001010'b'110000' (-0.09984201722715573-0.02133788400981146j) a'010010'b'000011' (-0.008087060359959928+0.05791325203933624j) a'010010'b'000101' (-0.14693208259553245+0.09638845129481265j) a'010010'b'001001' (0.026435240340975517+0.047004872273232176j) a'010010'b'010001' (-0.036990196500022596+0.01800747893687411j) a'010010'b'100001' (-0.07009496249537367+0.042256015627810055j) a'010010'b'000110' (-0.02244995481017592+0.016741550211303895j) a'010010'b'001010' (-0.0562211428542398-0.08220128711861979j) a'010010'b'010010' (-0.008319195360681042+0.010271109089452436j) a'010010'b'100010' (0.018169777127136983+0.03119761433925508j) a'010010'b'001100' (-0.03927065918632092-0.05880649422133783j) a'010010'b'010100' (-0.016378537179231926-0.07809140908879292j) a'010010'b'100100' (0.0269477291089116+0.013580818612302096j) a'010010'b'011000' (-0.005080977590832856+0.0016859455085465674j) a'010010'b'101000' (-0.043922930994449584+0.013393245712815484j) a'010010'b'110000' (-0.05775134034333935-0.009669182864133185j) a'100010'b'000011' (0.03758329391695649-0.04774645450014107j) a'100010'b'000101' (-0.025062539094646497+0.006895128416369227j) a'100010'b'001001' (-0.04860197079595307+0.05889436550951902j) a'100010'b'010001' (0.010785820607976159-0.047794890865337544j) a'100010'b'100001' (0.022492234079882517+0.0178720870712056j) a'100010'b'000110' (-0.006860820634763622-0.053771572758090136j) a'100010'b'001010' (-0.06409153673964336+0.015326096223035863j) a'100010'b'010010' (0.033806807889595995+0.09043511061243217j) a'100010'b'100010' (0.02357031559608922-0.0823055255380771j) a'100010'b'001100' (0.009215844386494889-0.048339554147814975j) a'100010'b'010100' (0.03628721720759691+0.03871856681308508j) a'100010'b'100100' (-0.06811006267830785+0.038465607332150334j) a'100010'b'011000' (0.0222430965700556+0.05167404948465573j) a'100010'b'101000' (-0.004958533704916356+0.025156917347877606j) a'100010'b'110000' (0.015972019765505375-0.031721893601024j) a'001100'b'000011' (0.03216775266880999+0.013864425794876256j) a'001100'b'000101' (0.05113861089966106+0.05539865604819474j) a'001100'b'001001' (-0.007366505403971083+0.13798737219227986j) a'001100'b'010001' (0.014887494655626936+0.0465423465777655j) a'001100'b'100001' (0.03888734646718156+0.00786036343072649j) a'001100'b'000110' (-0.049558123292735345-0.0667245700886407j) a'001100'b'001010' (-0.05013620071047328+0.020103476362339452j) a'001100'b'010010' (-0.0379170763267995+0.0292672159707697j) a'001100'b'100010' (-0.046655213704922344-0.057893539361309074j) a'001100'b'001100' (-0.004312340249438789+0.0728129775705044j) a'001100'b'010100' (-0.02674557557290109-0.0017145581166266j) a'001100'b'100100' (0.04330868332830201+0.03250525242032928j) a'001100'b'011000' (0.07664706886509418+0.07390014249102085j) a'001100'b'101000' (-0.06559842207857335-0.05528769051593297j) a'001100'b'110000' (-0.060055843576349806+0.05647416742870854j) a'010100'b'000011' (-0.016359655797618496+0.03470231369427661j) a'010100'b'000101' (0.012183965804510699-0.028103827663176765j) a'010100'b'001001' (0.02801505905901133-0.05179468955896677j) a'010100'b'010001' (0.020174623372893+0.016527338149256825j) a'010100'b'100001' (0.0794514765512855+0.05901592347676624j) a'010100'b'000110' (0.033225781785656466-0.02751675967971475j) a'010100'b'001010' (0.018356577569003128+0.02638115489071506j) a'010100'b'010010' (-0.019365499417941048-0.03886797170504313j) a'010100'b'100010' (0.1332648579560864+0.04261498264873938j) a'010100'b'001100' (0.014576277353004631+0.0020975247334225704j) a'010100'b'010100' (-0.050905008546583475-0.062195017746852356j) a'010100'b'100100' (0.028391226406269995+0.009432412951791588j) a'010100'b'011000' (0.0709783453054257+0.04268208775392184j) a'010100'b'101000' (-0.018967729861761477+0.0015069204526702378j) a'010100'b'110000' (-0.06233795265736616+0.017714256759907322j) a'100100'b'000011' (-0.0649731479926313+0.06314285408013005j) a'100100'b'000101' (0.14409948388467161+0.01165113023228086j) a'100100'b'001001' (-0.026453084218143016+0.03056586215266893j) a'100100'b'010001' (-0.018445515467492287-0.0447357210585858j) a'100100'b'100001' (0.012782750771519118-0.09732997061468046j) a'100100'b'000110' (-0.015444983612466302-0.028297603813025925j) a'100100'b'001010' (0.022808938131359226+0.042589991265342554j) a'100100'b'010010' (0.057779412140136724-0.10320924175817882j) a'100100'b'100010' (0.04651504133240945+0.005714261641346241j) a'100100'b'001100' (0.09678697696218343-0.05054037519039848j) a'100100'b'010100' (0.06281306936946038+0.016937144578143794j) a'100100'b'100100' (-0.02493560264966922+0.04991161268411913j) a'100100'b'011000' (0.025848430833563155+0.07377053833346704j) a'100100'b'101000' (-0.019669824368972865-0.024170801902314226j) a'100100'b'110000' (-0.012868696804700602-0.0652696963843389j) a'011000'b'000011' (-0.03931340563464792+0.003847186348568695j) a'011000'b'000101' (-0.029067360458778824-0.01845923176932486j) a'011000'b'001001' (-0.011521990642671056-0.012228505901212591j) a'011000'b'010001' (-0.0429377158124471+0.06849121430371305j) a'011000'b'100001' (0.03251938210901843+0.059245384124334215j) a'011000'b'000110' (0.0033014695828669192+0.03409601989170342j) a'011000'b'001010' (-0.0002822829165053127-0.008655081168945016j) a'011000'b'010010' (0.05321054384627781+0.10264370403764346j) a'011000'b'100010' (0.02920241875101994-0.01299068816815962j) a'011000'b'001100' (0.0908303097163301+0.04037621223127139j) a'011000'b'010100' (0.03387167930393763+0.016387545765327267j) a'011000'b'100100' (0.003836252125104768-0.08546858159447894j) a'011000'b'011000' (-0.010450181660688845+0.020993534195829226j) a'011000'b'101000' (-0.0455633678597734-0.012639448619820142j) a'011000'b'110000' (0.03402952990385347-0.04905306500510651j) a'101000'b'000011' (-0.05113506899644806+0.01093438613162309j) a'101000'b'000101' (-0.014459620195434078-0.0429778099092705j) a'101000'b'001001' (-0.013526263316223712+0.020830623062825886j) a'101000'b'010001' (-0.024100623528587613+0.008196051569001746j) a'101000'b'100001' (-0.031689492885625385+0.0014270736771923975j) a'101000'b'000110' (0.02965566885365466-0.010604267042793866j) a'101000'b'001010' (-0.09829691827305169+0.007417905367867071j) a'101000'b'010010' (0.0970266964775174+0.030545854001507184j) a'101000'b'100010' (0.09284247595900762-0.012225902856322803j) a'101000'b'001100' (0.0031777219269476524-0.05038457144089098j) a'101000'b'010100' (-0.022838700748048325-0.03777667055895876j) a'101000'b'100100' (0.014007815721149968+0.04305547430163692j) a'101000'b'011000' (0.03044135971463709+0.015315065258596095j) a'101000'b'101000' (-0.029306878745944214-0.0839465484863112j) a'101000'b'110000' (-0.012297497717633433-0.0015535440573267141j) a'110000'b'000011' (0.047127231979316675-0.03631764695025477j) a'110000'b'000101' (0.104901444744699+0.010029800145233343j) a'110000'b'001001' (0.080622136169737+0.004865576971989997j) a'110000'b'010001' (0.02504550383759916+0.026362887692858585j) a'110000'b'100001' (-0.01144438111198161+0.01697541526435416j) a'110000'b'000110' (-0.01652533695677743-0.0184254336843848j) a'110000'b'001010' (0.008205030458074357+0.013012741627496417j) a'110000'b'010010' (0.04375701288500724+0.015830789481583837j) a'110000'b'100010' (0.08066332654912811+0.018680350743442473j) a'110000'b'001100' (-0.014560307368807228+0.03891547995088309j) a'110000'b'010100' (0.037223756276096844-0.03860850078333454j) a'110000'b'100100' (0.06879262771170402+0.01812923662889827j) a'110000'b'011000' (-0.0017276916567051416-0.0470475028780923j) a'110000'b'101000' (0.04304046343824224-0.039381043974405595j) a'110000'b'110000' (-0.006836872322545871+0.06375197920471602j)
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.03669628587410053-0.010454869703613867j) a'000011'b'000101' (-0.04937231194701611+0.008416702863724805j) a'000011'b'001001' (0.052586250250306076+0.05445833396716117j) a'000011'b'010001' (0.1096026198632641+0.06043943412739877j) a'000011'b'100001' (0.009766255888494264-0.052968930915552034j) a'000011'b'000110' (-0.03811372993984018+0.002097960094066101j) a'000011'b'001010' (-0.03905915053433009-0.0613748507345054j) a'000011'b'010010' (-0.020763798160774682+0.0037035486158815763j) a'000011'b'100010' (-0.018488028840047653+0.005485566616403762j) a'000011'b'001100' (-0.033068098392882606+0.05581454854055689j) a'000011'b'010100' (-0.012765407276717013+0.04361810132388786j) a'000011'b'100100' (0.0215681669329731+0.0650100018002577j) a'000011'b'011000' (0.02087008366792915-0.005170017936179846j) a'000011'b'101000' (0.0065730088128195426-0.028294256113388216j) a'000011'b'110000' (-0.09922047544506145+0.010322961634738833j) a'000101'b'000011' (-0.07498360869391733+0.0032601319042513525j) a'000101'b'000101' (0.027022456678291732+0.0674218794137314j) a'000101'b'001001' (0.06062263340378269+0.05506759659197872j) a'000101'b'010001' (0.06185387950543839-0.031186512044089246j) a'000101'b'100001' (0.027384335202249567-0.036265610251048186j) a'000101'b'000110' (0.07473856956621602+0.01915265645075771j) a'000101'b'001010' (-0.030088075587251465-0.00710080472775789j) a'000101'b'010010' (-0.05202754884505829+0.08961074651207405j) a'000101'b'100010' (-0.04991085766071251-0.0403788226134974j) a'000101'b'001100' (0.05230122381255118+0.050534394232842596j) a'000101'b'010100' (0.01690432298460219-0.018934269579648073j) a'000101'b'100100' (-0.05804691441814379+0.005529707839232695j) a'000101'b'011000' (0.0664386609133045-0.020367708166833764j) a'000101'b'101000' (0.12128840037707339+0.07185643651611845j) a'000101'b'110000' (-0.01771025001159852+0.02708108785948544j) a'001001'b'000011' (0.011576519541684803-0.016948815629492076j) a'001001'b'000101' (0.018562498913643467-0.014632217518651132j) a'001001'b'001001' (0.038772924424316076-0.0356046746775801j) a'001001'b'010001' (-0.027621454683505995-0.02831064967482538j) a'001001'b'100001' (-0.012890098174744449-0.023133663574908172j) a'001001'b'000110' (0.07233365912408518-0.06653491552724464j) a'001001'b'001010' (0.025285411998744352-0.016730948454110665j) a'001001'b'010010' (-0.030163297142449315-0.033105064019574484j) a'001001'b'100010' (-0.024518355123719086+0.025134259150719148j) a'001001'b'001100' (-0.03267114151999907-0.08031617927311256j) a'001001'b'010100' (0.05971716812061827+0.07446864085870003j) a'001001'b'100100' (0.05200556537308731-0.05547407339065732j) a'001001'b'011000' (-0.060079798500333396+0.020208738199004747j) a'001001'b'101000' (-0.06934498393878201+0.00164748631523791j) a'001001'b'110000' (0.03249593045009722+0.03185719108836396j) a'010001'b'000011' (-0.07375171978166496-0.05224245633462392j) a'010001'b'000101' (0.07562314369416408-0.07380115628192023j) a'010001'b'001001' (-0.00021668098390341742+0.03725690313771157j) a'010001'b'010001' (0.045462356186959346-0.062352000721292586j) a'010001'b'100001' (0.056594289678389496+0.026302771670355943j) a'010001'b'000110' (-0.019244336491959824+0.03103777207706306j) a'010001'b'001010' (-0.00438336814769224-0.05457563333168434j) a'010001'b'010010' (0.040586452401643235-0.10958981259329038j) a'010001'b'100010' (-0.0100566345160211+0.04725550680935688j) a'010001'b'001100' (-0.009606807667486091+0.006530328998435088j) a'010001'b'010100' (0.08099679615219935-0.09337708773398071j) a'010001'b'100100' (-0.02410809385479798+0.06532025422472246j) a'010001'b'011000' (0.034309801777627935-0.008864229615995969j) a'010001'b'101000' (-0.009141994281498079-0.07284452133561732j) a'010001'b'110000' (0.02633070653009293+0.03227106009627691j) a'100001'b'000011' (0.03128865684117593+0.08591873692176435j) a'100001'b'000101' (0.04712374922369887-0.005018518198449052j) a'100001'b'001001' (0.09072579194113735-0.005180681809919737j) a'100001'b'010001' (-0.06513318822800378-0.06643932527971348j) a'100001'b'100001' (-0.0009219292951106056-0.01935232073946916j) a'100001'b'000110' (0.00962043410785851-0.0640408658018744j) a'100001'b'001010' (-0.022219345298266927+0.013724910977792755j) a'100001'b'010010' (0.05354955315800116+0.0036861410027754105j) a'100001'b'100010' (-0.027995726399517584+0.00631358845339984j) a'100001'b'001100' (0.07901629719927213+0.03389726115328301j) a'100001'b'010100' (0.02788457796452446-0.0515886763189994j) a'100001'b'100100' (0.053007201458327054-0.021343415860496356j) a'100001'b'011000' (-0.01675178358150871-0.07477306168485669j) a'100001'b'101000' (-0.015607530411376514+0.05088891330834273j) a'100001'b'110000' (0.0014203012185490123+0.0649591718213956j) a'000110'b'000011' (-0.005416252540292666-0.034743289527846236j) a'000110'b'000101' (0.013299911355870386-0.028000967354573688j) a'000110'b'001001' (-0.011310705872613647-0.026256758420822972j) a'000110'b'010001' (-0.09085197979075178-0.1392507960218832j) a'000110'b'100001' (0.05365716038415639+0.03977752683537471j) a'000110'b'000110' (-0.029868106423411155+0.05019698203988518j) a'000110'b'001010' (-0.0468898439328147-0.03942510286830948j) a'000110'b'010010' (-0.0188811631112918+0.07124176024280202j) a'000110'b'100010' (0.058820879690599945+0.036909013513829594j) a'000110'b'001100' (-0.1014403126355969+0.04108592293934626j) a'000110'b'010100' (-0.0235280591092229-0.016534743658706032j) a'000110'b'100100' (0.017616462832845653-0.015747084948777308j) a'000110'b'011000' (-0.009832796790560597+0.055540687680030836j) a'000110'b'101000' (0.09862079543721752+0.06820470748169166j) a'000110'b'110000' (-0.004630986553635872+0.035338436936954105j) a'001010'b'000011' (-0.03050760879850477+0.009631595232882298j) a'001010'b'000101' (0.006699885634914607+0.00832149778406086j) a'001010'b'001001' (0.04755004105136711-0.01522385590497149j) a'001010'b'010001' (0.05448908557199562+0.03604641067501089j) a'001010'b'100001' (-0.014522292531976056+0.01975544910888607j) a'001010'b'000110' (0.040264633147296065+0.011398014315823072j) a'001010'b'001010' (0.014135231586409471+0.012219067309471919j) a'001010'b'010010' (0.05765940378618635-0.03249303729049927j) a'001010'b'100010' (-0.06940196682695342-0.0284259847377154j) a'001010'b'001100' (0.03421479312174818-0.0026965613545938192j) a'001010'b'010100' (0.033513102817579014+0.008857859368439356j) a'001010'b'100100' (-0.019181076305569752-0.11087222939187366j) a'001010'b'011000' (0.06567198331281504-0.05209478063786421j) a'001010'b'101000' (-0.037931574388087835+0.036701274086015194j) a'001010'b'110000' (0.048328226884943634+0.08993395456756717j) a'010010'b'000011' (-0.05636182340772216+0.015578516270622766j) a'010010'b'000101' (-0.16725270169203205+0.05391014946732199j) a'010010'b'001001' (-0.05158806763272501-0.01571468190035677j) a'010010'b'010001' (0.000592428161774594-0.04113627308891005j) a'010010'b'100001' (0.017522317445935614-0.07994900259096063j) a'010010'b'000110' (-0.022831302750129553+0.01621763204627843j) a'010010'b'001010' (0.031991149635294286+0.09431031148716883j) a'010010'b'010010' (-0.012990595854743053-0.0024390803011261806j) a'010010'b'100010' (-0.012646673218297707-0.03381558217479502j) a'010010'b'001100' (0.005210149684007559-0.07052122216611569j) a'010010'b'010100' (0.002940006018554453+0.07973632182522314j) a'010010'b'100100' (-0.02911868099745006+0.007919668886782647j) a'010010'b'011000' (-0.004511037763185995+0.0028825828410375086j) a'010010'b'101000' (0.038630453007126905+0.024825208928248483j) a'010010'b'110000' (-0.045584630178909846+0.03675257678264587j) a'100010'b'000011' (-0.05206174933360562+0.03133372233404761j) a'100010'b'000101' (-0.018183073003079912+0.018575508550604282j) a'100010'b'001001' (-0.06964780324816203+0.03130305666743752j) a'100010'b'010001' (0.02728364774770904+0.04069751939118526j) a'100010'b'100001' (-0.021400553661222968-0.01916581313636598j) a'100010'b'000110' (0.046872623615432464-0.027228845955474926j) a'100010'b'001010' (0.06577004531197869+0.004112839256167898j) a'100010'b'010010' (-0.01806685675467245-0.09484196422561604j) a'100010'b'100010' (0.010500182492079504-0.08496767314120905j) a'100010'b'001100' (-0.037900074471637894+0.03138835194797467j) a'100010'b'010100' (-0.05287143585716604-0.004527783026186994j) a'100010'b'100100' (0.0002124113718664886-0.07822108709857785j) a'100010'b'011000' (0.025009458031598656-0.05039335019755256j) a'100010'b'101000' (-0.009601385551166285-0.023775427282145566j) a'100010'b'110000' (0.013423808601671052-0.03288138244736804j) a'001100'b'000011' (-0.02615404754079368-0.02330133926660152j) a'001100'b'000101' (-0.062457712851884464-0.042227985057360494j) a'001100'b'001001' (-0.02980308012578178+0.13493167419628996j) a'001100'b'010001' (0.0315234552973591-0.037337639028218746j) a'001100'b'100001' (0.030182831448482047-0.025748936177524745j) a'001100'b'000110' (-0.03991351051255565-0.0729046467406296j) a'001100'b'001010' (0.007432903470337268+0.05350271329131495j) a'001100'b'010010' (-0.04789794522921858-0.0002478924581197863j) a'001100'b'100010' (-0.000921937451208241+0.0743472991908077j) a'001100'b'001100' (-0.03729605679241097-0.06268436909506996j) a'001100'b'010100' (0.02644634081345482+0.004342416359545399j) a'001100'b'100100' (-0.038700571305545425-0.03787478405436602j) a'001100'b'011000' (-0.03181530090190275+0.10160605717340411j) a'001100'b'101000' (-0.06475219754370506-0.05627641259928743j) a'001100'b'110000' (-0.02491012778583374+0.0785844861796922j) a'010100'b'000011' (-0.024987471800160845+0.02911211374305715j) a'010100'b'000101' (-0.028194840637402116-0.01197184670293284j) a'010100'b'001001' (-0.05876435066817164+0.0037794829193673572j) a'010100'b'010001' (-0.026031322436470147-0.0015932943062995414j) a'010100'b'100001' (0.09430473123621312+0.030033881142146945j) a'010100'b'000110' (0.03133185166571114-0.02965534875426541j) a'010100'b'001010' (-0.001754363273778965+0.03209129917778873j) a'010100'b'010010' (0.01251539423470429+0.04158252877495834j) a'010100'b'100010' (-0.12758829799066293+0.05741763952004675j) a'010100'b'001100' (-0.014298553398721709-0.003524037766956983j) a'010100'b'010100' (-0.05573845476148011+0.05790306372258255j) a'010100'b'100100' (0.019185761297945345+0.022955145705559586j) a'010100'b'011000' (0.03852621215019181-0.07331723600005766j) a'010100'b'101000' (-0.015827228977809787+0.010561458622908682j) a'010100'b'110000' (-0.05153498839925593+0.03929325902437345j) a'100100'b'000011' (-0.02434808425369084+0.08726798252871518j) a'100100'b'000101' (0.09525945525859147+0.10874762652745437j) a'100100'b'001001' (0.007727227017568701+0.039677796768559134j) a'100100'b'010001' (-0.031966568713513485-0.036327128487912655j) a'100100'b'100001' (-0.06137056082215967+0.0766170748692152j) a'100100'b'000110' (-0.017836883264091736+0.02685418953853376j) a'100100'b'001010' (0.0095526977334746-0.04735927555057189j) a'100100'b'010010' (0.026045253693958437+0.1153787363926964j) a'100100'b'100010' (-0.027951774698387125+0.03761648770781404j) a'100100'b'001100' (-0.1025506612686871+0.037488802424450254j) a'100100'b'010100' (0.04451449008028597+0.04744268882521002j) a'100100'b'100100' (0.03591860279177846-0.04269434779591034j) a'100100'b'011000' (0.05852860320641725+0.05181347613577761j) a'100100'b'101000' (0.015148460190175581-0.02723332166985549j) a'100100'b'110000' (-0.01323024042593665+0.06519737235369999j) a'011000'b'000011' (0.025761645985606506-0.0299446539720743j) a'011000'b'000101' (-0.00019788017202524845+0.03443276818659446j) a'011000'b'001001' (0.008008947995856252+0.014769880735654602j) a'011000'b'010001' (0.07932367782986309-0.01557074216380546j) a'011000'b'100001' (0.03324561367046664+0.05884092899051089j) a'011000'b'000110' (-0.018369909467718843+0.02891340000777918j) a'011000'b'001010' (0.007936575803365747-0.0034642283705620157j) a'011000'b'010010' (0.0767974920023896+0.0864247486379156j) a'011000'b'100010' (-0.028799290996865706-0.013861460170924735j) a'011000'b'001100' (0.004512229722346664+0.09929765082942246j) a'011000'b'010100' (0.014410913101493008-0.03475870968060681j) a'011000'b'100100' (-0.03831140355875658-0.07649726549032695j) a'011000'b'011000' (0.02262724718262675+0.00615974510098907j) a'011000'b'101000' (-0.003296650665687903+0.0471689330653824j) a'011000'b'110000' (0.05482098372867047-0.02364047027648368j) a'101000'b'000011' (-0.050693830828766655-0.012825427760948999j) a'101000'b'000101' (-0.04274146729792247-0.015143966918024422j) a'101000'b'001001' (0.01999629724366714-0.014731692130514496j) a'101000'b'010001' (-0.023997992778548638+0.008491858358991519j) a'101000'b'100001' (0.030248521322900613-0.009554446944028927j) a'101000'b'000110' (-0.02961416452459999-0.010719628453562668j) a'101000'b'001010' (0.09855521385645273+0.0020443296540655965j) a'101000'b'010010' (-0.03948574478474648-0.09374489311325464j) a'101000'b'100010' (-0.0710557020906834+0.06099414105675392j) a'101000'b'001100' (0.003941656038080519-0.05033057026901954j) a'101000'b'010100' (-0.03835569038707109-0.02185232494061323j) a'101000'b'100100' (-0.03478600338092614+0.028981489564872395j) a'101000'b'011000' (0.008934966594869852-0.032884555297275145j) a'101000'b'101000' (-0.08884689286372427-0.0034850786298114647j) a'101000'b'110000' (0.011733270548417269+0.0039965374376950925j) a'110000'b'000011' (-0.006039760094232904+0.059190107045348286j) a'110000'b'000101' (0.10247777116515243-0.024560464521281158j) a'110000'b'001001' (0.08067588212046814+0.0038735931544626404j) a'110000'b'010001' (-0.01696515130817791-0.032163065013709406j) a'110000'b'100001' (-0.006274895457475509-0.019487541390111347j) a'110000'b'000110' (0.024607982060517605+0.0026515253915321314j) a'110000'b'001010' (0.0046133711090176645-0.014675516225754612j) a'110000'b'010010' (0.040896551170483235-0.022198247106223503j) a'110000'b'100010' (0.08188408588489736+0.012268831756286175j) a'110000'b'001100' (0.0062556671497078714+0.04107655972685385j) a'110000'b'010100' (0.020517559818017513-0.04955052071525661j) a'110000'b'100100' (-0.056524587016499685-0.043197985032196226j) a'110000'b'011000' (0.023411102916310354-0.04084571832844511j) a'110000'b'101000' (-0.05008505129609477+0.02991380541088494j) a'110000'b'110000' (-0.044858301169615054-0.04581255823297195j)
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.03669628587410055-0.010454869703613815j) a'000011'b'000101' (-0.049372311947016106+0.008416702863724888j) a'000011'b'001001' (0.052586250250306096+0.05445833396716114j) a'000011'b'010001' (0.10960261986326425+0.06043943412739844j) a'000011'b'100001' (0.009766255888494151-0.052968930915552076j) a'000011'b'000110' (-0.03811372993984018+0.0020979600940660894j) a'000011'b'001010' (-0.03905915053433009-0.061374850734505416j) a'000011'b'010010' (-0.02076379816077469+0.00370354861588157j) a'000011'b'100010' (-0.01848802884004766+0.005485566616403761j) a'000011'b'001100' (-0.033068098392882606+0.05581454854055688j) a'000011'b'010100' (-0.01276540727671701+0.04361810132388786j) a'000011'b'100100' (0.0215681669329731+0.06501000180025772j) a'000011'b'011000' (0.020870083667929147-0.005170017936179842j) a'000011'b'101000' (0.006573008812819557-0.028294256113388223j) a'000011'b'110000' (-0.09922047544506146+0.010322961634738809j) a'000101'b'000011' (-0.0749836086939173+0.0032601319042514856j) a'000101'b'000101' (0.027022456678292277+0.06742187941373118j) a'000101'b'001001' (0.06062263340378296+0.0550675965919784j) a'000101'b'010001' (0.06185387950543821-0.03118651204408956j) a'000101'b'100001' (0.027384335202249414-0.0362656102510483j) a'000101'b'000110' (0.07473856956621602+0.019152656450757734j) a'000101'b'001010' (-0.03008807558725146-0.007100804727757889j) a'000101'b'010010' (-0.05202754884505828+0.08961074651207407j) a'000101'b'100010' (-0.049910857660712515-0.040378822613497393j) a'000101'b'001100' (0.05230122381255112+0.050534394232842665j) a'000101'b'010100' (0.016904322984602205-0.018934269579648062j) a'000101'b'100100' (-0.058046914418143816+0.005529707839232685j) a'000101'b'011000' (0.06643866091330451-0.020367708166833705j) a'000101'b'101000' (0.12128840037707325+0.07185643651611864j) a'000101'b'110000' (-0.017710250011598518+0.027081087859485438j) a'001001'b'000011' (0.011576519541684795-0.01694881562949208j) a'001001'b'000101' (0.018562498913643397-0.014632217518651222j) a'001001'b'001001' (0.038772924424315916-0.035604674677580245j) a'001001'b'010001' (-0.027621454683506054-0.028310649674825307j) a'001001'b'100001' (-0.012890098174744576-0.023133663574908106j) a'001001'b'000110' (0.07233365912408518-0.06653491552724465j) a'001001'b'001010' (0.02528541199874436-0.016730948454110654j) a'001001'b'010010' (-0.030163297142449308-0.0331050640195745j) a'001001'b'100010' (-0.024518355123719096+0.025134259150719145j) a'001001'b'001100' (-0.03267114151999882-0.08031617927311265j) a'001001'b'010100' (0.0597171681206182+0.07446864085870007j) a'001001'b'100100' (0.05200556537308744-0.055474073390657234j) a'001001'b'011000' (-0.06007979850033339+0.020208738199004726j) a'001001'b'101000' (-0.06934498393878202+0.0016474863152379365j) a'001001'b'110000' (0.032495930450097216+0.031857191088363976j) a'010001'b'000011' (-0.07375171978166509-0.05224245633462368j) a'010001'b'000101' (0.07562314369416367-0.0738011562819206j) a'010001'b'001001' (-0.000216680983903322+0.03725690313771155j) a'010001'b'010001' (0.04546235618695918-0.06235200072129266j) a'010001'b'100001' (0.05659428967838955+0.02630277167035576j) a'010001'b'000110' (-0.019244336491959828+0.031037772077063056j) a'010001'b'001010' (-0.004383368147692215-0.05457563333168434j) a'010001'b'010010' (0.04058645240164326-0.10958981259329038j) a'010001'b'100010' (-0.01005663451602111+0.047255506809356876j) a'010001'b'001100' (-0.009606807667486094+0.006530328998435078j) a'010001'b'010100' (0.08099679615219943-0.09337708773398062j) a'010001'b'100100' (-0.024108093854797986+0.06532025422472247j) a'010001'b'011000' (0.03430980177762793-0.008864229615995941j) a'010001'b'101000' (-0.009141994281498053-0.0728445213356173j) a'010001'b'110000' (0.026330706530092913+0.03227106009627691j) a'100001'b'000011' (0.03128865684117611+0.08591873692176427j) a'100001'b'000101' (0.04712374922369886-0.0050185181984492445j) a'100001'b'001001' (0.0907257919411373-0.005180681809920217j) a'100001'b'010001' (-0.06513318822800399-0.06643932527971326j) a'100001'b'100001' (-0.0009219292951106444-0.01935232073946916j) a'100001'b'000110' (0.009620434107858511-0.06404086580187439j) a'100001'b'001010' (-0.02221934529826694+0.013724910977792734j) a'100001'b'010010' (0.053549553158001154+0.003686141002775426j) a'100001'b'100010' (-0.027995726399517584+0.006313588453399847j) a'100001'b'001100' (0.07901629719927207+0.033897261153283176j) a'100001'b'010100' (0.02788457796452446-0.05158867631899939j) a'100001'b'100100' (0.0530072014583271-0.021343415860496276j) a'100001'b'011000' (-0.016751783581508667-0.07477306168485669j) a'100001'b'101000' (-0.015607530411376561+0.05088891330834272j) a'100001'b'110000' (0.0014203012185489763+0.0649591718213956j) a'000110'b'000011' (-0.005416252540292647-0.03474328952784625j) a'000110'b'000101' (0.013299911355870404-0.028000967354573685j) a'000110'b'001001' (-0.011310705872613645-0.02625675842082297j) a'000110'b'010001' (-0.09085197979075177-0.13925079602188317j) a'000110'b'100001' (0.0536571603841564+0.0397775268353747j) a'000110'b'000110' (-0.029868106423411186+0.05019698203988514j) a'000110'b'001010' (-0.04688984393281467-0.039425102868309504j) a'000110'b'010010' (-0.01888116311129181+0.07124176024280202j) a'000110'b'100010' (0.058820879690599924+0.03690901351382962j) a'000110'b'001100' (-0.10144031263559694+0.041085922939346126j) a'000110'b'010100' (-0.0235280591092229-0.01653474365870602j) a'000110'b'100100' (0.01761646283284566-0.015747084948777305j) a'000110'b'011000' (-0.009832796790560622+0.05554068768003083j) a'000110'b'101000' (0.09862079543721752+0.06820470748169169j) a'000110'b'110000' (-0.004630986553635891+0.0353384369369541j) a'001010'b'000011' (-0.030507608798504778+0.009631595232882295j) a'001010'b'000101' (0.00669988563491461+0.00832149778406086j) a'001010'b'001001' (0.047550041051367134-0.015223855904971464j) a'001010'b'010001' (0.054489085571995596+0.03604641067501091j) a'001010'b'100001' (-0.01452229253197607+0.019755449108886065j) a'001010'b'000110' (0.040264633147296044+0.011398014315823093j) a'001010'b'001010' (0.014135231586409478+0.012219067309471926j) a'001010'b'010010' (0.05765940378618637-0.03249303729049927j) a'001010'b'100010' (-0.06940196682695345-0.028425984737715366j) a'001010'b'001100' (0.03421479312174819-0.0026965613545938075j) a'001010'b'010100' (0.03351310281757901+0.00885785936843937j) a'001010'b'100100' (-0.01918107630556975-0.11087222939187366j) a'001010'b'011000' (0.0656719833128151-0.05209478063786418j) a'001010'b'101000' (-0.03793157438808787+0.03670127408601521j) a'001010'b'110000' (0.04832822688494359+0.08993395456756723j) a'010010'b'000011' (-0.056361823407722195+0.015578516270622742j) a'010010'b'000101' (-0.16725270169203196+0.053910149467322005j) a'010010'b'001001' (-0.05158806763272501-0.01571468190035678j) a'010010'b'010001' (0.0005924281617745962-0.04113627308891005j) a'010010'b'100001' (0.017522317445935624-0.07994900259096063j) a'010010'b'000110' (-0.022831302750129553+0.016217632046278428j) a'010010'b'001010' (0.0319911496352943+0.09431031148716887j) a'010010'b'010010' (-0.012990595854743062-0.002439080301126181j) a'010010'b'100010' (-0.012646673218297728-0.03381558217479503j) a'010010'b'001100' (0.005210149684007587-0.07052122216611569j) a'010010'b'010100' (0.002940006018554422+0.07973632182522314j) a'010010'b'100100' (-0.029118680997450068+0.007919668886782631j) a'010010'b'011000' (-0.004511037763185998+0.0028825828410375073j) a'010010'b'101000' (0.03863045300712691+0.024825208928248507j) a'010010'b'110000' (-0.045584630178909895+0.03675257678264585j) a'100010'b'000011' (-0.05206174933360563+0.0313337223340476j) a'100010'b'000101' (-0.018183073003079916+0.018575508550604282j) a'100010'b'001001' (-0.06964780324816207+0.031303056667437504j) a'100010'b'010001' (0.02728364774770904+0.040697519391185266j) a'100010'b'100001' (-0.021400553661222975-0.01916581313636598j) a'100010'b'000110' (0.04687262361543247-0.027228845955474902j) a'100010'b'001010' (0.06577004531197872+0.004112839256167851j) a'100010'b'010010' (-0.018066856754672497-0.09484196422561605j) a'100010'b'100010' (0.010500182492079457-0.08496767314120905j) a'100010'b'001100' (-0.03790007447163791+0.03138835194797467j) a'100010'b'010100' (-0.05287143585716605-0.004527783026187018j) a'100010'b'100100' (0.00021241137186658182-0.07822108709857786j) a'100010'b'011000' (0.025009458031598694-0.050393350197552575j) a'100010'b'101000' (-0.009601385551166264-0.023775427282145583j) a'100010'b'110000' (0.013423808601671059-0.03288138244736805j) a'001100'b'000011' (-0.026154047540793684-0.02330133926660152j) a'001100'b'000101' (-0.062457712851884416-0.042227985057360584j) a'001100'b'001001' (-0.029803080125782186+0.13493167419628982j) a'001100'b'010001' (0.03152345529735913-0.03733763902821871j) a'001100'b'100001' (0.03018283144848211-0.025748936177524696j) a'001100'b'000110' (-0.03991351051255557-0.07290464674062963j) a'001100'b'001010' (0.007432903470337248+0.053502713291314966j) a'001100'b'010010' (-0.04789794522921858-0.000247892458119809j) a'001100'b'100010' (-0.000921937451208242+0.07434729919080771j) a'001100'b'001100' (-0.03729605679241078-0.06268436909507007j) a'001100'b'010100' (0.026446340813454813+0.004342416359545433j) a'001100'b'100100' (-0.03870057130554543-0.03787478405436604j) a'001100'b'011000' (-0.031815300901902925+0.10160605717340403j) a'001100'b'101000' (-0.06475219754370505-0.056276412599287486j) a'001100'b'110000' (-0.02491012778583375+0.0785844861796922j) a'010100'b'000011' (-0.024987471800160845+0.02911211374305715j) a'010100'b'000101' (-0.028194840637402106-0.011971846702932862j) a'010100'b'001001' (-0.058764350668171636+0.0037794829193672948j) a'010100'b'010001' (-0.026031322436470147-0.0015932943062995624j) a'010100'b'100001' (0.09430473123621311+0.030033881142146956j) a'010100'b'000110' (0.031331851665711126-0.029655348754265412j) a'010100'b'001010' (-0.0017543632737789805+0.032091299177788725j) a'010100'b'010010' (0.012515394234704273+0.041582528774958355j) a'010100'b'100010' (-0.12758829799066299+0.05741763952004667j) a'010100'b'001100' (-0.014298553398721698-0.0035240377669569995j) a'010100'b'010100' (-0.05573845476148011+0.05790306372258251j) a'010100'b'100100' (0.01918576129794535+0.022955145705559586j) a'010100'b'011000' (0.03852621215019181-0.07331723600005761j) a'010100'b'101000' (-0.015827228977809787+0.010561458622908677j) a'010100'b'110000' (-0.051534988399255854+0.039293259024373514j) a'100100'b'000011' (-0.02434808425369083+0.08726798252871518j) a'100100'b'000101' (0.09525945525859149+0.10874762652745443j) a'100100'b'001001' (0.007727227017568627+0.03967779676855916j) a'100100'b'010001' (-0.031966568713513485-0.036327128487912655j) a'100100'b'100001' (-0.06137056082215983+0.07661707486921512j) a'100100'b'000110' (-0.017836883264091743+0.026854189538533756j) a'100100'b'001010' (0.009552697733474603-0.0473592755505719j) a'100100'b'010010' (0.026045253693958374+0.11537873639269641j) a'100100'b'100010' (-0.027951774698387156+0.03761648770781403j) a'100100'b'001100' (-0.10255066126868713+0.03748880242445027j) a'100100'b'010100' (0.04451449008028599+0.04744268882521002j) a'100100'b'100100' (0.03591860279177847-0.042694347795910366j) a'100100'b'011000' (0.05852860320641724+0.0518134761357776j) a'100100'b'101000' (0.015148460190175633-0.027233321669855474j) a'100100'b'110000' (-0.013230240425936696+0.06519737235369999j) a'011000'b'000011' (0.025761645985606513-0.029944653972074284j) a'011000'b'000101' (-0.00019788017202527174+0.034432768186594444j) a'011000'b'001001' (0.008008947995856242+0.014769880735654599j) a'011000'b'010001' (0.07932367782986306-0.015570742163805398j) a'011000'b'100001' (0.03324561367046661+0.05884092899051088j) a'011000'b'000110' (-0.018369909467718853+0.028913400007779158j) a'011000'b'001010' (0.007936575803365748-0.0034642283705620088j) a'011000'b'010010' (0.07679749200238956+0.08642474863791569j) a'011000'b'100010' (-0.028799290996865706-0.013861460170924754j) a'011000'b'001100' (0.004512229722346481+0.09929765082942241j) a'011000'b'010100' (0.01441091310149301-0.0347587096806068j) a'011000'b'100100' (-0.03831140355875657-0.07649726549032697j) a'011000'b'011000' (0.02262724718262672+0.006159745100989142j) a'011000'b'101000' (-0.0032966506656879526+0.04716893306538239j) a'011000'b'110000' (0.054820983728670496-0.023640470276483663j) a'101000'b'000011' (-0.05069383082876666-0.01282542776094902j) a'101000'b'000101' (-0.04274146729792245-0.015143966918024504j) a'101000'b'001001' (0.019996297243667138-0.014731692130514508j) a'101000'b'010001' (-0.02399799277854864+0.00849185835899151j) a'101000'b'100001' (0.030248521322900627-0.009554446944028908j) a'101000'b'000110' (-0.029614164524599994-0.010719628453562677j) a'101000'b'001010' (0.09855521385645277+0.0020443296540656186j) a'101000'b'010010' (-0.039485744784746465-0.0937448931132547j) a'101000'b'100010' (-0.07105570209068347+0.06099414105675388j) a'101000'b'001100' (0.003941656038080551-0.05033057026901954j) a'101000'b'010100' (-0.03835569038707108-0.02185232494061324j) a'101000'b'100100' (-0.034786003380926196+0.028981489564872343j) a'101000'b'011000' (0.008934966594869892-0.03288455529727514j) a'101000'b'101000' (-0.0888468928637243-0.003485078629811622j) a'101000'b'110000' (0.011733270548417269+0.003996537437695102j) a'110000'b'000011' (-0.006039760094232922+0.05919010704534829j) a'110000'b'000101' (0.10247777116515243-0.024560464521281168j) a'110000'b'001001' (0.08067588212046817+0.003873593154462656j) a'110000'b'010001' (-0.0169651513081779-0.03216306501370941j) a'110000'b'100001' (-0.0062748954574755-0.01948754139011135j) a'110000'b'000110' (0.024607982060517605+0.0026515253915321488j) a'110000'b'001010' (0.004613371109017677-0.014675516225754616j) a'110000'b'010010' (0.04089655117048327-0.022198247106223465j) a'110000'b'100010' (0.08188408588489739+0.012268831756286184j) a'110000'b'001100' (0.006255667149707862+0.041076559726853853j) a'110000'b'010100' (0.020517559818017443-0.04955052071525665j) a'110000'b'100100' (-0.05652458701649966-0.04319798503219628j) a'110000'b'011000' (0.02341110291631037-0.0408457183284451j) a'110000'b'101000' (-0.050085051296094786+0.029913805410884918j) a'110000'b'110000' (-0.04485830116961509-0.045812558232971964j) 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