# sauddy/grinn architecture

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

- Interactive diagram: https://gitdiagram.com/sauddy/grinn
- Repository: https://github.com/sauddy/grinn

## Overview

##### Project type and purpose
- This is an academic/research codebase (“open-source tool”) for solving hydrodynamical PDEs (with self-gravity) using two approaches: traditional finite-difference (FD) solvers vs. Physics-Informed Neural Networks (PINNs).
- The README confirms the goal: study Jeans instability in self-gravitating gas and compare wave propagation and instability growth between FD and PINN methods.

##### File structure
- Top‐level directories correspond to experimental tracks:
- FD_vs_PINN – Jupyter notebooks comparing FD vs. PINN in 1D & 2D.
- HYDRO-FINITE-DIFF – pure FD implementations (LAX scheme in 1D, 2D, 3D).
- GRINN_torch_code – core Python modules (LAX.py, Plotting.py) plus a demo notebook using PyTorch (“torch_GHD_1D.ipynb”).
- PINNS-Poissons, PINNs-Hydro-Gravity, PINNs-Hydro – PINN experiments on Poisson, hydro+gravity, and hydro-wave equations.
- paper-case_studies – extended 3D wave / hydro‐wave case studies.
- Support artifacts:
– data files (train.dat, test.dat, loss.dat) in PINNS-Poissons
– output folders (figures_*, 1D_fig, 2D_fig_)
– Jupyter checkpoint directories
- No deployment or CI; this is a research repo—no microservices or MVC pattern; instead a “library + experiment notebooks” structure.

##### README for additional insights
- Confirms use of Physics-Informed Neural Networks (likely PyTorch under the hood).
- Shows animated outputs, indicating a data‐flow: PDE definitions → solver → result → visualization.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "Experiment Layer"
        expFD["FD_vs_PINN"]:::notebooks
        expFD2["HYDRO-FINITE-DIFF"]:::notebooks
        PP["PINNS-Poissons"]:::notebooks
        PHG["PINNs-Hydro-Gravity"]:::notebooks
        PH["PINNs-Hydro"]:::notebooks
        PCS["paper-case_studies"]:::notebooks
    end

    subgraph "Core Solver Library"
        LAX["LAX.py"]:::codeModule
        Plot["Plotting.py"]:::codeModule
        Demo["torch_GHD_1D.ipynb"]:::notebooks
    end

    subgraph "Data Stores"
        train["train.dat"]:::dataStore
        test["test.dat"]:::dataStore
        loss["loss.dat"]:::dataStore
    end

    subgraph "Output Figures"
        figFD1["1D_fig (FD_vs_PINN)"]:::dataStore
        figFD2["2D_fig (FD_vs_PINN)"]:::dataStore
        figPHG1["figures_1D (PINNs-Hydro-Gravity)"]:::dataStore
        figPHG2["figures_2D (PINNs-Hydro-Gravity)"]:::dataStore
        figPH1["figures_waves-1D (PINNs-Hydro)"]:::dataStore
        figPH2["figures_waves-2D (PINNs-Hydro)"]:::dataStore
    end

    subgraph "External Frameworks"
        pyRuntime["Python Runtime"]:::external
        pytorch["PyTorch"]:::external
        numpy["NumPy"]:::external
        mpl["Matplotlib"]:::external
        jupyter["Jupyter"]:::external
    end

    expFD -->|calls| LAX
    expFD -->|calls| Plot
    expFD -->|writes| figFD1
    expFD -->|writes| figFD2
    expFD -->|runs on| jupyter

    expFD2 -->|calls| LAX
    expFD2 -->|calls| Plot
    expFD2 -->|runs on| jupyter

    PP -->|calls| Demo
    PP -->|reads| train
    PP -->|reads| test
    PP -->|writes| loss
    PP -->|runs on| jupyter

    PHG -->|calls| Demo
    PHG -->|writes| figPHG1
    PHG -->|writes| figPHG2
    PHG -->|runs on| jupyter

    PH -->|calls| Demo
    PH -->|writes| figPH1
    PH -->|writes| figPH2
    PH -->|runs on| jupyter

    PCS -->|calls| LAX
    PCS -->|calls| Plot
    PCS -->|runs on| jupyter

    LAX -->|uses| numpy
    LAX -->|runs on| pyRuntime

    Plot -->|uses| mpl
    Plot -->|runs on| pyRuntime

    Demo -->|uses| pytorch
    Demo -->|runs on| pyRuntime

    classDef codeModule fill:#add8e6,stroke:#000
    classDef notebooks fill:#90ee90,stroke:#000
    classDef dataStore fill:#ffa500,stroke:#000
    classDef external fill:#d3d3d3,stroke:#000

    click expFD "https://github.com/sauddy/grinn/tree/main/FD_vs_PINN"
    click expFD2 "https://github.com/sauddy/grinn/tree/main/HYDRO-FINITE-DIFF"
    click PP "https://github.com/sauddy/grinn/tree/main/PINNS-Poissons"
    click PHG "https://github.com/sauddy/grinn/tree/main/PINNs-Hydro-Gravity"
    click PH "https://github.com/sauddy/grinn/tree/main/PINNs-Hydro"
    click PCS "https://github.com/sauddy/grinn/tree/main/paper-case_studies"
    click LAX "https://github.com/sauddy/grinn/blob/main/GRINN_torch_code/LAX.py"
    click Plot "https://github.com/sauddy/grinn/blob/main/GRINN_torch_code/Plotting.py"
    click Demo "https://github.com/sauddy/grinn/blob/main/GRINN_torch_code/torch_GHD_1D.ipynb"
    click train "https://github.com/sauddy/grinn/blob/main/PINNS-Poissons/train.dat"
    click test "https://github.com/sauddy/grinn/blob/main/PINNS-Poissons/test.dat"
    click loss "https://github.com/sauddy/grinn/blob/main/PINNS-Poissons/loss.dat"
    click figFD1 "https://github.com/sauddy/grinn/tree/main/FD_vs_PINN/1D_fig"
    click figFD2 "https://github.com/sauddy/grinn/tree/main/FD_vs_PINN/2D_fig_"
    click figPHG1 "https://github.com/sauddy/grinn/tree/main/PINNs-Hydro-Gravity/figures_1D"
    click figPHG2 "https://github.com/sauddy/grinn/tree/main/PINNs-Hydro-Gravity/figures_2D"
    click figPH1 "https://github.com/sauddy/grinn/tree/main/PINNs-Hydro/figures_waves-1D"
    click figPH2 "https://github.com/sauddy/grinn/tree/main/PINNs-Hydro/figures_waves-2D"
```
