Skip to main content

hamop

Tests PyPI License

One tight-binding Hamiltonian, every observable, strictly consistent. Build a Hamiltonian once, as real-space blocks in an orthogonal or nonorthogonal basis, and compute its band structure, density of states, Kubo-Greenwood optical conductivity and Landauer (NEGF) transmission from the same matrices.

The point of the package is the consistency, not any single solver. When the optics of a model and its spectrum are computed by different codes with different conventions, they drift: a different gauge for the velocity operator, a different treatment of the overlap matrix, a different broadening, and suddenly the absorption edge no longer sits at the band gap. Here every observable diagonalizes the same Bloch matrices through the same canonically orthogonalized solver, and the Kubo velocity operator is built from the exact k-derivative of the same assembly, so spectral, optical and transport statements about one model cannot disagree with each other.

What it does

  • TightBindingModel: sites with any number of orbitals, directed hopping blocks with automatic Hermitian completion, optional overlap blocks (LCAO-style nonorthogonal bases), periodic in any dimension or finite. Assembles H(k), S(k) and their exact k-derivatives in the atomic gauge.
  • Spectrum (bands, dos, fermi_level, band_edges): band structures along arbitrary k-lists, Gaussian-broadened densities of states, chemical potential at a given filling by bisection, band edges and gap about a chemical potential.
  • Optics (sigma_optical): Kubo-Greenwood real sheet conductivity in units of e²/(4ℏ), with the nonorthogonal velocity correction v = dH/dk − (eₙ+eₘ)/2 dS/dk that makes the result exactly invariant under a shift of the energy zero.
  • Transport (sancho_rubio, transmission, transmission_direct): two-probe Landauer transmission with Sancho-Rubio lead surface Green functions and a recursive Green function sweep, nonorthogonal bases included, plus a dense direct-inversion reference implementation of the same quantity.
  • gen_eigh: generalized eigensolver with canonical orthogonalization (Szabo and Ostlund, Modern Quantum Chemistry, sec. 3.4.5), so mildly overcomplete overlaps cannot blow up the spectrum — the standard remedy used inside electronic-structure codes.

Dependencies: NumPy and SciPy. Nothing else.

Validation against closed forms

Every physical claim in the package is pinned by a test against an exact result, not a stored number:

  • the single-orbital chain reproduces E(k) = e₀ + 2t cos ka to machine precision, and its nonorthogonal variant reproduces E(k) = 2t cos ka / (1 + 2s cos ka);
  • the chain density of states matches 1/(π√(4t² − E²)) and integrates to the orbital count;
  • graphene's nearest-neighbour model gives Dirac-point closure at K exactly, ±3|t| at Γ exactly, and the universal optical sheet conductivity e²/(4ℏ) on the interband plateau (Kuzmenko et al., Phys. Rev. Lett. 100, 117401 (2008)) — which is also the absolute anchor for the package's conductivity unit;
  • the two-site molecule absorbs at exactly 2|t| with the hand-derived velocity matrix element |M| = |a t|;
  • σ(ω) is invariant to 10⁻¹⁰ under H → H + cS with μ → μ + c, which pins the nonorthogonal velocity term;
  • the chain's lead surface Green function matches its closed form (E − i√(4t² − E²))/(2t²); a pristine chain transmits exactly one channel inside the band and nothing outside; two decoupled chains transmit two; an on-site impurity ε reproduces T = (4t² − E²)/((4t² − E²) + ε²);
  • the recursive Green function sweep agrees with dense direct inversion to machine precision, disorder and overlap included.

Run them yourself: pip install -e .[test] then pytest.

Install and use

pip install hamop
import numpy as np
from hamop import graphene, bands, dos, sigma_optical

g = graphene(t=-2.7, a=2.46)          # eV, Angstrom
omega = np.linspace(0.5, 2.0, 60)
sigma = sigma_optical(g, omega, mu=0.0, mesh=120, eta=0.12)
# sigma is ~1.0 on the plateau: the universal e^2/(4 hbar)

Building your own model:

from hamop import TightBindingModel, band_edges

m = TightBindingModel(positions=[[0.0], [0.7]], norb=1, cell=[[2.0]])
m.add_hop(0, 1, (0,), [[-1.0]])       # intra-cell bond
m.add_hop(1, 0, (1,), [[-0.6]])       # inter-cell bond
print(band_edges(m, mu=0.0, mesh=2001))   # the SSH gap, 2|t1 - t2|

Conventions, stated once: energies in eV, positions in Angstrom, k in 1/Angstrom, Cartesian. Each directed hopping block is added once and its Hermitian partner is implied. Optical conductivity is the real sheet conductivity in units of e²/(4ℏ) with spin degeneracy as an explicit factor (default 2). The velocity operator uses the standard atomistic position gauge (position operator diagonal at the sites); the intra-atomic dipole contribution is neglected, the common approximation in tight-binding optics.

