- Python 100%
|
|
||
|---|---|---|
| img | ||
| src | ||
| .gitignore | ||
| main.py | ||
| README.md | ||
| requirements.txt | ||
Physics-Informed Neural Network (PINN) for 2D Cylinder Flow
1. Project Overview
This repository contains a Physics-Informed Neural Network (PINN) implementation designed to solve the steady-state, incompressible Navier-Stokes equations. The model simulates fluid flow around a circular cylinder within a 2D channel, a classic benchmark in computational fluid dynamics (CFD).
Unlike traditional mesh-based solvers (FVM/FEM), this approach uses a neural network as a continuous functional approximator, integrating physical laws directly into the loss function via automatic differentiation.
2. Technical Architecture
The model is built using a fully connected deep neural network that maps spatial coordinates (x, y) to the velocity field (u, v) and pressure p.
Physics Constraints
The total loss function is a weighted sum of several components:
- Navier-Stokes Residuals: Ensures momentum conservation (
u \nabla u = -\nabla p + \nu \Delta u). - Continuity Equation: Enforces mass conservation (
\nabla \cdot \mathbf{u} = 0). - Boundary Conditions (BCs):
- Inlet: Parabolic velocity profile.
- Outlet: Zero pressure boundary.
- No-Slip: Zero velocity at channel walls and cylinder surface.
3. Implementation Highlights
- Dynamic Curriculum Learning: Implements a phased training schedule. The model first masters the geometry (Boundary Conditions) before gradually increasing the weight of the PDE residuals to handle lower viscosity (
\nu) regimes. - Advanced Visualization: Includes a custom plotting suite using
matplotlib.streamplotto visualize flow topology and identify divergence errors or recirculation zones. - Adaptive Weighting: Utilizes a custom weight curriculum to prevent the "gradient pathology" often found in PINNs where BC losses and PDE losses compete destructively.
4. Key Results (Epoch 15,000+)
The current state of the model demonstrates:
- Laminar Flow Reconstruction: Successfully captures the deflection of the flow field around the obstacle.
- Pressure Gradient: Realistic high-pressure zones at the stagnation point and low-pressure zones in the wake.
- Topology Analysis: Streamline visualization confirms that the model has learned the global structure of the flow field without manual labeling.
5. Getting Started
Prerequisites
- Python 3.x
- PyTorch
- NumPy
- Matplotlib
- Pandas
- Polars
Installation
git clone [https://github.com/fabianfrank-dev/NavierStokes.git]
cd NavierStokes
pip install -r requirements.txt
# RUnning the training
python3 main.py
6 Future Benchmarks
-
Transition to transient (time-dependent) Navier-Stokes.
-
Integration of Re-number as a parameterized input to the network.
-
Benchmarking performance against OpenFOAM/SimScale data.
