# dynaclim/posidonius architecture

> Architecture diagram of the GitHub repository dynaclim/posidonius, 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/posidonius
- Repository: https://github.com/dynaclim/posidonius

## Overview

Posidonius is a planetary N-body simulator with a Python case-definition package and a Rust simulation executable. The main workflow is to define a system, serialize it as JSON, run or resume an integration, save recovery and history snapshots, then inspect orbital history and resonances. The runtime includes particle/universe state, numerical integrators, and configurable physical effects. The README documents the user workflow; sampled Rust excerpts show effect initialization and integration calls, but several internal links are supported only by imports listed in the source index.

Main entry points: [`src/particles/universe.rs`](https://github.com/dynaclim/posidonius/blob/master/src/particles/universe.rs) (Effect Dispatch), [`posidonius/__init__.py`](https://github.com/dynaclim/posidonius/blob/master/posidonius/__init__.py) (Python Case API), [`src/integrator/output.rs`](https://github.com/dynaclim/posidonius/blob/master/src/integrator/output.rs) (Snapshot I/O), [`src/main.rs`](https://github.com/dynaclim/posidonius/blob/master/src/main.rs) (Simulator CLI)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_case["Case Definition"]
  node_case_python["Python Case API<br/>[__init__.py]"]
  node_case_universe["Case Universe<br/>[universe.py]"]
  node_case_particles["Particle Models<br/>[particle.py]"]
  node_evolution_python["Evolution Models<br/>[evolution.py]"]
  node_case_json["Simulation JSON"]
end

subgraph group_runtime["Simulation Runtime"]
  node_cli["Simulator CLI<br/>[main.rs]"]
  node_universe["Simulation Universe<br/>[universe.rs]"]
  node_particle["Particle State<br/>[particle.rs]"]
  node_ias15["IAS15 Integrator<br/>[ias15.rs]"]
  node_whfast["WHFast Integrator<br/>[whfast.rs]"]
  node_leapfrog["Leapfrog Integrator<br/>[leapfrog.rs]"]
  node_snapshots["Snapshot I/O<br/>[output.rs]"]
end

subgraph group_physics["Physical Models"]
  node_effects_dispatch["Effect Dispatch<br/>[universe.rs]"]
  node_disk["Disk Forces<br/>[disk.rs]"]
  node_evolution["Body Evolution<br/>[evolution.rs]"]
  node_relativity["Relativity"]
  node_flattening["Rotational Flattening"]
  node_tides["Tidal Forces<br/>[tides.rs]"]
  node_wind["Stellar Wind<br/>[wind.rs]"]
end

subgraph group_analysis["History Analysis"]
  node_raw_history["Raw History Export<br/>[raw_history.py]"]
  node_history_analysis["Orbital History<br/>[explore_history.py]"]
  node_resonance_analysis["Resonance Analysis<br/>[resonances.py]"]
  node_history_file["History Snapshot"]
end

node_user(("Researcher"))

node_user -->|"defines system"| node_case_python
node_case_python -->|"configures"| node_case_universe
node_case_python -->|"creates particles"| node_case_particles
node_case_python -->|"selects models"| node_evolution_python
node_case_universe -->|"writes case"| node_case_json
node_user -->|"starts or resumes"| node_cli
node_case_json -->|"loads case"| node_cli
node_cli -->|"runs simulation"| node_universe
node_universe -.->|"holds state"| node_particle
node_universe -->|"calculates effects"| node_effects_dispatch
node_effects_dispatch -->|"initializes"| node_disk
node_effects_dispatch -->|"initializes"| node_evolution
node_effects_dispatch -->|"initializes"| node_relativity
node_effects_dispatch -->|"initializes"| node_flattening
node_effects_dispatch -->|"initializes"| node_tides
node_effects_dispatch -->|"initializes"| node_wind
node_universe -.->|"integrates"| node_ias15
node_universe -.->|"integrates"| node_whfast
node_universe -.->|"integrates"| node_leapfrog
node_ias15 -->|"writes snapshots"| node_snapshots
node_whfast -.->|"uses snapshot I/O"| node_snapshots
node_snapshots -->|"stores history"| node_history_file
node_snapshots -->|"stores recovery"| node_history_file
node_user -->|"exports history"| node_raw_history
node_user -->|"explores history"| node_history_analysis
node_user -->|"studies resonances"| node_resonance_analysis
node_history_file -->|"reads snapshots"| node_raw_history
node_history_file -->|"reads snapshots"| node_history_analysis
node_history_file -->|"reads snapshots"| node_resonance_analysis

click node_case_python "https://github.com/dynaclim/posidonius/blob/master/posidonius/__init__.py"
click node_case_universe "https://github.com/dynaclim/posidonius/blob/master/posidonius/particles/universe.py"
click node_case_particles "https://github.com/dynaclim/posidonius/blob/master/posidonius/particles/particle.py"
click node_evolution_python "https://github.com/dynaclim/posidonius/blob/master/posidonius/effects/evolution.py"
click node_cli "https://github.com/dynaclim/posidonius/blob/master/src/main.rs"
click node_universe "https://github.com/dynaclim/posidonius/blob/master/src/particles/universe.rs"
click node_particle "https://github.com/dynaclim/posidonius/blob/master/src/particles/particle.rs"
click node_ias15 "https://github.com/dynaclim/posidonius/blob/master/src/integrator/ias15.rs"
click node_whfast "https://github.com/dynaclim/posidonius/blob/master/src/integrator/whfast.rs"
click node_leapfrog "https://github.com/dynaclim/posidonius/blob/master/src/integrator/leapfrog.rs"
click node_snapshots "https://github.com/dynaclim/posidonius/blob/master/src/integrator/output.rs"
click node_effects_dispatch "https://github.com/dynaclim/posidonius/blob/master/src/particles/universe.rs"
click node_disk "https://github.com/dynaclim/posidonius/blob/master/src/effects/disk.rs"
click node_evolution "https://github.com/dynaclim/posidonius/blob/master/src/effects/evolution.rs"
click node_relativity "https://github.com/dynaclim/posidonius/blob/master/src/effects/general_relativity.rs"
click node_flattening "https://github.com/dynaclim/posidonius/blob/master/src/effects/rotational_flattening.rs"
click node_tides "https://github.com/dynaclim/posidonius/blob/master/src/effects/tides.rs"
click node_wind "https://github.com/dynaclim/posidonius/blob/master/src/effects/wind.rs"
click node_raw_history "https://github.com/dynaclim/posidonius/blob/master/scripts/raw_history.py"
click node_history_analysis "https://github.com/dynaclim/posidonius/blob/master/scripts/explore_history.py"
click node_resonance_analysis "https://github.com/dynaclim/posidonius/blob/master/posidonius/analysis/resonances.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_python,node_case_universe,node_case_particles,node_evolution_python,node_case_json toneBlue
class node_cli,node_universe,node_particle,node_ias15,node_whfast,node_leapfrog,node_snapshots toneAmber
class node_effects_dispatch,node_disk,node_evolution,node_relativity,node_flattening,node_tides,node_wind toneMint
class node_raw_history,node_history_analysis,node_resonance_analysis,node_history_file toneRose
class node_user toneIndigo
```

## Components

### Case Definition

- [Python Case API](https://github.com/dynaclim/posidonius/blob/master/posidonius/__init__.py): `posidonius/__init__.py`
- [Case Universe](https://github.com/dynaclim/posidonius/blob/master/posidonius/particles/universe.py): `posidonius/particles/universe.py`
- [Particle Models](https://github.com/dynaclim/posidonius/blob/master/posidonius/particles/particle.py): `posidonius/particles/particle.py`
- [Evolution Models](https://github.com/dynaclim/posidonius/blob/master/posidonius/effects/evolution.py): `posidonius/effects/evolution.py`
- **Simulation JSON**

### Simulation Runtime

- [Simulator CLI](https://github.com/dynaclim/posidonius/blob/master/src/main.rs): `src/main.rs`
- [Simulation Universe](https://github.com/dynaclim/posidonius/blob/master/src/particles/universe.rs): `src/particles/universe.rs`
- [Particle State](https://github.com/dynaclim/posidonius/blob/master/src/particles/particle.rs): `src/particles/particle.rs`
- [IAS15 Integrator](https://github.com/dynaclim/posidonius/blob/master/src/integrator/ias15.rs): `src/integrator/ias15.rs`
- [WHFast Integrator](https://github.com/dynaclim/posidonius/blob/master/src/integrator/whfast.rs): `src/integrator/whfast.rs`
- [Leapfrog Integrator](https://github.com/dynaclim/posidonius/blob/master/src/integrator/leapfrog.rs): `src/integrator/leapfrog.rs`
- [Snapshot I/O](https://github.com/dynaclim/posidonius/blob/master/src/integrator/output.rs): `src/integrator/output.rs`

### Physical Models

- [Effect Dispatch](https://github.com/dynaclim/posidonius/blob/master/src/particles/universe.rs): `src/particles/universe.rs`
- [Disk Forces](https://github.com/dynaclim/posidonius/blob/master/src/effects/disk.rs): `src/effects/disk.rs`
- [Body Evolution](https://github.com/dynaclim/posidonius/blob/master/src/effects/evolution.rs): `src/effects/evolution.rs`
- [Relativity](https://github.com/dynaclim/posidonius/blob/master/src/effects/general_relativity.rs): `src/effects/general_relativity.rs`
- [Rotational Flattening](https://github.com/dynaclim/posidonius/blob/master/src/effects/rotational_flattening.rs): `src/effects/rotational_flattening.rs`
- [Tidal Forces](https://github.com/dynaclim/posidonius/blob/master/src/effects/tides.rs): `src/effects/tides.rs`
- [Stellar Wind](https://github.com/dynaclim/posidonius/blob/master/src/effects/wind.rs): `src/effects/wind.rs`

### History Analysis

- [Raw History Export](https://github.com/dynaclim/posidonius/blob/master/scripts/raw_history.py): `scripts/raw_history.py`
- [Orbital History](https://github.com/dynaclim/posidonius/blob/master/scripts/explore_history.py): `scripts/explore_history.py`
- [Resonance Analysis](https://github.com/dynaclim/posidonius/blob/master/posidonius/analysis/resonances.py): `posidonius/analysis/resonances.py`
- **History Snapshot**

### Other components

- **Researcher**

## Connections

- Researcher → Python Case API: defines system
- Python Case API → Case Universe: configures (evidence: `posidonius/__init__.py`)
- Python Case API → Particle Models: creates particles (evidence: `posidonius/__init__.py`)
- Python Case API → Evolution Models: selects models (evidence: `posidonius/__init__.py`)
- Case Universe → Simulation JSON: writes case
- Researcher → Simulator CLI: starts or resumes
- Simulation JSON → Simulator CLI: loads case
- Simulator CLI → Simulation Universe: runs simulation
- Simulation Universe → Particle State: holds state
- Simulation Universe → Effect Dispatch: calculates effects (evidence: `src/particles/universe.rs`)
- Effect Dispatch → Disk Forces: initializes (evidence: `src/particles/universe.rs`)
- Effect Dispatch → Body Evolution: initializes (evidence: `src/particles/universe.rs`)
- Effect Dispatch → Relativity: initializes (evidence: `src/particles/universe.rs`)
- Effect Dispatch → Rotational Flattening: initializes (evidence: `src/particles/universe.rs`)
- Effect Dispatch → Tidal Forces: initializes (evidence: `src/particles/universe.rs`)
- Effect Dispatch → Stellar Wind: initializes (evidence: `src/particles/universe.rs`)
- Simulation Universe → IAS15 Integrator: integrates
- Simulation Universe → WHFast Integrator: integrates
- Simulation Universe → Leapfrog Integrator: integrates
- IAS15 Integrator → Snapshot I/O: writes snapshots (evidence: `src/integrator/ias15.rs`)
- WHFast Integrator → Snapshot I/O: uses snapshot I/O (evidence: `src/integrator/whfast.rs`)
- Snapshot I/O → History Snapshot: stores history
- Snapshot I/O → History Snapshot: stores recovery
- Researcher → Raw History Export: exports history
- Researcher → Orbital History: explores history
- Researcher → Resonance Analysis: studies resonances
- History Snapshot → Raw History Export: reads snapshots
- History Snapshot → Orbital History: reads snapshots
- History Snapshot → Resonance Analysis: reads snapshots
