# ac-dias/wtb2kwant architecture

> Architecture diagram of the GitHub repository ac-dias/wtb2kwant, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-24). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ac-dias/wtb2kwant
- Repository: https://github.com/ac-dias/wtb2kwant

## Overview

wtb2kwant converts Wannier90-style orthogonal or WanTiBEXOS non-orthogonal Hamiltonians into a self-contained Kwant Python script. Users supply Hamiltonian data and, depending on the format, Wannier centres or orbital basis/structure; the CLI reads and assembles a model, optionally applies Löwdin orthogonalization, and generates the script. The generated runtime supports ribbon construction and band, transmission, spin-resolved transport, and I–V calculations. Source excerpts show conversion ownership and generated-runtime capabilities, but not every internal call between generated-script calculations, so those links are documented rather than inferred.

Main entry points: [`wtb2kwant/cli.py`](https://github.com/ac-dias/wtb2kwant/blob/main/wtb2kwant/cli.py) (CLI conversion), [`wtb2kwant/model.py`](https://github.com/ac-dias/wtb2kwant/blob/main/wtb2kwant/model.py) (Tight-binding model), [`wtb2kwant/codegen.py`](https://github.com/ac-dias/wtb2kwant/blob/main/wtb2kwant/codegen.py) (Script generation), [`wtb2kwant/lowdin.py`](https://github.com/ac-dias/wtb2kwant/blob/main/wtb2kwant/lowdin.py) (Löwdin transform)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_conversion["Input and conversion"]
  node_cli["CLI conversion<br/>[cli.py]"]
  node_ham_reader["Hamiltonian readers<br/>[readers.py]"]
  node_metadata_reader["Geometry readers<br/>[readers.py]"]
  node_generator["Script generation<br/>[codegen.py]"]
end

subgraph group_model["Model transforms"]
  node_wannier_model["Wannier assembly<br/>[model.py]"]
  node_nonorth_model["Nonorthogonal assembly<br/>[model.py]"]
  node_tb_model["Tight-binding model<br/>[model.py]"]
  node_lowdin["Löwdin transform<br/>[lowdin.py]"]
end

subgraph group_generated["Generated Kwant runtime"]
  node_generated_script["Self-contained script"]
  node_ribbons["Ribbon builders<br/>[codegen.py]"]
  node_band_calc["Band calculations<br/>[codegen.py]"]
  node_transport["Transmission<br/>[codegen.py]"]
  node_spin_transport["Spin transport<br/>[codegen.py]"]
  node_iv["I–V analysis<br/>[codegen.py]"]
end

node_user(("Researcher"))
node_kwant["Kwant"]

node_user -->|"runs conversion"| node_cli
node_cli -->|"reads Hamiltonian"| node_ham_reader
node_cli -->|"reads geometry"| node_metadata_reader
node_cli -->|"assembles Wannier"| node_wannier_model
node_cli -->|"assembles nonorthogonal"| node_nonorth_model
node_wannier_model -->|"returns model"| node_tb_model
node_nonorth_model -->|"returns model"| node_tb_model
node_cli -->|"optionally transforms"| node_lowdin
node_lowdin -->|"returns transformed"| node_tb_model
node_cli -->|"generates script"| node_generator
node_generator -->|"serializes model"| node_tb_model
node_generator -->|"writes script"| node_generated_script
node_user -->|"runs calculations"| node_generated_script
node_generated_script -->|"builds ribbons"| node_ribbons
node_generated_script -->|"computes bands"| node_band_calc
node_generated_script -->|"computes transmission"| node_transport
node_generated_script -->|"resolves spin"| node_spin_transport
node_generated_script -->|"computes current"| node_iv
node_transport -->|"uses transport engine"| node_kwant

click node_cli "https://github.com/ac-dias/wtb2kwant/blob/main/wtb2kwant/cli.py"
click node_ham_reader "https://github.com/ac-dias/wtb2kwant/blob/main/wtb2kwant/readers.py"
click node_metadata_reader "https://github.com/ac-dias/wtb2kwant/blob/main/wtb2kwant/readers.py"
click node_wannier_model "https://github.com/ac-dias/wtb2kwant/blob/main/wtb2kwant/model.py"
click node_nonorth_model "https://github.com/ac-dias/wtb2kwant/blob/main/wtb2kwant/model.py"
click node_tb_model "https://github.com/ac-dias/wtb2kwant/blob/main/wtb2kwant/model.py"
click node_lowdin "https://github.com/ac-dias/wtb2kwant/blob/main/wtb2kwant/lowdin.py"
click node_generator "https://github.com/ac-dias/wtb2kwant/blob/main/wtb2kwant/codegen.py"
click node_ribbons "https://github.com/ac-dias/wtb2kwant/blob/main/wtb2kwant/codegen.py"
click node_band_calc "https://github.com/ac-dias/wtb2kwant/blob/main/wtb2kwant/codegen.py"
click node_transport "https://github.com/ac-dias/wtb2kwant/blob/main/wtb2kwant/codegen.py"
click node_spin_transport "https://github.com/ac-dias/wtb2kwant/blob/main/wtb2kwant/codegen.py"
click node_iv "https://github.com/ac-dias/wtb2kwant/blob/main/wtb2kwant/codegen.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_cli,node_ham_reader,node_metadata_reader,node_generator toneBlue
class node_wannier_model,node_nonorth_model,node_tb_model,node_lowdin toneAmber
class node_generated_script,node_ribbons,node_band_calc,node_transport,node_spin_transport,node_iv toneMint
class node_user,node_kwant toneIndigo
```

## Components

### Input and conversion

- [CLI conversion](https://github.com/ac-dias/wtb2kwant/blob/main/wtb2kwant/cli.py): `wtb2kwant/cli.py`
- [Hamiltonian readers](https://github.com/ac-dias/wtb2kwant/blob/main/wtb2kwant/readers.py): `wtb2kwant/readers.py`
- [Geometry readers](https://github.com/ac-dias/wtb2kwant/blob/main/wtb2kwant/readers.py): `wtb2kwant/readers.py`
- [Script generation](https://github.com/ac-dias/wtb2kwant/blob/main/wtb2kwant/codegen.py): `wtb2kwant/codegen.py`

### Model transforms

- [Wannier assembly](https://github.com/ac-dias/wtb2kwant/blob/main/wtb2kwant/model.py): `wtb2kwant/model.py`
- [Nonorthogonal assembly](https://github.com/ac-dias/wtb2kwant/blob/main/wtb2kwant/model.py): `wtb2kwant/model.py`
- [Tight-binding model](https://github.com/ac-dias/wtb2kwant/blob/main/wtb2kwant/model.py): `wtb2kwant/model.py`
- [Löwdin transform](https://github.com/ac-dias/wtb2kwant/blob/main/wtb2kwant/lowdin.py): `wtb2kwant/lowdin.py`

### Generated Kwant runtime

- **Self-contained script**
- [Ribbon builders](https://github.com/ac-dias/wtb2kwant/blob/main/wtb2kwant/codegen.py): `wtb2kwant/codegen.py`
- [Band calculations](https://github.com/ac-dias/wtb2kwant/blob/main/wtb2kwant/codegen.py): `wtb2kwant/codegen.py`
- [Transmission](https://github.com/ac-dias/wtb2kwant/blob/main/wtb2kwant/codegen.py): `wtb2kwant/codegen.py`
- [Spin transport](https://github.com/ac-dias/wtb2kwant/blob/main/wtb2kwant/codegen.py): `wtb2kwant/codegen.py`
- [I–V analysis](https://github.com/ac-dias/wtb2kwant/blob/main/wtb2kwant/codegen.py): `wtb2kwant/codegen.py`

### Other components

- **Researcher**
- **Kwant**

## Connections

- Researcher → CLI conversion: runs conversion (evidence: `README.md`)
- CLI conversion → Hamiltonian readers: reads Hamiltonian (evidence: `wtb2kwant/cli.py`)
- CLI conversion → Geometry readers: reads geometry (evidence: `wtb2kwant/cli.py`)
- CLI conversion → Wannier assembly: assembles Wannier (evidence: `wtb2kwant/cli.py`)
- CLI conversion → Nonorthogonal assembly: assembles nonorthogonal (evidence: `wtb2kwant/cli.py`)
- Wannier assembly → Tight-binding model: returns model (evidence: `wtb2kwant/model.py`)
- Nonorthogonal assembly → Tight-binding model: returns model (evidence: `wtb2kwant/model.py`)
- CLI conversion → Löwdin transform: optionally transforms (evidence: `wtb2kwant/cli.py`)
- Löwdin transform → Tight-binding model: returns transformed (evidence: `wtb2kwant/lowdin.py`)
- CLI conversion → Script generation: generates script (evidence: `wtb2kwant/cli.py`)
- Script generation → Tight-binding model: serializes model (evidence: `wtb2kwant/codegen.py`)
- Script generation → Self-contained script: writes script
- Researcher → Self-contained script: runs calculations (evidence: `README.md`)
- Self-contained script → Ribbon builders: builds ribbons (evidence: `README.md`)
- Self-contained script → Band calculations: computes bands (evidence: `README.md`)
- Self-contained script → Transmission: computes transmission (evidence: `README.md`)
- Self-contained script → Spin transport: resolves spin (evidence: `README.md`)
- Self-contained script → I–V analysis: computes current (evidence: `README.md`)
- Transmission → Kwant: uses transport engine (evidence: `README.md`)
