{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "##### Copyright 2020 The OpenFermion Developers" ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "execution": { "iopub.execute_input": "2024-06-30T09:39:22.510354Z", "iopub.status.busy": "2024-06-30T09:39:22.509737Z", "iopub.status.idle": "2024-06-30T09:39:22.513767Z", "shell.execute_reply": "2024-06-30T09:39:22.513180Z" } }, "outputs": [], "source": [ "#@title Licensed under the Apache License, Version 2.0 (the \"License\");\n", "# you may not use this file except in compliance with the License.\n", "# You may obtain a copy of the License at\n", "#\n", "# https://www.apache.org/licenses/LICENSE-2.0\n", "#\n", "# Unless required by applicable law or agreed to in writing, software\n", "# distributed under the License is distributed on an \"AS IS\" BASIS,\n", "# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n", "# See the License for the specific language governing permissions and\n", "# limitations under the License." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# FQE vs OpenFermion vs Cirq: Diagonal Coulomb Operators" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n", " \n", " \n", " \n", " \n", "
\n", " View on QuantumAI\n", " \n", " Run in Google Colab\n", " \n", " View source on GitHub\n", " \n", " Download notebook\n", "
" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "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." ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "execution": { "iopub.execute_input": "2024-06-30T09:39:22.517422Z", "iopub.status.busy": "2024-06-30T09:39:22.516843Z", "iopub.status.idle": "2024-06-30T09:39:36.652462Z", "shell.execute_reply": "2024-06-30T09:39:36.651647Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\u001b[31mERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.\r\n", "tensorflow-metadata 1.15.0 requires protobuf<4.21,>=3.20.3; python_version < \"3.11\", but you have protobuf 4.25.3 which is incompatible.\u001b[0m\u001b[31m\r\n", "\u001b[0m" ] } ], "source": [ "try:\n", " import fqe\n", "except ImportError:\n", " !pip install fqe --quiet" ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "execution": { "iopub.execute_input": "2024-06-30T09:39:36.656567Z", "iopub.status.busy": "2024-06-30T09:39:36.656287Z", "iopub.status.idle": "2024-06-30T09:39:38.369700Z", "shell.execute_reply": "2024-06-30T09:39:38.368879Z" } }, "outputs": [], "source": [ "from itertools import product\n", "import fqe\n", "from fqe.hamiltonians.diagonal_coulomb import DiagonalCoulomb\n", "\n", "import numpy as np\n", "\n", "import openfermion as of\n", "\n", "from scipy.linalg import expm" ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "execution": { "iopub.execute_input": "2024-06-30T09:39:38.373660Z", "iopub.status.busy": "2024-06-30T09:39:38.373229Z", "iopub.status.idle": "2024-06-30T09:39:38.382553Z", "shell.execute_reply": "2024-06-30T09:39:38.381951Z" } }, "outputs": [], "source": [ "#Utility function\n", "def uncompress_tei(tei_mat, notation='chemistry'):\n", " \"\"\"\n", " uncompress chemist notation integrals\n", "\n", " tei_tensor[i, k, j, l] = tei_mat[(i, j), (k, l)]\n", " [1, 1, 2, 2] = [1, 1, 2, 2] = [1, 1, 2, 2] = [1, 1, 2, 2]\n", " [i, j, k, l] = [k, l, i, j] = [j, i, l, k]* = [l, k, j, i]*\n", "\n", " For real we also have swap of i <> j and k <> l\n", " [j, i, k, l] = [l, k, i, j] = [i, j, l, k] = [k, l, j, i]\n", "\n", " tei_mat[(i, j), (k, l)] = int dr1 int dr2 phi_i(dr1) phi_j(dr1) O(r12) phi_k(dr1) phi_l(dr1)\n", "\n", " Physics notation is the notation that is used in FQE.\n", "\n", " Args:\n", " tei_mat: compressed two electron integral matrix\n", "\n", " Returns:\n", " uncompressed 4-electron integral tensor. No antisymmetry.\n", " \"\"\"\n", " if notation not in ['chemistry', 'physics']:\n", " return ValueError(\"notation can be [chemistry, physics]\")\n", "\n", " norbs = int(0.5 * (np.sqrt(8 * tei_mat.shape[0] + 1) - 1))\n", " basis = {}\n", " cnt = 0\n", " for i, j in product(range(norbs), repeat=2):\n", " if i >= j:\n", " basis[(i, j)] = cnt\n", " cnt += 1\n", "\n", " tei_tensor = np.zeros((norbs, norbs, norbs, norbs))\n", " for i, j, k, l in product(range(norbs), repeat=4):\n", " if i >= j and k >= l:\n", " tei_tensor[i, j, k, l] = tei_mat[basis[(i, j)], basis[(k, l)]]\n", " tei_tensor[k, l, i, j] = tei_mat[basis[(i, j)], basis[(k, l)]]\n", " tei_tensor[j, i, l, k] = tei_mat[basis[(i, j)], basis[(k, l)]]\n", " tei_tensor[l, k, j, i] = tei_mat[basis[(i, j)], basis[(k, l)]]\n", "\n", " tei_tensor[j, i, k, l] = tei_mat[basis[(i, j)], basis[(k, l)]]\n", " tei_tensor[l, k, i, j] = tei_mat[basis[(i, j)], basis[(k, l)]]\n", " tei_tensor[i, j, l, k] = tei_mat[basis[(i, j)], basis[(k, l)]]\n", " tei_tensor[k, l, j, i] = tei_mat[basis[(i, j)], basis[(k, l)]]\n", "\n", " if notation == 'chemistry':\n", " return tei_tensor\n", " elif notation == 'physics':\n", " return np.asarray(tei_tensor.transpose(0, 2, 1, 3), order='C')\n", "\n", " return tei_tensor\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The first example we will perform is diagonal Coulomb evolution on the Hartree-Fock state. The diagonal Coulomb operator is defined as\n", "\n", "\\begin{align}\n", "V = \\sum_{\\alpha, \\beta \\in \\{\\uparrow, \\downarrow\\}}\\sum_{p,q} V_{pq,pq}n_{p,\\alpha}n_{q,\\beta}\n", "\\end{align}\n", "\n", "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.\n", "\n", "All the terms in $V$ commute and thus we can evolve under $V$ exactly by counting the accumulated phase on each bitstring.\n", "\n", "\n", "To start out let's define a Hartree-Fock wavefunction for 4-orbitals and 2-electrons $S_{z} =0$." ] }, { "cell_type": "code", "execution_count": 5, "metadata": { "execution": { "iopub.execute_input": "2024-06-30T09:39:38.385687Z", "iopub.status.busy": "2024-06-30T09:39:38.385438Z", "iopub.status.idle": "2024-06-30T09:39:38.395691Z", "shell.execute_reply": "2024-06-30T09:39:38.395001Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Sector N = 2 : S_z = 0\n", "a'0001'b'0001' (1+0j)\n" ] } ], "source": [ "norbs = 4\n", "tedim = norbs * (norbs + 1) // 2\n", "if (norbs // 2) % 2 == 0:\n", " n_elec = norbs // 2\n", "else:\n", " n_elec = (norbs // 2) + 1\n", "sz = 0\n", "fqe_wfn = fqe.Wavefunction([[n_elec, sz, norbs]])\n", "fci_data = fqe_wfn.sector((n_elec, sz))\n", "fci_graph = fci_data.get_fcigraph()\n", "hf_wf = np.zeros((fci_data.lena(), fci_data.lenb()), dtype=np.complex128)\n", "hf_wf[0, 0] = 1 # right most bit is zero orbital.\n", "fqe_wfn.set_wfn(strategy='from_data',\n", " raw_data={(n_elec, sz): hf_wf})\n", "fqe_wfn.print_wfn()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "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" ] }, { "cell_type": "code", "execution_count": 6, "metadata": { "execution": { "iopub.execute_input": "2024-06-30T09:39:38.399420Z", "iopub.status.busy": "2024-06-30T09:39:38.398830Z", "iopub.status.idle": "2024-06-30T09:39:38.406516Z", "shell.execute_reply": "2024-06-30T09:39:38.405805Z" } }, "outputs": [], "source": [ "tei_compressed = np.random.randn(tedim**2).reshape((tedim, tedim))\n", "tei_compressed = 0.5 * (tei_compressed + tei_compressed.T)\n", "tei_tensor = uncompress_tei(tei_compressed, notation='physics')\n", "\n", "diagonal_coulomb = of.FermionOperator()\n", "diagonal_coulomb_mat = np.zeros((norbs, norbs))\n", "for i, j in product(range(norbs), repeat=2):\n", " diagonal_coulomb_mat[i, j] = tei_tensor[i, j, i, j]\n", " for sigma, tau in product(range(2), repeat=2):\n", " diagonal_coulomb += of.FermionOperator(\n", " ((2 * i + sigma, 1), (2 * i + sigma, 0), (2 * j + tau, 1),\n", " (2 * j + tau, 0)), coefficient=diagonal_coulomb_mat[i, j])\n", "\n", "dc_ham = DiagonalCoulomb(diagonal_coulomb_mat)\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "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\". " ] }, { "cell_type": "code", "execution_count": 7, "metadata": { "execution": { "iopub.execute_input": "2024-06-30T09:39:38.410287Z", "iopub.status.busy": "2024-06-30T09:39:38.409622Z", "iopub.status.idle": "2024-06-30T09:39:38.424203Z", "shell.execute_reply": "2024-06-30T09:39:38.423490Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "(-0.9870409869369888+0.16046834611989685j)\n" ] } ], "source": [ "alpha_occs = [list(range(fci_graph.nalpha()))]\n", "beta_occs = [list(range(fci_graph.nbeta()))]\n", "occs = alpha_occs[0] + beta_occs[0]\n", "diag_ele = 0.\n", "for ind in occs:\n", " for jnd in occs:\n", " diag_ele += diagonal_coulomb_mat[ind, jnd]\n", "evolved_phase = np.exp(-1j * diag_ele)\n", "print(evolved_phase)\n", "\n", "# evolve FQE wavefunction\n", "evolved_hf_wfn = fqe_wfn.time_evolve(1, dc_ham)\n", "\n", "# check they the accumulated phase is equivalent!\n", "assert np.isclose(evolved_hf_wfn.get_coeff((n_elec, sz))[0, 0], evolved_phase)\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "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." ] }, { "cell_type": "code", "execution_count": 8, "metadata": { "execution": { "iopub.execute_input": "2024-06-30T09:39:38.428444Z", "iopub.status.busy": "2024-06-30T09:39:38.427808Z", "iopub.status.idle": "2024-06-30T09:39:38.444035Z", "shell.execute_reply": "2024-06-30T09:39:38.443322Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Random initial wavefunction\n", "Sector N = 4 : S_z = 0\n", "a'000011'b'000011' (0.0059692303566208004-0.028398657308747452j)\n", "a'000011'b'000101' (-0.039512173581870695+0.01701795806687059j)\n", "a'000011'b'001001' (0.03845542262292439-0.038026707275150416j)\n", "a'000011'b'010001' (0.022164075682562942+0.013523839960928112j)\n", "a'000011'b'100001' (-0.004675938305359342+0.09329716999452839j)\n", "a'000011'b'000110' (-0.0374012687640091+0.02520681958738527j)\n", "a'000011'b'001010' (0.019521139610251256+0.04968067339602323j)\n", "a'000011'b'010010' (0.0991784806405013-0.004367297583736528j)\n", "a'000011'b'100010' (0.007192695901838686+0.009703460363102984j)\n", "a'000011'b'001100' (-0.013216671625451131+0.006512875438970328j)\n", "a'000011'b'010100' (0.03708491655680964-0.026575571041964893j)\n", "a'000011'b'100100' (-0.030060446670603282-0.012651206801780465j)\n", "a'000011'b'011000' (-0.009450224669326797-0.05770552586177642j)\n", "a'000011'b'101000' (0.009175738289232594-0.04077117114669291j)\n", "a'000011'b'110000' (-0.005814617997613454-0.05795794403061433j)\n", "a'000101'b'000011' (-0.005611877504080999-0.07515977904904518j)\n", "a'000101'b'000101' (0.07896487676041951+0.020042619950303524j)\n", "a'000101'b'001001' (-0.02229197070352942+9.890888676679661e-05j)\n", "a'000101'b'010001' (0.015460606207543609+0.019665137213183612j)\n", "a'000101'b'100001' (-0.020239975175983183-0.06736594801683364j)\n", "a'000101'b'000110' (-0.03474639153797463+0.004989074334323147j)\n", "a'000101'b'001010' (-0.06841547412970925-0.03411285831131446j)\n", "a'000101'b'010010' (0.032554004281802065+0.02845596627789372j)\n", "a'000101'b'100010' (0.0598288571655583+0.015410511513126054j)\n", "a'000101'b'001100' (0.022324993209824912-0.071439544736213j)\n", "a'000101'b'010100' (-0.03130410484362679-3.565595400635683e-05j)\n", "a'000101'b'100100' (0.05675529437240588-0.011217300675013156j)\n", "a'000101'b'011000' (0.0452603980885472+0.047169087126775616j)\n", "a'000101'b'101000' (-0.045400435806593135-0.08543739707852459j)\n", "a'000101'b'110000' (0.06175371717162485+0.029365053193889417j)\n", "a'001001'b'000011' (-0.009353383609341143-0.011878244185078286j)\n", "a'001001'b'000101' (-0.039945351828145424+0.05664572783103645j)\n", "a'001001'b'001001' (0.02110342275571698-0.08647310975657253j)\n", "a'001001'b'010001' (0.03062644798847305+0.02151800524091509j)\n", "a'001001'b'100001' (0.03906798261534691+0.0030778171574784813j)\n", "a'001001'b'000110' (0.013563496665157698-0.028377177415655274j)\n", "a'001001'b'001010' (-0.029901818073470452+0.026827044554303448j)\n", "a'001001'b'010010' (0.08435768567050128+0.17149429419726997j)\n", "a'001001'b'100010' (0.0739963156965625+0.053271871184029984j)\n", "a'001001'b'001100' (-0.07435104154492048+0.021549847375894923j)\n", "a'001001'b'010100' (0.057300782305781096-0.05101455708543458j)\n", "a'001001'b'100100' (0.1042891240982101-0.002027290617439396j)\n", "a'001001'b'011000' (0.06830112035702846+0.11505088083186009j)\n", "a'001001'b'101000' (-0.06349538010343392-0.029090780511890704j)\n", "a'001001'b'110000' (-0.04712465438011051-0.057674638044346103j)\n", "a'010001'b'000011' (-0.032108081299691234-0.08886404844063048j)\n", "a'010001'b'000101' (-0.05346222065862725+0.094677931137734j)\n", "a'010001'b'001001' (0.06370541192317604-0.04040594891449364j)\n", "a'010001'b'010001' (0.04280144790134607+0.07686504428863333j)\n", "a'010001'b'100001' (-0.013397232232840117-0.07608890240938274j)\n", "a'010001'b'000110' (0.013408531047834089+0.009641100348395248j)\n", "a'010001'b'001010' (-0.0015871355879163158+0.06971521345825595j)\n", "a'010001'b'010010' (0.0014512271084466523+0.046119787259088246j)\n", "a'010001'b'100010' (-0.03721628033738327-0.03743398055687987j)\n", "a'010001'b'001100' (0.01146656058852233-0.007637609009065024j)\n", "a'010001'b'010100' (0.07784609371288859-0.05754148503680316j)\n", "a'010001'b'100100' (-0.07162661831422673-0.01606824970715518j)\n", "a'010001'b'011000' (0.03015669691713215+0.076797000667415j)\n", "a'010001'b'101000' (0.003287789804961207-0.001547487968205279j)\n", "a'010001'b'110000' (-0.03413376245821122+0.01665421978895424j)\n", "a'100001'b'000011' (-0.04463036181186851-0.03419128736879212j)\n", "a'100001'b'000101' (0.03276084252477456+0.010141158381706344j)\n", "a'100001'b'001001' (-0.01979642095929206+0.015818965529465136j)\n", "a'100001'b'010001' (-0.028781237363059903+0.013818246959582673j)\n", "a'100001'b'100001' (0.007381630698418642-0.005591043862049161j)\n", "a'100001'b'000110' (0.041775222825596287-0.013848403211604392j)\n", "a'100001'b'001010' (0.021379983031225888+0.0007848345477987299j)\n", "a'100001'b'010010' (0.055264138999297954-0.008540703981659072j)\n", "a'100001'b'100010' (-0.015518763171490186+0.010126628177566231j)\n", "a'100001'b'001100' (-0.007132537159842278+0.039073131368863825j)\n", "a'100001'b'010100' (-0.031008738524480158+0.04037887678244856j)\n", "a'100001'b'100100' (-0.02891092179013225+0.03816688126950392j)\n", "a'100001'b'011000' (-0.022972665359437414-0.023124512466497157j)\n", "a'100001'b'101000' (-0.06446805522362391+0.010169559847096488j)\n", "a'100001'b'110000' (-0.026109168141969532-0.04630026816297165j)\n", "a'000110'b'000011' (-0.003143431864242543-5.6978593278409644e-05j)\n", "a'000110'b'000101' (0.014403248449284834-0.06615168071111638j)\n", "a'000110'b'001001' (0.012763057820996626+0.024790558677266764j)\n", "a'000110'b'010001' (0.0419964975969245-0.10582052232379804j)\n", "a'000110'b'100001' (0.08337329724411689+0.040104980867594446j)\n", "a'000110'b'000110' (0.0021947209295719683+0.04780505594593157j)\n", "a'000110'b'001010' (0.030129976214039334-0.0073787286442729j)\n", "a'000110'b'010010' (-0.03461585856036916+0.008508524178848802j)\n", "a'000110'b'100010' (-0.04142532185053254+0.040262105975403216j)\n", "a'000110'b'001100' (0.0027039559669674363-0.004193106368680472j)\n", "a'000110'b'010100' (-0.030813009916080075+0.003952342466262531j)\n", "a'000110'b'100100' (-0.012019986234744708+0.00889266311057641j)\n", "a'000110'b'011000' (0.005297561092532449-0.1304756814613414j)\n", "a'000110'b'101000' (-0.020458271645629147-0.13257152943160896j)\n", "a'000110'b'110000' (-0.05242626267096586-0.02940273874708099j)\n", "a'001010'b'000011' (-0.03138669660678724-0.03855085825579984j)\n", "a'001010'b'000101' (0.03958399607722077-0.03654969874842652j)\n", "a'001010'b'001001' (-0.021965737099609417+0.061544689557587726j)\n", "a'001010'b'010001' (-0.0234640463890853-0.05717793054268311j)\n", "a'001010'b'100001' (0.017637833111708627+0.0011064537794681392j)\n", "a'001010'b'000110' (0.014076887124653598+0.003527247373465501j)\n", "a'001010'b'001010' (-0.05665497476934133+0.041772279252316934j)\n", "a'001010'b'010010' (0.011136043294020341+0.06405179602060938j)\n", "a'001010'b'100010' (0.07099169678014017+0.1085966417477429j)\n", "a'001010'b'001100' (-0.03983951327547103+0.054681906421823086j)\n", "a'001010'b'010100' (0.05184686279635146-0.04890579888506299j)\n", "a'001010'b'100100' (-0.0547284936727346+0.013284265604680372j)\n", "a'001010'b'011000' (0.01657686493729768+0.02660502121049557j)\n", "a'001010'b'101000' (0.08439323914509483+0.0854692434151423j)\n", "a'001010'b'110000' (0.030634422782817552+0.039840540423329664j)\n", "a'010010'b'000011' (0.033295030828504775-0.025175597476341714j)\n", "a'010010'b'000101' (0.05463054153950338-0.030504615833952167j)\n", "a'010010'b'001001' (0.0019030185752975685+0.0031326658417561142j)\n", "a'010010'b'010001' (0.03143606305519327-0.013107045683472271j)\n", "a'010010'b'100001' (0.03895852364064507+0.03557484131903349j)\n", "a'010010'b'000110' (0.0454843305382579-0.019532536903326878j)\n", "a'010010'b'001010' (-0.016234482613808228+0.0018680397265279053j)\n", "a'010010'b'010010' (-0.04841037483713336+0.012440693448993932j)\n", "a'010010'b'100010' (0.0029459284232994276-0.033560462782164104j)\n", "a'010010'b'001100' (-0.06007777737912047+0.005622357899191912j)\n", "a'010010'b'010100' (0.020868367947671836-0.02346680518797593j)\n", "a'010010'b'100100' (-0.03746801969160629-0.044452835906097464j)\n", "a'010010'b'011000' (-0.02036970866682371-0.05803854839829473j)\n", "a'010010'b'101000' (-0.017918714172443694+0.00858525332507514j)\n", "a'010010'b'110000' (0.03109824561493231+0.02733447915152858j)\n", "a'100010'b'000011' (0.0123521436518888+0.007939584290244517j)\n", "a'100010'b'000101' (-0.024323138080891954+0.015490633567176254j)\n", "a'100010'b'001001' (0.04438111713072363+0.02309071613910228j)\n", "a'100010'b'010001' (-0.031032989260187757+0.007385876962364989j)\n", "a'100010'b'100001' (0.004550475890629814-0.08520684046029531j)\n", "a'100010'b'000110' (0.009198381436132483-0.007626595506498053j)\n", "a'100010'b'001010' (-0.06823686203777757-0.010595133776325948j)\n", "a'100010'b'010010' (0.04376748051316233-0.008312661695110031j)\n", "a'100010'b'100010' (0.026355566657663948+0.000896244102710666j)\n", "a'100010'b'001100' (0.021067526709463033-0.12395704269140871j)\n", "a'100010'b'010100' (0.03525641181799579-0.0652504539413426j)\n", "a'100010'b'100100' (0.0068675429016236255+0.031961910855898196j)\n", "a'100010'b'011000' (-0.0598522302468331+0.12156879527279256j)\n", "a'100010'b'101000' (-0.011009767101531374-0.025387495309570535j)\n", "a'100010'b'110000' (0.052420191505782476+0.0517324918439839j)\n", "a'001100'b'000011' (-0.05108020302215197-0.11822194319493924j)\n", "a'001100'b'000101' (-0.019649287372596306-0.05722941172096268j)\n", "a'001100'b'001001' (0.0910192759071139+0.0037328493094391903j)\n", "a'001100'b'010001' (-0.06355146895192068+0.0016095231347152703j)\n", "a'001100'b'100001' (0.07601356054131664+0.02627564027167832j)\n", "a'001100'b'000110' (-0.017002981873502406+0.013756022410968715j)\n", "a'001100'b'001010' (-0.023976107069765076-0.06080036406766831j)\n", "a'001100'b'010010' (-0.056946435697319775+0.059177639562584254j)\n", "a'001100'b'100010' (-0.050368537544563205+0.05013858206087831j)\n", "a'001100'b'001100' (0.07705752542313883-0.06440675951398897j)\n", "a'001100'b'010100' (0.05368816704248061-0.017260501921614695j)\n", "a'001100'b'100100' (-0.03954551518367701+0.014648597843053767j)\n", "a'001100'b'011000' (-0.013544551789157932+0.005661577434842891j)\n", "a'001100'b'101000' (-0.0029136619222377685-0.007360538105564307j)\n", "a'001100'b'110000' (-0.014720951205427064+0.0657648904793333j)\n", "a'010100'b'000011' (0.06777593029796238-0.007550845149041949j)\n", "a'010100'b'000101' (0.0015431946160159341-0.058013267579912216j)\n", "a'010100'b'001001' (-0.0031956585370043105-0.01872647752432777j)\n", "a'010100'b'010001' (0.05668222118467067-0.006014971703376014j)\n", "a'010100'b'100001' (-0.014919842454785478-0.06639620828736363j)\n", "a'010100'b'000110' (-0.01306728189877607+0.02227790432995733j)\n", "a'010100'b'001010' (-0.03152802529170045-0.009413595487187803j)\n", "a'010100'b'010010' (-0.03490680532983525-0.00864419440190866j)\n", "a'010100'b'100010' (-0.018848875046128234-0.044189809448476156j)\n", "a'010100'b'001100' (0.06849102170391078-0.08763561988351462j)\n", "a'010100'b'010100' (0.00594587864808287-0.09409883430323204j)\n", "a'010100'b'100100' (-0.13160822584875376-0.013060735193096865j)\n", "a'010100'b'011000' (-0.02284996053249512-0.043721647370189014j)\n", "a'010100'b'101000' (-0.05443704828020708-0.02329075728329125j)\n", "a'010100'b'110000' (0.03525641502424447-0.09428871562099186j)\n", "a'100100'b'000011' (-0.031506527081546325+0.043279920280126304j)\n", "a'100100'b'000101' (0.02691199041745539+0.004618164917457191j)\n", "a'100100'b'001001' (-0.04545535748365663+0.014190355769815128j)\n", "a'100100'b'010001' (-0.05332810205739431-0.04885641018814852j)\n", "a'100100'b'100001' (0.006533181492069882+0.020580369765031446j)\n", "a'100100'b'000110' (-0.019453178291741098-0.021905807768132224j)\n", "a'100100'b'001010' (0.10420244113929325-0.01709710256648317j)\n", "a'100100'b'010010' (-0.027098502506778824+0.07610565296058164j)\n", "a'100100'b'100010' (-0.044995084113714744+0.042181296178543j)\n", "a'100100'b'001100' (-0.03980846983515254-0.036453666203769074j)\n", "a'100100'b'010100' (0.10381624127898822-0.10178773585388853j)\n", "a'100100'b'100100' (-0.10681287425140863+0.03398272769354482j)\n", "a'100100'b'011000' (-0.02882238180071978+0.06970055382722797j)\n", "a'100100'b'101000' (-0.020178320431757216-0.11148090215708698j)\n", "a'100100'b'110000' (-0.036968879940063-0.058392519437561755j)\n", "a'011000'b'000011' (-0.01491428376371052+0.0038432834574368625j)\n", "a'011000'b'000101' (0.027115477198006555+0.026021362127958393j)\n", "a'011000'b'001001' (0.060409685337956515-0.052290033815163374j)\n", "a'011000'b'010001' (0.0607367637407677-0.04788042229819744j)\n", "a'011000'b'100001' (0.03236352043998571+0.02377055374346314j)\n", "a'011000'b'000110' (0.02932746973143364+0.031044650724948206j)\n", "a'011000'b'001010' (0.06418954102329986-0.06666941850478253j)\n", "a'011000'b'010010' (0.03424592588960442+0.011136884912860478j)\n", "a'011000'b'100010' (0.016720551357271074+0.07638266369135349j)\n", "a'011000'b'001100' (-0.016269303334719206+0.031872484853861745j)\n", "a'011000'b'010100' (-0.048537208617315517+0.05111907121413584j)\n", "a'011000'b'100100' (-0.06968900610222047+0.04119703413184967j)\n", "a'011000'b'011000' (0.004097707407106102-0.057160377185310446j)\n", "a'011000'b'101000' (0.009675556121326524+0.016170672021785917j)\n", "a'011000'b'110000' (0.022256721945904067-0.0010649855648847725j)\n", "a'101000'b'000011' (-0.05459169615106567-0.056904213445942625j)\n", "a'101000'b'000101' (-0.03943449334683318-0.003385329290027214j)\n", "a'101000'b'001001' (-0.03213088738370981-0.05232622547889854j)\n", "a'101000'b'010001' (0.024247232288297754-0.053610628822761124j)\n", "a'101000'b'100001' (0.0476401959397676-0.02877639042852904j)\n", "a'101000'b'000110' (-0.09457506858278197+0.01431550006957483j)\n", "a'101000'b'001010' (-0.05395917469643207+0.001008885840792552j)\n", "a'101000'b'010010' (0.04644002339727731-0.015858037677576483j)\n", "a'101000'b'100010' (0.05439240291675636-0.05854211902726603j)\n", "a'101000'b'001100' (0.046839011146548336+0.05897295147675351j)\n", "a'101000'b'010100' (0.07357366105998553-0.019681223269861037j)\n", "a'101000'b'100100' (0.04484547842989464+0.011051852502542961j)\n", "a'101000'b'011000' (0.05581672183496987+0.040606963228178104j)\n", "a'101000'b'101000' (0.06953330412768279-0.005377718983374635j)\n", "a'101000'b'110000' (0.08548862606077874-0.06366641815156872j)\n", "a'110000'b'000011' (0.01661089581861554-0.020601863486223237j)\n", "a'110000'b'000101' (-0.04690815656896847+0.08412911544497027j)\n", "a'110000'b'001001' (-0.010455385778248545-0.016387428540293014j)\n", "a'110000'b'010001' (-0.004101897022238049-0.08269547260500604j)\n", "a'110000'b'100001' (-0.015600356983893554+0.06559523268394353j)\n", "a'110000'b'000110' (0.056747275141145484+0.10173447121663337j)\n", "a'110000'b'001010' (0.04214471773914416+0.012504851311949148j)\n", "a'110000'b'010010' (0.02296281933605609+0.037682339297424296j)\n", "a'110000'b'100010' (0.10128801512308445+0.006738439097075111j)\n", "a'110000'b'001100' (0.012619881929253073-0.03358742979340074j)\n", "a'110000'b'010100' (0.0004527019032424084+0.11900036808114736j)\n", "a'110000'b'100100' (0.039777344871455594-0.007764401906930268j)\n", "a'110000'b'011000' (-0.005824058804897906+0.020544154080993603j)\n", "a'110000'b'101000' (0.014149421258639992+0.018613877927525932j)\n", "a'110000'b'110000' (-0.01841949034950602-0.07181910309238866j)\n" ] } ], "source": [ "norbs = 6\n", "tedim = norbs * (norbs + 1) // 2\n", "if (norbs // 2) % 2 == 0:\n", " n_elec = norbs // 2\n", "else:\n", " n_elec = (norbs // 2) + 1\n", "sz = 0\n", "fqe_wfn = fqe.Wavefunction([[n_elec, sz, norbs]])\n", "fqe_wfn.set_wfn(strategy='random')\n", "initial_coeffs = fqe_wfn.get_coeff((n_elec, sz)).copy()\n", "print(\"Random initial wavefunction\")\n", "fqe_wfn.print_wfn()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We need to build our Diagoanl Coulomb operator For this bigger system." ] }, { "cell_type": "code", "execution_count": 9, "metadata": { "execution": { "iopub.execute_input": "2024-06-30T09:39:38.448046Z", "iopub.status.busy": "2024-06-30T09:39:38.447443Z", "iopub.status.idle": "2024-06-30T09:39:38.458144Z", "shell.execute_reply": "2024-06-30T09:39:38.457500Z" } }, "outputs": [], "source": [ "tei_compressed = np.random.randn(tedim**2).reshape((tedim, tedim))\n", "tei_compressed = 0.5 * (tei_compressed + tei_compressed.T)\n", "tei_tensor = uncompress_tei(tei_compressed, notation='physics')\n", "\n", "diagonal_coulomb = of.FermionOperator()\n", "diagonal_coulomb_mat = np.zeros((norbs, norbs))\n", "for i, j in product(range(norbs), repeat=2):\n", " diagonal_coulomb_mat[i, j] = tei_tensor[i, j, i, j]\n", " for sigma, tau in product(range(2), repeat=2):\n", " diagonal_coulomb += of.FermionOperator(\n", " ((2 * i + sigma, 1), (2 * i + sigma, 0), (2 * j + tau, 1),\n", " (2 * j + tau, 0)), coefficient=diagonal_coulomb_mat[i, j])\n", "\n", "dc_ham = DiagonalCoulomb(diagonal_coulomb_mat)\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Now we can convert our wavefunction to a cirq wavefunction, evolve under the diagonal_coulomb operator we constructed and then compare the outputs." ] }, { "cell_type": "code", "execution_count": 10, "metadata": { "execution": { "iopub.execute_input": "2024-06-30T09:39:38.461563Z", "iopub.status.busy": "2024-06-30T09:39:38.461093Z", "iopub.status.idle": "2024-06-30T09:39:39.375456Z", "shell.execute_reply": "2024-06-30T09:39:39.374553Z" } }, "outputs": [], "source": [ "cirq_wfn = fqe.to_cirq(fqe_wfn).reshape((-1, 1))\n", "final_cirq_wfn = expm(-1j * of.get_sparse_operator(diagonal_coulomb).todense()) @ cirq_wfn\n", "# recover a fqe wavefunction\n", "from_cirq_wfn = fqe.from_cirq(final_cirq_wfn.flatten(), 1.0E-8)\n" ] }, { "cell_type": "code", "execution_count": 11, "metadata": { "execution": { "iopub.execute_input": "2024-06-30T09:39:39.380072Z", "iopub.status.busy": "2024-06-30T09:39:39.379666Z", "iopub.status.idle": "2024-06-30T09:39:39.407631Z", "shell.execute_reply": "2024-06-30T09:39:39.406707Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Evolved wavefunction\n", "Sector N = 4 : S_z = 0\n", "a'000011'b'000011' (-0.02445676580705044-0.015619924911764692j)\n", "a'000011'b'000101' (0.028018099166678207+0.03264672842745247j)\n", "a'000011'b'001001' (-0.05399748499539621+0.003020200236683932j)\n", "a'000011'b'010001' (-0.02474363678579513-0.007867206414212133j)\n", "a'000011'b'100001' (-0.04677215295170172-0.08086156093154567j)\n", "a'000011'b'000110' (-0.04508338480317351+0.0013141817064688777j)\n", "a'000011'b'001010' (-0.05290702253295303-0.00707751138910098j)\n", "a'000011'b'010010' (0.028152078930614267-0.0951992897149326j)\n", "a'000011'b'100010' (-0.004863756484536653+0.011056034108746468j)\n", "a'000011'b'001100' (0.003842626907698079-0.01422435143641997j)\n", "a'000011'b'010100' (0.022344616943923815+0.03977775893462791j)\n", "a'000011'b'100100' (0.03260203056581747+0.0008894327198292375j)\n", "a'000011'b'011000' (0.0577309988900798+0.009293343232578313j)\n", "a'000011'b'101000' (-0.0130797920244022-0.03969132915919796j)\n", "a'000011'b'110000' (0.03457541280090836+0.04687722142321124j)\n", "a'000101'b'000011' (-0.070073717458666+0.0277517508879197j)\n", "a'000101'b'000101' (0.03275475824646413+0.0745941297186061j)\n", "a'000101'b'001001' (-0.01797411750475861+0.013186085118033536j)\n", "a'000101'b'010001' (-0.010813571371841982+0.022556920004826782j)\n", "a'000101'b'100001' (-0.04611058107471281-0.05311912894883993j)\n", "a'000101'b'000110' (0.0020154081690716944-0.03504483867184548j)\n", "a'000101'b'001010' (0.07080742817884221-0.02882138645622094j)\n", "a'000101'b'010010' (-0.0318571274371608+0.029234032274742895j)\n", "a'000101'b'100010' (-0.061344850797472754+0.00733384588526193j)\n", "a'000101'b'001100' (-0.0020887111823741163-0.07481745223898453j)\n", "a'000101'b'010100' (0.006021259586854643-0.0307195814488991j)\n", "a'000101'b'100100' (0.006628795696162439+0.057472170146520785j)\n", "a'000101'b'011000' (-0.014123496945868739+0.06382752736497911j)\n", "a'000101'b'101000' (-0.00013465854879960755+0.09675086696282002j)\n", "a'000101'b'110000' (-0.05994260193486933-0.03290459552814452j)\n", "a'001001'b'000011' (-0.0008595625045246908+0.015094357295514536j)\n", "a'001001'b'000101' (0.0009912948302237888+0.06930647118950545j)\n", "a'001001'b'001001' (0.014978919817421629+0.08774158149977694j)\n", "a'001001'b'010001' (0.03715676767555076-0.004514253187830737j)\n", "a'001001'b'100001' (0.03299388364912935+0.021146722342614496j)\n", "a'001001'b'000110' (0.012341428016631835+0.028929600660493302j)\n", "a'001001'b'001010' (-0.030769313805422648-0.025827473193499494j)\n", "a'001001'b'010010' (-0.18937471460792674+0.025762948997915962j)\n", "a'001001'b'100010' (0.09085394763732602+0.007675102268194664j)\n", "a'001001'b'001100' (0.06052723842233882+0.048258954710024636j)\n", "a'001001'b'010100' (0.07423677475759707+0.019358872928643852j)\n", "a'001001'b'100100' (-0.09297968298580851-0.04727694855083153j)\n", "a'001001'b'011000' (0.13234048183091357-0.019691244017933433j)\n", "a'001001'b'101000' (0.0038811564051725415+0.06973430597796997j)\n", "a'001001'b'110000' (-0.06437103417714114+0.037462873394289053j)\n", "a'010001'b'000011' (0.05231277778376421+0.07868367855249783j)\n", "a'010001'b'000101' (-0.10855586580863756-0.00614358859383725j)\n", "a'010001'b'001001' (0.02028172465530158-0.07266135053099922j)\n", "a'010001'b'010001' (-0.06436746696915317-0.05997522965291735j)\n", "a'010001'b'100001' (-0.03477160521058292-0.06899233560653371j)\n", "a'010001'b'000110' (-0.011054554055743251+0.012269325793099157j)\n", "a'010001'b'001010' (-0.06563146795042676-0.023563539665693873j)\n", "a'010001'b'010010' (-0.0032961073318400346-0.04602473805901387j)\n", "a'010001'b'100010' (0.051108126294559235+0.013202797019682704j)\n", "a'010001'b'001100' (0.012716840729694454+0.005300664577313785j)\n", "a'010001'b'010100' (-0.042267889085392155-0.08708881879358261j)\n", "a'010001'b'100100' (0.07057163580757868+0.020204091645651723j)\n", "a'010001'b'011000' (0.02366496578959261-0.07903907308818925j)\n", "a'010001'b'101000' (-0.0010108965423243908-0.0034903250556450388j)\n", "a'010001'b'110000' (-0.033725478346511704+0.017466221303743826j)\n", "a'100001'b'000011' (0.05604555867851421+0.004450694306154128j)\n", "a'100001'b'000101' (0.03403620183282699-0.004201530798529691j)\n", "a'100001'b'001001' (-0.024918103578060985+0.0046071756307880995j)\n", "a'100001'b'010001' (-0.023573271328145327+0.021531475845246936j)\n", "a'100001'b'100001' (0.006434145838288024-0.006659580359664927j)\n", "a'100001'b'000110' (-0.03391001927673214+0.02805455589188769j)\n", "a'100001'b'001010' (0.018744434094721096-0.010313381121222214j)\n", "a'100001'b'010010' (-0.043169459236775544+0.03554527356823164j)\n", "a'100001'b'100010' (-0.001476198866398358+0.01847163895073533j)\n", "a'100001'b'001100' (0.02467692162011865-0.031122856884603978j)\n", "a'100001'b'010100' (0.03330317704013882-0.03850836213246306j)\n", "a'100001'b'100100' (0.036682839479275225+0.030772089827200224j)\n", "a'100001'b'011000' (-0.02645109048179078+0.019047998394949407j)\n", "a'100001'b'101000' (0.060427353809017745-0.024659379623982538j)\n", "a'100001'b'110000' (-0.028245440760635166-0.04502886373501082j)\n", "a'000110'b'000011' (-0.0026263185636759075-0.001728253814495618j)\n", "a'000110'b'000101' (0.061970019009053565+0.02726197298096481j)\n", "a'000110'b'001001' (-0.027041939171802667-0.006797129563399115j)\n", "a'000110'b'010001' (0.10057170254686812+0.053357486842187496j)\n", "a'000110'b'100001' (-0.09224157475661716-0.007141993430786286j)\n", "a'000110'b'000110' (-0.0478128280410435-0.0020183281868797606j)\n", "a'000110'b'001010' (-0.02030105943782988-0.02345480950180769j)\n", "a'000110'b'010010' (-0.018263589286203332-0.03061199036257552j)\n", "a'000110'b'100010' (0.027384742868545274+0.05086423425176543j)\n", "a'000110'b'001100' (0.0028733834842722965-0.004078870706786224j)\n", "a'000110'b'010100' (-0.029223259204856557+0.010538676980761797j)\n", "a'000110'b'100100' (0.001308599999163887-0.014894532296243719j)\n", "a'000110'b'011000' (0.11637413628924524-0.05923704929571293j)\n", "a'000110'b'101000' (-0.013654633968013809-0.13344400423309355j)\n", "a'000110'b'110000' (0.036478175380960993+0.047774227197831885j)\n", "a'001010'b'000011' (0.04894470772039069-0.008701090869012365j)\n", "a'001010'b'000101' (0.001285680717770669+0.05386204831914689j)\n", "a'001010'b'001001' (-0.06402402787428334-0.013083052924375081j)\n", "a'001010'b'010001' (0.06166449141002132-0.004167458846401555j)\n", "a'001010'b'100001' (0.015699449334237597-0.008114473947477505j)\n", "a'001010'b'000110' (-0.003276790022888273-0.014137286596081926j)\n", "a'001010'b'001010' (-0.0061202629323821875+0.07012311930944577j)\n", "a'001010'b'010010' (0.014866871545096555-0.06328996890640451j)\n", "a'001010'b'100010' (0.00226864018648116-0.12972241472588797j)\n", "a'001010'b'001100' (-0.05186887500717805+0.043438663808192744j)\n", "a'001010'b'010100' (0.0680229902821914+0.021277855612791906j)\n", "a'001010'b'100100' (-0.05533601565365062+0.01046924562330926j)\n", "a'001010'b'011000' (-0.0120768072680193+0.028926982749181537j)\n", "a'001010'b'101000' (-0.11259721488081886-0.04182197489885823j)\n", "a'001010'b'110000' (-0.016745974268279985+0.04738469020966035j)\n", "a'010010'b'000011' (-0.01296749215205898-0.03967636492230805j)\n", "a'010010'b'000101' (0.024324138829221267+0.05764862466957197j)\n", "a'010010'b'001001' (-0.003573843533231464+0.000814074550648026j)\n", "a'010010'b'010001' (-0.03088623239817171+0.014354837345119746j)\n", "a'010010'b'100001' (-0.05165778776977985-0.010714889727173825j)\n", "a'010010'b'000110' (0.03198497885829104+0.03777969626436932j)\n", "a'010010'b'001010' (0.015667185718965186+0.0046462124150087715j)\n", "a'010010'b'010010' (0.027284717473827606-0.04187934380738317j)\n", "a'010010'b'100010' (-0.03353921432491071+0.0031787196944571923j)\n", "a'010010'b'001100' (-0.03430596412048562-0.04963920898771172j)\n", "a'010010'b'010100' (-0.006413896595937394+0.03074152984134743j)\n", "a'010010'b'100100' (0.01677981926611456+0.05566277737502465j)\n", "a'010010'b'011000' (-0.006723079937106397+0.06114080738354502j)\n", "a'010010'b'101000' (-0.016955587133395577-0.010358327915801801j)\n", "a'010010'b'110000' (0.030248247912357733+0.02827221478845535j)\n", "a'100010'b'000011' (-0.0007748836270772933+0.014663287723538735j)\n", "a'100010'b'000101' (0.017050294711608027-0.0232564447984204j)\n", "a'100010'b'001001' (0.049938748150273535-0.0029976929080809j)\n", "a'100010'b'010001' (0.022919757601873307-0.0221874359130904j)\n", "a'100010'b'100001' (-0.06463949582446145-0.055701418937194457j)\n", "a'100010'b'000110' (-0.004817380421614869-0.010934716545835318j)\n", "a'100010'b'001010' (0.05050232431986007+0.0470960872981249j)\n", "a'100010'b'010010' (-0.016099191921772282-0.0415392430647615j)\n", "a'100010'b'100010' (-0.022755457162568403-0.01332697702634492j)\n", "a'100010'b'001100' (0.027376511074600075-0.12271803353963899j)\n", "a'100010'b'010100' (-0.058231463316574736+0.04593182985514293j)\n", "a'100010'b'100100' (-0.03094768092145728+0.01053413198368488j)\n", "a'100010'b'011000' (-0.13455996615808183+0.01596486633623835j)\n", "a'100010'b'101000' (0.02627998906590844-0.008666144726414457j)\n", "a'100010'b'110000' (-0.0709613517877196-0.0197132884712388j)\n", "a'001100'b'000011' (0.1224940608855134+0.039759527680140516j)\n", "a'001100'b'000101' (-0.037171903490150836-0.04774462955241403j)\n", "a'001100'b'001001' (-0.04951049145222776-0.07646668547008682j)\n", "a'001100'b'010001' (-0.03660555351102872-0.05197512119100194j)\n", "a'001100'b'100001' (-0.05471307342765709-0.05894870867080008j)\n", "a'001100'b'000110' (-0.017551990124147182+0.013048263786556625j)\n", "a'001100'b'001010' (-0.008578823235300242-0.064791525471155j)\n", "a'001100'b'010010' (-0.0794763665688859-0.020697746733308795j)\n", "a'001100'b'100010' (-0.05286570620432256+0.047498253578123865j)\n", "a'001100'b'001100' (-0.058895917736748134-0.081347180463595j)\n", "a'001100'b'010100' (-0.007759172202146406+0.05585820847203037j)\n", "a'001100'b'100100' (-0.036062831225000126+0.02186095592482418j)\n", "a'001100'b'011000' (-0.012705771152444773-0.007353347648629563j)\n", "a'001100'b'101000' (0.0070354555738548165-0.0036289546523589566j)\n", "a'001100'b'110000' (-0.029582394021539535-0.060552532466492705j)\n", "a'010100'b'000011' (6.622821825742936e-05+0.0681952168707027j)\n", "a'010100'b'000101' (0.05664755155745416+0.012608551362744549j)\n", "a'010100'b'001001' (0.0138051397384802-0.013050337572465955j)\n", "a'010100'b'010001' (0.004496029529511566-0.056822880967882156j)\n", "a'010100'b'100001' (0.011035612932916137+0.06715112375090569j)\n", "a'010100'b'000110' (-0.007926576361187055+0.024581054996624604j)\n", "a'010100'b'001010' (-0.007221163323278212-0.032101198716699794j)\n", "a'010100'b'010010' (0.03457640928642192-0.009883272537517147j)\n", "a'010100'b'100010' (-0.0002100658318735185+0.04804139071616753j)\n", "a'010100'b'001100' (0.04921139098211052+0.09974598199436055j)\n", "a'010100'b'010100' (0.006272303880276687-0.094077639714006j)\n", "a'010100'b'100100' (-0.13033144231952862+0.022472718076640478j)\n", "a'010100'b'011000' (-0.02376087225247356-0.04323336784130257j)\n", "a'010100'b'101000' (0.057059244155773306-0.0158143686773337j)\n", "a'010100'b'110000' (-0.09958582055213429+0.014698334557906955j)\n", "a'100100'b'000011' (0.013667655504338473-0.051759133891604366j)\n", "a'100100'b'000101' (-0.006761905333534233+0.02645485421797603j)\n", "a'100100'b'001001' (0.04678657961983994+0.00886406725591139j)\n", "a'100100'b'010001' (0.05039837441774301+0.05187329892695733j)\n", "a'100100'b'100001' (0.020879635847606985-0.005502261984408794j)\n", "a'100100'b'000110' (0.029296559916562537-4.6224234887195736e-05j)\n", "a'100100'b'001010' (0.10494018744485221-0.011748051523380843j)\n", "a'100100'b'010010' (0.0550443077127877-0.05913140822850689j)\n", "a'100100'b'100010' (-0.04712287222195874-0.039790127610441046j)\n", "a'100100'b'001100' (-0.0459825246538286-0.02826997482793556j)\n", "a'100100'b'010100' (0.07294733158665508-0.12576661694561356j)\n", "a'100100'b'100100' (0.0833211126381411-0.07497605001654231j)\n", "a'100100'b'011000' (-0.021028541603996788-0.07243408958838198j)\n", "a'100100'b'101000' (0.11143190144680012+0.020447188098985658j)\n", "a'100100'b'110000' (-0.06532435889335994-0.022563522452408134j)\n", "a'011000'b'000011' (0.0010730525671674505-0.015364089498137617j)\n", "a'011000'b'000101' (-0.006599917256713282+0.036997317238882325j)\n", "a'011000'b'001001' (-0.025545180922587812-0.07570351016071912j)\n", "a'011000'b'010001' (-0.07733984929045139+0.00019240812307149037j)\n", "a'011000'b'100001' (0.02856668372417992-0.028220227879004037j)\n", "a'011000'b'000110' (-0.012719202300114975+0.04076877128797158j)\n", "a'011000'b'001010' (0.09153121113691055+0.013680128959847075j)\n", "a'011000'b'010010' (-0.026065695840054616-0.024847397166953698j)\n", "a'011000'b'100010' (-0.05497386815165179+0.05560361472712326j)\n", "a'011000'b'001100' (-0.0352176621951306+0.0063452179841532435j)\n", "a'011000'b'010100' (-0.04745566173938755+0.05212466048842462j)\n", "a'011000'b'100100' (0.028689233909716467-0.07570126188148839j)\n", "a'011000'b'011000' (-0.05601917739877246-0.012081046706559585j)\n", "a'011000'b'101000' (0.0025954874034302706-0.018664684970064294j)\n", "a'011000'b'110000' (0.02126083246419722+0.006668798164589973j)\n", "a'101000'b'000011' (-0.07607398924195341-0.020762730007560112j)\n", "a'101000'b'000101' (0.033204709675436844+0.021540356898001906j)\n", "a'101000'b'001001' (-0.03130067727988037+0.05282703284071474j)\n", "a'101000'b'010001' (-0.04912767484196668-0.03238053985091246j)\n", "a'101000'b'100001' (-0.039786443768841474+0.03891924726280558j)\n", "a'101000'b'000110' (-0.09518320985767065+0.0094622249429269j)\n", "a'101000'b'001010' (0.048482860520134945-0.023707016268290033j)\n", "a'101000'b'010010' (0.03858146636359309+0.030325296129766584j)\n", "a'101000'b'100010' (0.05337739639532226+0.05946904025892785j)\n", "a'101000'b'001100' (-0.0540393743270462+0.05245424666704675j)\n", "a'101000'b'010100' (-0.0451621603374589+0.06132547125641523j)\n", "a'101000'b'100100' (-0.02616185429052239+0.03806333878452581j)\n", "a'101000'b'011000' (-0.018043437504057146-0.06662481716338287j)\n", "a'101000'b'101000' (0.06628805381565807-0.021672428698911308j)\n", "a'101000'b'110000' (-0.07925704501995474-0.07127439091788104j)\n", "a'110000'b'000011' (-0.003772782423015139+0.026193983121901594j)\n", "a'110000'b'000101' (0.05171852177030193-0.0812605545399907j)\n", "a'110000'b'001001' (-0.017828400331268417+0.00774667977673274j)\n", "a'110000'b'010001' (-0.0060795019890248-0.08257364230861926j)\n", "a'110000'b'100001' (-0.01251630739736172+0.06625290739296169j)\n", "a'110000'b'000110' (-0.011775793756219274-0.11589429041624039j)\n", "a'110000'b'001010' (0.012450560453236994+0.042160788465662985j)\n", "a'110000'b'010010' (0.021800344002429188+0.03836658400434301j)\n", "a'110000'b'100010' (-0.09178264827968119+0.04336604713145422j)\n", "a'110000'b'001100' (0.011124344131791067+0.03411196018513739j)\n", "a'110000'b'010100' (0.10396414390529536-0.057902930189246964j)\n", "a'110000'b'100100' (0.026239307282112427-0.030887244217474946j)\n", "a'110000'b'011000' (-0.012545943541226333+0.017279503133101847j)\n", "a'110000'b'101000' (0.015462411321244141-0.01753842665657189j)\n", "a'110000'b'110000' (-0.024507797109820872+0.06997591781859352j)\n" ] } ], "source": [ "fqe_wfn = fqe_wfn.time_evolve(1, dc_ham)\n", "print(\"Evolved wavefunction\")\n", "fqe_wfn.print_wfn()" ] }, { "cell_type": "code", "execution_count": 12, "metadata": { "execution": { "iopub.execute_input": "2024-06-30T09:39:39.413888Z", "iopub.status.busy": "2024-06-30T09:39:39.412681Z", "iopub.status.idle": "2024-06-30T09:39:39.429805Z", "shell.execute_reply": "2024-06-30T09:39:39.428537Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "From Cirq Evolution\n", "Sector N = 4 : S_z = 0\n", "a'000011'b'000011' (-0.02445676580705045-0.015619924911764664j)\n", "a'000011'b'000101' (0.028018099166678176+0.032646728427452476j)\n", "a'000011'b'001001' (-0.05399748499539618+0.003020200236684003j)\n", "a'000011'b'010001' (-0.024743636785795137-0.007867206414212083j)\n", "a'000011'b'100001' (-0.04677215295170174-0.08086156093154567j)\n", "a'000011'b'000110' (-0.0450833848031735+0.0013141817064688671j)\n", "a'000011'b'001010' (-0.052907022532953006-0.007077511389100968j)\n", "a'000011'b'010010' (0.028152078930614305-0.09519928971493256j)\n", "a'000011'b'100010' (-0.004863756484536649+0.011056034108746473j)\n", "a'000011'b'001100' (0.0038426269076980765-0.014224351436419964j)\n", "a'000011'b'010100' (0.022344616943923805+0.039777758934627906j)\n", "a'000011'b'100100' (0.03260203056581748+0.0008894327198292369j)\n", "a'000011'b'011000' (0.057730998890079765+0.009293343232578315j)\n", "a'000011'b'101000' (-0.013079792024402216-0.03969132915919795j)\n", "a'000011'b'110000' (0.034575412800908346+0.04687722142321126j)\n", "a'000101'b'000011' (-0.070073717458666+0.027751750887919653j)\n", "a'000101'b'000101' (0.03275475824646415+0.0745941297186061j)\n", "a'000101'b'001001' (-0.017974117504758608+0.01318608511803354j)\n", "a'000101'b'010001' (-0.010813571371841992+0.022556920004826772j)\n", "a'000101'b'100001' (-0.046110581074712796-0.05311912894883995j)\n", "a'000101'b'000110' (0.0020154081690716896-0.03504483867184548j)\n", "a'000101'b'001010' (0.0708074281788422-0.028821386456220944j)\n", "a'000101'b'010010' (-0.03185712743716079+0.02923403227474289j)\n", "a'000101'b'100010' (-0.06134485079747276+0.007333845885261939j)\n", "a'000101'b'001100' (-0.002088711182374005-0.07481745223898453j)\n", "a'000101'b'010100' (0.006021259586854607-0.030719581448899105j)\n", "a'000101'b'100100' (0.006628795696162422+0.0574721701465208j)\n", "a'000101'b'011000' (-0.014123496945868605+0.0638275273649791j)\n", "a'000101'b'101000' (-0.00013465854879948086+0.09675086696282002j)\n", "a'000101'b'110000' (-0.05994260193486936-0.032904595528144474j)\n", "a'001001'b'000011' (-0.0008595625045246715+0.015094357295514537j)\n", "a'001001'b'000101' (0.000991294830223803+0.06930647118950546j)\n", "a'001001'b'001001' (0.01497891981742171+0.08774158149977697j)\n", "a'001001'b'010001' (0.03715676767555076-0.004514253187830761j)\n", "a'001001'b'100001' (0.03299388364912938+0.02114672234261448j)\n", "a'001001'b'000110' (0.012341428016631831+0.028929600660493302j)\n", "a'001001'b'001010' (-0.030769313805422645-0.025827473193499473j)\n", "a'001001'b'010010' (-0.18937471460792665+0.025762948997915897j)\n", "a'001001'b'100010' (0.09085394763732602+0.007675102268194629j)\n", "a'001001'b'001100' (0.0605272384223389+0.04825895471002453j)\n", "a'001001'b'010100' (0.0742367747575971+0.01935887292864371j)\n", "a'001001'b'100100' (-0.09297968298580857-0.04727694855083145j)\n", "a'001001'b'011000' (0.13234048183091351-0.01969124401793368j)\n", "a'001001'b'101000' (0.003881156405172625+0.06973430597796998j)\n", "a'001001'b'110000' (-0.06437103417714113+0.03746287339428908j)\n", "a'010001'b'000011' (0.052312777783764364+0.07868367855249774j)\n", "a'010001'b'000101' (-0.10855586580863755-0.006143588593837311j)\n", "a'010001'b'001001' (0.020281724655301526-0.07266135053099923j)\n", "a'010001'b'010001' (-0.06436746696915334-0.05997522965291721j)\n", "a'010001'b'100001' (-0.0347716052105829-0.06899233560653374j)\n", "a'010001'b'000110' (-0.011054554055743251+0.012269325793099152j)\n", "a'010001'b'001010' (-0.06563146795042674-0.023563539665693873j)\n", "a'010001'b'010010' (-0.0032961073318400437-0.046024738059013866j)\n", "a'010001'b'100010' (0.05110812629455924+0.013202797019682726j)\n", "a'010001'b'001100' (0.012716840729694461+0.00530066457731376j)\n", "a'010001'b'010100' (-0.04226788908539212-0.08708881879358259j)\n", "a'010001'b'100100' (0.07057163580757868+0.020204091645651664j)\n", "a'010001'b'011000' (0.023664965789592554-0.07903907308818925j)\n", "a'010001'b'101000' (-0.0010108965423243931-0.0034903250556450383j)\n", "a'010001'b'110000' (-0.033725478346511704+0.017466221303743826j)\n", "a'100001'b'000011' (0.05604555867851424+0.004450694306154114j)\n", "a'100001'b'000101' (0.03403620183282701-0.004201530798529675j)\n", "a'100001'b'001001' (-0.024918103578061+0.004607175630788116j)\n", "a'100001'b'010001' (-0.023573271328145344+0.021531475845246922j)\n", "a'100001'b'100001' (0.006434145838288042-0.006659580359664921j)\n", "a'100001'b'000110' (-0.03391001927673214+0.028054555891887697j)\n", "a'100001'b'001010' (0.018744434094721093-0.010313381121222218j)\n", "a'100001'b'010010' (-0.04316945923677556+0.035545273568231624j)\n", "a'100001'b'100010' (-0.0014761988663983486+0.018471638950735333j)\n", "a'100001'b'001100' (0.02467692162011862-0.031122856884604012j)\n", "a'100001'b'010100' (0.033303177040138784-0.03850836213246307j)\n", "a'100001'b'100100' (0.03668283947927525+0.030772089827200193j)\n", "a'100001'b'011000' (-0.026451090481790774+0.01904799839494942j)\n", "a'100001'b'101000' (0.060427353809017724-0.02465937962398265j)\n", "a'100001'b'110000' (-0.028245440760635163-0.04502886373501082j)\n", "a'000110'b'000011' (-0.002626318563675907-0.001728253814495619j)\n", "a'000110'b'000101' (0.06197001900905355+0.027261972980964794j)\n", "a'000110'b'001001' (-0.027041939171802663-0.006797129563399111j)\n", "a'000110'b'010001' (0.10057170254686808+0.05335748684218751j)\n", "a'000110'b'100001' (-0.09224157475661716-0.0071419934307862705j)\n", "a'000110'b'000110' (-0.0478128280410435-0.002018328186879692j)\n", "a'000110'b'001010' (-0.02030105943782987-0.02345480950180769j)\n", "a'000110'b'010010' (-0.01826358928620333-0.030611990362575524j)\n", "a'000110'b'100010' (0.027384742868545375+0.05086423425176537j)\n", "a'000110'b'001100' (0.002873383484272291-0.004078870706786226j)\n", "a'000110'b'010100' (-0.029223259204856532+0.010538676980761821j)\n", "a'000110'b'100100' (0.0013085999991638772-0.014894532296243716j)\n", "a'000110'b'011000' (0.11637413628924519-0.05923704929571294j)\n", "a'000110'b'101000' (-0.013654633968013814-0.13344400423309352j)\n", "a'000110'b'110000' (0.03647817538096101+0.04777422719783185j)\n", "a'001010'b'000011' (0.04894470772039067-0.008701090869012357j)\n", "a'001010'b'000101' (0.001285680717770677+0.05386204831914687j)\n", "a'001010'b'001001' (-0.06402402787428331-0.013083052924375052j)\n", "a'001010'b'010001' (0.061664491410021297-0.004167458846401538j)\n", "a'001010'b'100001' (0.015699449334237597-0.00811447394747751j)\n", "a'001010'b'000110' (-0.0032767900228882663-0.014137286596081917j)\n", "a'001010'b'001010' (-0.006120262932382194+0.07012311930944572j)\n", "a'001010'b'010010' (0.014866871545096565-0.06328996890640447j)\n", "a'001010'b'100010' (0.0022686401864811107-0.1297224147258879j)\n", "a'001010'b'001100' (-0.051868875007178+0.04343866380819274j)\n", "a'001010'b'010100' (0.06802299028219137+0.021277855612791902j)\n", "a'001010'b'100100' (-0.055336015653650615+0.010469245623309255j)\n", "a'001010'b'011000' (-0.012076807268019287+0.028926982749181512j)\n", "a'001010'b'101000' (-0.11259721488081884-0.041821974898858166j)\n", "a'001010'b'110000' (-0.016745974268279985+0.04738469020966034j)\n", "a'010010'b'000011' (-0.012967492152058958-0.03967636492230804j)\n", "a'010010'b'000101' (0.024324138829221256+0.057648624669571956j)\n", "a'010010'b'001001' (-0.0035738435332314626+0.0008140745506480254j)\n", "a'010010'b'010001' (-0.030886232398171704+0.014354837345119751j)\n", "a'010010'b'100001' (-0.05165778776977986-0.010714889727173844j)\n", "a'010010'b'000110' (0.031984978858291054+0.03777969626436932j)\n", "a'010010'b'001010' (0.01566718571896518+0.004646212415008767j)\n", "a'010010'b'010010' (0.027284717473827658-0.041879343807383125j)\n", "a'010010'b'100010' (-0.03353921432491071+0.003178719694457215j)\n", "a'010010'b'001100' (-0.03430596412048563-0.049639208987711694j)\n", "a'010010'b'010100' (-0.00641389659593739+0.03074152984134742j)\n", "a'010010'b'100100' (0.016779819266114597+0.05566277737502463j)\n", "a'010010'b'011000' (-0.006723079937106368+0.061140807383545j)\n", "a'010010'b'101000' (-0.01695558713339557-0.010358327915801796j)\n", "a'010010'b'110000' (0.030248247912357723+0.02827221478845536j)\n", "a'100010'b'000011' (-0.000774883627077283+0.014663287723538738j)\n", "a'100010'b'000101' (0.017050294711608023-0.023256444798420407j)\n", "a'100010'b'001001' (0.049938748150273556-0.0029976929080809227j)\n", "a'100010'b'010001' (0.022919757601873307-0.02218743591309039j)\n", "a'100010'b'100001' (-0.0646394958244615-0.05570141893719444j)\n", "a'100010'b'000110' (-0.004817380421614891-0.01093471654583531j)\n", "a'100010'b'001010' (0.05050232431986009+0.04709608729812489j)\n", "a'100010'b'010010' (-0.016099191921772317-0.041539243064761484j)\n", "a'100010'b'100010' (-0.02275545716256847-0.013326977026344822j)\n", "a'100010'b'001100' (0.02737651107460006-0.12271803353963899j)\n", "a'100010'b'010100' (-0.05823146331657471+0.045931829855142936j)\n", "a'100010'b'100100' (-0.030947680921457266+0.010534131983684929j)\n", "a'100010'b'011000' (-0.13455996615808177+0.015964866336238386j)\n", "a'100010'b'101000' (0.02627998906590844-0.008666144726414469j)\n", "a'100010'b'110000' (-0.07096135178771965-0.019713288471238603j)\n", "a'001100'b'000011' (0.12249406088551332+0.0397595276801405j)\n", "a'001100'b'000101' (-0.03717190349015075-0.047744629552414077j)\n", "a'001100'b'001001' (-0.049510491452227884-0.07646668547008674j)\n", "a'001100'b'010001' (-0.03660555351102878-0.05197512119100186j)\n", "a'001100'b'100001' (-0.05471307342765714-0.0589487086708j)\n", "a'001100'b'000110' (-0.01755199012414716+0.013048263786556638j)\n", "a'001100'b'001010' (-0.00857882323530028-0.06479152547115496j)\n", "a'001100'b'010010' (-0.07947636656888586-0.020697746733308788j)\n", "a'001100'b'100010' (-0.05286570620432255+0.047498253578123845j)\n", "a'001100'b'001100' (-0.058895917736748155-0.08134718046359499j)\n", "a'001100'b'010100' (-0.007759172202146301+0.05585820847203037j)\n", "a'001100'b'100100' (-0.03606283122500012+0.021860955924824173j)\n", "a'001100'b'011000' (-0.012705771152444771-0.007353347648629554j)\n", "a'001100'b'101000' (0.007035455573854808-0.0036289546523589687j)\n", "a'001100'b'110000' (-0.029582394021539622-0.060552532466492635j)\n", "a'010100'b'000011' (6.622821825741018e-05+0.06819521687070268j)\n", "a'010100'b'000101' (0.05664755155745417+0.012608551362744483j)\n", "a'010100'b'001001' (0.013805139738480172-0.013050337572465983j)\n", "a'010100'b'010001' (0.004496029529511587-0.05682288096788214j)\n", "a'010100'b'100001' (0.01103561293291618+0.06715112375090566j)\n", "a'010100'b'000110' (-0.007926576361187024+0.0245810549966246j)\n", "a'010100'b'001010' (-0.007221163323278204-0.03210119871669978j)\n", "a'010100'b'010010' (0.03457640928642191-0.00988327253751713j)\n", "a'010100'b'100010' (-0.0002100658318734995+0.048041390716167524j)\n", "a'010100'b'001100' (0.049211390982110706+0.09974598199436041j)\n", "a'010100'b'010100' (0.006272303880276709-0.09407763971400597j)\n", "a'010100'b'100100' (-0.13033144231952856+0.022472718076640752j)\n", "a'010100'b'011000' (-0.023760872252473527-0.043233367841302564j)\n", "a'010100'b'101000' (0.05705924415577326-0.015814368677333795j)\n", "a'010100'b'110000' (-0.09958582055213423+0.014698334557907054j)\n", "a'100100'b'000011' (0.013667655504338475-0.05175913389160436j)\n", "a'100100'b'000101' (-0.006761905333534244+0.026454854217976033j)\n", "a'100100'b'001001' (0.046786579619839966+0.008864067255911339j)\n", "a'100100'b'010001' (0.05039837441774306+0.05187329892695729j)\n", "a'100100'b'100001' (0.02087963584760698-0.005502261984408811j)\n", "a'100100'b'000110' (0.029296559916562527-4.6224234887214805e-05j)\n", "a'100100'b'001010' (0.10494018744485217-0.011748051523380834j)\n", "a'100100'b'010010' (0.05504430771278765-0.05913140822850689j)\n", "a'100100'b'100010' (-0.04712287222195877-0.039790127610440984j)\n", "a'100100'b'001100' (-0.0459825246538286-0.02826997482793556j)\n", "a'100100'b'010100' (0.07294733158665477-0.1257666169456137j)\n", "a'100100'b'100100' (0.0833211126381409-0.07497605001654252j)\n", "a'100100'b'011000' (-0.021028541603996913-0.0724340895883819j)\n", "a'100100'b'101000' (0.11143190144680012+0.020447188098985512j)\n", "a'100100'b'110000' (-0.06532435889335997-0.02256352245240806j)\n", "a'011000'b'000011' (0.0010730525671674563-0.01536408949813761j)\n", "a'011000'b'000101' (-0.006599917256713208+0.03699731723888233j)\n", "a'011000'b'001001' (-0.02554518092258797-0.07570351016071906j)\n", "a'011000'b'010001' (-0.07733984929045137+0.00019240812307152327j)\n", "a'011000'b'100001' (0.028566683724179906-0.028220227879004044j)\n", "a'011000'b'000110' (-0.012719202300114966+0.04076877128797155j)\n", "a'011000'b'001010' (0.09153121113691051+0.013680128959847056j)\n", "a'011000'b'010010' (-0.026065695840054602-0.02484739716695368j)\n", "a'011000'b'100010' (-0.054973868151651784+0.055603614727123246j)\n", "a'011000'b'001100' (-0.03521766219513058+0.006345217984153263j)\n", "a'011000'b'010100' (-0.04745566173938755+0.05212466048842456j)\n", "a'011000'b'100100' (0.028689233909716304-0.07570126188148843j)\n", "a'011000'b'011000' (-0.05601917739877244-0.01208104670655957j)\n", "a'011000'b'101000' (0.0025954874034302576-0.01866468497006429j)\n", "a'011000'b'110000' (0.021260832464197216+0.006668798164589958j)\n", "a'101000'b'000011' (-0.07607398924195338-0.020762730007560088j)\n", "a'101000'b'000101' (0.03320470967543686+0.021540356898001864j)\n", "a'101000'b'001001' (-0.03130067727988031+0.052827032840714785j)\n", "a'101000'b'010001' (-0.04912767484196669-0.03238053985091244j)\n", "a'101000'b'100001' (-0.039786443768841426+0.03891924726280567j)\n", "a'101000'b'000110' (-0.09518320985767062+0.009462224942926867j)\n", "a'101000'b'001010' (0.04848286052013493-0.023707016268290033j)\n", "a'101000'b'010010' (0.038581466363593074+0.030325296129766578j)\n", "a'101000'b'100010' (0.0533773963953223+0.059469040258927866j)\n", "a'101000'b'001100' (-0.05403937432704608+0.05245424666704686j)\n", "a'101000'b'010100' (-0.04516216033745876+0.06132547125641528j)\n", "a'101000'b'100100' (-0.026161854290522334+0.03806333878452584j)\n", "a'101000'b'011000' (-0.01804343750405718-0.06662481716338284j)\n", "a'101000'b'101000' (0.06628805381565804-0.021672428698911426j)\n", "a'101000'b'110000' (-0.0792570450199548-0.07127439091788099j)\n", "a'110000'b'000011' (-0.0037727824230151513+0.02619398312190159j)\n", "a'110000'b'000101' (0.05171852177030186-0.08126055453999075j)\n", "a'110000'b'001001' (-0.017828400331268417+0.00774667977673275j)\n", "a'110000'b'010001' (-0.006079501989024799-0.08257364230861923j)\n", "a'110000'b'100001' (-0.01251630739736173+0.06625290739296169j)\n", "a'110000'b'000110' (-0.011775793756219316-0.11589429041624034j)\n", "a'110000'b'001010' (0.012450560453236989+0.04216078846566297j)\n", "a'110000'b'010010' (0.021800344002429167+0.03836658400434302j)\n", "a'110000'b'100010' (-0.09178264827968109+0.04336604713145446j)\n", "a'110000'b'001100' (0.011124344131791123+0.03411196018513736j)\n", "a'110000'b'010100' (0.10396414390529524-0.05790293018924706j)\n", "a'110000'b'100100' (0.026239307282112385-0.030887244217474973j)\n", "a'110000'b'011000' (-0.012545943541226316+0.01727950313310185j)\n", "a'110000'b'101000' (0.015462411321244124-0.017538426656571907j)\n", "a'110000'b'110000' (-0.024507797109820838+0.06997591781859351j)\n", "Wavefunctions are equivalent\n" ] } ], "source": [ "print(\"From Cirq Evolution\")\n", "from_cirq_wfn.print_wfn()\n", "assert np.allclose(from_cirq_wfn.get_coeff((n_elec, sz)),\n", " fqe_wfn.get_coeff((n_elec, sz)))\n", "print(\"Wavefunctions are equivalent\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Finally, we can compare against evolving each term of $V$ individually." ] }, { "cell_type": "code", "execution_count": 13, "metadata": { "execution": { "iopub.execute_input": "2024-06-30T09:39:39.435967Z", "iopub.status.busy": "2024-06-30T09:39:39.435457Z", "iopub.status.idle": "2024-06-30T09:39:39.527085Z", "shell.execute_reply": "2024-06-30T09:39:39.526357Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Individual term evolution is equivalent\n" ] } ], "source": [ "fqe_wfn = fqe.Wavefunction([[n_elec, sz, norbs]])\n", "fqe_wfn.set_wfn(strategy='from_data',\n", " raw_data={(n_elec, sz): initial_coeffs})\n", "for term, coeff in diagonal_coulomb.terms.items():\n", " op = of.FermionOperator(term, coefficient=coeff)\n", " fqe_wfn = fqe_wfn.time_evolve(1, op)\n", "\n", "assert np.allclose(from_cirq_wfn.get_coeff((n_elec, sz)),\n", " fqe_wfn.get_coeff((n_elec, sz)))\n", "print(\"Individual term evolution is equivalent\")" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.10.14" } }, "nbformat": 4, "nbformat_minor": 4 }