No description
Find a file
Fabian Frank 4c874906fa
docs: Fix image path in README.md
Updated image path in README for proper display.
2026-04-05 18:49:09 +03:00
img docs: Added a folder for progress images 2026-04-05 18:43:16 +03:00
src feat: added training loop and visualisation options 2026-04-05 18:31:35 +03:00
.gitignore Initial commit 2026-04-05 18:20:28 +03:00
main.py feat: added training loop and visualisation options 2026-04-05 18:31:35 +03:00
README.md docs: Fix image path in README.md 2026-04-05 18:49:09 +03:00
requirements.txt added requirements for the model 2026-04-05 18:26:02 +03:00

Physics-Informed Neural Network (PINN) for 2D Cylinder Flow

alt text

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.streamplot to 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.