# exoclime/helios architecture

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

- Interactive diagram: https://gitdiagram.com/exoclime/helios
- Repository: https://github.com/exoclime/helios

## Overview

1. **Repository purpose and top-level flow**  
   HELIOS is a GPU-accelerated 1D atmospheric radiative-transfer solver for exoplanets. The main scientific flow is: read planetary/stellar/atmospheric inputs, build or load opacity data, solve radiative-convective equilibrium on a vertical column, then write temperature profiles and emission spectra.

2. **Main application entry point**  
   `helios.py` is the primary run script and likely the orchestration layer. It sits above the `source/` package and coordinates parameter parsing, model setup, solver execution, convergence, and output generation.

3. **Core compute engine boundary**  
   `source/` contains the runtime engine for the model. This is where the physics and numerics live, separated from documentation, plotting, and preprocessing tools. The presence of `source/kernels.cu` indicates the expensive radiative-transfer and/or iteration work is offloaded to CUDA on the GPU.

4. **Radiative-transfer and atmosphere physics**  
   The core physics boundary is in `source/computation.py`, with supporting modules for constants, derived quantities, and host-side execution. The model is described by the README as hemispheric two-stream radiative transfer with non-isotropic scattering, radiative-convective equilibrium, and optional solid-surface handling.

5. **Atmospheric ingredients and parameter sources**  
   Several `source/*` modules provide model inputs and physical subcomponents:  
   - `species_database.py`, `planet_database.py`, `phys_const.py` define reference data and constants.  
   - `clouds.py`, `additional_heating.py`, `realtime_plotting.py` add optional physical or workflow features.  
   - `read.py` and `write.py` form the I/O boundary for loading inputs and producing outputs.  
   - `tools.py` and `host_functions.py` are utility and CPU-side helper layers.

6. **Opacity handling is its own subsystem**  
   HELIOS separates opacity generation and opacity use. The main solver consumes opacity tables, while the `ktable/` subtree generates or combines them. The README notes support for premixed tables, on-the-fly opacity mixing, correlated-k, and random overlap mixing, so opacity preparation is a distinct upstream stage from the atmosphere solve.

7. **`ktable/` preprocessing pipeline**  
   `ktable/ktable.py` is the entry script for k-distribution table generation. The `ktable/source_ktable/` package splits the task into smaller stages: building individual opacities, handling continuum and Rayleigh terms, parameter management, and combining species into final tables. Inputs and outputs are kept under `ktable/input/` and `ktable/param_ktable.dat`.

8. **Input data and configuration boundary**  
   The repo uses flat parameter files like `param.dat` and `input/species.dat` at the top level, plus package-specific input folders. `install_input_files.bash` installs the canonical input archive from Zenodo, which makes model data a required external asset rather than something generated inside the repository.

9. **Stellar spectrum tooling is separate from the atmosphere solver**  
   `star_tool/` is a preprocessing utility for creating stellar input spectra, with `star_tool/run.py` as its driver and `star_tool/functions.py` plus ASCII solar-spectrum data under `star_tool/input/`. This produces boundary-condition data for HELIOS rather than participating in the radiative-transfer solve itself.

10. **Visualization and analysis are downstream tools**  
   `plotting/plot_spectrum.py` and `plotting/plot_tp.py` are post-processing scripts for viewing output spectra and temperature-pressure profiles. They sit outside the solver path and consume generated results.

11. **Documentation and reproducibility assets**  
   `docs/` is a Sphinx documentation tree, with generated HTML already checked in under `docs/build/`. `supplementary/reproducing_Fig4_of_Malik2017/` contains a self-contained scientific reproduction bundle, including TEA chemistry outputs and analysis scripts, showing the repo’s emphasis on reproducible experiments.

12. **Practical architecture diagram takeaway**  
   A good diagram should show three main zones:  
   - preprocessing/data preparation (`install_input_files.bash`, `ktable/`, `star_tool/`),  
   - the GPU-based solver core (`helios.py`, `source/`, `source/kernels.cu`),  
   - and post-processing/docs (`plotting/`, `docs/`, `supplementary/`).  
   The key data flow is from input databases and opacity tables into the solver, then to temperature-profile and spectrum outputs.

