コード例 #1
0
def create(D, seed=None):
    if not seed is None:
        sp.random.seed(seed)
    s = tdvp.EvoMPS_TDVP_Uniform(D, qn, get_ham(Jx, Jy, Jz), L=block_length)
    s.symm_gauge = True
    s.zero_tol = zero_tol
    s.sanity_checks = sanity_checks
    s.ev_arpack_CUDA = use_CUDA
    s.PPinv_use_CUDA = use_CUDA
    return s
コード例 #2
0
The following function will return a Hamiltonian for the chain, given the
the parameters J and h.
"""


def get_ham(Jx, Jy, Jz):
    h = (Jx * sp.kron(Sx, Sx) + Jy * sp.kron(Sy, Sy) +
         Jz * sp.kron(Sz, Sz)).reshape(qn, qn, qn, qn)
    return h


"""
Now we are ready to create an instance of the evoMPS class.
"""
s = tdvp.EvoMPS_TDVP_Uniform(bond_dim, qn, get_ham(Jx, Jy, Jz))
s.zero_tol = zero_tol
s.sanity_checks = sanity_checks
"""
The following loads a ground state from a file.
The ground state will be saved automatically when it is declared found.
"""
grnd_fname = "heis_af_uni_D%d_q%d_S%g_Jx%g_Jy%g_Jz%g_s%g_dtau%g_ground.npy" % (
    bond_dim, qn, S, Jx, Jy, Jz, tol_im, step)

if load_saved_ground:
    try:
        a_file = open(grnd_fname, 'rb')
        s.load_state(a_file)
        a_file.close
        real_time = True
コード例 #3
0
D = 8 #The bond dimension
q = 2 #The site dimension

"""
Set the initial Hamiltonian parameters.
"""
h = -0.5
J = 1.00

lam = -J / h
print "Exact energy = ", h * 2 / sp.pi * (1 + lam) * spe.ellipe((4 * lam / (1 + lam)**2))

"""
Now we are ready to create an instance of the evoMPS class.
"""
s = tdvp.EvoMPS_TDVP_Uniform(D, q, get_ham_3s_v2(J, h))

"""
We're going to simulate a quench after we find the ground state.
Set the new J parameter for the real time evolution here.
"""
J_real = 0.25

"""
Now set the step sizes for the imaginary and the real time evolution.
These are currently fixed.
"""
step = 0.1
realstep = 0.01

"""
コード例 #4
0
ファイル: find_spectrum.py プロジェクト: wfBranch/testing
step = 0.08

plt.close('all')
gsAlreadyFound = False
exAlreadyFound = False
try:
    gsAlreadyFound
except:
    gsAlreadyFound = False
if not gsAlreadyFound:
    #    hamTerm = me.make_Heis_for_MPS(1,J, h)[1]
    #    hamTerm = me.random_hermitian(q**2).reshape(q,q,q,q)
    J = 0.1
    hamTerm = (J * np.kron(me.Sz, me.Sz) + np.kron(me.Sx, np.eye(2))).reshape(
        q, q, q, q)  #TFIM
    su = tdvpu.EvoMPS_TDVP_Uniform(D, q, hamTerm)
    su.zero_tol = zero_tol
    su.randomize()
    #    print 'Initial energy = ',su.h_expect.real
    print('Finding g.s.')
    for i in range(nSteps):
        su.take_step(step)
        su.update()
    #    print 'Step %d'%i+', E=%f'%su.h_expect.real
#    print 'G.s. energy = ',su.h_expect.real
    gsAlreadyFound = True

pList = np.linspace(0, np.pi, num=50)
for i in range(len(pList)):
    ev1, eV1 = su.excite_top_triv(p1, nev=nev, return_eigenvectors=True)
