---
id: wiki-2026-0508-physics-informed-neural-networks
title: Physics-informed Neural Networks
category: 10_Wiki/Topics
status: verified
canonical_id: self
aliases: [PINN, physics-informed-NN, scientific-ML]
duplicate_of: none
source_trust_level: A
confidence_score: 0.9
verification_status: applied
tags: [pinn, scientific-ml, pde, deep-learning]
raw_sources: []
last_reinforced: 2026-05-10
github_commit: pending
tech_stack:
  language: Python
  framework: PyTorch / DeepXDE
---

# Physics-informed Neural Networks (PINN)

## 매 한 줄
> **"매 NN 매 PDE 의 solution 매 학습 — 매 physics 의 loss 의 embed"**. 매 Raissi/Perdikaris/Karniadakis (2019, JCP) 매 popularize. 매 soft constraint 매 PDE residual + boundary/initial conditions → 매 mesh-free PDE solver. 매 sparse data + known physics regime 매 best.

## 매 핵심

### 매 formulation
- **매 NN**: u_θ(x, t) — 매 neural network 매 solution 의 approximate.
- **매 PDE residual loss**: L_pde = ||N[u_θ] - 0||² (e.g. ∂u/∂t + u ∂u/∂x - ν ∂²u/∂x² for Burgers).
- **매 BC/IC loss**: L_bc + L_ic — 매 boundary + initial conditions.
- **매 data loss** (optional): L_data — 매 sparse measurements 의 fit.
- **매 total**: L = λ_pde·L_pde + λ_bc·L_bc + λ_ic·L_ic + λ_data·L_data.
- **매 autograd**: 매 ∂u/∂x, ∂²u/∂x² 의 torch.autograd.grad 로 compute.

### 매 강점 + 약점
- **매 강점**: mesh-free, 매 inverse problems, 매 sparse/noisy data, 매 high-dim PDEs (curse-resistant), 매 unified forward+inverse.
- **매 약점**: 매 stiff PDEs (multi-scale) 매 fail, 매 training slow, 매 loss balancing tricky, 매 FEM 보다 매 large-domain 의 underperform.

### 매 변형
- **매 XPINN** (extended): 매 domain decomposition.
- **매 cPINN** (conservative): 매 conservation laws.
- **매 hp-VPINN**: variational + hp-refinement.
- **매 PINO** (Physics-Informed Neural Operator): 매 operator learning + physics loss.
- **매 DeepONet + PINN hybrid**.
- **매 SA-PINN**: self-adaptive loss weights.

### 매 modern (2026)
- **매 Neural Operators (FNO, DeepONet)**: 매 PINN 보다 매 generalization across PDE families.
- **매 Foundation models for PDEs**: Poseidon (2024), DPOT (2024).
- **매 Diffusion-based PDE solvers**.
- **매 PINN 매 still useful**: 매 inverse problems + 매 physics-constrained design.

### 매 응용
1. 매 fluid dynamics (Navier-Stokes inverse).
2. 매 cardiovascular flow modeling.
3. 매 subsurface flow (oil/gas).
4. 매 metamaterial inverse design.

## 💻 패턴

### Vanilla PINN — 1D Burgers
```python
import torch, torch.nn as nn

class PINN(nn.Module):
    def __init__(self):
        super().__init__()
        self.net = nn.Sequential(
            nn.Linear(2, 64), nn.Tanh(),
            *[layer for _ in range(4) for layer in (nn.Linear(64, 64), nn.Tanh())],
            nn.Linear(64, 1),
        )
    def forward(self, x, t):
        return self.net(torch.cat([x, t], dim=1))

def pde_residual(model, x, t, nu=0.01/torch.pi):
    x.requires_grad_(True); t.requires_grad_(True)
    u = model(x, t)
    u_t = torch.autograd.grad(u, t, torch.ones_like(u), create_graph=True)[0]
    u_x = torch.autograd.grad(u, x, torch.ones_like(u), create_graph=True)[0]
    u_xx = torch.autograd.grad(u_x, x, torch.ones_like(u_x), create_graph=True)[0]
    return u_t + u * u_x - nu * u_xx
```

### Loss assembly + training
```python
model = PINN().cuda()
opt = torch.optim.Adam(model.parameters(), lr=1e-3)

x_f = torch.rand(10000, 1, device="cuda") * 2 - 1   # collocation points
t_f = torch.rand(10000, 1, device="cuda")
x_b = torch.tensor([[-1.], [1.]], device="cuda")     # boundary
t_b = torch.rand(2, 1, device="cuda")
x_i = torch.linspace(-1, 1, 200, device="cuda").unsqueeze(1)  # initial t=0
t_i = torch.zeros_like(x_i)

for it in range(20000):
    opt.zero_grad()
    L_pde = (pde_residual(model, x_f, t_f)**2).mean()
    L_bc  = (model(x_b, t_b)**2).mean()
    L_ic  = ((model(x_i, t_i) + torch.sin(torch.pi * x_i))**2).mean()
    L = L_pde + 10*L_bc + 10*L_ic
    L.backward(); opt.step()
```

