deeponet-fno

repository·main·Indexed 18 days ago

https://github.com/lu-group/deeponet-fno

A research repository providing implementations and datasets for comparing DeepONet and Fourier Neural Operators (FNO) across scientific computing benchmarks. It includes code and data for problems such as the Advection equation, Burgers' equation, Darcy problems (rectangular and triangular domains), linear instability waves, Navier-Stokes, and Euler equations. The repository features FNO1d and FNO2d architectures, spectral convolution implementations, and utilities for data normalization and loading from MAT or H5 files.

Tokens
13.3K
Snippets
42
Records
53
Agent score
63%

What's inside deeponet-fno

  1. Overview of DeepONet & FNO implementations

    main
    This repository provides the data and code for the research paper comparing DeepONet and Fourier Neural Operators (FNO) using FAIR data. It includes implementations for various scientific computing problems, including fluid dynamics (Navier-Stokes, Euler equations), transport equations (Advection, Burgers'), and porous media flow (Darcy problems).
  2. Access Darcy problem data for rectangular domains

    main

    The dataset for the Darcy problem in a rectangular domain (piecewise constant) is sourced from the original Fourier Neural Operator repository. You can download the data via the provided SharePoint link.

    Note: This data is specifically for the piecewise constant version of the Darcy problem in a rectangular domain.

    Data Link: https://yaleedu-my.sharepoint.com/:f:/g/personal/lu_lu_yale_edu/Ei-oRTd9XvBEjwdAqOl1kUYBr2cGoeiJigfL1yuvS1mzaw?e=vUoqEb
  3. Access DeepONet code for linear instability waves

    main
    The implementation for DeepONet prediction of linear instability waves in high-speed boundary layers is documented in the research paper: P. Clark Di Leoni, L. Lu, C. Meneveau, G. E. Karniadakis, & T. A. Zaki. DeepONet prediction of linear instability waves in high-speed boundary layers. arXiv preprint arXiv:2105.08697, 2021.
  4. Access Burgers' equation data

    main

    The Burgers' equation dataset used in this repository is sourced from the original Fourier Neural Operator implementation. You can download the data via the provided SharePoint link.

    Data Link: https://yaleedu-my.sharepoint.com/:f:/g/personal/lu_lu_yale_edu/Ei-oRTd9XvBEjwdAqOl1kUYBr2cGoeiJigfL1yuvS1mzaw?e=vUoqEb
  5. Available datasets and problem implementations

    main

    The repository is organized into datasets and corresponding code implementations for several scientific problems. You can find specific implementations in the src/ directory and their associated data in the data/ directory.

    Supported Problems:

    • Burgers' equation: data/burgers and src/burgers
    • Darcy problem (Rectangular, Piecewise constant): data/darcy_rectangular_pwc and src/darcy_rectangular_pwc
    • Darcy problem (Triangular domain with notch): data/darcy_triangular_notch and src/darcy_triangular_notch
    • Advection equation (Case II & III): src/advection_II_III
    • Linear instability waves: data/instability_wave and src/instability_wave

    Other problems available (check directories for specific code/data):

    • Darcy problem (Continuous, Pentagram with hole, Triangular domain)
    • Electroconvection
    • Compressible Euler equations
    • Flapping airfoil
    • Navier-Stokes (vorticity-velocity form)
    • Regularized cavity flows (Steady/Unsteady)
  6. Configure FNO2d Hyperparameters

    main

    When setting up an FNO2d model, consider the following hyperparameter constraints observed in the implementation:

    • modes1 & modes2: These define the number of Fourier modes used in the spectral convolution. They should be chosen based on the grid resolution (e.g., modes1 $\le$ $n_t$, modes2 $\le$ $n_x/2 + 1$).
    • width: The hidden channel dimension. Increasing width increases model capacity but significantly increases memory usage. For example, a width of 64 is used in the reference implementation, but higher values may cause Out-of-Memory (OOM) errors on consumer GPUs.
    • Input Channels: The current implementation of FNO2d uses self.fc0 = nn.Linear(3, self.width), meaning it expects an input with 3 channels (typically representing the coefficient function, spatial coordinates, and time).
  7. DeepONet Hyperparameters and Architecture

    main

    The DeepONet architecture in this implementation is defined by the following parameters:

    • Output dimension (p): The dimension of the Branch and Trunk net outputs (default: 100).
    • Branch net layers (layer_B): Defines the structure of the Branch network. Example: [num, 128, 128, p] where num is the input dimension.
    • Trunk net layers (layer_T): Defines the structure of the Trunk network. Example: [2, 128, 128, 128, p] where 2 represents the input coordinates (x, y).
    • Resolution (h): The number of points used for resolution (default: num).
    • Batch size (bs): Number of samples per training step (default: 100).
    • Input size (nx): The number of spatial points for the Trunk net (default: 2295).
    • Epochs: Total training iterations (default: 20000).
  8. Train a POD-based DeepONet for Darcy flow

    main

    This script implements a POD-based (Proper Orthogonal Decomposition) DeepONet training pipeline for the Darcy triangular notch problem. It uses a hybrid architecture where a CNN processes input functions (branch net) and combines them with a pre-computed POD basis to reconstruct the solution field.

    Workflow

    1. Data Loading: Uses DataSet to generate minibatches and compute the POD basis.
    2. Architecture:
      • Branch Net: A combination of an FNN (Feedforward Neural Network) and a CNN (Convolutional Neural Network) that maps input functions to coefficients.
      • POD Reconstruction: The output coefficients are multiplied by the u_basis using tf.einsum to predict the full solution field.
    3. Training: Uses the AdamOptimizer to minimize the mean squared error between the predicted and ground truth solution fields.
    4. Evaluation: Periodically calculates the relative L2 error on a test batch.
    5. Saving: Uses SaveData to persist results.

    Configuration Parameters

    The script uses several hardcoded hyperparameters that define the network architecture and data dimensions:

    • p: Output dimension of Branch/Trunk.
    • modes: Number of POD modes.
    • s, s_in: Dimensions for the FNN layers.
    • layer_B: Dimensions for the Branch net output layers.
    • h, w: Resolution for the CNN input.
    • bs: Batch size.
    • nx: Size of the input for the Trunk net.

    Requirements

    • TensorFlow 1.x (tensorflow.compat.v1)
    • NumPy
    • Matplotlib
    • Local modules: dataset, fnn, conv, savedata
    import os
    # Set GPU device
    os.environ['CUDA_VISIBLE_DEVICES']='1'
    
    # The script is executed as a standalone training entrypoint
    if __name__ == "__main__":
        main()