# dynaclim/spiroid architecture

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

- Interactive diagram: https://gitdiagram.com/dynaclim/spiroid
- Repository: https://github.com/dynaclim/spiroid

## Overview

Spiroid simulates the rotational and orbital evolution of a star–planet system. The user workflow is to generate JSON configuration cases, run the simulator on one case or a batch, then inspect or compare JSONL results with plotting tools. The runtime model includes stellar evolution, planetary and stellar state, orbital physics, and optional relativistic, magnetic, wind, and tidal effects. Edges reflect README statements and the supplied source index; unsampled implementation details and unverified runtime links are omitted.

Main entry points: [`src/universe/physics.rs`](https://github.com/dynaclim/spiroid/blob/main/src/universe/physics.rs) (Orbital physics), [`scripts/plotter.py`](https://github.com/dynaclim/spiroid/blob/main/scripts/plotter.py) (Plotter), [`src/universe.rs`](https://github.com/dynaclim/spiroid/blob/main/src/universe.rs) (Evolution integrator), [`src/universe/particles.rs`](https://github.com/dynaclim/spiroid/blob/main/src/universe/particles.rs) (Particle models)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_workflow["User workflow"]
  node_case_setup["Case generator<br/>[setup.py]"]
  node_case_config["Config builder<br/>[configmaker.py]"]
  node_config_model["Config model<br/>[config.py]"]
end

subgraph group_runtime["Simulation runtime"]
  node_cli["Simulator CLI<br/>[main.rs]"]
  node_integrator["Evolution integrator<br/>[universe.rs]"]
  node_physics["Orbital physics<br/>[physics.rs]"]
end

subgraph group_bodies["System state"]
  node_particle_model["Particle models<br/>[particles.rs]"]
  node_star["Star evolution<br/>[star.rs]"]
  node_planet["Planet state<br/>[planet.rs]"]
  node_star_csv["Stellar CSV data<br/>[star_csv.rs]"]
end

subgraph group_effects["Physical effects"]
  node_relativity["General relativity"]
  node_magnetism["Magnetic interaction<br/>[magnetism.rs]"]
  node_wind["Stellar wind<br/>[wind.rs]"]
  node_tides["Tidal models<br/>[tides.rs]"]
  node_ctl["Constant-time lag"]
  node_kaula["Kaula tides<br/>[kaula.rs]"]
  node_love["Love numbers<br/>[love_number.rs]"]
  node_polynomials["Kaula polynomials<br/>[polynomials.rs]"]
end

subgraph group_analysis["Result analysis"]
  node_plotter["Plotter<br/>[plotter.py]"]
  node_flatten["JSON flattener<br/>[flatten_json.py]"]
  node_units["Unit conversions<br/>[units.py]"]
end

node_user(("User"))
node_case_files["Case files"]
node_results["JSONL results"]
node_plots["Plots"]

node_user -->|"configures cases"| node_case_setup
node_case_setup -->|"builds configs"| node_case_config
node_case_config -->|"uses model"| node_config_model
node_case_setup -->|"writes cases"| node_case_files
node_user -->|"launches"| node_cli
node_case_files -->|"provides inputs"| node_cli
node_cli -.->|"runs simulation"| node_integrator
node_integrator -->|"uses physics"| node_physics
node_integrator -->|"holds system state"| node_particle_model
node_particle_model -->|"models star"| node_star
node_particle_model -->|"models planet"| node_planet
node_star -->|"reads evolution data"| node_star_csv
node_particle_model -->|"configures tides"| node_tides
node_physics -->|"uses tidal models"| node_tides
node_tides -->|"dispatches model"| node_ctl
node_tides -->|"dispatches model"| node_kaula
node_kaula -->|"uses Love numbers"| node_love
node_kaula -->|"uses polynomials"| node_polynomials
node_user -->|"analyses results"| node_plotter
node_results -->|"provides data"| node_plotter
node_plotter -->|"flattens data"| node_flatten
node_plotter -->|"uses conversions"| node_units
node_plotter -->|"writes plots"| node_plots
node_integrator -.->|"writes JSONL"| node_results
node_physics -.->|"includes effect"| node_relativity
node_physics -.->|"includes effect"| node_magnetism
node_physics -.->|"includes effect"| node_wind

click node_case_setup "https://github.com/dynaclim/spiroid/blob/main/scripts/setup.py"
click node_case_config "https://github.com/dynaclim/spiroid/blob/main/scripts/spiroid/configmaker.py"
click node_config_model "https://github.com/dynaclim/spiroid/blob/main/scripts/spiroid/config.py"
click node_cli "https://github.com/dynaclim/spiroid/blob/main/src/main.rs"
click node_integrator "https://github.com/dynaclim/spiroid/blob/main/src/universe.rs"
click node_physics "https://github.com/dynaclim/spiroid/blob/main/src/universe/physics.rs"
click node_particle_model "https://github.com/dynaclim/spiroid/blob/main/src/universe/particles.rs"
click node_star "https://github.com/dynaclim/spiroid/blob/main/src/universe/particles/star.rs"
click node_planet "https://github.com/dynaclim/spiroid/blob/main/src/universe/particles/planet.rs"
click node_star_csv "https://github.com/dynaclim/spiroid/blob/main/src/universe/particles/star/star_csv.rs"
click node_relativity "https://github.com/dynaclim/spiroid/blob/main/src/universe/effects/general_relativity.rs"
click node_magnetism "https://github.com/dynaclim/spiroid/blob/main/src/universe/effects/magnetism.rs"
click node_wind "https://github.com/dynaclim/spiroid/blob/main/src/universe/effects/wind.rs"
click node_tides "https://github.com/dynaclim/spiroid/blob/main/src/universe/effects/tides.rs"
click node_ctl "https://github.com/dynaclim/spiroid/blob/main/src/universe/effects/tides/constant_time_lag.rs"
click node_kaula "https://github.com/dynaclim/spiroid/blob/main/src/universe/effects/tides/kaula.rs"
click node_love "https://github.com/dynaclim/spiroid/blob/main/src/universe/effects/tides/kaula/love_number.rs"
click node_polynomials "https://github.com/dynaclim/spiroid/blob/main/src/universe/effects/tides/kaula/polynomials.rs"
click node_plotter "https://github.com/dynaclim/spiroid/blob/main/scripts/plotter.py"
click node_flatten "https://github.com/dynaclim/spiroid/blob/main/scripts/flatten_json.py"
click node_units "https://github.com/dynaclim/spiroid/blob/main/scripts/units.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_case_setup,node_case_config,node_config_model,node_user toneBlue
class node_cli,node_integrator,node_physics toneAmber
class node_particle_model,node_star,node_planet,node_star_csv toneMint
class node_relativity,node_magnetism,node_wind,node_tides,node_ctl,node_kaula,node_love,node_polynomials toneRose
class node_plotter,node_flatten,node_units,node_case_files,node_results,node_plots toneIndigo
```

## Components

### User workflow

- [Case generator](https://github.com/dynaclim/spiroid/blob/main/scripts/setup.py): `scripts/setup.py`
- [Config builder](https://github.com/dynaclim/spiroid/blob/main/scripts/spiroid/configmaker.py): `scripts/spiroid/configmaker.py`
- [Config model](https://github.com/dynaclim/spiroid/blob/main/scripts/spiroid/config.py): `scripts/spiroid/config.py`

### Simulation runtime

- [Simulator CLI](https://github.com/dynaclim/spiroid/blob/main/src/main.rs): `src/main.rs`
- [Evolution integrator](https://github.com/dynaclim/spiroid/blob/main/src/universe.rs): `src/universe.rs`
- [Orbital physics](https://github.com/dynaclim/spiroid/blob/main/src/universe/physics.rs): `src/universe/physics.rs`

### System state

- [Particle models](https://github.com/dynaclim/spiroid/blob/main/src/universe/particles.rs): `src/universe/particles.rs`
- [Star evolution](https://github.com/dynaclim/spiroid/blob/main/src/universe/particles/star.rs): `src/universe/particles/star.rs`
- [Planet state](https://github.com/dynaclim/spiroid/blob/main/src/universe/particles/planet.rs): `src/universe/particles/planet.rs`
- [Stellar CSV data](https://github.com/dynaclim/spiroid/blob/main/src/universe/particles/star/star_csv.rs): `src/universe/particles/star/star_csv.rs`

### Physical effects

- [General relativity](https://github.com/dynaclim/spiroid/blob/main/src/universe/effects/general_relativity.rs): `src/universe/effects/general_relativity.rs`
- [Magnetic interaction](https://github.com/dynaclim/spiroid/blob/main/src/universe/effects/magnetism.rs): `src/universe/effects/magnetism.rs`
- [Stellar wind](https://github.com/dynaclim/spiroid/blob/main/src/universe/effects/wind.rs): `src/universe/effects/wind.rs`
- [Tidal models](https://github.com/dynaclim/spiroid/blob/main/src/universe/effects/tides.rs): `src/universe/effects/tides.rs`
- [Constant-time lag](https://github.com/dynaclim/spiroid/blob/main/src/universe/effects/tides/constant_time_lag.rs): `src/universe/effects/tides/constant_time_lag.rs`
- [Kaula tides](https://github.com/dynaclim/spiroid/blob/main/src/universe/effects/tides/kaula.rs): `src/universe/effects/tides/kaula.rs`
- [Love numbers](https://github.com/dynaclim/spiroid/blob/main/src/universe/effects/tides/kaula/love_number.rs): `src/universe/effects/tides/kaula/love_number.rs`
- [Kaula polynomials](https://github.com/dynaclim/spiroid/blob/main/src/universe/effects/tides/kaula/polynomials.rs): `src/universe/effects/tides/kaula/polynomials.rs`

### Result analysis

- [Plotter](https://github.com/dynaclim/spiroid/blob/main/scripts/plotter.py): `scripts/plotter.py`
- [JSON flattener](https://github.com/dynaclim/spiroid/blob/main/scripts/flatten_json.py): `scripts/flatten_json.py`
- [Unit conversions](https://github.com/dynaclim/spiroid/blob/main/scripts/units.py): `scripts/units.py`

### Other components

- **User**
- **Case files**
- **JSONL results**
- **Plots**

## Connections

- User → Case generator: configures cases
- Case generator → Config builder: builds configs (evidence: `scripts/setup.py`)
- Config builder → Config model: uses model (evidence: `scripts/spiroid/configmaker.py`)
- Case generator → Case files: writes cases
- User → Simulator CLI: launches
- Case files → Simulator CLI: provides inputs
- Simulator CLI → Evolution integrator: runs simulation
- Evolution integrator → Orbital physics: uses physics (evidence: `src/universe.rs`)
- Evolution integrator → Particle models: holds system state (evidence: `src/universe.rs`)
- Particle models → Star evolution: models star (evidence: `src/universe/particles.rs`)
- Particle models → Planet state: models planet (evidence: `src/universe/particles.rs`)
- Star evolution → Stellar CSV data: reads evolution data (evidence: `src/universe/particles/star.rs`)
- Particle models → Tidal models: configures tides (evidence: `src/universe/particles.rs`)
- Orbital physics → Tidal models: uses tidal models (evidence: `src/universe/physics.rs`)
- Tidal models → Constant-time lag: dispatches model (evidence: `src/universe/effects/tides.rs`)
- Tidal models → Kaula tides: dispatches model (evidence: `src/universe/effects/tides.rs`)
- Kaula tides → Love numbers: uses Love numbers (evidence: `src/universe/effects/tides/kaula.rs`)
- Kaula tides → Kaula polynomials: uses polynomials (evidence: `src/universe/effects/tides/kaula.rs`)
- User → Plotter: analyses results
- JSONL results → Plotter: provides data
- Plotter → JSON flattener: flattens data (evidence: `scripts/plotter.py`)
- Plotter → Unit conversions: uses conversions (evidence: `scripts/plotter.py`)
- Plotter → Plots: writes plots
- Evolution integrator → JSONL results: writes JSONL
- Orbital physics → General relativity: includes effect
- Orbital physics → Magnetic interaction: includes effect
- Orbital physics → Stellar wind: includes effect
