# boyuanliuoptics/dos-calculation architecture

> Architecture diagram of the GitHub repository boyuanliuoptics/dos-calculation, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-07-16). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/boyuanliuoptics/dos-calculation
- Repository: https://github.com/boyuanliuoptics/dos-calculation

## Overview

#### Purpose and Entry Points
This repository computes photonic-crystal density of states (DOS) from sampled band structures. It provides two MATLAB workflows: Generalized Gilat–Raubenheimer (GGR), which uses frequencies plus group velocities, and tetrahedron (Tr), which uses sampled frequencies and k-space positions. Primary entry points are `DOS_GGR.m`, `DOS_Tr.m`, and the MPB preprocessing launcher `dompb.sh`.

#### Band-Data Generation and Normalization
The optional upstream simulation path runs MIT Photonic-Bands (MPB) against the example structure definition in `3Dexample.ctl`. `dompb.sh` is the integration boundary: it invokes MPB and converts its output into text files accepted by the MATLAB DOS programs. MPB is external infrastructure; the repository is not itself a band solver.

Relevant paths:
- `dompb.sh`
- `3Dexample.ctl`

#### GGR DOS Pipeline
`DOS_GGR.m` is the higher-accuracy DOS path. It consumes a flat, line-aligned frequency stream and corresponding 3-component group velocities. Each frequency/velocity row pair represents the same k-point and band; therefore input ordering is a critical data-integrity boundary. The algorithm evaluates DOS from local linearized band behavior, requiring both data sources.

Relevant path:
- `DOS_GGR.m`

#### Tetrahedron DOS Pipeline
`DOS_Tr.m` computes DOS from gridded k-point positions and per-point band frequencies, without velocities. Its input couples the first three columns (reciprocal-space coordinates) with following band-frequency columns. This is the alternative when velocity data is unavailable, with lower relative accuracy than GGR.

Relevant path:
- `DOS_Tr.m`

#### Input and Output Contract
The MATLAB stages expect working-directory data files generated by `dompb.sh` or reshaped from another band-computing package: `frequency_GGR.txt` plus `velocity_GGR.txt` for GGR, and `frequency_Tr.txt` for tetrahedra. `band.txt` is optional plotting-oriented band-path data. Both solvers produce DOS data and a corresponding plot; file naming and current-directory placement form the main operational boundary.

Relevant paths:
- `DOS_GGR.m`
- `DOS_Tr.m`
- `dompb.sh`

#### Python Exploration Path
A separate Python area appears to provide notebook-oriented experimentation and reusable material/integration utilities, rather than replacing the documented MATLAB production flow. Its likely entry point is the example notebook; consult its local README for its specific execution model.

Relevant paths:
- `python/3Dexample.ipynb`
- `python/integrators.py`
- `python/material.py`
- `python/README.md`

#### Runtime Boundaries
The main workflow requires Linux shell execution for `dompb.sh`, MPB for band and velocity generation, and MATLAB for DOS calculation and plotting. External solvers may substitute for MPB only if they emit data matching the repository’s ordering and coordinate conventions.