コード例 #5
0
ファイル: master.py プロジェクト: amilsted/kollider1D
def prepare_vacua(J, hx, hz, J2, J3, J4, J5, hzx, D, save_states=True):
    symm_broken = (hz != 0) or (hzx != 0)

    ham = get_ham(J, hx, hz, J2, J3, J4, J5, hzx)
    try:
        state = tdvp.EvoMPS_TDVP_Uniform.from_file("vac_true_uniform.npy", ham)
        print("Loaded existing state from vac_true_uniform.npy")
    except FileNotFoundError:
        state = tdvp.EvoMPS_TDVP_Uniform(4, 2, ham, L=1)

    state = dyn.find_ground(state,
                            tol=1e-11,
                            h_init=0.01,
                            cb_func=cbf,
                            max_itr=1000,
                            expand_to_D=D,
                            expand_step=2)
    state.update()

    h_orig = state.h_expect.real
    z_orig = state.expect_1s(Sz).real
    print("Correlation length:", state.correlation_length())
    print("Energy:", h_orig)
    print("<Z>:", z_orig)
    print("Schmidt coeff:", np.sqrt(state.schmidt_sq().real))

    np.save(
        "state_info.npy",
        np.array(
            [state.h_expect,
             state.expect_1s(Sz),
             state.correlation_length()]))

    try:
        state_flipped = tdvp.EvoMPS_TDVP_Uniform.from_file(
            "vac_false_uniform.npy", ham)
        print("Loaded existing state from vac_false_uniform.npy")
    except FileNotFoundError:
        state_flipped = copy.deepcopy(state)
        state_flipped.apply_op_1s(Sx)

    state_flipped.update()

    h_flipped = state_flipped.h_expect.real
    z_flipped = state_flipped.expect_1s(Sz).real
    print("Flipped energy:", h_flipped)
    print("Flipped <Z>:", z_flipped)

    if symm_broken:
        # Flipped state is not an eigenstate: "cool it down"
        state_flipped = dyn.find_ground(state_flipped,
                                        tol=1e-11,
                                        h_init=0.01,
                                        cb_func=cbf,
                                        max_itr=1000,
                                        expand_to_D=D,
                                        expand_step=2)
        state_flipped.update()

        if state_flipped.eta.real > 1e-11:
            raise RuntimeError("Failed to cool flipped state.")

    h_flipped = state_flipped.h_expect.real
    z_flipped = state_flipped.expect_1s(Sz).real
    print("Flipped and cooled energy:", h_flipped)
    print("Flipped and cooled <Z>:", z_flipped)

    if symm_broken and np.sign(z_flipped) == np.sign(z_orig):
        raise RuntimeError("Failed to preserve metastable vacuum.")

    print("Flipped and cooled correlation length:",
          state_flipped.correlation_length())
    print("Schmidt coeff:", np.sqrt(state_flipped.schmidt_sq().real))
    print("Energy density gap:", h_flipped - h_orig)

    if symm_broken and (h_flipped <
                        h_orig) or (not symm_broken) and (z_flipped > z_orig):
        vac_true, vac_false = state_flipped, state
    else:
        vac_false, vac_true = state_flipped, state

    if save_states:
        vac_true.save_state("vac_true_uniform.npy")
        vac_false.save_state("vac_false_uniform.npy")

    return vac_true, vac_false
