# lululxvi/deeponet architecture

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

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

## Overview

##### Overall Project Type and Purpose
- Type: A research-oriented deep learning framework designed for learning nonlinear operators.
- Purpose: Demonstrate various applications of DeepONet (and related architectures such as CNNs or sequence-to-sequence models) to solve differential equations, including fractional derivatives, ODEs/PDEs, advection-diffusion, and even Hamiltonian-based integrators.
- Main use cases include generating datasets, training the neural network models (DeepONet, seq2seq, CNNs, etc.), and evaluating the trained models with metrics such as MSE.

##### Main Components
A. Data Generation & Preprocessing
- MATLAB-based Data Generation:
- In the “fractional” directory (e.g., Caputo_1D.m, Fractional_Lap_2D.m, Orthogonal_polynomials.m, etc.) used to generate training and test datasets.
- “matrix_for_frac_Lap.m”, “GJ_generate.m”, etc. for data preparation.
- Python-based Data Generation:
- In the “src” folder (e.g., deeponet_pde.py, sde.py, and various solver scripts like ADR_solver.py, ADVD_solver.py, CVC_solver.py).
- In “seq2seq” modules for generating datasets that feed into seq2seq experiments.
- Data Packaging and Compression:
- “datasets.py” in the fractional folder and related data modules in “seq2seq/learner/data”.

B. Neural Network Model Components & Learning Modules
- DeepONet Training Modules:
- “DeepONet_float32_batch.py” which trains models for fractional cases.
- “deeponet_pde.py” in src used for antiderivative experiments and other PDE setups.
- Alternative Architectures:
- “seq2seq/learner/nn/seq2seq.py” for sequence-to-sequence neural network training.
- Other NN modules in “seq2seq/learner/nn” (deeponet.py, fnn.py, hnn.py, sympnet.py) representing different architectures that may be used depending on the experimental case.
- Training Orchestration:
- “seq2seq/learner/brain.py” and “seq2seq/learner/utils.py” for supervision and training utilities.
- The integrator module (especially “seq2seq/learner/integrator/hamiltonian/stormer_verlet.py”) indicating support for time integration in dynamic systems.

C. Solvers & System Specifics
- In the “src” directory, you have solvers like ADR_solver.py, ADVD_solver.py, and CVC_solver.py that contribute simulation capabilities.
- “system.py” and “config.py” help to configure and manage overall simulation settings.

D. Infrastructure & Deployment
- Configuration and settings files (e.g., requirements.txt, config.py).
- Model saving and evaluation utilities (e.g., output log details, saving checkpoints in seq2seq/seq2seq_main.py and outputs/ folder).

##### Relationships and Interactions to Highlight
- Data Flow: Data Generation (MATLAB scripts or Python scripts) → Data Packaging (datasets.py or learner/data modules) → Neural Network Training (DeepONet modules in both fractional and seq2seq directories) → Model Evaluation & Prediction (logs, figures, output files).
- Cross-Language Interplay: Emphasize the integration between MATLAB-based preprocessing and Python-based training pipelines.
- Task Differentiation: Clarify separate branching for different experiments. For instance, one branch for fractional derivative modeling (using MATLAB scripts then Python model training) versus the seq2seq branch for ODE/PDE tasks.
- Optional Integration Points: Note that some experiments, such as CNN operators (via CNN_operator_alpha.py), have a separate data-to-training workflow that can be highlighted as an alternative pipeline.

##### Architectural Patterns & Design Principles
- Modularity: Each experimental case is broken into isolated modules (data generation, preprocessing, learning, evaluation) that can be swapped or extended.
- Separation of Concerns: The code separates solvers/simulators (in src) from model definition and training (in seq2seq and fractional folders).
- Hybrid Integration: The project leverages both MATLAB and Python environments, indicating a dual-language workflow.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Data Generation Layer
    subgraph "Data Generation"
        A["MATLAB Data Generation"]:::matlab
        B["Python Data Generation (src)"]:::python
        C["Python Data Generation (seq2seq)"]:::python
    end

    %% Data Packaging Layer
    subgraph "Data Packaging & Preprocessing"
        D["Data Packaging & Compression"]:::python
    end

    %% Neural Network Training & Orchestration Layer
    subgraph "Neural Network Training & Orchestration"
        E["DeepONet Training"]:::training
        F["Alternative NN Architectures"]:::training
        G["Training Orchestration & Utilities"]:::training
        H["Integrator Module"]:::training
        I["Seq2Seq Main Runner & Evaluation"]:::training
    end

    %% Solvers & Simulation Layer
    subgraph "Solvers & Simulation"
        J["Solvers & Simulation Modules"]:::solver
    end

    %% Infrastructure & Deployment Layer
    subgraph "Infrastructure & Deployment"
        K["Infra & Deployment"]:::deployment
    end

    %% External Dependencies
    subgraph "External Dependencies"
        ED["DeepXDE"]:::external
    end

    %% Connections
    A --> D
    B --> D
    C --> D

    D --> E
    D --> F
    D --> J

    E --> G
    F --> G
    G --> I
    G --> H

    J --> K

    E --> ED

    %% Click Events
    click A "https://github.com/lululxvi/deeponet/tree/master/fractional/"
    click B "https://github.com/lululxvi/deeponet/tree/master/src/"
    click C "https://github.com/lululxvi/deeponet/blob/master/seq2seq/data.py"
    click D "https://github.com/lululxvi/deeponet/blob/master/fractional/datasets.py"
    click D "https://github.com/lululxvi/deeponet/blob/master/seq2seq/learner/data/data.py"
    click E "https://github.com/lululxvi/deeponet/blob/master/fractional/DeepONet_float32_batch.py"
    click E "https://github.com/lululxvi/deeponet/blob/master/src/deeponet_pde.py"
    click E "https://github.com/lululxvi/deeponet/blob/master/seq2seq/learner/nn/deeponet.py"
    click F "https://github.com/lululxvi/deeponet/tree/master/seq2seq/learner/nn/"
    click G "https://github.com/lululxvi/deeponet/blob/master/seq2seq/learner/brain.py"
    click G "https://github.com/lululxvi/deeponet/blob/master/seq2seq/learner/utils.py"
    click H "https://github.com/lululxvi/deeponet/blob/master/seq2seq/learner/integrator/hamiltonian/stormer_verlet.py"
    click J "https://github.com/lululxvi/deeponet/tree/master/src/"
    click K "https://github.com/lululxvi/deeponet/blob/master/requirements.txt"
    click K "https://github.com/lululxvi/deeponet/blob/master/src/config.py"
    click I "https://github.com/lululxvi/deeponet/blob/master/seq2seq/seq2seq_main.py"

    %% Styles
    classDef matlab fill:#90ee90,stroke:#006400,stroke-width:2px;
    classDef python fill:#add8e6,stroke:#00008b,stroke-width:2px;
    classDef training fill:#FFD700,stroke:#B8860B,stroke-width:2px;
    classDef solver fill:#FFA07A,stroke:#FF4500,stroke-width:2px;
    classDef deployment fill:#D3D3D3,stroke:#696969,stroke-width:2px;
    classDef external fill:#f9d6a5,stroke:#DA8A67,stroke-width:2px;
```
