Exemplo n.º 1
0
import cProfile
from dmrg import *
from mpo.asep import return_mpo
import pstats

# Set Calculation Parameters
N = 50
p = 0.1
mbd = np.array([16])
s = 0.5

# Set up calculation
mpo = return_mpo(N, (0.5, 0.5, p, 1 - p, 0.5, 0.5, s))
cProfile.run('E,EE,gap = run_dmrg(mpo,mbd=mbd,nStates=2,fname="tmp")',
             'mps_stats')

p = pstats.Stats('mps_stats')
p.sort_stats('cumulative').print_stats(20)
Exemplo n.º 2
0
fname = path + 'MPS_'

# Set up Plotting Stuff
if make_plt:
    import matplotlib.pyplot as plt
    f = plt.figure()
    ax0 = f.add_subplot(311)
    ax1 = f.add_subplot(323)
    ax2 = f.add_subplot(324)
    ax3 = f.add_subplot(325)
    ax4 = f.add_subplot(326)

# Run initial Calculation
print(s0)
hamParams[-1] = s0
mpo = return_mpo(N, hamParams)
Etmp, EEtmp, gaptmp, env = run_dmrg(
    mpo,
    mbd=mbd,
    #initGuess = 'saved_states/singleLane_MCSHD_N100mbd10_1553109008/MPS_s242',
    fname=fname + 's0',
    nStates=nStates,
    alg=alg,
    returnEnv=True,
    calcLeftState=leftState)
"""
Etmp,EEtmp,gaptmp,env = run_dmrg(mpo,
                                 mbd=mbd,
                                 initGuess = fname+'s0',
                                 initEnv = env,
                                 fname=fname+'s0',
Exemplo n.º 3
0
    # Return Results
    if len(Evec) == 1:
        output = [E, EE, gap]
    else:
        output = [Evec, EEvec, gapvec]
    if returnEntSpec:
        output.append(EEs)
    if returnState:
        output.append(mpsList)
    if returnEnv:
        output.append(env)
    return output


if __name__ == "__main__":
    from mpo.asep import return_mpo
    # Hamiltonian Parameters
    p = 0.1
    alpha = 0.2  # in at left
    gamma = 1. - alpha  # Out at left
    q = 1. - p  # Jump left
    beta = 0.4  # Out at right
    delta = 1. - beta  # In at right
    s = -0.5
    # Get MPO
    hamParams = np.array([alpha, gamma, p, q, beta, delta, s])
    mpo = return_mpo(4, hamParams)
    # Run idmrg
    output = run_idmrg(mpo, mbd=10)
Exemplo n.º 4
0
# Get initial path from input argument
path = argv[1]

# Load results file and find out initial information
fname = path + 'results.npz'
npzfile = np.load(fname)
s = npzfile['s']
N = int(npzfile['N'])
nStates = 4
p = 0.1
E = np.zeros((len(s), nStates))
PT = np.zeros((len(s), nStates))
# Loop through all results in s vector
for sInd in range(len(s)):
    print('Processing s={}'.format(s[sInd]))
    mpo = return_mpo(N, (0.5, 0.5, p, 1. - p, 0.5, 0.5, s[sInd]))
    cmpo = curr_mpo(N, (0.5, 0.5, p, 1. - p, 0.5, 0.5, s[sInd]))
    for state in range(nStates):
        fname_mps = path + 'MPS_s' + str(sInd) + '_mbd0'
        fname_lmps = path + 'MPS_s' + str(sInd) + '_mbd0_left'
        E[sInd,
          state] = contract(mps=fname_mps, mpo=mpo, state=state) / contract(
              mps=fname_mps, state=state)
        # Calculate PT Stuff
        #PT[sInd,state]= contract(mps=fname_mps,mpo=cmpo,state=0,lstate=state)*contract(mps=fname_mps,mpo=cmpo,state=state,lstate=0)/(E[sInd,0]-E[sInd,state])
        PT[sInd, state] = contract(
            mps=fname_mps, lmps=fname_lmps, mpo=cmpo, state=0, lstate=state
        ) * contract(
            mps=fname_mps, lmps=fname_lmps, mpo=cmpo, state=state,
            lstate=0) / (E[sInd, 0] - E[sInd, state])
    print(PT[sInd, :])