| --- |
| license: apache-2.0 |
| language: |
| - en |
| tags: |
| - OneScience |
| - fluid dynamics |
| - physics-informed neural networks |
| - long-horizon physical prediction |
| frameworks: PyTorch |
| --- |
| <p align="center"> |
| <strong> |
| <span style="font-size: 30px;">PINNsformer</span> |
| </strong> |
| </p> |
| |
| # Model Overview |
|
|
| PINNsFormer is a Transformer-based physics-informed neural network framework developed by researchers at the Georgia Institute of Technology and Carnegie Mellon University. It enables rapid prediction of solutions to time-dependent partial differential equations and their associated physical fields. |
|
|
| Paper: [PINNsFormer: A Transformer-Based Framework For Physics-Informed Neural Networks](https://arxiv.org/abs/2307.11833). |
|
|
| # Model Description |
|
|
| PINNsFormer uses a Transformer encoder–decoder with multi-head attention to numerically solve time-dependent partial differential equations, including convection, reaction, wave, and Navier–Stokes equations. |
|
|
|
|
|
|
| # Use Cases |
|
|
| | Use Case | Description | |
| | :--- | :--- | |
| | Time-dependent PDE solving | Train a continuous-field surrogate constrained by physical residuals, boundary conditions, and initial conditions | |
| | Physics-informed neural network validation | Rapidly validate the PINNsFormer network, loss functions, weight serialization, and inference pipeline | |
| | One-dimensional reaction equation example | Generate target fields from an analytical solution for pipeline validation and error analysis | |
| | ModelScope/OneCode execution | Download the standalone model package, install its dependencies, and run the provided scripts | |
|
|
|
|
| # Usage |
|
|
| ## 1. OneCode |
|
|
| Use the online OneCode environment for an intelligent, one-click AI for Science (AI4S) programming experience: |
|
|
| [Launch OneCode for one-click AI4S programming](https://web-2069360198568017922-iaaj.ksai.scnet.cn:58043/home) |
|
|
| ## 2. Manual Setup |
|
|
| **Hardware Requirements** |
|
|
| * A CPU can be used for small-scale pipeline validation. |
| * A GPU or DCU is recommended for training on larger grids or for more epochs. |
| * DCU users must install DTK in advance. DTK 25.04.2 or later, or the OneScience-recommended version for the target cluster, is recommended. |
|
|
| ### Download the Model Package |
|
|
| ```bash |
| modelscope download --model OneScience/PINNsformer --local_dir ./PINNsformer |
| cd PINNsformer |
| ``` |
|
|
| ### Set Up the Runtime Environment |
|
|
|
|
| **DCU Environment** |
|
|
| ```bash |
| # Activate DTK and Conda first |
| conda create -n onescience311 python=3.11 -y |
| conda activate onescience311 |
| # Installation with uv is also supported |
| pip install onescience[cfd-dcu] -i http://mirrors.onescience.ai:3141/pypi/simple/ --trusted-host mirrors.onescience.ai |
| ``` |
|
|
| **GPU Environment** |
| ```bash |
| # Activate Conda first |
| conda create -n onescience311 python=3.11 -y libstdcxx-ng=12 libgcc-ng=12 gcc_linux-64=12 gxx_linux-64=12 |
| conda activate onescience311 |
| # Installation with uv is also supported |
| pip install onescience[cfd-gpu] -i http://mirrors.onescience.ai:3141/pypi/simple/ --trusted-host mirrors.onescience.ai |
| ``` |
|
|
| ### Training Data |
|
|
| To use real data, download it from the link below and set `data.data_dir` in `conf/config.yaml` to the correct path. |
|
|
| | Source | Link | Extraction Code | Destination | |
| |---|---|---|---| |
| | Baidu Netdisk | https://pan.baidu.com/s/1pM4ICc6FJX5pLF7WEoozxQ?pwd=5gha | `5gha` | `convection/convection.mat` and `navier_stokes/cylinder_nektar_wake.mat` | |
|
|
| ### Training |
|
|
| ```bash |
| python scripts/train.py |
| ``` |
| The default configuration uses a smaller grid and fewer L-BFGS iterations for rapid end-to-end validation. To restore the scale of the original example, edit `conf/config.yaml`: |
|
|
| ```yaml |
| data: |
| x_num: 101 |
| t_num: 101 |
| |
| training: |
| epochs: 500 |
| ``` |
|
|
| ### Model Weights |
| This repository will provide PINNsFormer model weights in the `weights/` directory. The weights will be uploaded soon. |
|
|
| ### Inference |
|
|
| ```bash |
| python scripts/inference.py |
| ``` |
|
|
| Inference loads `weight/1dreaction_pinnsformer.pt` and saves: |
|
|
| ```text |
| result/prediction.npz |
| ``` |
|
|
| ### Evaluation and Visualization |
|
|
| ```bash |
| python scripts/result.py |
| ``` |
|
|
| # Official OneScience Resources |
|
|
| | Platform | OneScience Repository | Skills Repository | |
| | --- | --- | --- | |
| | Gitee | https://gitee.com/onescience-ai/onescience | https://gitee.com/onescience-ai/oneskills | |
| | GitHub | https://github.com/onescience-ai/OneScience | https://github.com/onescience-ai/oneskills | |
|
|
| # Citations and License |
|
|
| * Original PINNsformer paper: [PINNsFormer: A Transformer-Based Framework For Physics-Informed Neural Networks](https://arxiv.org/abs/2307.11833). |
| * This repository retains the relevant source and attribution notices. Follow all applicable license requirements when using, modifying, or distributing its contents. |
|
|