# pmocz/latticeboltzmann-python architecture

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

- Interactive diagram: https://gitdiagram.com/pmocz/latticeboltzmann-python
- Repository: https://github.com/pmocz/latticeboltzmann-python

## Overview

This is a compact, single-file Lattice Boltzmann simulation of flow past a cylinder. Running the script initializes the lattice and obstacle, iterates streaming, fluid-variable calculation, collision, and boundary handling, then visualizes and saves the vorticity result. All implementation stages share one source file; the README documents the run command and simulation purpose.

Main entry points: [`latticeboltzmann.py`](https://github.com/pmocz/latticeboltzmann-python/blob/main/latticeboltzmann.py) (Simulation Loop)

## Diagram (Mermaid)

```mermaid
flowchart TD

node_user(("User"))
node_simulation["Simulation Loop"]
node_initialization["Lattice Setup"]
node_streaming["Particle Streaming"]
node_fluid["Fluid Variables"]
node_collision["Collision Update"]
node_boundary["Cylinder Boundary"]
node_visualization["Vorticity Display"]
node_output["Image Output"]

node_user -->|"runs script"| node_simulation
node_simulation -->|"initializes"| node_initialization
node_simulation -->|"streams particles"| node_streaming
node_simulation -->|"calculates variables"| node_fluid
node_simulation -->|"updates populations"| node_collision
node_simulation -->|"applies reflection"| node_boundary
node_simulation -->|"renders vorticity"| node_visualization
node_simulation -->|"saves figure"| node_output

click node_simulation "https://github.com/pmocz/latticeboltzmann-python/blob/main/latticeboltzmann.py"
click node_initialization "https://github.com/pmocz/latticeboltzmann-python/blob/main/latticeboltzmann.py"
click node_streaming "https://github.com/pmocz/latticeboltzmann-python/blob/main/latticeboltzmann.py"
click node_fluid "https://github.com/pmocz/latticeboltzmann-python/blob/main/latticeboltzmann.py"
click node_collision "https://github.com/pmocz/latticeboltzmann-python/blob/main/latticeboltzmann.py"
click node_boundary "https://github.com/pmocz/latticeboltzmann-python/blob/main/latticeboltzmann.py"
click node_visualization "https://github.com/pmocz/latticeboltzmann-python/blob/main/latticeboltzmann.py"
click node_output "https://github.com/pmocz/latticeboltzmann-python/blob/main/latticeboltzmann.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_user toneBlue
class node_simulation,node_initialization,node_streaming,node_fluid,node_collision,node_boundary,node_visualization,node_output toneTeal
```

## Components

### Other components

- **User**
- [Simulation Loop](https://github.com/pmocz/latticeboltzmann-python/blob/main/latticeboltzmann.py): `latticeboltzmann.py`
- [Lattice Setup](https://github.com/pmocz/latticeboltzmann-python/blob/main/latticeboltzmann.py): `latticeboltzmann.py`
- [Particle Streaming](https://github.com/pmocz/latticeboltzmann-python/blob/main/latticeboltzmann.py): `latticeboltzmann.py`
- [Fluid Variables](https://github.com/pmocz/latticeboltzmann-python/blob/main/latticeboltzmann.py): `latticeboltzmann.py`
- [Collision Update](https://github.com/pmocz/latticeboltzmann-python/blob/main/latticeboltzmann.py): `latticeboltzmann.py`
- [Cylinder Boundary](https://github.com/pmocz/latticeboltzmann-python/blob/main/latticeboltzmann.py): `latticeboltzmann.py`
- [Vorticity Display](https://github.com/pmocz/latticeboltzmann-python/blob/main/latticeboltzmann.py): `latticeboltzmann.py`
- [Image Output](https://github.com/pmocz/latticeboltzmann-python/blob/main/latticeboltzmann.py): `latticeboltzmann.py`

## Connections

- User → Simulation Loop: runs script (evidence: `README.md`)
- Simulation Loop → Lattice Setup: initializes (evidence: `latticeboltzmann.py`)
- Simulation Loop → Particle Streaming: streams particles (evidence: `latticeboltzmann.py`)
- Simulation Loop → Fluid Variables: calculates variables (evidence: `latticeboltzmann.py`)
- Simulation Loop → Collision Update: updates populations (evidence: `latticeboltzmann.py`)
- Simulation Loop → Cylinder Boundary: applies reflection (evidence: `latticeboltzmann.py`)
- Simulation Loop → Vorticity Display: renders vorticity (evidence: `latticeboltzmann.py`)
- Simulation Loop → Image Output: saves figure (evidence: `latticeboltzmann.py`)
