gPINNs

Model Overview

gPINNs (Gradient-enhanced Physics-Informed Neural Networks) augment the PDE residual constraints of conventional PINNs with constraints on residual gradients with respect to the input coordinates. This additional higher-order derivative information can improve sample efficiency and solution accuracy for selected forward and inverse problems.

This model package provides one-dimensional and two-dimensional Poisson examples, together with a Burgers equation example using residual-based adaptive refinement (RAR).

Paper: Gradient-enhanced physics-informed neural networks for forward and inverse PDE problems
https://doi.org/10.1016/j.cma.2022.114823

Model Description

gPINNs use automatic differentiation to compute both PDE residuals and their coordinate gradients, incorporating both as training constraints. The two-dimensional Poisson example applies a hard-boundary output transformation, while the Burgers example uses RAR to add collocation points progressively in high-residual regions.

Use Cases

Use Case Description
One-dimensional Poisson equation Validate joint training with residual-gradient constraints and boundary loss
Two-dimensional Poisson equation Solve a homogeneous Dirichlet boundary-value problem using a hard-boundary output transformation
Burgers equation Combine higher-order automatic differentiation with RAR in high-residual regions
Pipeline validation Validate training, inference, and plotting with the bundled data and pretrained weights

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

2. Manual Setup

Hardware Requirements

  • A GPU or DCU is recommended for training.
  • A CPU can be used for inference and small-scale pipeline validation, but full training will be slow.
  • DCU users must install DTK and a PyTorch environment compatible with the target cluster.

Download the Model Package

hf download OneScience-Group/gPINNs --local-dir ./gPINNs
cd gPINNs

Set Up the Runtime Environment

DCU Environment

# Activate DTK and Conda first
conda create -n onescience311 python=3.11 -y
conda activate onescience311
pip install onescience[cfd-dcu] -i http://mirrors.onescience.ai:3141/pypi/simple/ --trusted-host mirrors.onescience.ai

GPU Environment

# 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
pip install onescience[cfd-gpu] -i http://mirrors.onescience.ai:3141/pypi/simple/ --trusted-host mirrors.onescience.ai

Training Data

The one- and two-dimensional Poisson examples construct training and evaluation data from analytical solutions; the Burgers example uses the bundled reference solution data/Burgers.npz. Data and training parameters can be adjusted in conf/config.yaml.

Training

To train all examples:

python scripts/train.py --case all

Alternatively, train an individual example with --case 1d, --case 2d, or --case burgers. The --epochs and --nf options override the defaults for the selected example; --lbfgs-iters applies only to the one-dimensional Poisson case, --rar-rounds controls the number of RAR rounds for the Burgers case, and --quick skips RAR for rapid pipeline validation.

Model Weights

This model package provides pretrained weights for the one-dimensional Poisson, two-dimensional Poisson, and Burgers equation examples in the weight/ directory.

Inference, Evaluation, and Visualization

The model package provides weights for validating all three examples. Run:

python scripts/inference.py --case all

The script reports the relative L2 error for each example and saves prediction visualizations under result/. Use --case to select an individual example. Model, data, and training parameters can all be modified in conf/config.yaml.

Official OneScience Resources

Citations and License

  • Yu, J., Lu, L., Meng, X., and Karniadakis, G. E. Gradient-enhanced physics-informed neural networks for forward and inverse PDE problems. Computer Methods in Applied Mechanics and Engineering, 393, 114823, 2022.
  • This model package is released under the Apache-2.0 license and retains attribution to the original paper and data sources.

中文说明

模型概述

gPINNs(梯度增强物理信息神经网络,Gradient-enhanced Physics-Informed Neural Networks)在常规物理信息神经网络的 PDE 残差约束基础上,增加了残差相对于输入坐标的梯度约束。对于部分正问题和反问题,这些额外的高阶导数信息可以提高样本效率和求解精度。

本模型包提供一维和二维 Poisson 算例,以及采用基于残差的自适应加密(RAR)的 Burgers 方程算例。

论文《求解 PDE 正问题与反问题的梯度增强物理信息神经网络》
https://doi.org/10.1016/j.cma.2022.114823

模型描述

gPINNs 使用自动微分计算 PDE 残差及其坐标梯度,将两者均用作训练约束。二维 Poisson 算例采用硬边界输出变换,Burgers 算例则使用 RAR 在高残差区域逐步添加配置点。

使用场景

使用场景 说明
一维 Poisson 方程 验证残差梯度约束和边界损失的联合训练
二维 Poisson 方程 使用硬边界输出变换求解齐次 Dirichlet 边值问题
Burgers 方程 在高残差区域结合高阶自动微分与 RAR
流程验证 使用随附数据和预训练权重验证训练、推理(inference)和绘图

使用方法

1. OneCode

通过 OneCode 在线环境体验智能一键科学智能(AI for Science,AI4S)编程。

启动 OneCode 进行一键 AI4S 编程

2. 手动配置

硬件要求

  • 建议使用 GPU 或 DCU 进行训练。
  • CPU 可用于推理和小规模流程验证,但完整训练的速度较慢。
  • DCU 用户必须安装 DTK 和与目标集群兼容的 PyTorch 环境。

下载模型包

hf download OneScience-Group/gPINNs --local-dir ./gPINNs
cd gPINNs

配置运行环境

DCU 环境

# Activate DTK and Conda first
conda create -n onescience311 python=3.11 -y
conda activate onescience311
pip install onescience[cfd-dcu] -i http://mirrors.onescience.ai:3141/pypi/simple/ --trusted-host mirrors.onescience.ai

GPU 环境

# 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
pip install onescience[cfd-gpu] -i http://mirrors.onescience.ai:3141/pypi/simple/ --trusted-host mirrors.onescience.ai

训练数据

一维和二维 Poisson 算例使用解析解构建训练和评估数据,Burgers 算例使用随附的参考解 data/Burgers.npz。可在 conf/config.yaml 中调整数据和训练参数。

训练

使用以下命令训练所有算例。

python scripts/train.py --case all

也可以用 --case 1d、--case 2d 或 --case burgers 训练单个算例。--epochs 和 --nf 选项覆盖所选算例的默认值。--lbfgs-iters 仅适用于一维 Poisson 算例,--rar-rounds 控制 Burgers 算例的 RAR 轮数,--quick 跳过 RAR 以快速验证流程。

模型权重

本模型包在 weight/ 目录中提供一维 Poisson、二维 Poisson 和 Burgers 方程算例的预训练权重。

推理、评估与可视化

本模型包提供用于验证全部三个算例的权重。运行以下命令。

python scripts/inference.py --case all

脚本报告每个算例的相对 L2 误差,并将预测可视化结果保存至 result/。使用 --case 选择单个算例。模型、数据和训练参数均可在 conf/config.yaml 中修改。

OneScience 官方资源

引用与许可证

  • Yu, J., Lu, L., Meng, X., and Karniadakis, G. E. Gradient-enhanced physics-informed neural networks for forward and inverse PDE problems. Computer Methods in Applied Mechanics and Engineering, 393, 114823, 2022.
  • 本模型包采用 Apache-2.0 许可证发布,并保留原始论文和数据来源的署名。
Downloads last month
18
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support