Relation to existing tools

Excellent tools cover parts of this space: PythTB and pybinding build tight-binding models and their spectra, and Kwant is the standard for quantum transport. hamop does not replace any of them, and for their core use cases they are more capable. Its niche is the combination they leave open: nonorthogonal (LCAO-style) overlap matrices as first-class citizens across all observables, optics and transport computed from the same Bloch assembly as the spectrum so the three can never disagree, and a deliberately small NumPy/SciPy-only core validated line by line against closed forms -- the shape of engine an LCAO electronic-structure pipeline exports its Hamiltonians into.

Status

v0.1.0 (alpha). Implemented and tested: the model container with exact k-derivatives, canonical-orthogonalization eigensolver, band structures, densities of states, filling-resolved chemical potentials, band edges, Kubo-Greenwood optical conductivity for periodic and finite systems, Sancho-Rubio surface Green functions, and recursive plus direct-inversion Landauer transmission.

Not yet implemented, stated plainly: k-space symmetry reduction (grids are full Monkhorst-Pack), Lorentzian and adaptive broadenings, the Drude (intraband) term of the conductivity, spin-orbit-coupled blocks as a first-class convention (complex blocks work, but no helper), Hall/off-diagonal conductivity tensors, and interaction self-energies in the transport module. Sparse or very large models are out of scope for now: matrices are dense.

Where it comes from

Methodological basis:

"Learning the quantum Hamiltonian of defective monolayer MoS2 reveals collective vacancy brightness decoupled from defect count"; code for the paper: https://github.com/Tanvir-Mahmud-Mahim/mos2-vacancy-optics

That study computes the optics, the electronic structure and the transport of vacancy-disordered MoS2 supercells from one density-functional Hamiltonian, so that a defect configuration's optical and electronic signatures are strictly consistent — and its conclusions depend on that consistency. This package is the general-purpose engine distilled from that pipeline: the same observables for any Hamiltonian a user supplies, with the material-specific machinery (DFT extraction, machine-learned Hamiltonians, MoS2 structures) left in the paper repository.

Support and governance

The package is written and maintained by Tanvir Mahmud Mahim (Department of Electrical and Electronic Engineering, BRAC University), who reviews every change and takes the final decision on scope and releases. There is no separate governance body; design questions are discussed in the open in issues and pull requests, and the standing rule of CONTRIBUTING.md binds the maintainer exactly as it binds contributors: a change that touches physics arrives with a test, and a constant arrives with its source.

Support runs through the issue tracker at https://github.com/TaN-MM-Org/hamop/issues. Usage questions are welcome there alongside bug reports; a docstring that left a unit or a sign convention unclear is treated as a documentation bug, not as user error. The maintainer aims to respond within a week.

While the version is below 1.0 the API may still move between minor versions; such changes are called out in the release notes. The limitations named under Status are deliberate scope, recorded there precisely so that a user can tell a designed-out feature from an oversight.

License

Apache-2.0 (see LICENSE). Citation metadata is in CITATION.cff.

Download files

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

Source Distribution

hamop-0.1.1.tar.gz (25.9 kB view details)

Uploaded Source

Built Distribution

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

hamop-0.1.1-py3-none-any.whl (21.5 kB view details)

Uploaded Python 3

File details

Details for the file hamop-0.1.1.tar.gz.

File metadata

  • Download URL: hamop-0.1.1.tar.gz
  • Upload date:
  • Size: 25.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for hamop-0.1.1.tar.gz
Algorithm Hash digest
SHA256 9d9229cca5ca70e07792a8d6253da5cef5532ef7a36f0fb9ef38882d84aa084c
MD5 9af1eae22dc283b8f11c55535b26a86f
BLAKE2b-256 b1481b2abff6d08b783069c93068e529a637b700d928cf4e5c309764c227b566

See more details on using hashes here.

Provenance

The following attestation bundles were made for hamop-0.1.1.tar.gz:

Publisher: publish.yml on TaN-MM-Org/hamop

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

File details

Details for the file hamop-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: hamop-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 21.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for hamop-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c3f69a274a7bb53204c8f9c8eb8c23bc9628819680562ededa886a1a61fc90cb
MD5 053d063dc68d77a0f90cbac22fbb399a
BLAKE2b-256 b04d4f90087a57f4d7d934a0e1adcb20a74d461bb781b35b07cae331309555ea

See more details on using hashes here.

Provenance

The following attestation bundles were made for hamop-0.1.1-py3-none-any.whl:

Publisher: publish.yml on TaN-MM-Org/hamop

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

Release history Release notifications | RSS feed

0.5.0

2 files

0.4.0

2 files

0.3.0

2 files

0.2.0

2 files

This release

0.1.1 This release

2 files

0.1.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page