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.0.tar.gz (24.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.0-py3-none-any.whl (26.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: realspace_tb-0.2.0.tar.gz
  • Upload date:
  • Size: 24.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.13

File hashes

Hashes for realspace_tb-0.2.0.tar.gz
Algorithm Hash digest
SHA256 1ea67001149d1c2f948929adc035c6fa32b90e8b1f9c0688a501cc6f60002375
MD5 26df95b1015c01c5ef9eee709eaaebba
BLAKE2b-256 8008545680e5828772275ba1ae88c34c263566023a0a05dd904975b43f28b12d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: realspace_tb-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 26.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.13

File hashes

Hashes for realspace_tb-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 19814dcc42d67eac5269ae9ad7712c63dedb3a3a03a27ceeb81556196a3c2af0
MD5 a616b6a8d51772c9abac5b5aef9d9bcc
BLAKE2b-256 b7c0886401383e58ea0315849407904f0b4fbc1bef887bcf38d2745a33a2ba66

See more details on using hashes here.

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