PINNs 入门:物理信息神经网络的核心思想

519 字
3 分钟
PINNs 入门:物理信息神经网络的核心思想

什么是 PINNs#

物理信息神经网络(Physics-Informed Neural Networks, PINNs)由 Raissi et al. (2019) 提出,其核心思想是将物理定律(以 PDE 形式)嵌入神经网络的损失函数中

数学框架#

考虑一般的 PDE 问题:

N[u](x)=f(x),xΩB[u](x)=g(x),xΩ\begin{aligned} \mathcal{N}[u](x) &= f(x), \quad x \in \Omega \\ \mathcal{B}[u](x) &= g(x), \quad x \in \partial\Omega \end{aligned}

其中 N\mathcal{N} 是微分算子,B\mathcal{B} 是边界条件算子。

损失函数#

PINNs 的损失函数由两部分组成:

L(θ)=Ldata+λLphys\mathcal{L}(\theta) = \mathcal{L}_{data} + \lambda \mathcal{L}_{phys}

其中:

  • 数据损失Ldata=1Ndi=1Nduθ(xi)ui2\mathcal{L}_{data} = \frac{1}{N_d} \sum_{i=1}^{N_d} \|u_\theta(x_i) - u_i\|^2
  • 物理损失Lphys=1Npj=1NpN[uθ](xj)f(xj)2\mathcal{L}_{phys} = \frac{1}{N_p} \sum_{j=1}^{N_p} \|\mathcal{N}[u_\theta](x_j) - f(x_j)\|^2
  • λ\lambda 是平衡参数

自动微分#

物理损失中使用自动微分(Automatic Differentiation)来计算导数:

import torch
def pde_residual(model, x):
"""
计算 PDE 残差
model: 神经网络 u_theta(x)
x: 配置点 [N, d]
"""
x.requires_grad_(True)
u = model(x)
# 一阶导数
du_dx = torch.autograd.grad(
u, x,
grad_outputs=torch.ones_like(u),
create_graph=True
)[0]
# 二阶导数
d2u_dx2 = torch.autograd.grad(
du_dx, x,
grad_outputs=torch.ones_like(du_dx),
create_graph=True
)[0]
# 对于 Poisson 方程: -Δu = f
residual = -d2u_dx2.sum(dim=1) - f(x)
return residual

简单示例:1D Poisson 方程#

求解 u(x)=π2sin(πx),x[0,1]-u''(x) = \pi^2 \sin(\pi x), x \in [0, 1],边界条件 u(0)=u(1)=0u(0) = u(1) = 0

解析解:u(x)=sin(πx)u(x) = \sin(\pi x)

import torch
import torch.nn as nn
class PINN(nn.Module):
def __init__(self, layers):
super().__init__()
self.net = nn.Sequential()
for i in range(len(layers) - 1):
self.net.append(nn.Linear(layers[i], layers[i+1]))
if i < len(layers) - 2:
self.net.append(nn.Tanh())
def forward(self, x):
return self.net(x)
# 网络结构: [1, 32, 32, 32, 1]
model = PINN([1, 32, 32, 32, 1])
# 训练配置
optimizer = torch.optim.Adam(model.parameters(), lr=1e-3)
lambda_phys = 1.0

PINNs 的优势与挑战#

优势
  • 无网格:不需要传统的网格生成
  • 数据融合:自然地结合观测数据和物理定律
  • 反向问题:容易处理参数识别的反向问题
挑战
  • 训练困难:损失函数刚性,收敛慢
  • 高频问题:受频率原理影响,难以学习高频解
  • 权重平衡λ\lambda 的选择对结果影响大
  • 可扩展性:高维问题计算量激增

参考文献#

  1. Raissi, M., Perdikaris, P., & Karniadakis, G. E. “Physics-informed neural networks: A deep learning framework for solving forward and inverse problems involving nonlinear partial differential equations.” Journal of Computational Physics, 2019.
  2. Lu, L., Meng, X., Mao, Z., & Karniadakis, G. E. “DeepXDE: A deep learning library for solving differential equations.” SIAM Review, 2021.
  3. Karniadakis, G. E., et al. “Physics-informed machine learning.” Nature Reviews Physics, 2021.

文章分享

如果这篇文章对你有帮助,欢迎分享给更多人!

PINNs 入门:物理信息神经网络的核心思想
https://sciml.com.cn/posts/pinns-intro/
作者
SciML 研究者
发布于
2026-05-12
许可协议
CC BY-NC-SA 4.0
Profile Image of the Author
SciML 研究者
科学机器学习研究笔记 | 频率原理 · PINNs · 神经算子 · 深度学习理论
欢迎
SciML 研究笔记 — 专注于科学机器学习领域的论文阅读、代码复现与理论探索。
分类
标签
站点统计
文章
3
分类
2
标签
12
总字数
3,021
运行时长
0
最后活动
0 天前

文章目录