Skip to content

Index arithmetic / nearest-neighbour shifts #149

@oameye

Description

@oameye

An Index is currently a single name::Symbol, so lattice Hamiltonians like $H = -J \sum_i (\sigma_i^+ \sigma_{i+1}^- + \mathrm{h.c.})$ can't be written natively — i+1 has no representation.

MVP: add a shift::Int field to Index so Index(name=:i, shift=1) means $i+1$. Touches:

  • index_types.jl — struct, ==, hash, isless extended over (name, shift).
  • index.jlchange_index, get_indices, and especially _diagonal_split!: with shifts, decide when (i,1) colliding with free j on the same subspace should emit j → i+1.
  • Per-operator _site_compare — sort key becomes (space_index, name, shift).
  • Numeric Σ enumeration — respect boundary conditions (open i+1 ≤ N vs periodic (i mod N)+1) via a boundary=:open|:periodic kwarg on Σ.

Out of scope for the MVP: sparse-pattern DoubleIndexedVariable like J(i,j), generic j = f(i) for higher-shell shifts, and explicit boundary-condition objects.

Motivation: unblocks an indexed Heisenberg/XXZ chain example (spin-wave dispersion $\varepsilon(k) = J(1-\cos k)$ via Holstein-Primakoff).

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request
    No fields configured for Feature.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions