# lululxvi/deepxde architecture

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

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

## Overview

##### Project type and purpose
- DeepXDE is an open-source Python library (not a web or mobile app) for scientific machine learning—especially physics-informed neural networks (PINNs), DeepONet, and multifidelity neural networks—to solve differential equations.
- It provides a concise user API, plugs into multiple tensor-computation backends (TensorFlow v1 & v2, PyTorch, JAX, PaddlePaddle), and exposes modular components for data, geometry, gradients, networks, optimizers, and utilities.

##### File structure
- Top-level “deepxde/” directory holds the core library.
– deepxde/backend: adapter layer and Tensor/ops uniform API + subdirs for each backend
– deepxde/data, geometry, gradients, icbc: problem definition (domains, PDEs/BCs, sampling)
– deepxde/nn: network abstractions (FNN, DeepONet, etc.) with per-backend implementations
– deepxde/optimizers: optimizer wrappers with per-backend code
– deepxde/utils: cross-backend compatibility utilities
– deepxde/model.py, callbacks.py, losses.py, metrics.py: training pipeline and high-level abstractions
– deepxde/zcs: zero-coordinate-shift AD strategy
- Infrastructure folders: docs/ (documentation), examples/ (demo scripts), docker/, CI workflows.

##### README for additional insights
- Confirms plug-and-play backend support, lists algorithms (PINN, DeepONet, MFNN), AD methods, sampling, geometries, BCs, and training features (callbacks, data-parallel).
- Contains architecture snapshots (images/pinn.png, backend.png) that hint at layered design.

##### Essential elements
– Notes indicating “same structure for other backends”

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User Layer
    User["User Code & Examples"]:::user

    %% Core API & Training Pipeline
    subgraph "Core API & Training Pipeline"
        Model["deepxde/model.py"]:::core
        Callbacks["deepxde/callbacks.py"]:::core
        Losses["deepxde/losses.py"]:::core
        Metrics["deepxde/metrics.py"]:::core
        Config["deepxde/config.py"]:::core
    end

    %% Problem-Definition Modules
    subgraph "Problem-Definition Modules"
        Data["deepxde/data"]:::problem
        Geometry["deepxde/geometry"]:::problem
        ICBC["deepxde/icbc"]:::problem
    end

    %% Network & AD Engine
    subgraph "Network & AD Engine"
        NN["deepxde/nn"]:::network
        Gradients["deepxde/gradients"]:::ad
        ZCS["deepxde/zcs"]:::ad
    end

    %% Adapter Layer
    subgraph "Adapter Layer"
        Backend["deepxde/backend"]:::adapter
        Optimizers["deepxde/optimizers"]:::adapter
    end

    %% Utility Layer
    Utils["deepxde/utils"]:::util

    %% External Tensor Libraries
    subgraph "External Tensor Libraries"
        TF2["TensorFlow 2.x"]:::ext
        Others["PyTorch, JAX, Paddle"]:::ext
    end

    %% Infrastructure
    subgraph "Infrastructure"
        Docs["docs/"]:::infra
        Docker["docker/"]:::infra
        CI[".github/workflows/"]:::infra
    end

    %% Relationships & Data Flow
    User -->|"defines PDE & config"| Model
    Model -->|uses problem setup| Data
    Model -->|uses problem setup| Geometry
    Model -->|uses problem setup| ICBC
    Model -->|builds NN| NN
    Model -->|invokes backend ops| Backend
    Model -->|registers callbacks, losses, metrics| Callbacks
    Model -->|registers callbacks, losses, metrics| Losses
    Model -->|registers callbacks, losses, metrics| Metrics
    Model -->|reads config| Config

    NN -->|build compute graph| Backend
    Backend -->|execute ops| TF2
    Backend -->|execute ops| Others
    Backend -->|compute derivatives| Gradients
    Backend -->|ZCS strategy| ZCS
    Losses -->|require gradients| Gradients
    Gradients -->|parameter gradients| Optimizers
    ZCS -->|parameter gradients| Optimizers
    Optimizers -->|update weights| Backend
    Callbacks -->|persistence & I/O| Utils

    %% Click Events
    click User "https://github.com/lululxvi/deepxde/tree/master/examples/"
    click Model "https://github.com/lululxvi/deepxde/blob/master/deepxde/model.py"
    click Callbacks "https://github.com/lululxvi/deepxde/blob/master/deepxde/callbacks.py"
    click Losses "https://github.com/lululxvi/deepxde/blob/master/deepxde/losses.py"
    click Metrics "https://github.com/lululxvi/deepxde/blob/master/deepxde/metrics.py"
    click Config "https://github.com/lululxvi/deepxde/blob/master/deepxde/config.py"
    click Data "https://github.com/lululxvi/deepxde/tree/master/deepxde/data/"
    click Geometry "https://github.com/lululxvi/deepxde/tree/master/deepxde/geometry/"
    click ICBC "https://github.com/lululxvi/deepxde/tree/master/deepxde/icbc/"
    click NN "https://github.com/lululxvi/deepxde/tree/master/deepxde/nn/"
    click Gradients "https://github.com/lululxvi/deepxde/tree/master/deepxde/gradients/"
    click ZCS "https://github.com/lululxvi/deepxde/tree/master/deepxde/zcs/"
    click Backend "https://github.com/lululxvi/deepxde/tree/master/deepxde/backend/"
    click Optimizers "https://github.com/lululxvi/deepxde/tree/master/deepxde/optimizers/"
    click Utils "https://github.com/lululxvi/deepxde/tree/master/deepxde/utils/"
    click Docs "https://github.com/lululxvi/deepxde/tree/master/docs/"
    click Docker "https://github.com/lululxvi/deepxde/tree/master/docker/"
    click CI "https://github.com/lululxvi/deepxde/tree/master/.github/workflows/"

    %% Styles
    classDef user fill:#E0F7FA,stroke:#006064
    classDef core fill:#BBDEFB,stroke:#1E88E5
    classDef problem fill:#C8E6C9,stroke:#2E7D32
    classDef network fill:#FFE0B2,stroke:#EF6C00
    classDef ad fill:#FFE0B2,stroke:#EF6C00
    classDef adapter fill:#FFCC80,stroke:#EF6C00
    classDef util fill:#F0F4C3,stroke:#9E9D24
    classDef ext fill:#FFF9C4,stroke:#FBC02D
    classDef infra fill:#ECEFF1,stroke:#607D8B
```
