본문으로 건너뛰기
cccskills
무료GitHub에 공개

pinn-training

Train Physics-Informed Neural Networks (PINNs) using DeepXDE. Solve forward and inverse PDE problems by embedding physics equations into the neural network loss function. Supports 1D/2D/3D, time-dependent, and parametric PDEs.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

설치 방법 보기

포함된 파일(1)

  • SKILL.md6.2 KB

SKILL.md(원문)

설치하기 전에 에이전트에게 전달되는 지시 내용을 확인할 수 있습니다.

PINN Training (DeepXDE)

Overview

Solve PDEs using Physics-Informed Neural Networks. A neural network approximates the solution u(x,t), trained by minimizing the PDE residual + boundary/initial condition losses. Works for forward problems (solve PDE) and inverse problems (discover parameters from data).

When to Use

  • Complex geometries where meshing is difficult
  • Inverse problems (discovering PDE parameters from data)
  • Noisy or sparse data with known governing equations
  • Multi-physics problems with coupled PDEs
  • When you need a differentiable surrogate of the PDE solution

Do NOT Use When

  • Simple 1D/2D problems on regular grids (use finite differences — faster)
  • You need guaranteed error bounds (PINNs don't provide rigorous bounds)
  • Very high accuracy is needed (< 1e-6 relative error is hard for PINNs)

Installation

pip install deepxde
# DeepXDE auto-detects backend: TensorFlow, PyTorch, or JAX
# Set backend: export DDE_BACKEND=pytorch

Core Workflows

1. Forward Problem: 1D Heat Equation

$$\frac{\partial u}{\partial t} = \alpha \frac{\partial^2 u}{\partial x^2}$$

import deepxde as dde
import numpy as np

alpha = 0.01  # thermal diffusivity

def pde(x, u):
    """Heat equation residual: u_t - alpha * u_xx = 0"""
    du_t = dde.grad.jacobian(u, x, i=0, j=1)   # du/dt
    du_xx = dde.grad.hessian(u, x, i=0, j=0)    # d²u/dx²
    return du_t - alpha * du_xx

# Domain: x in [0, 1], t in [0, 1]
geom = dde.geometry.Interval(0, 1)
timedomain = dde.geometry.TimeDomain(0, 1)
geomtime = dde.geometry.GeometryXTime(geom, timedomain)

# Boundary conditions: u(0,t) = u(1,t) = 0
bc = dde.icbc.DirichletBC(geomtime, lambda x: 0,
                           lambda x, on_boundary: on_boundary)

# Initial condition: u(x,0) = sin(pi*x)
ic = dde.icbc.IC(geomtime, lambda x: np.sin(np.pi * x[:, 0:1]),
                  lambda x, on_initial: on_initial)

# Collocation points
data = dde.data.TimePDE(geomtime, pde, [bc, ic],
                         num_domain=2000, num_boundary=100,
                         num_initial=100, num_test=500)

# Neural network: 2 inputs (x,t) → 1 output (u)
net = dde.nn.FNN([2] + [64]*3 + [1], "tanh", "Glorot uniform")

model = dde.Model(data, net)

# Train: Adam first, then L-BFGS for fine-tuning
model.compile("adam", lr=1e-3)
losshistory, train_state = model.train(epochs=10000, display_every=2000)

model.compile("L-BFGS")
losshistory, train_state = model.train()

# Evaluate
x_test = np.linspace(0, 1, 100)
t_test = np.array([0.1, 0.3, 0.5, 0.8])
for t_val in t_test:
    X = np.column_stack([x_test, np.full_like(x_test, t_val)])
    u_pred = model.predict(X)
    u_exact = np.sin(np.pi * x_test) * np.exp(-alpha * np.pi**2 * t_val)
    error = np.max(np.abs(u_pred.flatten() - u_exact))
    print(f"t={t_val:.1f}: max error = {error:.4e}")

2. Inverse Problem: Discover Diffusion Coefficient

# Given noisy measurements of u(x,t), find alpha
alpha_var = dde.Variable(0.05)  # initial guess, will be optimized

def pde_inverse(x, u):
    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 - alpha_var * du_xx

# Add observation data
def generate_data(n_obs=50):
    x_obs = np.random.rand(n_obs, 1)
    t_obs = np.random.rand(n_obs, 1) * 0.5
    u_obs = np.sin(np.pi * x_obs) * np.exp(-0.01 * np.pi**2 * t_obs)
    u_obs += 0.01 * np.random.randn(n_obs, 1)  # noise
    return np.hstack([x_obs, t_obs]), u_obs

observe_x, observe_u = generate_data()
observe_bc = dde.icbc.PointSetBC(observe_x, observe_u)

data = dde.data.TimePDE(geomtime, pde_inverse, [bc, ic, observe_bc],
                         num_domain=2000, num_boundary=100,
                         num_initial=100)

net = dde.nn.FNN([2] + [64]*3 + [1], "tanh", "Glorot uniform")
model = dde.Model(data, net)
model.compile("adam", lr=1e-3, external_trainable_variables=[alpha_var])
model.train(epochs=20000, display_every=5000)
model.compile("L-BFGS", external_trainable_variables=[alpha_var])
model.train()

print(f"Discovered alpha = {alpha_var.numpy():.6f} (true: 0.01)")

3. 2D Poisson Equation

def pde_poisson(x, u):
    du_xx = dde.grad.hessian(u, x, i=0, j=0)
    du_yy = dde.grad.hessian(u, x, i=1, j=1)
    # Source term: -2pi^2 sin(pi*x)*sin(pi*y)
    f = -2 * np.pi**2 * np.sin(np.pi * x[:, 0:1]) * np.sin(np.pi * x[:, 1:2])
    return du_xx + du_yy - f

geom = dde.geometry.Rectangle([0, 0], [1, 1])
bc = dde.icbc.DirichletBC(geom, lambda x: 0, lambda x, on_boundary: on_boundary)

data = dde.data.PDE(geom, pde_poisson, [bc], num_domain=2000, num_boundary=200)
net = dde.nn.FNN([2] + [64]*4 + [1], "tanh", "Glorot uniform")
model = dde.Model(data, net)
model.compile("adam", lr=1e-3)
model.train(epochs=15000)
model.compile("L-BFGS")
model.train()

Training Strategy

PhaseOptimizerEpochsLearning RatePurpose
1Adam10,000-30,0001e-3Get near the minimum
2L-BFGSuntil convergenceautoFine-tune to high accuracy

Network Architecture Guide

PDE ComplexityArchitectureActivation
Simple 1D/2D[2] + [32]*3 + [1]tanh
Moderate 2D[2] + [64]*4 + [1]tanh
Complex / 3D[3] + [128]*5 + [1]tanh or sin
Time-dependent[2] + [64]*4 + [1] with causal trainingtanh

Common Pitfalls

PitfallFix
Loss doesn't decreaseReduce learning rate, increase network size
BC/IC loss much larger than PDE lossUse loss weights: model.compile(..., loss_weights=[1, 100, 100])
Solution is flat/constantCheck PDE implementation (sign errors common)
Training unstableUse tanh activation (not ReLU), reduce LR
Inverse problem doesn't convergeNeed more observation data, better initial guess
Slow trainingUse GPU: export DDE_BACKEND=pytorch + CUDA

리뷰

아직 리뷰가 없습니다. 사용해 본 소감을 남겨 주세요.

댓글

로그인 없이 쓸 수 있습니다. 사용 후기, 질문, 작동하지 않은 환경 등을 편하게 남겨 주세요.

아직 댓글이 없습니다. 첫 댓글을 남겨 보세요.

보내면 바로 공개됩니다. 이메일 주소나 전화번호 같은 개인 정보는 쓰지 마세요. URL은 2개까지입니다.

0 / 1,000자

이 양식은 reCAPTCHA로 보호되며 Google 개인정보처리방침 및 서비스 약관이 적용됩니다.

같은 저장소의 스킬

Simplest distributed training API. 4 lines to add distributed support to any PyTorch script. Unified API for DeepSpeed/FSDP/Megatron/DDP. Automatic device placement, mixed precision (FP16/BF16/FP8). Interactive config, single launch command. HuggingFace ecosystem standard.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

huang-sh/DeepScience42026년 7월 15일 업데이트

ADMET property prediction for drug candidates. Full pharmacokinetic panel (Caco-2, PPB, clearance, CYP), toxicity (hERG, AMES, DILI), drug-likeness (Lipinski, QED), using RDKit descriptors and TDC models.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

huang-sh/DeepScience42026년 7월 15일 업데이트

Interpretable ADMET analysis with mechanistic reasoning. Maps liabilities to structural causes and biological pathways. Based on CoTox (Park 2025) and DrugR (Liu 2026).

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

huang-sh/DeepScience42026년 7월 15일 업데이트

aeon

무료

This skill should be used for time series machine learning tasks including classification, regression, clustering, forecasting, anomaly detection, segmentation, and similarity search. Use when working with temporal data, sequential patterns, or time-indexed observations requiring specialized algorithms beyond standard ML approaches. Particularly suited for univariate and multivariate time series analysis with scikit-learn compatible APIs.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

huang-sh/DeepScience42026년 7월 15일 업데이트

arboreto

무료

Infer gene regulatory networks (GRNs) from gene expression data using scalable algorithms (GRNBoost2, GENIE3). Use when analyzing transcriptomics data (bulk RNA-seq, single-cell RNA-seq) to identify transcription factor-target gene relationships and regulatory interactions. Supports distributed computation for large-scale datasets.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

huang-sh/DeepScience42026년 7월 15일 업데이트

astropy

무료

Comprehensive Python library for astronomy and astrophysics. This skill should be used when working with astronomical data including celestial coordinates, physical units, FITS files, cosmological calculations, time systems, tables, world coordinate systems (WCS), and astronomical data analysis. Use when tasks involve coordinate transformations, unit conversions, FITS file manipulation, cosmological distance calculations, time scale conversions, or astronomical data processing.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

huang-sh/DeepScience42026년 7월 15일 업데이트

huang-sh의 스킬 모두 보기

이 스킬의 문제 신고