# ashcat2005/lynx architecture

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

- Interactive diagram: https://gitdiagram.com/ashcat2005/lynx
- Repository: https://github.com/ashcat2005/lynx

## Overview

##### Project Type & Purpose
- The project is research-oriented and deals with computational astrophysics.
- Its purpose is to simulate gravitational dynamics using different numerical integrators (e.g., Euler, RK4, Adaptive RK methods, LeapFrog/Verlet) which are applied to both 2-body and N-body problems.
- This is evident from the directory names (2_Body_Problem and N_Body_Problem) and the integration notebooks/scripts included.

##### Analyzing the File Structure
- There are two principal sections: “2_Body_Problem” and “N_Body_Problem”.
- The “2_Body_Problem” directory contains Jupyter notebooks with different integration methods (Euler, RK integrators, and symplectic integrators), showcasing simulation examples in an interactive format.
- The “N_Body_Problem” directory is more structured as it includes:
- A “common” directory containing shared modules such as gravSystem.py (likely defining gravitational system dynamics) and plots.py (for visualization).
- An “integrators” directory that contains Python files for various integration algorithms (RK4.py, logHreg.py, and velocityVerlet.py).
- Example scripts demonstrating use cases (example01_SunEarth.py, example02_BinarySystem.py, example03_GalacticCenter.py).
- Top-level files like .gitignore and LICENSE confirm standard project configuration.

##### Key Components
- 2-Body Simulation Module:
- Interactive Jupyter notebooks under “2_Body_Problem” as a module for educational demonstrations of different integrators.
- Different notebooks (Euler, RK, and Symplectic Integrators) can be annotated as sub-components that use a similar underlying physical model.
- N-Body Simulation Module:
- Breakdown into core components:
- Common Utilities: “gravSystem.py” (module for gravitational dynamics) and “plots.py” (for plotting and results visualization).
- Integrators: Group the different integration modules (RK4, logHreg, velocityVerlet) showing that each implements a numerical method to advance state.
- Example Scripts: Illustrate scenarios (Sun-Earth, Binary System, Galactic Center) which tie together the integrator components and common utilities.
- Data Flow & Relationships:
- Data flows from the gravitational system models to the integrators which perform the computational physics simulation.
- The outputs from integrators are then sent to plotting/visualization modules to produce the results seen in the examples.
- Inter-component communication is well-defined: simulation examples call on both integrators and common utilities to encapsulate physics and visualization.
- Architectural Patterns:
- Modular decomposition: separation of simulation types (2-body vs. N-body), with integrators and common modules decoupled for reusability.
- Clear separation of concerns: integration algorithms, common gravitational model, and visualization components.
- The use of Jupyter notebooks for interactive experimentation vs. reusable Python modules for structured simulations.

##### Elements
- Components: Label modules such as “2-Body Simulation (Notebooks)”, “Gravitational System (gravSystem.py)”, “Visualization (plots.py)”, “Integrators (RK4, logHreg, velocityVerlet)”, and “Examples (SunEarth, Binary, Galactic Center)”.
- Flow from “Integrators” to “Visualization” for output rendering.
- How “Examples” integrate all these pieces by calling functions/methods from these modules.
- Architectural Patterns:

- Split it into two sections: 2-Body and N-Body.
- Similar details for the 2-Body side to reflect its focus on interactive, demonstrative notebooks.

## Diagram (Mermaid)

```mermaid
graph TD
    subgraph "2-Body Simulation"
        tb1("Interactive Notebooks"):::notebook
    end

    subgraph "N-Body Simulation"
        subgraph "Common Modules"
            ncm1("Gravitational System (gravSystem.py)"):::library
            ncm2("Visualization (plots.py)"):::library
        end
        subgraph "Numerical Integrators"
            ni1("RK4 Integrator (RK4.py)"):::integrator
            ni2("LogH Reg Integrator (logHreg.py)"):::integrator
            ni3("Velocity Verlet (velocityVerlet.py)"):::integrator
        end
        subgraph "Example Simulations"
            ex1("Sun-Earth Simulation (example01_SunEarth.py)"):::example
            ex2("Binary System Simulation (example02_BinarySystem.py)"):::example
            ex3("Galactic Center Simulation (example03_GalacticCenter.py)"):::example
        end
    end

    %% Data Flow Connections
    tb1 -->|"simulates"| ncm1
    tb1 -->|"visualizes"| ncm2

    ncm1 -->|"model"| ni1
    ncm1 -->|"model"| ni2
    ncm1 -->|"model"| ni3

    ni1 -->|"output"| ncm2
    ni2 -->|"output"| ncm2
    ni3 -->|"output"| ncm2

    ex1 -->|"calls"| ncm1
    ex1 -->|"calls"| ni1
    ex1 -->|"calls"| ncm2

    ex2 -->|"calls"| ncm1
    ex2 -->|"calls"| ni2
    ex2 -->|"calls"| ncm2

    ex3 -->|"calls"| ncm1
    ex3 -->|"calls"| ni3
    ex3 -->|"calls"| ncm2

    %% Click Events Mapping
    click tb1 "https://github.com/ashcat2005/lynx/tree/main/2_Body_Problem"
    click ncm1 "https://github.com/ashcat2005/lynx/blob/main/N_Body_Problem/common/gravSystem.py"
    click ncm2 "https://github.com/ashcat2005/lynx/blob/main/N_Body_Problem/common/plots.py"
    click ni1 "https://github.com/ashcat2005/lynx/blob/main/N_Body_Problem/integrators/RK4.py"
    click ni2 "https://github.com/ashcat2005/lynx/blob/main/N_Body_Problem/integrators/logHreg.py"
    click ni3 "https://github.com/ashcat2005/lynx/blob/main/N_Body_Problem/integrators/velocityVerlet.py"
    click ex1 "https://github.com/ashcat2005/lynx/blob/main/N_Body_Problem/example01_SunEarth.py"
    click ex2 "https://github.com/ashcat2005/lynx/blob/main/N_Body_Problem/example02_BinarySystem.py"
    click ex3 "https://github.com/ashcat2005/lynx/blob/main/N_Body_Problem/example03_GalacticCenter.py"

    %% Styles
    classDef notebook fill:#ffcc00,stroke:#000,stroke-width:2px;
    classDef library fill:#ccffcc,stroke:#000,stroke-width:2px;
    classDef integrator fill:#ccccff,stroke:#000,stroke-width:2px;
    classDef example fill:#ffcccc,stroke:#000,stroke-width:2px;
```
