# nuc-astro/winnet architecture

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

- Interactive diagram: https://gitdiagram.com/nuc-astro/winnet
- Repository: https://github.com/nuc-astro/winnet

## Overview

#### Purpose and Entry Points
WinNet is a compiled, single-zone nuclear reaction-network simulator. The Fortran executable is driven by `src/driver.f90`; runs are configured through parameter files in `par/`, with `makerun.py.example` providing the intended run-setup interface. Example scenarios pair parameters with trajectories, seeds, and networks under `data/Example_data/`.

#### Run Configuration and Initialization
Startup reads and validates run parameters, resolves input files, and creates global single-zone state. `src/readini.f90` and `src/parameter_class.f90` define parameter ingestion; `src/global_class.f90` and `src/single_zone_vars.f90` hold shared simulation state. The network is initialized from isotope/network and rate data by `src/network_init_module.f90`.

#### Nuclear Network and Rate Sources
The network represents nuclei and reactions, assembling rate contributions from multiple physical datasets. Core isotope bookkeeping is in `src/nucstuff_class.f90`; Reaclib, tabulated, beta-decay, alpha-decay, fission, and weak-rate implementations reside in `src/reaclib_rate_module.f90`, `src/tabulated_rate_module.f90`, and `src/fission_rate_module.f90`. Canonical input datasets are versioned in `data/Reaclib_18_9_20`, `data/winvne_v2.0.dat`, and fission/decay files under `data/`.

#### Thermodynamic and Neutrino Boundaries
The solver consumes prescribed hydrodynamic trajectories or expansion models and evolves thermodynamic coupling where configured. `src/hydro_trajectory.f90` reads trajectory-driven conditions, while `src/expansion_module.f90` supports expansion evolution. Equation-of-state calculations integrate the vendored Timmes implementation in `src/eostable_ls_timmes/`; neutrino flux and thermal losses are handled by `src/nuflux_class.f90` and `src/thermal_neutrinos/thermal_neutrino_module.f90`. These form clear boundaries between external astrophysical conditions and reaction-network evolution.

#### Evolution, Linear Algebra, and Physics Coupling
At each timestep, WinNet computes reaction flows, constructs the coupled abundance system/Jacobian, solves it implicitly, and updates heating and composition. `src/flow_module.f90` computes reaction flows; `src/jacobian_class.f90` constructs derivatives; `src/gear_module.f90` provides the stiff integration method; and `src/timestep_module.f90` controls advancement. `src/nuclear_heating.f90`, `src/screening_module.f90`, `src/detailed_balance.f90`, and `src/winnse_module.f90` add energy, plasma screening, reverse-rate, and NSE behavior.

#### Output and Analysis
Run-state persistence and scientific outputs are separated from core evolution. `src/hdf5_module.f90` is the structured-output boundary; `src/analysis.f90` produces derived diagnostics. Python readers and visualization/reporting tools consume these results through `bin/class_files/winnet_class.py`, `bin/movie_script/winnet_movie.py`, and `bin/summary_script/summarize.py`.

#### Runtime and Delivery
The core runtime is Fortran, with Python used for setup, conversion, post-processing, and batch operations. Optional numerical dependencies include vendored Quadpack/MINPACK code in `src/external_tools/` and a PARDISO integration boundary in `src/pardiso_class.f90`. Docker packaging is defined by `install/docker/Dockerfile`; GitHub Actions build/test, publish Docker images, and generate documentation via `.github/workflows/`.

