Source code for edlgt.models.ising_model

"""Ising spin model built on top of :class:`edlgt.models.quantum_model.QuantumModel`."""

import logging

from edlgt.modeling import LocalTerm, TwoBodyTerm
from edlgt.operators import get_Pauli_operators

from .quantum_model import QuantumModel

logger = logging.getLogger(__name__)
__all__ = ["IsingModel"]


[docs] class IsingModel(QuantumModel): """Nearest-neighbor Ising model with a transverse field.""" def __init__(self, sectors=None, **kwargs): """Initialize the Ising model and site-local Pauli operators. Parameters ---------- sectors : list or None, optional Target sector(s) for the global Z2 parity symmetry. Pass ``[1]`` for the even-parity sector or ``[-1]`` for odd. If ``None``, no symmetry reduction is applied. **kwargs Arguments forwarded to :class:`~edlgt.models.quantum_model.QuantumModel`. """ # Initialize base class with the common parameters super().__init__(**kwargs) # ------------------------------------------------------------------------------- # Acquire operators and project onto the local Hilbert space self.project_operators(get_Pauli_operators()) # ------------------------------------------------------------------------------- # GLOBAL SYMMETRIES if sectors is not None: global_ops = [self.ops["Sz"]] global_sectors = sectors else: global_ops = None global_sectors = None # GET SYMMETRY SECTOR self.get_abelian_symmetry_sector( global_ops=global_ops, global_sectors=global_sectors, global_sym_type="Z", ) # DEFAULT PARAMS self.default_params()
[docs] def build_Hamiltonian(self, coeffs): """Assemble the Ising Hamiltonian. Parameters ---------- coeffs : dict Coupling dictionary with keys ``"J"`` (nearest-neighbor coupling) and ``"h"`` (transverse-field strength). """ logger.info("BUILDING HAMILTONIAN") # Hamiltonian Coefficients self.coeffs = coeffs h_terms = {} # ------------------------------------------------------------------------------- # NEAREST NEIGHBOR INTERACTION for d in self.directions: op_names_list = ["Sx", "Sx"] op_list = [self.ops[op] for op in op_names_list] h_terms["SxSx"] = TwoBodyTerm( axis=d, op_list=op_list, op_names_list=op_names_list, **self.def_params ) self.H.add_term(h_terms["SxSx"].get_Hamiltonian(strength=-self.coeffs["J"])) # ------------------------------------------------------------------------------- # EXTERNAL MAGNETIC FIELD op_name = "Sz" h_terms["Sz"] = LocalTerm(self.ops[op_name], op_name, **self.def_params) self.H.add_term(h_terms["Sz"].get_Hamiltonian(strength=-self.coeffs["h"])) # ------------------------------------------------------------------------------- self.H.build(self.ham_format)