# skalhoef/grit architecture

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

- Interactive diagram: https://gitdiagram.com/skalhoef/grit
- Repository: https://github.com/skalhoef/grit

## Overview

GRIT is an MPI-parallel Fortran research application that consumes precomputed electronic, phononic, and electron–phonon data and computes finite-temperature thermodynamic properties. The documented workflow runs from upstream Quantum ESPRESSO/Wannier90/EPW data through GRIT’s task orchestration to text results and optional binary caches. Source excerpts were unavailable, so internal relationships are limited to capabilities and responsibilities stated in the README.

Main entry points: [`grit.f90`](https://github.com/skalhoef/grit/blob/main/grit.f90) (Task orchestration), [`modmain.f90`](https://github.com/skalhoef/grit/blob/main/modmain.f90) (Configuration and paths), [`utils.f90`](https://github.com/skalhoef/grit/blob/main/utils.f90) (Numerics and data I/O)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_upstream["Upstream data"]
  node_qe["Quantum ESPRESSO"]
  node_w90["Wannier90"]
  node_epw["EPW"]
  node_wanniertools["WannierTools"]
  node_fine_data[("Fine-grid datasets")]
end

subgraph group_runtime["GRIT runtime"]
  node_entry["Task orchestration<br/>[grit.f90]"]
  node_configuration["Configuration and paths<br/>[modmain.f90]"]
  node_numerics_io["Numerics and data I/O<br/>[utils.f90]"]
  node_mpi["MPI distribution<br/>[utils.f90]"]
end

subgraph group_physics["Physics tasks"]
  node_state_count["State counting<br/>[utils.f90]"]
  node_chemical_potential["Chemical potential<br/>[utils.f90]"]
  node_spectral["Green-function spectra<br/>[utils.f90]"]
  node_specific_heat["Specific heat<br/>[utils.f90]"]
  node_refinement["Grid refinement<br/>[modmain.f90]"]
end

subgraph group_products["Results and caches"]
  node_text_results["Text results"]
  node_binary_cache[("Binary caches")]
end

node_user(("Researcher"))

node_qe -->|"provides input"| node_w90
node_w90 -->|"provides input"| node_epw
node_qe -->|"exports Fermi energy and phonons"| node_fine_data
node_epw -->|"exports energies and couplings"| node_fine_data
node_wanniertools -.->|"exports energies"| node_fine_data
node_user -->|"sets modes and paths"| node_configuration
node_configuration -->|"configures tasks"| node_entry
node_entry -->|"orchestrates calculations"| node_numerics_io
node_entry -->|"distributes work"| node_mpi
node_fine_data -->|"loads datasets"| node_numerics_io
node_mpi -->|"loads local slices"| node_numerics_io
node_entry -->|"runs task"| node_state_count
node_entry -->|"runs task"| node_chemical_potential
node_entry -->|"runs task"| node_spectral
node_entry -->|"runs task"| node_specific_heat
node_configuration -->|"enables refinement"| node_refinement
node_entry -->|"writes results"| node_text_results
node_entry -.->|"creates optional caches"| node_binary_cache

click node_entry "https://github.com/skalhoef/grit/blob/main/grit.f90"
click node_configuration "https://github.com/skalhoef/grit/blob/main/modmain.f90"
click node_numerics_io "https://github.com/skalhoef/grit/blob/main/utils.f90"
click node_mpi "https://github.com/skalhoef/grit/blob/main/utils.f90"
click node_state_count "https://github.com/skalhoef/grit/blob/main/utils.f90"
click node_chemical_potential "https://github.com/skalhoef/grit/blob/main/utils.f90"
click node_spectral "https://github.com/skalhoef/grit/blob/main/utils.f90"
click node_specific_heat "https://github.com/skalhoef/grit/blob/main/utils.f90"
click node_refinement "https://github.com/skalhoef/grit/blob/main/modmain.f90"

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_qe,node_w90,node_epw,node_wanniertools,node_fine_data toneBlue
class node_entry,node_configuration,node_numerics_io,node_mpi toneAmber
class node_state_count,node_chemical_potential,node_spectral,node_specific_heat,node_refinement toneMint
class node_text_results,node_binary_cache toneRose
class node_user toneIndigo
```

## Components

### Upstream data

- **Quantum ESPRESSO**
- **Wannier90**
- **EPW**
- **WannierTools**
- **Fine-grid datasets**

### GRIT runtime

- [Task orchestration](https://github.com/skalhoef/grit/blob/main/grit.f90): `grit.f90`
- [Configuration and paths](https://github.com/skalhoef/grit/blob/main/modmain.f90): `modmain.f90`
- [Numerics and data I/O](https://github.com/skalhoef/grit/blob/main/utils.f90): `utils.f90`
- [MPI distribution](https://github.com/skalhoef/grit/blob/main/utils.f90): `utils.f90`

### Physics tasks

- [State counting](https://github.com/skalhoef/grit/blob/main/utils.f90): `utils.f90`
- [Chemical potential](https://github.com/skalhoef/grit/blob/main/utils.f90): `utils.f90`
- [Green-function spectra](https://github.com/skalhoef/grit/blob/main/utils.f90): `utils.f90`
- [Specific heat](https://github.com/skalhoef/grit/blob/main/utils.f90): `utils.f90`
- [Grid refinement](https://github.com/skalhoef/grit/blob/main/modmain.f90): `modmain.f90`

### Results and caches

- **Text results**
- **Binary caches**

### Other components

- **Researcher**

## Connections

- Quantum ESPRESSO → Wannier90: provides input
- Wannier90 → EPW: provides input
- Quantum ESPRESSO → Fine-grid datasets: exports Fermi energy and phonons
- EPW → Fine-grid datasets: exports energies and couplings
- WannierTools → Fine-grid datasets: exports energies
- Researcher → Configuration and paths: sets modes and paths
- Configuration and paths → Task orchestration: configures tasks
- Task orchestration → Numerics and data I/O: orchestrates calculations
- Task orchestration → MPI distribution: distributes work
- Fine-grid datasets → Numerics and data I/O: loads datasets
- MPI distribution → Numerics and data I/O: loads local slices
- Task orchestration → State counting: runs task
- Task orchestration → Chemical potential: runs task
- Task orchestration → Green-function spectra: runs task
- Task orchestration → Specific heat: runs task
- Configuration and paths → Grid refinement: enables refinement
- Task orchestration → Text results: writes results
- Task orchestration → Binary caches: creates optional caches
