Skip to content

Various methods for solving PDEs using artificial intelligence

License

Notifications You must be signed in to change notification settings

Michael-Jackson666/AI4CFD

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

AI4CFD: AI Methods for Computational Fluid Dynamics

License: MIT Python 3.8+ PyTorch

Complete implementations of deep learning methods for solving Partial Differential Equations (PDEs), including tutorials, training code, and real-world applications.

🧠 Core Methods

1. Physics-Informed Neural Networks (PINNs)

Neural networks that encode physical laws directly into the loss function

Core Idea: Construct physics-constrained loss using automatic differentiation:

$$ \begin{aligned} \mathcal{L} = \mathcal{L}_{data} + \mathcal{L}_{PDE} = \frac{1}{N_b}\sum_{i=1}^{N_b}\left|u(x_b^i) - u_b^i\right|^2 + \frac{1}{N_f}\sum_{j=1}^{N_f}\left|\mathcal{N} \left[u\right] (x_f^j)\right|^2 \end{aligned} $$

  • Advantages: Low data requirements, handles complex boundaries, suitable for inverse problems
  • Location: PINNs/
  • Tutorials: 8 Jupyter notebooks (English & Chinese), from basics to advanced
  • Applications: Poisson, Heat, Navier-Stokes, Vlasov-Poisson systems

2. Deep Operator Networks (DeepONet)

Neural networks learning mappings between infinite-dimensional function spaces

Core Idea: Branch-Trunk architecture for learning operators $G: u \to G(u)$:

$$ G(u)(y) \approx \sum_{k=1}^{p} \underbrace{b_k(u)}_{\text{Branch}} \cdot \underbrace{t_k(y)}_{\text{Trunk}} $$

  • Advantages: Train once, fast inference (milliseconds), efficient for multi-query
  • Location: DeepONet/
  • Tutorials: Pure PyTorch implementation tutorial
  • Applications: Heat equation, Burgers, Darcy flow, VP systems

3. Fourier Neural Operators (FNO)

Neural operators solving PDEs in frequency domain

Core Idea: Convolution in Fourier space for global information propagation:

$$ v_{t+1}(x) = \sigma\left( W v_t(x) + \mathcal{F}^{-1}(R \cdot \mathcal{F}(v_t))(x) \right) $$

  • Advantages: Resolution-invariant, excellent for periodic problems, high-resolution solving
  • Location: FNO/
  • Applications: Navier-Stokes, turbulence modeling, Darcy flow

4. Physics-Informed Neural Operators (PINO)

Neural operators combining FNO architecture with physics constraints

Core Idea: Learn solution operators with both data fitting and PDE residuals:

$$ \mathcal{L}_{PINO} = \underbrace{\mathcal{L}_{data}}_{\text{Data Loss}} + \lambda \underbrace{\mathcal{L}_{PDE}}_{\text{Physics Loss}} $$

  • Advantages: Less data than FNO, better generalization than PINNs, fast inference, physics-consistent
  • Location: PINO/
  • Tutorials: Complete overview notebook, 3 example implementations (Burgers, Darcy, Heat)
  • Applications: Burgers equation, Darcy flow, heat conduction, parametric PDEs

5. Tensor Neural Networks (TNN)

Neural networks using tensor decomposition for high-dimensional PDEs

Core Idea: Decompose high-dimensional functions into products of low-dimensional functions:

$$ u(x_1, \dots, x_d) \approx \sum_{r=1}^{R} \prod_{k=1}^{d} \phi_k^{(r)}(x_k) $$

  • Advantages: Linear parameter growth (vs exponential), suitable for high-dimensional problems
  • Location: TNN/
  • Tutorials: Complete Jupyter tutorial and 5D examples
  • Applications: 5D Poisson equation, high-dimensional PDE solving

6. Kolmogorov-Arnold Networks (KAN)

Neural networks with learnable activation functions inspired by Kolmogorov-Arnold representation theorem

Core Idea: Replace fixed activation functions with learnable univariate functions (B-splines):

$$ f(x_1, \dots, x_n) = \sum_{q=0}^{2n} \Phi_q\left(\sum_{p=1}^{n} \phi_{q,p}(x_p)\right) $$

  • Advantages: Higher accuracy with fewer parameters, interpretable, excellent for smooth PDEs
  • Location: KAN/
  • Tutorials: Complete PDE solving tutorial with B-spline implementation
  • Applications: Poisson, Heat, Burgers equations, smooth PDE problems

7. Flow Map Learning

Neural networks learning time integration operators for dynamical systems and PDEs

Core Idea: Learn the flow map $\Phi_{\Delta t}$ instead of directly solving the equation:

$$ \mathbf{x}(t+\Delta t) = \Phi_{\Delta t}(\mathbf{x}(t)) \approx \mathbf{x}(t) + \text{NN}(\mathbf{x}(t), \Delta t) $$

  • Advantages: Efficient long-term prediction, natural residual structure, flexible time stepping
  • Location: FLowMap/
  • Tutorials: Complete Flow Map tutorial with ODE and PDE examples
  • Applications: Lorenz chaotic system, heat equation, dynamical systems

8. Transformer-based Methods

Sequence models using attention mechanisms for PDE solving

Core Idea: Capture long-range dependencies in spatial/temporal domains via self-attention:

$$ \text{Attention}(Q, K, V) = \text{softmax}\left(\frac{QK^T}{\sqrt{d_k}}\right)V $$

  • Advantages: Long-range dependency capture, flexible architecture design
  • Location: Transformer/
  • Applications: Time-series prediction, multi-physics coupling

πŸ“ Project Structure