コード例 #6
0
ファイル: master.py プロジェクト: amilsted/kollider1D
def check_kinematics(J, hx, hz, J2, J3, J4, J5, hzx, D):
    ham = get_ham(J, hx, 0.0, J2, J3, J4, J5, 0.0)
    try:
        state = tdvp.EvoMPS_TDVP_Uniform.from_file("vac_true_uniform.npy", ham)
        print("Loaded existing state from vac_true_uniform.npy")
    except FileNotFoundError:
        state = tdvp.EvoMPS_TDVP_Uniform(4, 2, ham, L=1)
    state = dyn.find_ground(state,
                            tol=1e-11,
                            h_init=0.01,
                            cb_func=cbf,
                            max_itr=1000,
                            expand_to_D=D,
                            expand_step=2)
    if state.expect_1s(Sz).real < 1:
        state.apply_op_1s(Sx)
    state.update()
    state.save_state("vac_symm_uniform.npy")

    state_flipped = copy.deepcopy(state)
    state_flipped.apply_op_1s(Sx)
    state_flipped.update()

    state_flipped.phase_align(state)

    print("Unbroken correlation length:", state.correlation_length())
    print("Smallest Schmidt-squared:", state.schmidt_sq().real.min())

    ens_triv = []
    ens_top = []
    ps = np.linspace(0.0, np.pi, num=40)
    for p in ps:
        ens_triv.append(np.sort(state.excite_top_triv_brute(p)))
        ens_top.append(
            np.sort(
                state.excite_top_nontriv_brute(state_flipped,
                                               p,
                                               phase_align=False)))
        print(p, ens_triv[-1].min(), ens_top[-1].min())

    ens_triv = np.array(ens_triv)
    ens_top = np.array(ens_top)
    np.save("symm_scalar_spec.npy", ens_triv)
    np.save("symm_scalar_spec_ps.npy", ps)
    np.save("symm_kink_spec.npy", ens_top)
    np.save("symm_kink_spec_ps.npy", ps)

    spec_info = {
        "gap_triv_p0": ens_triv[0][0],
        "gap_top_p0": ens_top[0][0],
    }
    with open("spec_info_symm.json", "w") as f:
        json.dump(spec_info, f)

    E_triv_0 = ens_triv[0].min()
    E_kink_0 = ens_top[0].min()

    es_kink_min = ens_top.T[0, :]
    ind = np.argmax(np.diff(es_kink_min))
    print("p(v_max) ~", ps[ind])
    E_kink_1 = ens_top[ind].min()

    print("E_triv(0) = ", E_triv_0)
    print("E_kink(0) = ", E_kink_0)
    print("E_kink(v_max) = ", E_kink_1)
    print("KE_kink(v_max) = ", E_kink_1 - E_kink_0)

    if 2 * E_kink_0 > E_triv_0:
        print("Possible non-mesonic trivial excitation!")

    if E_kink_1 > E_triv_0:
        print("Kinks at v_max surpass scalar-production threshold!")

    E_kinetic = E_kink_1 - E_kink_0
    sep_required = E_kinetic / hz
    print("Required separation approx.:", sep_required)
コード例 #7
0
lam = J / h
print("Exact energy = ", -h * 2 / sp.pi * (1 + lam) * spe.ellipe(
    (4 * lam / (1 + lam)**2)))


def contract_uni(A, B):
    M = sp.dot(matmul.H(A[0][0]), B[0][0]) + sp.dot(matmul.H(A[0][1]), B[0][1])
    tr = sp.trace(matmul.H(A[0][0])) * sp.trace(B[0][0]) + sp.trace(
        matmul.H(A[0][1])) * sp.trace(B[0][1])
    return tr.real


"""
Now we are ready to create an instance of the evoMPS class.
"""
s = tdvp.EvoMPS_TDVP_Uniform(bond_dim, 2, get_ham(J, h))
s.zero_tol = zero_tol
s.sanity_checks = sanity_checks
"""
The following loads a ground state from a file.
The ground state will be saved automatically when it is declared found.
"""
grnd_fname = "t_ising_uni_D%d_J%g_h%g_s%g_dtau%g_ground.npy" % (bond_dim, J, h,
                                                                tol_im, step)

if load_saved_ground:
    try:
        a_file = open(grnd_fname, 'rb')
        s.load_state(a_file)
        a_file.close
        real_time = True
コード例 #8
0
For each term, the indices 0 and 1 are the 'bra' indices for the first and
second sites and the indices 2 and 3 are the 'ket' indices:

  ham[n][s,t,u,v] = <st|h|uv> (for sites n and n+1)
'''


def get_hamiltonian(h):
    ham = -(sp.kron(Sx, Sx) + h * sp.kron(Sz, sp.eye(2))).reshape(2, 2, 2, 2)
    return ham


'''
create an instance of the uniform evoMPS class.
'''
s = utdvp.EvoMPS_TDVP_Uniform(bond_dim, 2, get_hamiltonian(h))
s.zero_tol = zero_tol
s.sanity_checks = sanity_checks
"""
The following loads a ground state from a file.
The ground state will be saved automatically when it is declared found.
"""
grnd_fname = "t_ising_uni_D%d_h%g_s%g_dtau%g_ground.npy" % (bond_dim, h,
                                                            tol_im, step)

if __name__ == '__main__':

    print "Bond dimensions: " + str(s.D)
    print
    col_heads = ["Step", "t", "<H>",
                 "eta"]  #These last three are for testing the midpoint method.