def __init__(self, model_params): model_params = asConfig(model_params, "AKLTModel") L = model_params.get('L', 2) site = SpinSite(S=1., conserve='Sz') # lattice bc_MPS = model_params.get('bc_MPS', 'finite') bc = 'open' if bc_MPS == 'finite' else 'periodic' lat = Chain(L, site, bc=bc, bc_MPS=bc_MPS) Sp, Sm, Sz = site.Sp, site.Sm, site.Sz S_dot_S = 0.5 * (kron(Sp, Sm) + kron(Sm, Sp)) + kron(Sz, Sz) S_dot_S_square = npc.tensordot(S_dot_S, S_dot_S, [['(p0*.p1*)'], ['(p0.p1)']]) H_bond = S_dot_S + S_dot_S_square / 3. # P_2 = H_bond * 0.5 + 1/3 * npc.eye_like(S_dot_S) J = model_params.get('J', 1.) H_bond = J * H_bond.split_legs().transpose(['p0', 'p1', 'p0*', 'p1*']) H_bond = [H_bond] * L # H_bond[i] acts on sites (i-1, i) if bc_MPS == "finite": H_bond[0] = None # 7) initialize H_bond (the order of 7/8 doesn't matter) NearestNeighborModel.__init__(self, lat, H_bond) # 9) initialize H_MPO MPOModel.__init__(self, lat, self.calc_H_MPO_from_bond())
def __init__(self, model_param): # 0) Read and set parameters. L = get_parameter(model_param, 'L', 1, self.__class__) bc_MPS = get_parameter(model_param, 'bc_MPS', 'finite', self.__class__) t = get_parameter(model_param, 't', 1., self.__class__) alpha = get_parameter(model_param, 'alpha', 1.0, self.__class__) delta = get_parameter(model_param, 'delta', 1.0, self.__class__) beta = get_parameter(model_param, 'beta', 1.0, self.__class__) conserve_fermionic_boson = get_parameter(model_param, \ 'conserve_fermionic_boson', 'Sz', self.__class__) conserve_spin = get_parameter(model_param, 'conserve_spin', None, self.__class__) unused_parameters(model_param, self.__class__) # 1) Sites and lattice. boson_site = SpinHalfSite(conserve=conserve_fermionic_boson, ) bond_spin = SpinHalfSite(conserve=conserve_spin) double_site = DoubleSite(site0=boson_site, site1=bond_spin, label0='0', label1='1', charges='independent') # lat = Lattice(Ls=[1], unit_cell=[bond_spin], order='default', bc_MPS=bc_MPS, # basis=None, positions=None) lat = Chain(L=L, site=double_site, bc_MPS='finite') # 2) Initialize CouplingModel bc_coupling = 'periodic' if bc_MPS == 'infinite' else 'open' CouplingModel.__init__(self, lat, bc_coupling) # 3) Build the Hamiltonian. # 3a) on-site terms self.add_onsite(delta / 2.0, 0, 'Sigmaz1') self.add_onsite(beta, 0, 'Sigmax1') # 3b) coupling terms. # 3bi) standard Bose-Hubbard coupling terms self.add_coupling(-t, 0, 'Sp0', 0, 'Sm0', 1) self.add_coupling(-t, 0, 'Sm0', 0, 'Sp0', 1) # 3bii) coupling on site bosons to bond spin self.add_coupling(-alpha, 0, 'Sp0 Sigmaz1', 0, 'Sm0', 1) self.add_coupling(-alpha, 0, 'Sm0 Sigmaz1', 0, 'Sp0', 1) # 4) Initialize MPO MPOModel.__init__(self, lat, self.calc_H_MPO()) # 5) Initialize H bond # LS: what does this mean? NearestNeighborModel.__init__(self, self.lat, self.calc_H_bond())
def __init__(self, L=2, S=0.5, J=1., Delta=1., hz=0.): spin = SpinSite(S=S, conserve="Sz") # the lattice defines the geometry lattice = Chain(L, spin, bc="open", bc_MPS="finite") CouplingModel.__init__(self, lattice) # add terms of the Hamiltonian self.add_coupling(J * 0.5, 0, "Sp", 0, "Sm", 1) # Sp_i Sm_{i+1} self.add_coupling(J * 0.5, 0, "Sp", 0, "Sm", -1) # Sp_i Sm_{i-1} self.add_coupling(J * Delta, 0, "Sz", 0, "Sz", 1) # (for site dependent prefactors, the strength can be an array) self.add_onsite(-hz, 0, "Sz") # finish initialization # generate MPO for DMRG MPOModel.__init__(self, lat, self.calc_H_MPO()) # generate H_bond for TEBD NearestNeighborModel.__init__(self, lat, self.calc_H_bond())
def example_TEBD_gs_tf_ising_next_nearest_neighbor(L, g, Jp, verbose=True): from tenpy.models.spins_nnn import SpinChainNNN2 from tenpy.models.model import NearestNeighborModel print("finite TEBD, imaginary time evolution, transverse field Ising next-nearest neighbor") print("L={L:d}, g={g:.2f}, Jp={Jp:.2f}".format(L=L, g=g, Jp=Jp)) model_params = dict(L=L, Jx=1., Jy=0., Jz=0., Jxp=Jp, Jyp=0., Jzp=0., hz=g, bc_MPS='finite', conserve=None, verbose=verbose) # we start with the non-grouped sites, but next-nearest neighbor interactions, building the MPO M = SpinChainNNN2(model_params) product_state = ["up"] * M.lat.N_sites psi = MPS.from_product_state(M.lat.mps_sites(), product_state, bc=M.lat.bc_MPS) # now we group each to sites ... psi.group_sites(n=2) # ... in the state M.group_sites(n=2) # ... and model # now, M has only 'nearest-neighbor' interactions with respect to the grouped sites # thus, we can convert the MPO into H_bond terms: M_nn = NearestNeighborModel.from_MPOModel(M) # hence, we can initialize H_bond from the MPO # now, we continue to run TEBD as before tebd_params = { 'order': 2, 'delta_tau_list': [0.1, 0.01, 0.001, 1.e-4, 1.e-5], 'N_steps': 10, 'max_error_E': 1.e-6, 'trunc_params': { 'chi_max': 30, 'svd_min': 1.e-10 }, 'verbose': verbose, } eng = tebd.Engine(psi, M_nn, tebd_params) # use M_nn and grouped psi eng.run_GS() # the main work... # expectation values: E = np.sum(M_nn.bond_energies(psi)) # bond_energies() works only a for NearestNeighborModel print("E = {E:.13f}".format(E=E)) print("final bond dimensions: ", psi.chi) # we can split the sites of the state again for an easier evaluation of expectation values psi.group_split() mag_x = 2. * np.sum(psi.expectation_value("Sx")) # factor of 2 for Sx vs Sigmax mag_z = 2. * np.sum(psi.expectation_value("Sz")) print("magnetization in X = {mag_x:.5f}".format(mag_x=mag_x)) print("magnetization in Z = {mag_z:.5f}".format(mag_z=mag_z)) return E, psi, M
def test_SpinChainNNN_comparison(): model_pars = { 'hz': 0.5, 'Jx': -2., 'Jy': -2., 'Jz': 0.4, 'L': 3, 'conserve': 'Sz', 'bc_MPS': 'finite' } M1 = spins_nnn.SpinChainNNN(model_pars.copy()) model_pars['L'] = 2 * model_pars['L'] M2 = spins_nnn.SpinChainNNN2(model_pars.copy()) M2.group_sites(2) M2nn = NearestNeighborModel.from_MPOModel(M2) ED1 = ExactDiag(M1) ED2 = ExactDiag(M2) ED2nn = ExactDiag(M2nn) ED1.build_full_H_from_mpo() ED2.build_full_H_from_mpo() ED2nn.build_full_H_from_bonds() assert (ED1.full_H - ED2.full_H).norm() < 1.e-13 assert (ED1.full_H - ED2nn.full_H).norm() < 1.e-13