Source code for tenpy.models.tf_ising

"""Prototypical example of a quantum model: the transverse field Ising model.

Like the :class:`~tenpy.models.xxz_chain.XXZChain`, the transverse field ising chain
:class:`TFIChain` is contained in the more general :class:`~tenpy.models.spins.SpinChain`;
the idea is more to serve as a pedagogical example for a 'model'.

We choose the field along z to allow to conserve the parity, if desired.
"""
# Copyright 2018-2019 TeNPy Developers, GNU GPLv3

from .model import CouplingMPOModel, NearestNeighborModel
from ..tools.params import get_parameter
from ..networks.site import SpinHalfSite

__all__ = ['TFIModel', 'TFIChain']


[docs]class TFIModel(CouplingMPOModel): r"""Transverse field Ising model on a general lattice. The Hamiltonian reads: .. math :: H = - \sum_{\langle i,j\rangle, i < j} \mathtt{J} \sigma^x_i \sigma^x_{j} - \sum_{i} \mathtt{g} \sigma^z_i Here, :math:`\langle i,j \rangle, i< j` denotes nearest neighbor pairs, each pair appearing exactly once. All parameters are collected in a single dictionary `model_params` and read out with :func:`~tenpy.tools.params.get_parameter`. Parameters ---------- conserve : None | 'parity' What should be conserved. See :class:`~tenpy.networks.Site.SpinHalfSite`. J, g : float | array Couplings as defined for the Hamiltonian above. lattice : str | :class:`~tenpy.models.lattice.Lattice` Instance of a lattice class for the underlaying geometry. Alternatively a string being the name of one of the Lattices defined in :mod:`~tenpy.models.lattice`, e.g. ``"Chain", "Square", "HoneyComb", ...``. bc_MPS : {'finite' | 'infinte'} MPS boundary conditions along the x-direction. For 'infinite' boundary conditions, repeat the unit cell in x-direction. Coupling boundary conditions in x-direction are chosen accordingly. Only used if `lattice` is a string. order : string Ordering of the sites in the MPS, e.g. 'default', 'snake'; see :meth:`~tenpy.models.lattice.Lattice.ordering`. Only used if `lattice` is a string. L : int Lenght of the lattice. Only used if `lattice` is the name of a 1D Lattice. Lx, Ly : int Length of the lattice in x- and y-direction. Only used if `lattice` is the name of a 2D Lattice. bc_y : 'ladder' | 'cylinder' Boundary conditions in y-direction. Only used if `lattice` is the name of a 2D Lattice. """ def __init__(self, model_params): CouplingMPOModel.__init__(self, model_params)
[docs] def init_sites(self, model_params): conserve = get_parameter(model_params, 'conserve', 'parity', self.name) assert conserve != 'Sz' if conserve == 'best': conserve = 'parity' if self.verbose >= 1.: print(self.name + ": set conserve to", conserve) site = SpinHalfSite(conserve=conserve) return site
[docs] def init_terms(self, model_params): J = get_parameter(model_params, 'J', 1., self.name, True) g = get_parameter(model_params, 'g', 1., self.name, True) for u in range(len(self.lat.unit_cell)): self.add_onsite(-g, u, 'Sigmaz') for u1, u2, dx in self.lat.pairs['nearest_neighbors']: self.add_coupling(-J, u1, 'Sigmax', u2, 'Sigmax', dx)
# done
[docs]class TFIChain(TFIModel, NearestNeighborModel): """The :class:`TFIModel` on a Chain, suitable for TEBD. See the :class:`TFIModel` for the documentation of parameters. """ def __init__(self, model_params): model_params.setdefault('lattice', "Chain") CouplingMPOModel.__init__(self, model_params)