# joeeliang/doublependulum architecture

> Architecture diagram of the GitHub repository joeeliang/doublependulum, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/joeeliang/doublependulum
- Repository: https://github.com/joeeliang/doublependulum

## Overview

##### Project type and purpose
- This is a standalone Python‐based interactive visualization and simulation tool.
- Purpose: compute and display a Lyapunov‐exponent heatmap for a double pendulum, allow the user to hover over heatmap points to see chaos metrics, and animate the pendulum at a chosen starting angle.

##### File structure
- Top‐level scripts:
- main.py – entry point, orchestrates UI, heatmap rendering, event handling
- 3d.py – alternative 3D heatmap visualization
- animation.py – routines that animate the pendulum motion in matplotlib
- lyapunov.py – compute or load Lyapunov exponents
- pendulum.py – physics simulation of the double pendulum’s equations of motion
- dataFormat.py – load/transform CSV files (data.csv, redoData.csv)
- Data files: data.csv, redoData.csv – precomputed exponent values
- Config: requirements.txt – list of Python libraries (matplotlib, numpy, pandas, etc.)

##### README for additional insights
- Interactive heatmap as primary UI
- “u” key triggers an animation of the double pendulum
- 2 modes: 2D (main.py) and 3D (3d.py) heatmap
- Core workflow: load or compute exponents → render heatmap → on hover show values → on key press launch pendulum animation

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Data Layer
    subgraph "Data Layer"
        CSV["CSV Files (data.csv, redoData.csv)"]:::data
        DF["dataFormat.py"]:::data
    end

    %% Computation Layer
    subgraph "Computation Layer"
        LYAP["lyapunov.py"]:::comp
    end

    %% UI Layer
    subgraph "Presentation/UI Layer"
        UI2D["main.py"]:::ui
        UI3D["3d.py"]:::ui
    end

    %% Simulation & Animation Layer
    subgraph "Simulation & Animation"
        ANIM["animation.py"]:::simulate
        PEND["pendulum.py"]:::simulate
    end

    %% External Dependencies
    subgraph "External Dependencies"
        MATP["matplotlib"]:::ext
        NP["numpy"]:::ext
        PD["pandas"]:::ext
        SCIP["scipy"]:::ext
    end

    %% Data Flows
    CSV -->|reads CSV| DF
    DF -->|provides data| LYAP
    DF -->|provides data| UI2D
    DF -->|provides data| UI3D
    LYAP -->|computes exponents| UI2D
    LYAP -->|computes exponents| UI3D

    %% UI Rendering
    UI2D -->|renders 2D heatmap| UI2D
    UI3D -->|renders 3D heatmap| UI3D

    %% Animation Flow
    UI2D -->|u key triggers| ANIM
    ANIM -->|uses simulation| PEND
    PEND -->|computes frames| ANIM
    ANIM -->|renders animation| UI2D

    %% External Dependencies Usage
    MATP --> DF
    NP --> DF
    PD --> DF
    NP --> LYAP
    SCIP --> PEND
    MATP --> UI2D
    MATP --> UI3D
    MATP --> ANIM

    %% Click Events
    click DF "https://github.com/joeeliang/doublependulum/blob/main/dataFormat.py"
    click CSV "https://github.com/joeeliang/doublependulum/blob/main/data.csv"
    click CSV "https://github.com/joeeliang/doublependulum/blob/main/redoData.csv"
    click LYAP "https://github.com/joeeliang/doublependulum/blob/main/lyapunov.py"
    click PEND "https://github.com/joeeliang/doublependulum/blob/main/pendulum.py"
    click ANIM "https://github.com/joeeliang/doublependulum/blob/main/animation.py"
    click UI2D "https://github.com/joeeliang/doublependulum/blob/main/main.py"
    click UI3D "https://github.com/joeeliang/doublependulum/blob/main/3d.py"
    click MATP "https://github.com/joeeliang/doublependulum/blob/main/requirements.txt"

    %% Styles
    classDef data fill:#DCEEFB,stroke:#0C4A6E,color:#0C4A6E;
    classDef comp fill:#DCFCE7,stroke:#166534,color:#166534;
    classDef simulate fill:#DCFCE7,stroke:#166534,color:#166534;
    classDef ui fill:#FEF3C7,stroke:#B45309,color:#B45309;
    classDef ext fill:#E5E7EB,stroke:#374151,color:#374151
```