AI4CFD/
β”œβ”€β”€ PINNs/              # Physics-Informed Neural Networks
β”‚   β”œβ”€β”€ tutorial/       # 8 tutorials (English & Chinese)
β”‚   β”œβ”€β”€ vp_system/      # Vlasov-Poisson system implementation
β”‚   └── README.md
β”œβ”€β”€ DeepONet/           # Deep Operator Networks
β”‚   β”œβ”€β”€ tutorial/       # PyTorch implementation tutorial
β”‚   β”œβ”€β”€ vp_system/      # VP operator learning
β”‚   └── README.md
β”œβ”€β”€ FNO/                # Fourier Neural Operators
β”‚   └── README.md
β”œβ”€β”€ PINO/               # Physics-Informed Neural Operators
β”‚   β”œβ”€β”€ tutorial/       # Overview notebook
β”‚   β”œβ”€β”€ examples/       # Burgers, Darcy, Heat examples
β”‚   └── README.md
β”œβ”€β”€ KAN/                # Kolmogorov-Arnold Networks
β”‚   β”œβ”€β”€ tutorial/       # Complete PDE solving tutorial
β”‚   β”œβ”€β”€ examples/       # Poisson, Heat, Burgers examples
β”‚   β”œβ”€β”€ models.py       # KAN & B-spline implementation
β”‚   └── utils.py        # Utility functions
β”œβ”€β”€ FLowMap/            # Flow Map Learning
β”‚   β”œβ”€β”€ tutorial/       # Flow Map tutorial notebook
β”‚   β”œβ”€β”€ examples/       # Lorenz, heat equation examples
β”‚   β”œβ”€β”€ models.py       # FlowMapMLP, FlowMapCNN, etc.
β”‚   └── utils.py        # Data generation & visualization
β”œβ”€β”€ TNN/                # Tensor Neural Networks
β”‚   β”œβ”€β”€ tutorial/       # Complete tutorial
β”‚   β”œβ”€β”€ train/dim5/     # 5D PDE solving example
β”‚   └── README.md
β”œβ”€β”€ Transformer/        # Transformer-based methods
β”‚   └── README.md
β”œβ”€β”€ VP_system/          # Vlasov-Poisson applications
β”‚   └── TwoStreamInstability/  # Two-stream instability
└── utils/              # Shared utility functions

πŸš€ Quick Start

Installation

git clone https://github.com/Michael-Jackson666/AI4CFD.git
cd AI4CFD
pip install -r requirements.txt

Run Examples

PINNs Tutorial (Recommended for Beginners):

cd PINNs/tutorial
jupyter notebook tutorial_eng.ipynb  # English tutorial
# or
jupyter notebook tutorial_chinese.ipynb  # Chinese tutorial

TNN 5D Example:

cd TNN/train/dim5
python ex_5_1_dim5.py

PINO Tutorial (Physics-Informed Operators):

cd PINO/tutorial
jupyter notebook pino_overview.ipynb

DeepONet Tutorial:

cd DeepONet/tutorial
jupyter notebook operator_learning_torch.ipynb

KAN Tutorial (Kolmogorov-Arnold Networks):

cd KAN/tutorial
jupyter notebook kan_pde_tutorial.ipynb

KAN Examples:

cd KAN/examples
python poisson_1d.py   # 1D Poisson equation
python heat_1d.py      # 1D heat equation
python burgers_1d.py   # 1D Burgers equation

Flow Map Tutorial (Flow Map Learning):

cd FLowMap/tutorial
jupyter notebook flowmap_tutorial.ipynb

Flow Map Examples:

cd FLowMap/examples
python lorenz_system.py          # Lorenz chaotic system
python heat_equation_flowmap.py  # 1D heat equation

πŸ“Š Method Comparison

Method Training Data Single Solve Speed Parameter Query Best For
PINNs Low (physics-informed) Seconds Re-train needed Complex boundaries, inverse problems, data scarcity
DeepONet High (needs solutions) Milliseconds One forward pass Multi-query, real-time prediction
FNO High (needs solutions) Milliseconds One forward pass Periodic problems, turbulence, high-resolution
PINO Medium (data + physics) Milliseconds One forward pass Parametric PDEs, less data scenarios, physics-consistent operators
Flow Map Medium (trajectory data) Milliseconds Autoregressive Long-term prediction, dynamical systems, time evolution
TNN Medium Seconds Re-train needed High-dimensional problems (5D+)
Transformer High (needs solutions) Milliseconds One forward pass Time-series, long-range dependencies

🎯 Typical Applications

  • Fluid Dynamics: Navier-Stokes equations, turbulence modeling, shape optimization
  • Heat Transfer: Heat equation, convection-diffusion, multi-physics coupling
  • Plasma Physics: Vlasov-Poisson systems, two-stream instability
  • General PDEs: Poisson equation, Burgers equation, Darcy flow

πŸ”§ Dependencies

  • Python >= 3.8
  • PyTorch >= 1.10
  • NumPy, SciPy, Matplotlib
  • Jupyter (optional, for tutorials)

πŸ“– Documentation

Each method has detailed README documentation:

  • PINNs/README.md: Complete PINNs guide and tutorial index
  • DeepONet/README.md: Operator learning detailed explanation
  • FNO/README.md: Fourier Neural Operator implementation
  • PINO/README.md: Physics-Informed Neural Operators guide
  • FLowMap/README.md: Flow Map Learning theory and implementation
  • TNN/README.md: Tensor neural network theory and implementation
  • TNN/train/dim5/README.md: 5D PDE solving example guide

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.


⭐ Star this repository if you find it helpful! ⭐