# lunnichi/lga architecture

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

- Interactive diagram: https://gitdiagram.com/lunnichi/lga
- Repository: https://github.com/lunnichi/lga

## Overview

This C project simulates two-dimensional flow on a hexagonal FHP lattice. The principal workflow initializes collision rules and a grid containing a cylinder, then repeats collision and streaming steps; streaming applies boundary behavior and supplies inlet particles. The program periodically writes PPM frames and, at completion, reports average density and saves the final grid. Binary loading is also documented as a capability, though the sampled main program does not invoke it. Edges reflect calls visible in the excerpts or capabilities stated in the README.

Main entry points: [`main.c`](https://github.com/lunnichi/lga/blob/main/main.c) (Simulation Runner), [`physics.c`](https://github.com/lunnichi/lga/blob/main/physics.c) (Collision Rules), [`io.c`](https://github.com/lunnichi/lga/blob/main/io.c) (PPM Frames)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_control["Simulation Control"]
  node_runner["Simulation Runner<br/>[main.c]"]
  node_cell_model["Cell Model<br/>[lga.h]"]
end

subgraph group_physics["Lattice Physics"]
  node_collision_rules["Collision Rules<br/>[physics.c]"]
  node_grid_init["Grid and Cylinder<br/>[physics.c]"]
  node_collision["Collision Phase<br/>[physics.c]"]
  node_streaming["Streaming and Boundaries<br/>[physics.c]"]
end

subgraph group_io["Output and Analysis"]
  node_ppm["PPM Frames<br/>[io.c]"]
  node_density["Density Analysis<br/>[io.c]"]
  node_binary_save["Binary Save<br/>[io.c]"]
  node_binary_load["Binary Load<br/>[io.c]"]
end

node_user(("User"))

node_user -->|"runs"| node_runner
node_runner -->|"initializes"| node_collision_rules
node_runner -->|"initializes"| node_grid_init
node_runner -->|"calls"| node_collision
node_runner -->|"calls"| node_streaming
node_runner -->|"saves frames"| node_ppm
node_runner -->|"calculates"| node_density
node_runner -->|"saves state"| node_binary_save
node_collision_rules -->|"provides lookup"| node_collision
node_runner -.->|"can load"| node_binary_load

click node_runner "https://github.com/lunnichi/lga/blob/main/main.c"
click node_cell_model "https://github.com/lunnichi/lga/blob/main/lga.h"
click node_collision_rules "https://github.com/lunnichi/lga/blob/main/physics.c"
click node_grid_init "https://github.com/lunnichi/lga/blob/main/physics.c"
click node_collision "https://github.com/lunnichi/lga/blob/main/physics.c"
click node_streaming "https://github.com/lunnichi/lga/blob/main/physics.c"
click node_ppm "https://github.com/lunnichi/lga/blob/main/io.c"
click node_density "https://github.com/lunnichi/lga/blob/main/io.c"
click node_binary_save "https://github.com/lunnichi/lga/blob/main/io.c"
click node_binary_load "https://github.com/lunnichi/lga/blob/main/io.c"

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_runner,node_cell_model,node_user toneBlue
class node_collision_rules,node_grid_init,node_collision,node_streaming toneAmber
class node_ppm,node_density,node_binary_save,node_binary_load toneMint
```

## Components

### Simulation Control

- [Simulation Runner](https://github.com/lunnichi/lga/blob/main/main.c): `main.c`
- [Cell Model](https://github.com/lunnichi/lga/blob/main/lga.h): `lga.h`

### Lattice Physics

- [Collision Rules](https://github.com/lunnichi/lga/blob/main/physics.c): `physics.c`
- [Grid and Cylinder](https://github.com/lunnichi/lga/blob/main/physics.c): `physics.c`
- [Collision Phase](https://github.com/lunnichi/lga/blob/main/physics.c): `physics.c`
- [Streaming and Boundaries](https://github.com/lunnichi/lga/blob/main/physics.c): `physics.c`

### Output and Analysis

- [PPM Frames](https://github.com/lunnichi/lga/blob/main/io.c): `io.c`
- [Density Analysis](https://github.com/lunnichi/lga/blob/main/io.c): `io.c`
- [Binary Save](https://github.com/lunnichi/lga/blob/main/io.c): `io.c`
- [Binary Load](https://github.com/lunnichi/lga/blob/main/io.c): `io.c`

### Other components

- **User**

## Connections

- User → Simulation Runner: runs (evidence: `README.md`)
- Simulation Runner → Collision Rules: initializes (evidence: `main.c`)
- Simulation Runner → Grid and Cylinder: initializes (evidence: `main.c`)
- Simulation Runner → Collision Phase: calls (evidence: `main.c`)
- Simulation Runner → Streaming and Boundaries: calls (evidence: `main.c`)
- Simulation Runner → PPM Frames: saves frames (evidence: `main.c`)
- Simulation Runner → Density Analysis: calculates (evidence: `main.c`)
- Simulation Runner → Binary Save: saves state (evidence: `main.c`)
- Collision Rules → Collision Phase: provides lookup (evidence: `physics.c`)
- Simulation Runner → Binary Load: can load (evidence: `README.md`)
