Beispiel #1
0
 def __init__(self, psi, model, TDVP_params, environment=None):
     self.verbose = get_parameter(TDVP_params, 'verbose', 1, 'TDVP')
     self.TDVP_params = TDVP_params
     if environment is None:
         environment = MPOEnvironment(psi, model.H_MPO, psi)
     self.evolved_time = get_parameter(TDVP_params, 'start_time', 0., 'TDVP')
     self.H_MPO = model.H_MPO
     self.environment = environment
     if not psi.finite:
         raise ValueError("TDVP is only implemented for finite boundary conditions")
     self.psi = psi
     self.L = self.psi.L
     self.dt = get_parameter(TDVP_params, 'dt', 2, 'TDVP')
     self.trunc_params = get_parameter(TDVP_params, 'trunc_params', {}, 'TDVP')
     self.N_steps = get_parameter(TDVP_params, 'N_steps', 10, 'TDVP')
Beispiel #2
0
 def __init__(self, psi, model, options, environment=None, **kwargs):
     TimeEvolutionAlgorithm.__init__(self, psi, model, options, **kwargs)
     options = self.options
     if model.H_MPO.explicit_plus_hc:
         raise NotImplementedError(
             "TDVP does not respect 'MPO.explicit_plus_hc' flag")
     self.lanczos_options = options.subconfig('lanczos_options')
     if environment is None:
         environment = MPOEnvironment(psi, model.H_MPO, psi)
     self.evolved_time = options.get('start_time', 0.)
     self.H_MPO = model.H_MPO
     self.environment = environment
     if not psi.finite:
         raise ValueError(
             "TDVP is only implemented for finite boundary conditions")
     self.L = self.psi.L
     self.dt = options.get('dt', 2)
     self.N_steps = options.get('N_steps', 10)
Beispiel #3
0
 def __init__(self, psi, model, options, environment=None):
     if model.H_MPO.explicit_plus_hc:
         raise NotImplementedError("TDVP does not respect 'MPO.explicit_plus_hc' flag")
     self.options = options = asConfig(options, "TDVP")
     self.verbose = options.get('verbose', 1)
     self.lanczos_options = options.subconfig('lanczos_options')
     if environment is None:
         environment = MPOEnvironment(psi, model.H_MPO, psi)
     self.evolved_time = options.get('start_time', 0.)
     self.H_MPO = model.H_MPO
     self.environment = environment
     if not psi.finite:
         raise ValueError("TDVP is only implemented for finite boundary conditions")
     self.psi = psi
     self.L = self.psi.L
     self.dt = options.get('dt', 2)
     self.trunc_params = options.get('trunc_params', {})
     self.N_steps = options.get('N_steps', 10)
Beispiel #4
0
          [None, None, None, None, 0.5 * Jxx * Sm],
          [None, None, None, None, 0.5 * Jxx * Sp],
          [None, None, None, None, Jz * Sz       ],
          [None, None, None, None, Id            ]]  # yapf:disable

W = npc.grid_outer(W_grid, [mpo_leg, mpo_leg.conj()])
W.iset_leg_labels(['wL', 'wR', 'p', 'p*'])  # wL/wR = virtual left/right of the MPO
Ws = [W] * L
Ws[0] = W[:1, :]
Ws[-1] = W[:, -1:]
H = MPO(psi.sites, Ws, psi.bc, IdL=0, IdR=-1)

print("3) define 'environments' left and right")

# this is automatically done during initialization of MPOEnvironment
env = MPOEnvironment(psi, H, psi)
envL = env.get_LP(0)
envR = env.get_RP(L - 1)

print("4) contract MPS and MPO to calculate the energy <psi|H|psi>")

E = env.full_contraction(L - 1)
print("E =", E)

print("5) calculate two-site hamiltonian ``H2`` from the MPO")
# label left, right physical legs with p, q
W0 = H.get_W(0).replace_labels(['p', 'p*'], ['p0', 'p0*'])
W1 = H.get_W(1).replace_labels(['p', 'p*'], ['p1', 'p1*'])
H2 = npc.tensordot(W0, W1, axes=('wR', 'wL')).itranspose(['wL', 'wR', 'p0', 'p1', 'p0*', 'p1*'])
H2 = H2[H.IdL[0], H.IdR[2]]  # (If H has single-site terms, it's not that simple anymore)
print("H2 labels:", H2.get_leg_labels())