Main entry points: [`src/gear_module.f90`](https://github.com/nuc-astro/winnet/blob/master/src/gear_module.f90) (Stiff evolution), [`src/readini.f90`](https://github.com/nuc-astro/winnet/blob/master/src/readini.f90) (Configuration & state), [`src/network_init_module.f90`](https://github.com/nuc-astro/winnet/blob/master/src/network_init_module.f90) (Network initialization), [`makerun.py.example`](https://github.com/nuc-astro/winnet/blob/master/makerun.py.example) (Run setup)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_inputs["Run Inputs"]
  node_setup["Run setup<br/>Python setup<br/>[makerun.py.example]"]
  node_parameters["Parameters<br/>run configuration<br/>[template.par]"]
  node_examples["Example scenarios<br/>scenario data<br/>[README.md]"]
  node_rate_data[("Rate datasets<br/>nuclear data")]
end

subgraph group_runtime["Fortran Runtime"]
  node_driver["Simulation driver<br/>Fortran entry point<br/>[driver.f90]"]
  node_initialization["Configuration &amp; state<br/>initialization<br/>[readini.f90]"]
  node_network_init["Network initialization<br/>network builder"]
  node_nuclear_network{{"Nuclear network<br/>nuclei and rates<br/>[nucstuff_class.f90]"}}
  node_flows["Reaction flows<br/>flow calculation<br/>[flow_module.f90]"]
  node_jacobian["Abundance Jacobian<br/>implicit system assembly<br/>[jacobian_class.f90]"]
  node_integrator["Stiff evolution<br/>Gear integrator<br/>[gear_module.f90]"]
end

subgraph group_physics["Physics Boundaries"]
  node_trajectory["Hydro trajectory<br/>thermodynamic input"]
  node_expansion["Expansion model<br/>thermodynamic evolution"]
  node_eos["Timmes EOS<br/>equation of state"]
  node_neutrinos["Neutrino physics<br/>flux and thermal losses<br/>[nuflux_class.f90]"]
  node_coupling["Physics coupling<br/>heating, screening, NSE"]
end

subgraph group_outputs["Output &amp; Analysis"]
  node_hdf5[("Structured results<br/>HDF5 output<br/>[hdf5_module.f90]")]
  node_analysis["Diagnostics<br/>Fortran analysis<br/>[analysis.f90]"]
  node_python_tools["Python post-processing<br/>readers and reports<br/>[winnet_class.py]"]
end

subgraph group_delivery["Delivery"]
  node_docker["Docker image<br/>container packaging"]
  node_ci["CI workflows<br/>build, publish, docs<br/>[run_tests.yml]"]
end

node_setup -->|"writes"| node_parameters
node_examples -.->|"provides templates"| node_setup
node_parameters -->|"read at startup"| node_initialization
node_driver -->|"starts"| node_initialization
node_initialization -->|"configures"| node_network_init
node_rate_data -->|"loads"| node_network_init
node_network_init -->|"builds"| node_nuclear_network
node_trajectory -->|"prescribes conditions"| node_integrator
node_expansion -->|"evolves conditions"| node_integrator
node_eos -->|"thermodynamics"| node_integrator
node_neutrinos -->|"losses and flux"| node_integrator
node_nuclear_network -->|"rates and nuclei"| node_flows
node_flows -->|"reaction derivatives"| node_jacobian
node_jacobian -->|"implicit system"| node_integrator
node_coupling -->|"heating and corrections"| node_integrator
node_integrator -->|"persists run state"| node_hdf5
node_integrator -->|"supplies state"| node_analysis
node_hdf5 -->|"read results"| node_python_tools
node_analysis -.->|"derived outputs"| node_python_tools
node_docker -.->|"packages runtime"| node_driver
node_ci -->|"builds and publishes"| node_docker

click node_setup "https://github.com/nuc-astro/winnet/blob/master/makerun.py.example"
click node_parameters "https://github.com/nuc-astro/winnet/blob/master/par/template.par"
click node_examples "https://github.com/nuc-astro/winnet/blob/master/data/Example_data/README.md"
click node_driver "https://github.com/nuc-astro/winnet/blob/master/src/driver.f90"
click node_initialization "https://github.com/nuc-astro/winnet/blob/master/src/readini.f90"
click node_network_init "https://github.com/nuc-astro/winnet/blob/master/src/network_init_module.f90"
click node_nuclear_network "https://github.com/nuc-astro/winnet/blob/master/src/nucstuff_class.f90"
click node_rate_data "https://github.com/nuc-astro/winnet/tree/master/data/Reaclib_18_9_20"
click node_trajectory "https://github.com/nuc-astro/winnet/blob/master/src/hydro_trajectory.f90"
click node_expansion "https://github.com/nuc-astro/winnet/blob/master/src/expansion_module.f90"
click node_eos "https://github.com/nuc-astro/winnet/tree/master/src/eostable_ls_timmes/README"
click node_neutrinos "https://github.com/nuc-astro/winnet/blob/master/src/nuflux_class.f90"
click node_flows "https://github.com/nuc-astro/winnet/blob/master/src/flow_module.f90"
click node_jacobian "https://github.com/nuc-astro/winnet/blob/master/src/jacobian_class.f90"
click node_integrator "https://github.com/nuc-astro/winnet/blob/master/src/gear_module.f90"
click node_coupling "https://github.com/nuc-astro/winnet/blob/master/src/nuclear_heating.f90"
click node_hdf5 "https://github.com/nuc-astro/winnet/blob/master/src/hdf5_module.f90"
click node_analysis "https://github.com/nuc-astro/winnet/blob/master/src/analysis.f90"
click node_python_tools "https://github.com/nuc-astro/winnet/blob/master/bin/class_files/winnet_class.py"
click node_docker "https://github.com/nuc-astro/winnet/tree/master/install/docker/Dockerfile"
click node_ci "https://github.com/nuc-astro/winnet/blob/master/.github/workflows/run_tests.yml"

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_setup,node_parameters,node_examples,node_rate_data toneBlue
class node_driver,node_initialization,node_network_init,node_nuclear_network,node_flows,node_jacobian,node_integrator toneAmber
class node_trajectory,node_expansion,node_eos,node_neutrinos,node_coupling toneMint
class node_hdf5,node_analysis,node_python_tools toneRose
class node_docker,node_ci toneIndigo
```

## Components

### Run Inputs

- [Run setup](https://github.com/nuc-astro/winnet/blob/master/makerun.py.example): Python setup · Creates configured run inputs. · `makerun.py.example`
- [Parameters](https://github.com/nuc-astro/winnet/blob/master/par/template.par): run configuration · `par/template.par`
- [Example scenarios](https://github.com/nuc-astro/winnet/blob/master/data/Example_data/README.md): scenario data · Parameters, trajectories, seeds, and networks. · `data/Example_data/README.md`
- [Rate datasets](https://github.com/nuc-astro/winnet/tree/master/data/Reaclib_18_9_20): nuclear data · Reaclib, weak-rate, fission, and decay inputs. · `data/Reaclib_18_9_20`

### Fortran Runtime

- [Simulation driver](https://github.com/nuc-astro/winnet/blob/master/src/driver.f90): Fortran entry point · `src/driver.f90`
- [Configuration & state](https://github.com/nuc-astro/winnet/blob/master/src/readini.f90): initialization · Reads parameters and creates single-zone shared state. · `src/readini.f90`
- [Network initialization](https://github.com/nuc-astro/winnet/blob/master/src/network_init_module.f90): network builder · Loads nuclei, reactions, and rate sources. · `src/network_init_module.f90`
- [Nuclear network](https://github.com/nuc-astro/winnet/blob/master/src/nucstuff_class.f90): nuclei and rates · Assembles reaction-rate contributions. · `src/nucstuff_class.f90`
- [Reaction flows](https://github.com/nuc-astro/winnet/blob/master/src/flow_module.f90): flow calculation · `src/flow_module.f90`
- [Abundance Jacobian](https://github.com/nuc-astro/winnet/blob/master/src/jacobian_class.f90): implicit system assembly · `src/jacobian_class.f90`
- [Stiff evolution](https://github.com/nuc-astro/winnet/blob/master/src/gear_module.f90): Gear integrator · Advances abundance and thermodynamic state. · `src/gear_module.f90`

### Physics Boundaries

- [Hydro trajectory](https://github.com/nuc-astro/winnet/blob/master/src/hydro_trajectory.f90): thermodynamic input · `src/hydro_trajectory.f90`
- [Expansion model](https://github.com/nuc-astro/winnet/blob/master/src/expansion_module.f90): thermodynamic evolution · `src/expansion_module.f90`
- [Timmes EOS](https://github.com/nuc-astro/winnet/tree/master/src/eostable_ls_timmes/README): equation of state · `src/eostable_ls_timmes/README`
- [Neutrino physics](https://github.com/nuc-astro/winnet/blob/master/src/nuflux_class.f90): flux and thermal losses · `src/nuflux_class.f90`
- [Physics coupling](https://github.com/nuc-astro/winnet/blob/master/src/nuclear_heating.f90): heating, screening, NSE · `src/nuclear_heating.f90`

### Output & Analysis

- [Structured results](https://github.com/nuc-astro/winnet/blob/master/src/hdf5_module.f90): HDF5 output · `src/hdf5_module.f90`
- [Diagnostics](https://github.com/nuc-astro/winnet/blob/master/src/analysis.f90): Fortran analysis · `src/analysis.f90`
- [Python post-processing](https://github.com/nuc-astro/winnet/blob/master/bin/class_files/winnet_class.py): readers and reports · Reads results for visualization and summaries. · `bin/class_files/winnet_class.py`

### Delivery

- [Docker image](https://github.com/nuc-astro/winnet/tree/master/install/docker/Dockerfile): container packaging · `install/docker/Dockerfile`
- [CI workflows](https://github.com/nuc-astro/winnet/blob/master/.github/workflows/run_tests.yml): build, publish, docs · `.github/workflows/run_tests.yml`

## Connections

- Run setup → Parameters: writes
- Example scenarios → Run setup: provides templates
- Parameters → Configuration & state: read at startup
- Simulation driver → Configuration & state: starts
- Configuration & state → Network initialization: configures
- Rate datasets → Network initialization: loads
- Network initialization → Nuclear network: builds
- Hydro trajectory → Stiff evolution: prescribes conditions
- Expansion model → Stiff evolution: evolves conditions
- Timmes EOS → Stiff evolution: thermodynamics
- Neutrino physics → Stiff evolution: losses and flux
- Nuclear network → Reaction flows: rates and nuclei
- Reaction flows → Abundance Jacobian: reaction derivatives
- Abundance Jacobian → Stiff evolution: implicit system
- Physics coupling → Stiff evolution: heating and corrections
- Stiff evolution → Structured results: persists run state
- Stiff evolution → Diagnostics: supplies state
- Structured results → Python post-processing: read results
- Diagnostics → Python post-processing: derived outputs
- Docker image → Simulation driver: packages runtime
- CI workflows → Docker image: builds and publishes