Main entry points: [`dompb.sh`](https://github.com/boyuanliuoptics/dos-calculation/blob/master/dompb.sh) (MPB launcher), [`python/3Dexample.ipynb`](https://github.com/boyuanliuoptics/dos-calculation/blob/master/python/3Dexample.ipynb) (3D example notebook), [`DOS_GGR.m`](https://github.com/boyuanliuoptics/dos-calculation/blob/master/DOS_GGR.m) (GGR DOS), [`DOS_Tr.m`](https://github.com/boyuanliuoptics/dos-calculation/blob/master/DOS_Tr.m) (Tetrahedron DOS)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_mpb["MPB preprocessing"]
  node_structure["3D example structure<br/>MPB control<br/>[3Dexample.ctl]"]
  node_launcher["MPB launcher<br/>shell entry point<br/>[dompb.sh]"]
  node_mpb_runtime{{"MIT Photonic Bands<br/>external solver"}}
end

subgraph group_matlab["MATLAB DOS workflows"]
  node_ggr_frequency["GGR frequencies<br/>working-directory data"]
  node_ggr_velocity["GGR velocities<br/>working-directory data"]
  node_ggr_solver["GGR DOS<br/>MATLAB entry point<br/>[DOS_GGR.m]"]
  node_tr_frequency["Tetrahedron frequencies<br/>working-directory data"]
  node_tr_solver["Tetrahedron DOS<br/>MATLAB entry point<br/>[DOS_Tr.m]"]
  node_dos_output["DOS data and plot<br/>solver output"]
end

subgraph group_python["Python exploration"]
  node_notebook["3D example notebook<br/>Python entry point<br/>[3Dexample.ipynb]"]
  node_integrators["Integration utilities<br/>Python module<br/>[integrators.py]"]
  node_materials["Material utilities<br/>Python module<br/>[material.py]"]
  node_python_readme["Python README<br/>local guide<br/>[README.md]"]
end

node_band_path["Band-path data<br/>optional data"]
node_external_source{{"Alternative band solver<br/>external producer"}}

node_structure -->|"input structure"| node_launcher
node_launcher -->|"invokes"| node_mpb_runtime
node_mpb_runtime -->|"band output"| node_launcher
node_launcher -->|"writes"| node_ggr_frequency
node_launcher -->|"writes"| node_ggr_velocity
node_launcher -->|"writes"| node_tr_frequency
node_ggr_frequency -->|"aligned rows"| node_ggr_solver
node_ggr_velocity -->|"aligned rows"| node_ggr_solver
node_tr_frequency -->|"coordinates + bands"| node_tr_solver
node_ggr_solver -->|"writes"| node_dos_output
node_tr_solver -->|"writes"| node_dos_output
node_external_source -.->|"compatible export"| node_ggr_frequency
node_external_source -.->|"compatible export"| node_ggr_velocity
node_external_source -.->|"compatible export"| node_tr_frequency
node_notebook -->|"uses"| node_integrators
node_notebook -->|"uses"| node_materials
node_python_readme -.->|"guides"| node_notebook

click node_structure "https://github.com/boyuanliuoptics/dos-calculation/blob/master/3Dexample.ctl"
click node_launcher "https://github.com/boyuanliuoptics/dos-calculation/blob/master/dompb.sh"
click node_ggr_solver "https://github.com/boyuanliuoptics/dos-calculation/blob/master/DOS_GGR.m"
click node_tr_solver "https://github.com/boyuanliuoptics/dos-calculation/blob/master/DOS_Tr.m"
click node_notebook "https://github.com/boyuanliuoptics/dos-calculation/blob/master/python/3Dexample.ipynb"
click node_integrators "https://github.com/boyuanliuoptics/dos-calculation/blob/master/python/integrators.py"
click node_materials "https://github.com/boyuanliuoptics/dos-calculation/blob/master/python/material.py"
click node_python_readme "https://github.com/boyuanliuoptics/dos-calculation/blob/master/python/README.md"

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_structure,node_launcher,node_mpb_runtime toneBlue
class node_ggr_frequency,node_ggr_velocity,node_ggr_solver,node_tr_frequency,node_tr_solver,node_dos_output toneAmber
class node_notebook,node_integrators,node_materials,node_python_readme toneMint
class node_band_path,node_external_source toneNeutral
```

## Components

### MPB preprocessing

Optional upstream band-data generation.

- [3D example structure](https://github.com/boyuanliuoptics/dos-calculation/blob/master/3Dexample.ctl): MPB control · `3Dexample.ctl`
- [MPB launcher](https://github.com/boyuanliuoptics/dos-calculation/blob/master/dompb.sh): shell entry point · Runs MPB and normalizes output text files. · `dompb.sh`
- **MIT Photonic Bands**: external solver · External band and velocity generator.

### MATLAB DOS workflows

Production DOS calculation paths.

- **GGR frequencies**: working-directory data · Flat frequency stream aligned with velocity rows.
- **GGR velocities**: working-directory data · Three-component velocities aligned to frequency rows.
- [GGR DOS](https://github.com/boyuanliuoptics/dos-calculation/blob/master/DOS_GGR.m): MATLAB entry point · Higher-accuracy local-linearized DOS calculation. · `DOS_GGR.m`
- **Tetrahedron frequencies**: working-directory data · k-space coordinates followed by band frequencies.
- [Tetrahedron DOS](https://github.com/boyuanliuoptics/dos-calculation/blob/master/DOS_Tr.m): MATLAB entry point · DOS calculation without group velocities. · `DOS_Tr.m`
- **DOS data and plot**: solver output · Each MATLAB solver writes DOS results and a plot.

### Python exploration

Notebook-oriented experimental utilities.

- [3D example notebook](https://github.com/boyuanliuoptics/dos-calculation/blob/master/python/3Dexample.ipynb): Python entry point · `python/3Dexample.ipynb`
- [Integration utilities](https://github.com/boyuanliuoptics/dos-calculation/blob/master/python/integrators.py): Python module · `python/integrators.py`
- [Material utilities](https://github.com/boyuanliuoptics/dos-calculation/blob/master/python/material.py): Python module · `python/material.py`
- [Python README](https://github.com/boyuanliuoptics/dos-calculation/blob/master/python/README.md): local guide · Documents the Python execution model. · `python/README.md`

### Other components

- **Band-path data**: optional data · Optional plotting-oriented band data.
- **Alternative band solver**: external producer · Must preserve required ordering and coordinate conventions.

## Connections

- 3D example structure → MPB launcher: input structure
- MPB launcher → MIT Photonic Bands: invokes
- MIT Photonic Bands → MPB launcher: band output
- MPB launcher → GGR frequencies: writes
- MPB launcher → GGR velocities: writes
- MPB launcher → Tetrahedron frequencies: writes
- GGR frequencies → GGR DOS: aligned rows
- GGR velocities → GGR DOS: aligned rows
- Tetrahedron frequencies → Tetrahedron DOS: coordinates + bands
- GGR DOS → DOS data and plot: writes
- Tetrahedron DOS → DOS data and plot: writes
- Alternative band solver → GGR frequencies: compatible export
- Alternative band solver → GGR velocities: compatible export
- Alternative band solver → Tetrahedron frequencies: compatible export
- 3D example notebook → Integration utilities: uses
- 3D example notebook → Material utilities: uses
- Python README → 3D example notebook: guides
