LocalTerm Class
Single-site Hamiltonian contributions and local-observable measurements on a lattice.
- class edlgt.modeling.local_term.LocalTerm(operator, op_name, **kwargs)[source]
Bases:
QMBTermSingle-site term on a lattice model.
Initialize a local term definition.
- Parameters:
operator (
scipy.sparse.spmatrix) – Single-site operator.op_name (
str) – Human-readable operator name.**kwargs – Additional keyword arguments forwarded to
QMBTerm.
- Return type:
- get_hamiltonian(strength, mask=None)[source]
Build the local Hamiltonian contribution.
- Parameters:
strength (
scalar) – Coupling constant multiplying the local term.mask (
numpy.ndarray, optional) – Boolean lattice mask selecting the sites where the term is applied.
- Returns:
Return type depends on the current workflow:
if
self.sector_configs is None: sparse matrix Hamiltonian term;otherwise:
(r_list, c_list, v_list)as three NumPy arrays in the symmetry-reduced basis.
- Return type:
- Raises:
TypeError – If
strengthis not scalar.
- get_Hamiltonian(strength, mask=None)
Build the local Hamiltonian contribution.
- Parameters:
strength (
scalar) – Coupling constant multiplying the local term.mask (
numpy.ndarray, optional) – Boolean lattice mask selecting the sites where the term is applied.
- Returns:
Return type depends on the current workflow:
if
self.sector_configs is None: sparse matrix Hamiltonian term;otherwise:
(r_list, c_list, v_list)as three NumPy arrays in the symmetry-reduced basis.
- Return type:
- Raises:
TypeError – If
strengthis not scalar.
- get_expval(psi, stag_label=None, print_values=True, get_variance=False)[source]
Compute local expectation values (and optionally variances) on all sites.
- Parameters:
psi (
QMB_state) – Quantum many-body state used for the measurement.stag_label (
str, optional) – Optional staggered-site selector ("even"or"odd").print_values (
bool, optional) – IfTrue, log per-site values and final averages.get_variance (
bool, optional) – IfTrue, also compute local variances when supported.
- Returns:
Results are stored on the instance attributes
obs,var(if requested),avg, andstd.- Return type:
- Raises:
TypeError – If
psiis not aQMB_stateinstance.
Notes
For local operators without momentum basis, squaring the non-zero matrix entries is sufficient to compute the variance contribution. In momentum basis, the variance requires constructing a dedicated operator.