Skip to main content

Real-space tight-binding simulations with time-dependent density matrix evolution

Project description

realspace-tb

Real-space tight-binding simulations with time-dependent density matrix evolution, primarily for studying orbital magnetism in graphene-like 2D systems.

realspace_tb solves the von Neumann equation for a density matrix on a tight-binding lattice and measures observables at each time step. The core module provides generic infrastructure (time integrator, abstract Hamiltonian/Observable, CPU/GPU backend). The orbitronics_2d submodule supplies concrete components for honeycomb-lattice simulations of orbital angular momentum from loop currents.

Documentation: API reference (pdoc)

Installation

pip install realspace-tb

For GPU acceleration (optional):

pip install "realspace-tb[gpu]"

Quick start

import numpy as np
import realspace_tb as tb
from realspace_tb import orbitronics_2d as o2d
from realspace_tb.orbitronics_2d import observables as obs

geom = o2d.HoneycombLatticeGeometry(Lx=20, Ly=10)

field = o2d.RampedACFieldAmplitude(
    E0=0.01, omega=3.0, T_ramp=5.0, direction=np.array([1.0, 0.0])
)

H = o2d.LinearFieldHamiltonianPeierls(geom, field)
rho = H.ground_state_density_matrix(fermi_level=0.0)

window = tb.MeasurementWindow(start_time=0.0, stride=10)
frame_obs = obs.LatticeFrameObservable(geom, hamiltonian=H, window=window)

solver = tb.RK4NeumannSolver()
solver.evolve(rho, H, dt=0.01, total_time=50.0, observables=[frame_obs])

o2d.save_simulation_animation(frame_obs, "result.gif", fps=15)

See examples/quickstart.ipynb for a runnable version and examples/custom_observable.ipynb for how to define your own observables.

Architecture

realspace_tb
  backend          -- NumPy/CuPy switch + precision control
  Hamiltonian      -- abstract base class: return sparse H(t)
  Observable       -- abstract base class: measure from rho(t)
  MeasurementWindow-- control when measurements happen
  RK4NeumannSolver -- RK4 time integrator (von Neumann + optional relaxation)

realspace_tb.orbitronics_2d
  HoneycombLatticeGeometry       -- honeycomb lattice with OBC/PBC
  LinearFieldHamiltonian         -- dipole-gauge E-field coupling
  LinearFieldHamiltonianPeierls  -- Peierls-gauge E-field coupling
  RampedACFieldAmplitude         -- ramped AC electric field E(t)
  observables.*                  -- OAM, density, currents, composite frame
  ohc, fourier_at_omega          -- orbital Hall conductivity analysis
  save_simulation_animation      -- render animated GIF/MP4
  show_simulation_frame          -- render a single snapshot

Core concepts

Backend. Call tb.backend.set_backend(use_gpu=False, precision="double") before constructing any objects. All Hamiltonians, observables, and arrays use the selected backend and precision. Do not change it mid-simulation.

Hamiltonian. Subclass Hamiltonian and implement at_time(t) returning a sparse matrix. Built-in implementations couple a honeycomb hopping matrix to a homogeneous electric field in either dipole gauge or Peierls gauge.

Observable. Subclass Observable and implement _compute(rho, t). The base class handles windowed/strided measurement and result accumulation. After evolve(), access results via obs.values and obs.measurement_times.

Solver. RK4NeumannSolver().evolve() integrates the (optionally damped) von Neumann equation in-place. The density matrix rho is modified directly — copy it beforehand if needed.

Provided observables

Observable Output shape Description
PlaquetteOAMObservable (frames, plaquettes) Orbital angular momentum per hexagonal plaquette from loop currents
OrbitalPolarizationObservable (frames, 2) Macroscopic orbital polarization vector
SiteDensityObservable (frames, sites) Diagonal of the density matrix
BondCurrentObservable (frames, bonds) Gauge-invariant nearest-neighbor bond currents
LatticeFrameObservable dict Composite: density + currents + OAM (for animation)

Common pitfalls

  • Set the backend before constructing anything. Objects read dtype/device settings at construction time.
  • Dipole gauge + PBC is unphysical. Use LinearFieldHamiltonianPeierls for periodic systems.
  • Pass the Hamiltonian to current-based observables when using Peierls gauge. Without it, the simple 2 Im(rho_ij) formula is not gauge-invariant.
  • ground_state_density_matrix() uses dense diagonalisation — O(N^3), practical up to a few thousand sites.
  • electron_mass=0.741 is the default effective mass in natural units (t_hop = 1, a = 1). Adjust if using different parameters.

Extending

Custom Hamiltonians, observables, geometries, and field amplitudes can be defined by subclassing the corresponding abstract base classes. See examples/custom_observable.ipynb and the API reference for details.

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

realspace_tb-0.2.1.tar.gz (25.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

realspace_tb-0.2.1-py3-none-any.whl (27.6 kB view details)

Uploaded Python 3

File details

Details for the file realspace_tb-0.2.1.tar.gz.

File metadata

  • Download URL: realspace_tb-0.2.1.tar.gz
  • Upload date:
  • Size: 25.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for realspace_tb-0.2.1.tar.gz
Algorithm Hash digest
SHA256 c3f60a657e92242843950a70d9ee0a2c03f32d3078defd24a155b7086c6f052e
MD5 3720094bed2e330666713ec47f1ad2e1
BLAKE2b-256 b02523a47f32d41cad6c5881f861fdd5b231d530a73dff0bf2c9b24ef953438e

See more details on using hashes here.

Provenance

The following attestation bundles were made for realspace_tb-0.2.1.tar.gz:

Publisher: publish.yml on Leonard-P/realspace-tb

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file realspace_tb-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: realspace_tb-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 27.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for realspace_tb-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 089ee10f9661202bd9080f75bcdd894e0a3205d1f3e88a3d1dd2cf189874325d
MD5 cb902cdf053c328263da8f664b203dc1
BLAKE2b-256 44c2443b33ea8bd278e5c79a39f4f8410527169265cffd973fcc1d289e8a4a8f

See more details on using hashes here.

Provenance

The following attestation bundles were made for realspace_tb-0.2.1-py3-none-any.whl:

Publisher: publish.yml on Leonard-P/realspace-tb

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page