# tamids-hyperreduction/pyhyperrom architecture

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

## Overview

##### Project Identification and Purpose
- pyHyperRom is an open-source Python framework for reduced-order modeling (ROM) and hyper-reduction methods applied to mechanics and heat conduction.
- It is organized as a Python package (`pyHyperRom/src/codes/...`) supplemented by Jupyter-based examples and resource files.

##### File-Structure Analysis
- Top level:
- Resources (plotting styles, documentation)
- examples (end-to-end Jupyter notebooks demonstrating usage)
- src/codes (core library)
- requirements.txt, README.md, contributors.md
- Core library subdirectories:
- algorithms — implementations of hyperreduction methods (DEIM, ECM, ECSW, etc.)
- prob_classes — domain/model definitions (heat conduction problem classes)
- reductor — high-level ROM orchestration (ROM class handling projection/hyperreduction)
- utils — supporting functions (file I/O, finite element utilities, plotting)

##### README Insights
- Explicit three-step workflow:
a. Problem statement & data generation (FEM linear/nonlinear)
b. ROM without hyperreduction
c. Two hyperreduction approaches (approximate-then-project vs. project-then-approximate)
- Emphasis on modularity and extensibility for new models and algorithms.

1. User Interface Layer
- Jupyter Notebooks (examples/)
2. Core Library
- Problem Classes (`prob_classes`)
- Algorithms (`algorithms`)
- Reductor (`reductor/rom_class_ms.py`)
- Utilities (`utils`)
3. Resources & Configuration
- Plot Styles, PDFs (Resources/)
- requirements.txt (External Dependencies)
4. External Libraries
- NumPy, SciPy, Matplotlib, etc.
- Notebooks → import → Problem Classes → generate snapshots/full-order data
- Notebooks/Reductor → call → Algorithms → compute reduction operators or sampling indices
- Reductor → coordinate → projection/lifting between reduced and full spaces
- All modules → rely on → Utils for I/O and plotting
- Core Library → depends on → External Libraries
- Notebooks → read from → Resources
c. Architectural Patterns & Principles
- Layered architecture: UI layer (notebooks) atop core library modules
- Plugin-style extensibility: each hyperreduction algorithm lives in its own module under `algorithms/`
- Single Responsibility: domain definitions (prob_classes) are separate from numerical methods (algorithms) and orchestration (reductor).
d. Key Technologies & Frameworks
- Python 3.x packaging
- Jupyter notebooks for demonstration
- NumPy/SciPy for numerics
- Matplotlib (with sci_mplstyle) for visualizations

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% UI Layer
    subgraph "UI Layer" 
        direction TB
        UI["Jupyter Notebooks"]:::ui
    end

    %% Core Library
    subgraph "Core Library" 
        direction TB
        subgraph "Problem Classes" 
            direction TB
            Prob["prob_classes"]:::core
            HeatHC["Heat Conduction Base Class"]:::core
        end
        subgraph "Algorithms" 
            direction TB
            DEIM["DEIM"]:::core
            ECM["ECM"]:::core
            ECSW["ECSW"]:::core
            EmpCub["Empirical Cubature Method"]:::core
            NNLS["NNLS Solver"]:::core
        end
        Red["Reductor (ROM Orchestration)"]:::core
        subgraph "Utilities" 
            direction TB
            FEMHC["FEM Utilities (Heat Conduction)"]:::core
            DirU["Directory Utilities"]:::core
            ROMU["ROM Utilities"]:::core
            PlotU["Plotting Utilities"]:::core
            Anim1D["Animation 1D"]:::core
            Anim2D["Animation 2D"]:::core
            PubStyle["Publication Style"]:::core
        end
    end

    %% Resources & Config
    subgraph "Resources & Configuration" 
        direction TB
        Res["Resources"]:::resources
        StylePkg["Matplotlib Style Package"]:::resources
    end

    %% External Dependencies
    External["External Dependencies (NumPy, SciPy, Matplotlib)"]:::external

    %% Data Store
    Snapshots[(Full-Order Snapshots)]:::data
    Reduced[(Reduced Data)]:::data

    %% Connections
    UI -->|imports| Prob
    UI -->|imports| Red
    UI -->|reads| Res
    Prob -->|generates snapshots| Snapshots
    Snapshots -->|used by| Red
    Red -->|calls| Alg
    Alg -->|computes operators| Reduced
    Reduced -->|visualized by| UI
    Prob -->|depends on| Utils
    Alg -->|depends on| Utils
    Red -->|depends on| Utils
    Prob -->|depends on| External
    Alg -->|depends on| External
    Red -->|depends on| External
    Utils -->|depends on| External

    %% Click Events
    click UI "https://github.com/tamids-hyperreduction/pyhyperrom/tree/main/pyHyperRom/examples"
    click Prob "https://github.com/tamids-hyperreduction/pyhyperrom/tree/main/pyHyperRom/src/codes/prob_classes"
    click HeatHC "https://github.com/tamids-hyperreduction/pyhyperrom/blob/main/pyHyperRom/src/codes/prob_classes/heat_conduction/base_class_heat_conduction.py"
    click DEIM "https://github.com/tamids-hyperreduction/pyhyperrom/blob/main/pyHyperRom/src/codes/algorithms/deim.py"
    click ECM "https://github.com/tamids-hyperreduction/pyhyperrom/blob/main/pyHyperRom/src/codes/algorithms/ecm.py"
    click ECSW "https://github.com/tamids-hyperreduction/pyhyperrom/blob/main/pyHyperRom/src/codes/algorithms/ecsw.py"
    click EmpCub "https://github.com/tamids-hyperreduction/pyhyperrom/blob/main/pyHyperRom/src/codes/algorithms/empirical_cubature_method.py"
    click NNLS "https://github.com/tamids-hyperreduction/pyhyperrom/blob/main/pyHyperRom/src/codes/algorithms/nnls_scipy.py"
    click Red "https://github.com/tamids-hyperreduction/pyhyperrom/blob/main/pyHyperRom/src/codes/reductor/rom_class_ms.py"
    click FEMHC "https://github.com/tamids-hyperreduction/pyhyperrom/blob/main/pyHyperRom/src/codes/utils/fem_utils_HC.py"
    click DirU "https://github.com/tamids-hyperreduction/pyhyperrom/blob/main/pyHyperRom/src/codes/utils/dir_utils.py"
    click ROMU "https://github.com/tamids-hyperreduction/pyhyperrom/blob/main/pyHyperRom/src/codes/utils/rom_utils.py"
    click PlotU "https://github.com/tamids-hyperreduction/pyhyperrom/blob/main/pyHyperRom/src/codes/utils/plot_files/plot_utils.py"
    click Anim1D "https://github.com/tamids-hyperreduction/pyhyperrom/blob/main/pyHyperRom/src/codes/utils/plot_files/animate_1D.py"
    click Anim2D "https://github.com/tamids-hyperreduction/pyhyperrom/blob/main/pyHyperRom/src/codes/utils/plot_files/animate_2D.py"
    click PubStyle "https://github.com/tamids-hyperreduction/pyhyperrom/blob/main/pyHyperRom/src/codes/utils/plot_files/publication.mplstyle"
    click Res "https://github.com/tamids-hyperreduction/pyhyperrom/tree/main/pyHyperRom/Resources"
    click StylePkg "https://github.com/tamids-hyperreduction/pyhyperrom/blob/main/pyHyperRom/Resources/sci_mplstyle_package.zip"
    click External "https://github.com/tamids-hyperreduction/pyhyperrom/blob/main/requirements.txt"

    %% Styles
    classDef ui fill:#ccf,stroke:#333,stroke-width:1px;
    classDef core fill:#cfc,stroke:#333,stroke-width:1px;
    classDef resources fill:#ffc,stroke:#333,stroke-width:1px;
    classDef external fill:#ccc,stroke:#333,stroke-width:1px;
    classDef data fill:#eef,stroke:#333,stroke-width:1px,stroke-dasharray: 5 5;
    class Alg DEIM,ECM,ECSW,EmpCub,NNLS;
    class Utils FEMHC,DirU,ROMU,PlotU,Anim1D,Anim2D,PubStyle;
    class Prob,HeatHC,Red core;
```
