This repository contains the code to reproduce the numerical implementations presented in the manuscript "The Bethe Ansatz as a Quantum Circuit".
-
Pyhton>=3.11.7
-
qibo==0.2.5
XXZ_model.py
contains a class to generate the unitary matrices
from XXZ_model import XXZ_model
from utils import unitarize_pink, check_unitariry
nspins = 4
nmagnons = 2
delta = 0.5
roots = [-0.574, 0.574]
t = XXZ_model(nspins, nmagnons, delta)
t.get_roots(roots)
t.get_indexes()
P_xxz = []
for k in range(1, nspins):
P_xxz.append(t.get_Pk_matrix(k=k, a=True, b=True))
for k in range(nmagnons-1, nspins-1):
P_xxz[k] = unitarize_pink(P_xxz[k])
for k in range(nspins-1):
print(check_unitariry(P_xxz[k]))
XXZ_model_QR.py
contains the functions to generate the matrices
from XXZ_model_QR import get_P_G
from utils import unitarize_pink, check_unitariry
nspins = 4
roots = [-0.574, 0.574]
delta = 0.5
roots = [-0.574, 0.574]
P_xxz_qr = get_P_G(nspins, roots, delta)[0]
for k in range(nmagnons-1, nspins-1):
P_xxz_qr[k] = unitarize_pink(P_xxz_qr[k])
for k in range(nspins-1):
print(check_unitariry(P_xxz_qr[k]))
XX_model.py
contains a class to generate the quantum circuit to prepare Bethe eigensates of the XX model. These circuits are efficient in the number of qubits and magnons.
from XX_model import XX_model
nspins = 4
nmagnons = 2
roots = [-0.561, 0.561]
t = XX_model(nspins, nmagnons)
t.get_roots(roots)
t.P_list()
t.get_circuit()
circ = t.circuit
state_xx_efficient = circ().state()
bethe_circuit.py
defines the class BetheCircuit
which implements the Bethe Ansatz for the XXZ model with both the non-unitary matrices
import numpy as np
from qibo.quantum_info import fidelity
from bethe_circuit import BetheCircuitTN
nspins = 4
nmagnons = 2
roots = [-0.574, 0.574]
delta = 0.5
v = BetheCircuitTN(nspins, nmagnons)
state_mps = v.mps_state(roots, delta)().state()
state_mps = [state_mps[i] for i in range(0, len(state_mps), 2**nmagnons)]
state_mps /= np.linalg.norm(state_mps)
state_lambda = v.unitary_circuit(P_xxz)().state()
state_gamma = v.unitary_circuit(P_xxz_qr)().state()
fidelity_mps_lambda = fidelity(state_mps, state_lambda)
fidelity_mps_gamma = fidelity(state_mps, state_gamma)
print('fidelity lambda', fidelity_mps_lambda)
print('fidelity gamma', fidelity_mps_gamma)
The fidelity of the XX eigenstate can be computed as
nspins = 4
nmagnons = 2
roots = [-0.561,0.561]
delta = 0
v = BetheCircuitTN(nspins, nmagnons)
state_mps = v.mps_state(roots,delta)().state()
state_mps = [state_mps[i] for i in range(0,len(state_mps),2**nmagnons)]
state_mps /= np.linalg.norm(state_mps)
fidelity_mps_xx = fidelity(state_mps,state_xx_efficient)
print('fidelity xx', fidelity_mps_xx)