Main entry points: [`helios.py`](https://github.com/exoclime/helios/blob/master/helios.py) (HELIOS run), [`source/computation.py`](https://github.com/exoclime/helios/blob/master/source/computation.py) (Computation), [`star_tool/run.py`](https://github.com/exoclime/helios/blob/master/star_tool/run.py) (Star tool), [`param.dat`](https://github.com/exoclime/helios/blob/master/param.dat) (Param files)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_group_preprocess["Preprocessing"]
  node_node_inputs["Param files<br/>configuration<br/>[param.dat]"]
  node_node_input_species["Species list<br/>input data<br/>[species.dat]"]
  node_node_install["Install data<br/>asset setup"]
  node_node_ktable_run["K-table driver<br/>opacity pipeline<br/>[ktable.py]"]
  node_node_ktable_build["Opacity build<br/>opacity stage"]
  node_node_ktable_terms["Continuum terms<br/>opacity stage<br/>[continuous.py]"]
  node_node_ktable_mix["Mixing stage<br/>opacity stage<br/>[combination.py]"]
  node_node_star_run["Star tool<br/>stellar prep<br/>[run.py]"]
  node_node_star_funcs["Star functions<br/>stellar prep<br/>[functions.py]"]
end

subgraph group_group_solver["Solver Core"]
  node_node_helios["HELIOS run<br/>orchestrator<br/>[helios.py]"]
  node_node_source_comp["Computation<br/>physics engine<br/>[computation.py]"]
  node_node_source_cuda["GPU kernels<br/>cuda compute<br/>[kernels.cu]"]
  node_node_source_io["I/O layer<br/>input-output<br/>[read.py]"]
  node_node_source_state["Reference data<br/>model data<br/>[phys_const.py]"]
  node_node_source_utils["Host tools<br/>utilities<br/>[tools.py]"]
  node_node_source_clouds["Clouds<br/>physics module<br/>[clouds.py]"]
  node_node_source_heating["Extra heating<br/>physics module"]
end

subgraph group_group_post["Post-processing"]
  node_node_plot_spectrum["Spectrum plot<br/>analysis<br/>[plot_spectrum.py]"]
  node_node_plot_tp["TP plot<br/>analysis<br/>[plot_tp.py]"]
  node_node_docs["Docs<br/>documentation<br/>[index.rst]"]
  node_node_supplementary["Reproduction bundle<br/>supplementary analysis"]
end

node_node_install -->|"installs"| node_node_inputs
node_node_inputs -->|"configures"| node_node_helios
node_node_input_species -->|"species"| node_node_helios
node_node_star_run -->|"stellar BC"| node_node_helios
node_node_star_run -->|"uses"| node_node_star_funcs
node_node_ktable_run -->|"starts"| node_node_ktable_build
node_node_ktable_build -->|"adds terms"| node_node_ktable_terms
node_node_ktable_terms -->|"feeds"| node_node_ktable_mix
node_node_ktable_mix -->|"opacity tables"| node_node_helios
node_node_helios -->|"loads/writes"| node_node_source_io
node_node_helios -->|"executes"| node_node_source_comp
node_node_source_comp -->|"offloads"| node_node_source_cuda
node_node_source_comp -->|"uses"| node_node_source_state
node_node_source_comp -->|"helpers"| node_node_source_utils
node_node_source_comp -->|"couples"| node_node_source_clouds
node_node_source_comp -->|"couples"| node_node_source_heating
node_node_plot_spectrum -->|"analyzes output"| node_node_helios
node_node_plot_tp -->|"analyzes output"| node_node_helios
node_node_docs -->|"documents"| node_node_helios
node_node_supplementary -->|"reproduces"| node_node_helios

click node_node_helios "https://github.com/exoclime/helios/blob/master/helios.py"
click node_node_source_comp "https://github.com/exoclime/helios/blob/master/source/computation.py"
click node_node_source_cuda "https://github.com/exoclime/helios/blob/master/source/kernels.cu"
click node_node_source_io "https://github.com/exoclime/helios/blob/master/source/read.py"
click node_node_source_state "https://github.com/exoclime/helios/blob/master/source/phys_const.py"
click node_node_source_utils "https://github.com/exoclime/helios/blob/master/source/tools.py"
click node_node_source_clouds "https://github.com/exoclime/helios/blob/master/source/clouds.py"
click node_node_source_heating "https://github.com/exoclime/helios/blob/master/source/additional_heating.py"
click node_node_inputs "https://github.com/exoclime/helios/blob/master/param.dat"
click node_node_input_species "https://github.com/exoclime/helios/blob/master/input/species.dat"
click node_node_install "https://github.com/exoclime/helios/blob/master/install_input_files.bash"
click node_node_ktable_run "https://github.com/exoclime/helios/blob/master/ktable/ktable.py"
click node_node_ktable_build "https://github.com/exoclime/helios/blob/master/ktable/source_ktable/build_individual_opacities.py"
click node_node_ktable_terms "https://github.com/exoclime/helios/blob/master/ktable/source_ktable/continuous.py"
click node_node_ktable_mix "https://github.com/exoclime/helios/blob/master/ktable/source_ktable/combination.py"
click node_node_star_run "https://github.com/exoclime/helios/blob/master/star_tool/run.py"
click node_node_star_funcs "https://github.com/exoclime/helios/blob/master/star_tool/functions.py"
click node_node_plot_spectrum "https://github.com/exoclime/helios/blob/master/plotting/plot_spectrum.py"
click node_node_plot_tp "https://github.com/exoclime/helios/blob/master/plotting/plot_tp.py"
click node_node_docs "https://github.com/exoclime/helios/blob/master/docs/index.rst"
click node_node_supplementary "https://github.com/exoclime/helios/tree/master/supplementary/reproducing_Fig4_of_Malik2017"

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_node_inputs,node_node_input_species,node_node_install,node_node_ktable_run,node_node_ktable_build,node_node_ktable_terms,node_node_ktable_mix,node_node_star_run,node_node_star_funcs toneBlue
class node_node_helios,node_node_source_comp,node_node_source_cuda,node_node_source_io,node_node_source_state,node_node_source_utils,node_node_source_clouds,node_node_source_heating toneAmber
class node_node_plot_spectrum,node_node_plot_tp,node_node_docs,node_node_supplementary toneMint
```

## Components

### Preprocessing

Input preparation, opacity generation, and stellar boundary-condition tooling.

- [Param files](https://github.com/exoclime/helios/blob/master/param.dat): configuration · Top-level runtime parameters and species configuration. · `param.dat`
- [Species list](https://github.com/exoclime/helios/blob/master/input/species.dat): input data · Canonical species definition list used by the model. · `input/species.dat`
- [Install data](https://github.com/exoclime/helios/blob/master/install_input_files.bash): asset setup · Bootstrap script for installing the required external input archive. · `install_input_files.bash`
- [K-table driver](https://github.com/exoclime/helios/blob/master/ktable/ktable.py): opacity pipeline · Entry point for generating k-distribution opacity tables. · `ktable/ktable.py`
- [Opacity build](https://github.com/exoclime/helios/blob/master/ktable/source_ktable/build_individual_opacities.py): opacity stage · Builds individual species opacities before mixing. · `ktable/source_ktable/build_individual_opacities.py`
- [Continuum terms](https://github.com/exoclime/helios/blob/master/ktable/source_ktable/continuous.py): opacity stage · Handles continuum and Rayleigh contributions in table generation. · `ktable/source_ktable/continuous.py`
- [Mixing stage](https://github.com/exoclime/helios/blob/master/ktable/source_ktable/combination.py): opacity stage · Combines species into final correlated-k or overlap tables. · `ktable/source_ktable/combination.py`
- [Star tool](https://github.com/exoclime/helios/blob/master/star_tool/run.py): stellar prep · Driver for producing stellar input spectra. · `star_tool/run.py`
- [Star functions](https://github.com/exoclime/helios/blob/master/star_tool/functions.py): stellar prep · Utility functions and solar-spectrum data used by the stellar preprocessing tool. · `star_tool/functions.py`

### Solver Core

Main GPU-accelerated radiative-convective atmosphere model.

- [HELIOS run](https://github.com/exoclime/helios/blob/master/helios.py): orchestrator · Primary entry script coordinating a full model run. · `helios.py`
- [Computation](https://github.com/exoclime/helios/blob/master/source/computation.py): physics engine · Host-side radiative-transfer and equilibrium computation logic. · `source/computation.py`
- [GPU kernels](https://github.com/exoclime/helios/blob/master/source/kernels.cu): cuda compute · CUDA implementation of the expensive radiative-transfer and iteration work. · `source/kernels.cu`
- [I/O layer](https://github.com/exoclime/helios/blob/master/source/read.py): input-output · Reads model inputs and writes solved profiles and spectra. · `source/read.py`
- [Reference data](https://github.com/exoclime/helios/blob/master/source/phys_const.py): model data · Constants, planetary databases, species data, and derived quantities used by the solver. · `source/phys_const.py`
- [Host tools](https://github.com/exoclime/helios/blob/master/source/tools.py): utilities · CPU-side helpers, optional physics, realtime plotting, and output formatting. · `source/tools.py`
- [Clouds](https://github.com/exoclime/helios/blob/master/source/clouds.py): physics module · Cloud and aerosol treatment used as an optional atmospheric ingredient. · `source/clouds.py`
- [Extra heating](https://github.com/exoclime/helios/blob/master/source/additional_heating.py): physics module · Additional heating terms coupled into the atmosphere solve. · `source/additional_heating.py`

### Post-processing

Plotting, documentation, and reproduction artifacts.

- [Spectrum plot](https://github.com/exoclime/helios/blob/master/plotting/plot_spectrum.py): analysis · Post-processing script for model spectra. · `plotting/plot_spectrum.py`
- [TP plot](https://github.com/exoclime/helios/blob/master/plotting/plot_tp.py): analysis · Post-processing script for temperature-pressure profiles. · `plotting/plot_tp.py`
- [Docs](https://github.com/exoclime/helios/blob/master/docs/index.rst): documentation · Sphinx documentation sources and built site. · `docs/index.rst`
- [Reproduction bundle](https://github.com/exoclime/helios/tree/master/supplementary/reproducing_Fig4_of_Malik2017): supplementary analysis · Self-contained materials for reproducing a published figure. · `supplementary/reproducing_Fig4_of_Malik2017`

## Connections

- Install data → Param files: installs · Sets up required input assets and configuration.
- Param files → HELIOS run: configures · Runtime parameters steer the main solver run.
- Species list → HELIOS run: species · Species definitions feed the atmosphere setup.
- Star tool → HELIOS run: stellar BC · Produces stellar spectra used as boundary conditions.
- Star tool → Star functions: uses · Driver relies on stellar preprocessing helpers.
- K-table driver → Opacity build: starts · Coordinates generation of individual opacities.
- Opacity build → Continuum terms: adds terms · Incorporates continuum and Rayleigh contributions.
- Continuum terms → Mixing stage: feeds · Prepared opacity terms are combined into final tables.
- Mixing stage → HELIOS run: opacity tables · Final k-tables are consumed by the atmosphere solver.
- HELIOS run → I/O layer: loads/writes · Main run reads inputs and emits solved outputs.
- HELIOS run → Computation: executes · Entry point delegates physics and numerics to computation.
- Computation → GPU kernels: offloads · Heavy radiative-transfer work is accelerated on the GPU.
- Computation → Reference data: uses · Computation depends on model constants and reference data.
- Computation → Host tools: helpers · Uses host-side utilities and optional runtime support.
- Computation → Clouds: couples · Cloud physics modifies radiative and atmospheric properties.
- Computation → Extra heating: couples · Extra heating terms are folded into the energy balance.
- Spectrum plot → HELIOS run: analyzes output · Consumes generated spectra for visualization.
- TP plot → HELIOS run: analyzes output · Consumes solved temperature profiles for visualization.
- Docs → HELIOS run: documents · Documentation describes the solver, parameters, and preprocessing.
- Reproduction bundle → HELIOS run: reproduces · Supplementary bundle demonstrates a scientific reproduction workflow.
