DeepFlow: Physics-Informed Neural Networks for Fluid Dynamics
DeepFlow is a user-friendly framework for solving partial differential equations (PDEs), such as the Navier-Stokes equations, using Physics-Informed Neural Networks (PINNs). It provides a CFD-solver-style workflow to make PINN-based simulations accessible and straightforward.
Table of Contents
- Key Features
- Current Implementations
- Installation
- Requirements
- Quick Start
- Examples
- Contributing
- License
- DeepFlow Milestones
Key Features
- ⟁ Physics-Attached Geometry: AUTO GENERATE TRAINING DATA by explicitly attach physics and neural network to geometries.
- 🔧 CFD-Solver Style: Straightforward workflow similar to CFD software.
- 📊 Built-in Visualization: Tools to evaluate and plot results.
- 🚀 GPU Acceleration: Enable GPU for faster training.
- Flexible Domain Definition: Easily define complex 2D geometries.
Current Implementations
- Supported problems: solving forward partial differential equations (PDEs)
- transient & steady 2D imcompressible Navier-Stokes equations, 2D Fourier Heat equation, Burgers' equation
- Sampling methods: Uniform, Random, Latin Hypercube Sampling, RAR-G [0], R3 [1]
- 2D Geometries: Custom functions, Rectangle, Circle, Polygon, and combinations & subtractions.
- Hard Boundary Conditions: Automatic Hard BC w.r.t. to geometry.
- Neural Network Architectures: Fully connected feedforward networks (FNN).
- Optimizers: Adam, L-BFGS
- Backend: PyTorch
Installation
You can install DeepFlow via pip:
pip install deepflow
For development or to build from source:
git clone https://github.com/YoYo-XYZ/deepflow.git
cd deepflow
pip install -e .
Requirements
- Python >= 3.8
- PyTorch >= 1.7.0
- NumPy >= 1.19.0
- Matplotlib >= 3.3.0
- SymPy >= 1.5.0
- SciPy >= 1.5.0
- Ultrplot >= 1.0.0
Quick Start
This example demonstrates how to simulate Steady channel flow under 20 lines of code! We recommend using a Python notebook (
.ipynb) for interactive experience.
1. Define the Geometry and Physics
import deepflow as df
# Define the area and bounds
rectangle = df.geometry.rectangle([0, 5], [0, 1])
domain = df.domain(rectangle)
domain.show_setup() # Display the domain setup
# Define Boundary Conditions
domain.bound_list[0].define_bc({'u': 1, 'v': 0}) # Inflow: u=1
domain.bound_list[1].define_bc({'u': 0, 'v': 0}) # Wall: No slip
domain.bound_list[2].define_bc({'p': 0}) # Outflow: p=0
domain.bound_list[3].define_bc({'u': 0, 'v': 0}) # Wall: No slip
# Define PDE (Navier-Stokes)
domain.area_list[0].define_pde(df.pde.NavierStokes(U=0.0001, L=1, mu=0.001, rho=1000))
domain.show_setup() # Display the domain setup
# Sample points: [Left, Bottom, Right, Top], [Interior]
domain.sampling_random([200, 400, 200, 400], [5000])
domain.show_coordinates(display_physics=True)
2. Create and Train the model
# Initialize the PINN model
model0 = df.PINN(width=40, length=4)
# Train the model using Adam Optimizer
model1 = model0.train_adam(
calc_loss=df.calc_loss_simple(domain),
learning_rate=0.001,
epochs=2000,)
3. Visualize Results
# Evaluate the best model
prediction = domain.area_list[0].evaluate(model1_best)
prediction.sampling_area([500, 100])
# Plot Velocity Field
_ = prediction.plot_color('u', cmap='jet')
# Plot Training Loss
_ =prediction.plot_loss_curve()
Examples
Explore the examples directory for real use cases, including:
- Steady flow around a cylinder
- Lid-driven cavity flow
- Burgers' Equation
- Time-dependent Fourier Heat Equation
Each example includes Jupyter notebooks and data files.
Contributing
Feel free to submit a Pull Request. For major changes, open an issue first to discuss the proposed changes.
DeepFlow Milestones
- Define custom PDE
- Inverse problems PDE
- 3D Geometries
- More sampling methods
- More neural network architectures (e.g., CNN, RNN)
License
This project is licensed under the MIT License - see the LICENSE file for details.
Metadata
Release files for deepflow 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| deepflow-0.1.2.tar.gz | 24.8 kB | Without provenance | Details for deepflow-0.1.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| deepflow-0.1.2-py3-none-any.whl | Python 3 | none | any | Details for deepflow-0.1.2-py3-none-any.whl |
Total release size: 50.3 kB
Release files / deepflow-0.1.2.tar.gz
| Download URL | deepflow-0.1.2.tar.gz |
|---|---|
| Size | 24.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e9398e433f0bb2a09754dc94c85c5b805d88a2274c091fb6e3146cbae6171aa2
|
|
BLAKE2b-256 checksum How to use checksums |
bb8e2d8b1a24e824e831d34a7ab98d08c6cc7b011cd38e251c43f65faff0b9ee
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.9
|
Release files / deepflow-0.1.2-py3-none-any.whl
| Download URL | deepflow-0.1.2-py3-none-any.whl |
|---|---|
| Size | 25.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9eae44de3a0e18c5245340bf8870c5bdacaf8619b572548710da0a4f8bbb2fc6
|
|
BLAKE2b-256 checksum How to use checksums |
ac301a9cbb508f54400923b1617892117b007069fea1c7c79861a37b02a5130a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.9
|
Security for deepflow 0.1.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.