示例#1
0
import numpy as np
from xmps.spin import paulis, CNOT, swap, H, CZ, CRy
from scipy.linalg import expm
from qmps.tools import split_ns, unitary_to_tensor
from qmps.tools import get_env_exact
from functools import reduce
from scipy import integrate
import matplotlib.pyplot as plt

from tenpy.networks.mps import MPS
from tenpy.models.tf_ising import TFIChain
from tenpy.models.spins import SpinModel
from tenpy.algorithms import dmrg

plt.style.use('pub_slow')
X, Y, Z = paulis(0.5)
I = np.eye(2)


def D2_gse(g):
    def example_DMRG_heisenberg_xxz_infinite(Jx=1,
                                             Jy=1,
                                             Jz=1,
                                             hx=0,
                                             hy=0,
                                             hz=0,
                                             conserve='best',
                                             verbose=False,
                                             chi_max=100,
                                             S=0.5):
        if verbose:
import numpy as np
from xmps.iMPS import iMPS
from xmps.spin import paulis, N_body_spins
import matplotlib as mpl
import matplotlib.pyplot as plt
from tqdm import tqdm

#mpl.style.use('pub_fast')
X, Y, Z = paulis(0.5)
XI, YI, ZI = N_body_spins(0.5, 1, 2)
IX, IY, IZ = N_body_spins(0.5, 2, 2)

T = np.linspace(0, 1, 100)
dt = T[1] - T[0]
D = 10
mps = iMPS().random(2, D).left_canonicalise()
evs = []

H = -(XI @ IX + YI @ IY + ZI @ IZ)

for _ in tqdm(T):
    k1 = mps.dA_dt([H]) * dt
    k2 = (mps + k1 / 2).dA_dt([H]) * dt
    k3 = (mps + k2 / 2).dA_dt([H]) * dt
    k4 = (mps + k3).dA_dt([H]) * dt
    mps = (mps + (k1 + 2 * k2 + 2 * k3 + k4) / 6).left_canonicalise()
    evs.append(mps.Es(paulis(0.5)))
plt.plot(T, evs)
plt.scatter(T, evs, marker='x')
plt.savefig('evo.jpg')
#plt.show()
示例#3
0
from qmps.ground_state import Hamiltonian
import matplotlib.pyplot as plt
import matplotlib as mpl
from qmps.represent import ShallowFullStateTensor
from qmps.tools import tensor_to_unitary, environment_to_unitary
from qmps.rotosolve import gate as gate_
from scipy.linalg import null_space, norm
from tqdm import tqdm
from xmps.spin import paulis
from qmps.represent import ShallowFullStateTensor
from qmps.tools import tensor_to_unitary
from qmps.rotosolve import gate
from scipy.linalg import null_space
from scipy.optimize import minimize
from xmps.tensor import rotate_to_hermitian
I, X, Y, Z = np.eye(2), *paulis(0.5)


def merge(A, B):
    # -A- -B-  ->  -A-B-
    #  |   |        ||
    return np.tensordot(A, B,
                        [2, 1]).transpose([0, 2, 1,
                                           3]).reshape(2 * A.shape[0], 2, 2)


def put_env_on_left_site(q, ret_n=False):
    # Take a matrix q (2x2) and create U such that
    # (right 0-|---|--0
    #          | u |        =  q_{ij}
    # (left) i-|---|--j
示例#4
0
from .tools import get_env_exact, split_2s
from qmps.time_evolve_tools import merge

from scipy.optimize import approx_fprime
from scipy.linalg import cholesky

from typing import Callable, List, Dict
from functools import reduce
from itertools import product

from xmps.spin import spins, swap, paulis, SU, U4
from xmps.iMPS import iMPS, TransferMatrix

π = np.pi

Sx, Sy, Sz = paulis(0.5)
S = {'I': eye(2), 'X': Sx, 'Y': Sy, 'Z': Sz}


class PauliMeasure(cirq.Gate):
    """PauliMeasure:apply appropriate transformation to 2 qubits
       st. measuring qb[0] in z basis measures string"""
    def __init__(self, string):
        if string == 'II':
            raise Exception('don\'t measure the identity')
        assert len(string) == 2
        self.string = string

    def _decompose_(self, qubits):
        def single_qubits(string, qubit):
            assert len(string) == 1