### DeepXDE — 매 high-level library
```python
import deepxde as dde, numpy as np

def pde(x, u):
    du_x = dde.grad.jacobian(u, x, i=0, j=0)
    du_t = dde.grad.jacobian(u, x, i=0, j=1)
    du_xx = dde.grad.hessian(u, x, i=0, j=0)
    return du_t + u * du_x - 0.01/np.pi * du_xx

geom = dde.geometry.Interval(-1, 1)
timedomain = dde.geometry.TimeDomain(0, 1)
geomtime = dde.geometry.GeometryXTime(geom, timedomain)

bc = dde.icbc.DirichletBC(geomtime, lambda x: 0, lambda _, on_b: on_b)
ic = dde.icbc.IC(geomtime, lambda x: -np.sin(np.pi*x[:,0:1]), lambda _, on_i: on_i)

data = dde.data.TimePDE(geomtime, pde, [bc, ic], num_domain=2540, num_boundary=80, num_initial=160)
net = dde.nn.FNN([2] + [64]*4 + [1], "tanh", "Glorot normal")
model = dde.Model(data, net)
model.compile("adam", lr=1e-3); model.train(iterations=15000)
model.compile("L-BFGS"); model.train()
```

### Inverse problem — discover ν
```python
# Treat viscosity as trainable parameter
nu = torch.nn.Parameter(torch.tensor(0.05, device="cuda"))
opt = torch.optim.Adam([*model.parameters(), nu], lr=1e-3)

# Add data loss from sparse measurements
x_d, t_d, u_d = load_measurements()
L_data = ((model(x_d, t_d) - u_d)**2).mean()
# nu converges to true value during training
```

### Self-adaptive weights (SA-PINN)
```python
# Trainable per-point weights — 매 hard regions 의 emphasize
lambda_pde = nn.Parameter(torch.ones(N_collocation, 1, device="cuda"))
L_pde = (lambda_pde * pde_residual(...)**2).mean()
# Maximize w.r.t. lambda, minimize w.r.t. theta — adversarial-ish
```

### Fourier features — 매 high-frequency PDE
```python
class FourierEmbed(nn.Module):
    def __init__(self, in_dim, mapping_size=64, scale=10):
        super().__init__()
        self.B = nn.Parameter(torch.randn(in_dim, mapping_size) * scale, requires_grad=False)
    def forward(self, x):
        proj = 2 * torch.pi * x @ self.B
        return torch.cat([torch.sin(proj), torch.cos(proj)], dim=-1)
```

## 매 결정 기준
| 상황 | 방법 |
|---|---|
| 매 known PDE + sparse data | 매 PINN |
| 매 inverse problem (parameter ID) | 매 PINN (best fit) |
| 매 solve same PDE many times | 매 FNO / DeepONet |
| 매 large-scale forward solve | 매 FEM/FVM (still better) |
| 매 stiff multi-scale | 매 PINN 매 careful (XPINN, sequence-to-sequence) |
| 매 high-D Black-Scholes | 매 PINN ≫ FEM |

**기본값**: 매 DeepXDE (forward+inverse, well-engineered).

## 🔗 Graph
- 부모: [[Scientific-Machine-Learning]] · [[Differential-Equations]]
- 변형: [[Neural-Operators]] · [[FNO]] · [[DeepONet]]
- 응용: [[Inverse-Problems]] · [[Computational-Fluid-Dynamics]]
- Adjacent: [[Automatic-Differentiation]] · [[Finite-Element-Methods]]

## 🤖 LLM 활용
**언제**: 매 forward/inverse PDE problems 매 sparse data, 매 mesh-free desired, 매 unified data+physics framework 의 wanted.
**언제 X**: 매 production CFD (FEM/FVM 매 mature), 매 stiff multi-scale (notorious failure), 매 same PDE solved 1000s of times (operator learning).

## ❌ 안티패턴
- **매 unbalanced loss weights**: 매 L_pde dominates → 매 BC violation. 매 SA-PINN 또는 manual tuning.
- **매 single-stage stiff training**: 매 sequence-to-sequence (causal) training 의 사용.
- **매 ReLU activation**: 매 PINN 매 smooth activation (tanh, sin, GELU) 의 필요 — autograd hessian.
- **매 PINN > FEM claim**: 매 standard forward problems 매 still FEM-superior.

## 🧪 검증 / 중복
- Verified (Raissi 2019 JCP, DeepXDE docs, NVIDIA Modulus).
- 신뢰도 A.

## 🕓 Changelog
| 날짜 | 변경 |
|---|---|
| 2026-05-08 | Phase 1 |
| 2026-05-10 | Manual cleanup — PINN formulation + DeepXDE + inverse + SA-PINN |
