# vihanga-senarath/monte-carlo-neutron-slab-transport-energy-deposition architecture

> Architecture diagram of the GitHub repository vihanga-senarath/monte-carlo-neutron-slab-transport-energy-deposition, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-21). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/vihanga-senarath/monte-carlo-neutron-slab-transport-energy-deposition
- Repository: https://github.com/vihanga-senarath/monte-carlo-neutron-slab-transport-energy-deposition

## Overview

This is a C++ Monte Carlo prototype for 1D neutron transport through a slab. The workflow initializes histories, repeatedly samples free paths and resolves collisions until each neutron is absorbed, transmitted, or reflected, then tallies outcomes and absorbed energy by depth bin. It writes the deposition profile to CSV, which a Python script reads to plot. The transport routines are implemented in main.cpp; transport.hpp declares their types and interfaces. Empty I/O and physics files are omitted. The available excerpts do not show additional runtime subsystems.

Main entry points: [`main.cpp`](https://github.com/vihanga-senarath/monte-carlo-neutron-slab-transport-energy-deposition/blob/main/main.cpp) (History Loop), [`transport.hpp`](https://github.com/vihanga-senarath/monte-carlo-neutron-slab-transport-energy-deposition/blob/main/transport.hpp) (Transport Types), [`plot_deposit.py`](https://github.com/vihanga-senarath/monte-carlo-neutron-slab-transport-energy-deposition/blob/main/plot_deposit.py) (Profile Plotter)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_simulation["Simulation"]
  node_history_loop["History Loop<br/>[main.cpp]"]
  node_tallies["Outcome Tallies<br/>[main.cpp]"]
end

subgraph group_transport["Neutron Transport"]
  node_free_path["Free-Path Sampling<br/>[main.cpp]"]
  node_collision["Collision Branching<br/>[main.cpp]"]
  node_step["Transport Step<br/>[main.cpp]"]
  node_transport_api["Transport Types<br/>[transport.hpp]"]
end

subgraph group_analysis["Deposition Analysis"]
  node_csv["Deposit CSV<br/>[main.cpp]"]
  node_plotter["Profile Plotter<br/>[plot_deposit.py]"]
end

node_user(("User"))

node_user -->|"runs"| node_history_loop
node_history_loop -->|"advances histories"| node_step
node_step -->|"samples path"| node_free_path
node_step -->|"resolves collision"| node_collision
node_transport_api -->|"declares interface"| node_history_loop
node_history_loop -->|"counts outcomes"| node_tallies
node_history_loop -->|"writes bins"| node_csv
node_csv -->|"provides profile"| node_plotter

click node_history_loop "https://github.com/vihanga-senarath/monte-carlo-neutron-slab-transport-energy-deposition/blob/main/main.cpp"
click node_tallies "https://github.com/vihanga-senarath/monte-carlo-neutron-slab-transport-energy-deposition/blob/main/main.cpp"
click node_free_path "https://github.com/vihanga-senarath/monte-carlo-neutron-slab-transport-energy-deposition/blob/main/main.cpp"
click node_collision "https://github.com/vihanga-senarath/monte-carlo-neutron-slab-transport-energy-deposition/blob/main/main.cpp"
click node_step "https://github.com/vihanga-senarath/monte-carlo-neutron-slab-transport-energy-deposition/blob/main/main.cpp"
click node_transport_api "https://github.com/vihanga-senarath/monte-carlo-neutron-slab-transport-energy-deposition/blob/main/transport.hpp"
click node_csv "https://github.com/vihanga-senarath/monte-carlo-neutron-slab-transport-energy-deposition/blob/main/main.cpp"
click node_plotter "https://github.com/vihanga-senarath/monte-carlo-neutron-slab-transport-energy-deposition/blob/main/plot_deposit.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_history_loop,node_tallies,node_user toneBlue
class node_free_path,node_collision,node_step,node_transport_api toneAmber
class node_csv,node_plotter toneMint
```

## Components

### Simulation

- [History Loop](https://github.com/vihanga-senarath/monte-carlo-neutron-slab-transport-energy-deposition/blob/main/main.cpp): `main.cpp`
- [Outcome Tallies](https://github.com/vihanga-senarath/monte-carlo-neutron-slab-transport-energy-deposition/blob/main/main.cpp): `main.cpp`

### Neutron Transport

- [Free-Path Sampling](https://github.com/vihanga-senarath/monte-carlo-neutron-slab-transport-energy-deposition/blob/main/main.cpp): `main.cpp`
- [Collision Branching](https://github.com/vihanga-senarath/monte-carlo-neutron-slab-transport-energy-deposition/blob/main/main.cpp): `main.cpp`
- [Transport Step](https://github.com/vihanga-senarath/monte-carlo-neutron-slab-transport-energy-deposition/blob/main/main.cpp): `main.cpp`
- [Transport Types](https://github.com/vihanga-senarath/monte-carlo-neutron-slab-transport-energy-deposition/blob/main/transport.hpp): `transport.hpp`

### Deposition Analysis

- [Deposit CSV](https://github.com/vihanga-senarath/monte-carlo-neutron-slab-transport-energy-deposition/blob/main/main.cpp): `main.cpp`
- [Profile Plotter](https://github.com/vihanga-senarath/monte-carlo-neutron-slab-transport-energy-deposition/blob/main/plot_deposit.py): `plot_deposit.py`

### Other components

- **User**

## Connections

- User → History Loop: runs (evidence: `README.md`)
- History Loop → Transport Step: advances histories (evidence: `main.cpp`)
- Transport Step → Free-Path Sampling: samples path (evidence: `main.cpp`)
- Transport Step → Collision Branching: resolves collision (evidence: `main.cpp`)
- Transport Types → History Loop: declares interface (evidence: `main.cpp`)
- History Loop → Outcome Tallies: counts outcomes (evidence: `main.cpp`)
- History Loop → Deposit CSV: writes bins (evidence: `main.cpp`)
- Deposit CSV → Profile Plotter: provides profile (evidence: `plot_deposit.py`)
