# ehsanhaghighat/en-deeponet architecture

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

- Interactive diagram: https://gitdiagram.com/ehsanhaghighat/en-deeponet
- Repository: https://github.com/ehsanhaghighat/en-deeponet

## Overview

##### Project Type & Purpose
- This is a machine-learning research repository implementing and evaluating a novel neural-operator architecture (“En-DeepONet”) across several PDE/test-case experiments (Laplace, Level-set/Eikonal, Marmousi, OpenFWI, SmoothVelocity).
- The README confirms the goal: train/enhance DeepONet to learn moving-solution operators for seismic applications and compare performance.

##### File Structure
- Top-level directories (Laplace, Levelset, Marmousi, OpenFWI, SmoothVelocity) each contain:
- A Jupyter notebook (.ipynb) orchestrating data loading, model instantiation/training, and result plotting.
- A same-named subfolder capturing artifacts (loss_history.csv, weights-*.hdf5, PDF figures).
- Optional raw data (e.g., Laplace/data/*.txt, Marmousi/vel.rsf).
- requirements.txt lists Python≥3.8 deps (likely TensorFlow/Keras for .hdf5 storage).
- No “service” layers–this is a research pipeline, not a web or microservices app.

##### Extract Insights from README
- Core components: data ingestion (synthetic/comsol or real velocity fields), model architecture (BranchNet, TrunkNet, plus “root” enrichment net, and add/subtract operations), training engine, evaluation/visualization.

##### System Components
a. Data Layer
- Raw data stores (txt, rsf) per experiment.
- Preprocessing scripts embedded in notebooks.
b. Model Layer
- En-DeepONet architecture:
- Branch network (parameterizes input function).
- Trunk network (parameterizes spatial coordinates).
- Root network (enrichment).
- Merge operations (add/subtract).
c. Training Pipeline
- Experiment orchestrator (Jupyter notebook + Python scripts).
- Loss computation, optimizer (e.g., Adam/L-BFGS), checkpointing to .hdf5.
d. Postprocessing & Visualization
- Loss history analysis (loss_history.csv → plots).
- Result PDFs (.pdf) and interactive Jupyter outputs.
e. Environment & Dependencies
- Python runtime, Jupyter, TensorFlow/Keras, NumPy, Matplotlib, any comsol-data loader.

##### Relationships & Data Flows
- Preprocessing → Model inputs.
- Model → Checkpointing (weights-*.hdf5) and LossHistory (.csv).
- Checkpoints & CSV → Postprocessing/Plot module → PDF/Notebook visuals.

##### Architectural Patterns
- Pipeline pattern: data → model → evaluate
- Modular ML design: separation of “network definition” vs. “training loop” vs. “evaluation scripts.”
- Experiment isolation: each top-level folder is an independent run, sharing common code patterns.

##### Detail Checklist
- All major folders (Laplace, Levelset, Marmousi, OpenFWI, SmoothVelocity) shown as parallel workflows.
- Data ingestion blocks connected to their respective notebooks.
- Model definition block subdivided into three sub-components (BranchNet, TrunkNet, RootNet) with merge operations highlighted.
- Training block showing optimizer, loss computation → HDF5 & CSV outputs.
- Postprocessing block reading CSV/HDF5 → generating PDF plots.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Environment container
    subgraph "Environment: Python3.8–3.10, TensorFlow/Keras, Jupyter, NumPy, Matplotlib" 
        style Environment fill:#D3D3D3,stroke:#666,stroke-width:2px
        Environment{{ }}
    end

    %% Laplace Experiment
    subgraph "Laplace Experiment"
        direction TB
        LaplaceData["Raw Data (txt)"]:::data
        LaplacePI_DEEP["PI-DeepONet Baseline Notebook"]:::model
        LaplacePI_EN["PI-En-DeepONet Notebook"]:::model
        LaplaceTrainBase["Training Outputs (Baseline)"]:::training
        LaplaceTrainEn["Training Outputs (En-DeepONet)"]:::training
        LaplacePlot["PlotResults.ipynb"]:::results

        LaplaceData -->|".txt → numpy array"| LaplacePI_DEEP
        LaplaceData -->|".txt → numpy array"| LaplacePI_EN
        LaplacePI_DEEP -->|".hdf5 checkpoint & .csv"| LaplaceTrainBase
        LaplacePI_EN -->|".hdf5 checkpoint & .csv"| LaplaceTrainEn
        LaplaceTrainBase -->|".csv & .hdf5 → plots"| LaplacePlot
        LaplaceTrainEn -->|".csv & .hdf5 → plots"| LaplacePlot
    end

    %% Level-set Experiment
    subgraph "Level-set Experiment"
        direction TB
        LevelData["Raw Data (rsf/txt)"]:::data
        LS_DEEP_DR["DeepONet Data-driven"]:::model
        LS_DEEP_PINN["DeepONet PINN"]:::model
        LS_EN_DR["En-DeepONet Data-driven"]:::model
        LS_EN_PINN["En-DeepONet PINN"]:::model
        LS_TrainDeepDR["Training Outputs (Data-driven)"]:::training
        LS_TrainDeepPINN["Training Outputs (PINN)"]:::training
        LS_TrainEnDR["Training Outputs En-DeepONet DR"]:::training
        LS_TrainEnPINN["Training Outputs En-DeepONet PINN"]:::training
        LS_Plot["PlotResults-pinn.ipynb"]:::results

        LevelData -->|".rsf/txt → numpy array"| LS_DEEP_DR
        LevelData -->|".rsf/txt → numpy array"| LS_DEEP_PINN
        LevelData -->|".rsf/txt → numpy array"| LS_EN_DR
        LevelData -->|".rsf/txt → numpy array"| LS_EN_PINN
        LS_DEEP_DR -->|".hdf5 & .csv"| LS_TrainDeepDR
        LS_DEEP_PINN -->|".hdf5 & .csv"| LS_TrainDeepPINN
        LS_EN_DR -->|".hdf5 & .csv"| LS_TrainEnDR
        LS_EN_PINN -->|".hdf5 & .csv"| LS_TrainEnPINN
        LS_TrainDeepPINN -->|".csv & .hdf5 → plots"| LS_Plot
        LS_TrainEnPINN -->|".csv & .hdf5 → plots"| LS_Plot
    end

    %% Marmousi Experiment
    subgraph "Marmousi Experiment"
        direction TB
        MarmData["Raw Data (vel.rsf)"]:::data
        Marm_EN["En-DeepONet Notebook"]:::model
        Marm_Train["Training Outputs"]:::training
        Marm_Plot["PlotResults.ipynb"]:::results

        MarmData -->|".rsf → numpy array"| Marm_EN
        Marm_EN -->|".hdf5 & .csv"| Marm_Train
        Marm_Train -->|".csv & .hdf5 → plots"| Marm_Plot
    end

    %% OpenFWI Experiment
    subgraph "OpenFWI Experiment"
        direction TB
        FWIData["Raw Data"]:::data
        FWI_EN["En-DeepONet Notebook"]:::model
        FWI_Train["Training Outputs"]:::training
        FWI_Plot["PlotResults.ipynb"]:::results

        FWIData -->|".data → numpy array"| FWI_EN
        FWI_EN -->|".hdf5 & .csv"| FWI_Train
        FWI_Train -->|".csv & .hdf5 → plots"| FWI_Plot
    end

    %% SmoothVelocity Experiment
    subgraph "SmoothVelocity Experiment"
        direction TB
        SVData["Raw Data"]:::data
        SV_EN["En-DeepONet Notebook"]:::model
        SV_Train["Training Outputs"]:::training
        SV_Plot["PlotResults.ipynb"]:::results

        SVData -->|".data → numpy array"| SV_EN
        SV_EN -->|".hdf5 & .csv"| SV_Train
        SV_Train -->|".csv & .hdf5 → plots"| SV_Plot
    end

    %% Click Events
    click LaplaceData "https://github.com/ehsanhaghighat/en-deeponet/tree/main/Laplace/data/"
    click MarmData "https://github.com/ehsanhaghighat/en-deeponet/blob/main/Marmousi/vel.rsf"
    click LaplacePI_DEEP "https://github.com/ehsanhaghighat/en-deeponet/blob/main/Laplace/PI_DeepONet_Laplace.ipynb"
    click LaplacePI_EN "https://github.com/ehsanhaghighat/en-deeponet/blob/main/Laplace/PI_EnDeepONet_Laplace.ipynb"
    click LS_DEEP_DR "https://github.com/ehsanhaghighat/en-deeponet/blob/main/Levelset/DeepONet_Eikonal-datadriven.ipynb"
    click LS_DEEP_PINN "https://github.com/ehsanhaghighat/en-deeponet/blob/main/Levelset/DeepONet_Eikonal-pinn.ipynb"
    click LS_EN_DR "https://github.com/ehsanhaghighat/en-deeponet/blob/main/Levelset/EnDeepONet_Eikonal-datadriven.ipynb"
    click LS_EN_PINN "https://github.com/ehsanhaghighat/en-deeponet/blob/main/Levelset/EnDeepONet_Eikonal-pinn.ipynb"
    click Marm_EN "https://github.com/ehsanhaghighat/en-deeponet/blob/main/Marmousi/EnDeepONet_Eikonal_Marmousi.ipynb"
    click FWI_EN "https://github.com/ehsanhaghighat/en-deeponet/blob/main/OpenFWI/EnDeepONet-OpenFWI.ipynb"
    click SV_EN "https://github.com/ehsanhaghighat/en-deeponet/blob/main/SmoothVelocity/EnDeepONet_SmoothVelocity.ipynb"
    click LaplaceTrainBase "https://github.com/ehsanhaghighat/en-deeponet/tree/main/Laplace/PI_DeepONet_Laplace/"
    click LaplaceTrainEn "https://github.com/ehsanhaghighat/en-deeponet/tree/main/Laplace/PI_EnDeepONet_Laplace/"
    click LS_TrainDeepDR "https://github.com/ehsanhaghighat/en-deeponet/tree/main/Levelset/DeepONet_Eikonal-datadriven/"
    click LS_TrainDeepPINN "https://github.com/ehsanhaghighat/en-deeponet/tree/main/Levelset/DeepONet_Eikonal-pinn/"
    click LS_TrainEnDR "https://github.com/ehsanhaghighat/en-deeponet/tree/main/Levelset/EnDeepONet_Eikonal-datadriven/"
    click LS_TrainEnPINN "https://github.com/ehsanhaghighat/en-deeponet/tree/main/Levelset/EnDeepONet_Eikonal-pinn/"
    click Marm_Train "https://github.com/ehsanhaghighat/en-deeponet/tree/main/Marmousi/EnDeepONet_Eikonal_Marmousi/"
    click FWI_Train "https://github.com/ehsanhaghighat/en-deeponet/tree/main/OpenFWI/EnDeepONet-OpenFWI/"
    click SV_Train "https://github.com/ehsanhaghighat/en-deeponet/tree/main/SmoothVelocity/EnDeepONet_SmoothVelocity/"
    click LaplacePlot "https://github.com/ehsanhaghighat/en-deeponet/blob/main/Laplace/PlotResults.ipynb"
    click LS_Plot "https://github.com/ehsanhaghighat/en-deeponet/blob/main/Levelset/PlotResults-pinn.ipynb"
    click Marm_Plot "https://github.com/ehsanhaghighat/en-deeponet/blob/main/Marmousi/PlotResults.ipynb"
    click FWI_Plot "https://github.com/ehsanhaghighat/en-deeponet/blob/main/OpenFWI/PlotResults.ipynb"
    click SV_Plot "https://github.com/ehsanhaghighat/en-deeponet/blob/main/SmoothVelocity/PlotResults.ipynb"

    %% Styles
    classDef data fill:#ADD8E6,stroke:#000,stroke-width:1px
    classDef model fill:#90EE90,stroke:#000,stroke-width:1px
    classDef training fill:#FFA500,stroke:#000,stroke-width:1px
    classDef results fill:#DA70D6,stroke:#000,stroke-width:1px
    classDef env fill:#D3D3D3,stroke:#666,stroke-width:2px
```
