[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6XGMJMSYYXEST3YZWFV3ZKS":3,"skill-same:01M6XGMJMSYYXEST3YZWFV3ZKS":80},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":41,"linkOnly":42,"markdownContent":43,"markdownBody":44,"frontMatter":45,"refName":60,"commitSha":61,"skillDirectory":62,"forksCount":14,"repositoryHtmlUrl":63,"repositoryHomepageUrl":6,"ownerHtmlUrl":64,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":65,"install":66,"resources":79},"01M6XGMJMSYYXEST3YZWFV3ZKS","pde-solver",null,"Solve partial differential equations — finite differences, spectral methods, and physics-informed neural networks (PINNs via DeepXDE). Supports 1D\u002F2D\u002F3D, steady\u002Ftransient, linear\u002Fnonlinear PDEs with Dirichlet, Neumann, and periodic boundary conditions.","fadrienne\u002FMyGitHub","fadrienne","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F197874571?v=4","01M6X64V8VWCRSMFZ4EPS2BWXG","Francesca Adrienne","01M6X64VD5MW4F9PHDWQKS7ZAF",0,"MIT","https:\u002F\u002Fgithub.com\u002Ffadrienne\u002FMyGitHub\u002Fblob\u002Fmain\u002Fopenscience\u002Fbackend\u002Fcli\u002Fskills\u002Fphysics\u002Fpde-solver\u002FSKILL.md",[],[19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40],"pde solver","solver","pde","Boundary Conditions","neural networks","Physics-Informed","Nonlinear","2d","partial differential equations","with","spectral","synthetic","differential equations","physics","scipy","numpy","methods","Neural","periodic","simulation","3D","networks","2026-11-10 10:12:30",false,"---\nname: pde-solver\ndescription: Solve partial differential equations — finite differences, spectral methods, and physics-informed neural networks (PINNs via DeepXDE). Supports 1D\u002F2D\u002F3D, steady\u002Ftransient, linear\u002Fnonlinear PDEs with Dirichlet, Neumann, and periodic boundary conditions.\ncategory: physics\nversion: 1.0.0\nauthor: Synthetic Sciences\nlicense: MIT\ntags: [PDE, Finite Difference, Spectral Methods, PINN, DeepXDE, Simulation, Physics]\ndependencies: [\"scipy>=1.11.0\", \"numpy>=1.24.0\", \"matplotlib>=3.7.0\"]\n---\n\n# PDE Solver\n\n## Overview\n\nSolve partial differential equations using finite differences, spectral methods, or physics-informed neural networks (PINNs). Covers elliptic (Laplace, Poisson), parabolic (heat, diffusion), and hyperbolic (wave) equations in 1D, 2D, and 3D.\n\n## When to Use\n\n- Solving any PDE in physics (heat equation, wave equation, Navier-Stokes, Schrodinger, etc.)\n- Steady-state or time-dependent problems\n- Problems on simple geometries (rectangles, circles, boxes)\n- Inverse problems (discovering parameters from data)\n\n## Do NOT Use When\n\n- Complex 3D geometries with unstructured meshes (use FEniCS — `pip install fenics-dolfinx`)\n- Turbulent fluid dynamics on periodic domains (use `fluidsim`)\n- Already know it's an ODE system (use `ode-solver`)\n\n## Method Selection\n\n| PDE Type | Simple Geometry | Complex Geometry | Inverse Problem |\n|---|---|---|---|\n| 1D steady | Finite differences | FEM (FEniCS) | PINN (DeepXDE) |\n| 1D transient | MOL + `solve_ivp` | FEM | PINN |\n| 2D steady | Finite differences \u002F spectral | FEM | PINN |\n| 2D transient | MOL or ADI | FEM | PINN |\n| 3D | Spectral if periodic | FEM (Modal GPU) | PINN (Modal GPU) |\n\n## Core Workflows\n\n### 1. 1D Heat Equation (Finite Differences)\n\n$$\\frac{\\partial u}{\\partial t} = \\alpha \\frac{\\partial^2 u}{\\partial x^2}$$\n\n```python\nimport numpy as np\nimport matplotlib.pyplot as plt\n\ndef solve_heat_1d(L=1.0, T=0.5, alpha=0.01, Nx=100, Nt=5000,\n                  u_left=0.0, u_right=0.0, u0_func=None):\n    \"\"\"\n    Solve 1D heat equation with Dirichlet BCs using explicit finite differences.\n    Method of Lines approach: discretize space, integrate in time.\n    \"\"\"\n    dx = L \u002F Nx\n    dt = T \u002F Nt\n\n    # CFL stability check\n    r = alpha * dt \u002F dx**2\n    if r > 0.5:\n        raise ValueError(f\"CFL violated: r = {r:.4f} > 0.5. Reduce dt or increase Nx.\")\n    print(f\"Grid: Nx={Nx}, Nt={Nt}, dx={dx:.4e}, dt={dt:.4e}, CFL r={r:.4f}\")\n\n    x = np.linspace(0, L, Nx + 1)\n    u = u0_func(x) if u0_func else np.sin(np.pi * x \u002F L)\n\n    # Enforce BCs\n    u[0] = u_left\n    u[-1] = u_right\n\n    # Time stepping (explicit Euler)\n    u_history = [u.copy()]\n    t_history = [0.0]\n\n    for n in range(Nt):\n        u_new = u.copy()\n        u_new[1:-1] = u[1:-1] + r * (u[2:] - 2*u[1:-1] + u[:-2])\n        u_new[0] = u_left\n        u_new[-1] = u_right\n        u = u_new\n\n        if (n + 1) % (Nt \u002F\u002F 10) == 0:\n            u_history.append(u.copy())\n            t_history.append((n + 1) * dt)\n\n    return x, u_history, t_history\n\n# Solve and plot\nx, u_hist, t_hist = solve_heat_1d()\n\nfig, ax = plt.subplots(figsize=(10, 6))\nfor u, t in zip(u_hist, t_hist):\n    ax.plot(x, u, label=f't = {t:.3f}')\nax.set_xlabel('x')\nax.set_ylabel('u(x,t)')\nax.set_title('1D Heat Equation')\nax.legend()\nax.grid(True, alpha=0.3)\nplt.savefig('heat_1d.png', dpi=150, bbox_inches='tight')\n\n# Validate against analytical solution\n# u(x,t) = sin(πx\u002FL) * exp(-α(π\u002FL)²t)\nu_exact = np.sin(np.pi * x) * np.exp(-0.01 * (np.pi)**2 * t_hist[-1])\nerror = np.max(np.abs(u_hist[-1] - u_exact))\nprint(f\"Max error vs analytical: {error:.2e}\")\n```\n\n### 2. 2D Poisson Equation (Finite Differences)\n\n$$\\nabla^2 u = f(x,y)$$\n\n```python\ndef solve_poisson_2d(Nx=50, Ny=50, Lx=1.0, Ly=1.0,\n                     source_func=None, bc_func=None):\n    \"\"\"\n    Solve 2D Poisson equation using direct sparse solver.\n    Dirichlet BCs on all boundaries.\n    \"\"\"\n    from scipy.sparse import diags, kron, eye\n    from scipy.sparse.linalg import spsolve\n\n    dx = Lx \u002F Nx\n    dy = Ly \u002F Ny\n    x = np.linspace(0, Lx, Nx + 1)\n    y = np.linspace(0, Ly, Ny + 1)\n    X, Y = np.meshgrid(x, y)\n\n    # Interior points only\n    n_interior_x = Nx - 1\n    n_interior_y = Ny - 1\n    N = n_interior_x * n_interior_y\n\n    # 1D Laplacian operators\n    Dxx = diags([1, -2, 1], [-1, 0, 1], shape=(n_interior_x, n_interior_x)) \u002F dx**2\n    Dyy = diags([1, -2, 1], [-1, 0, 1], shape=(n_interior_y, n_interior_y)) \u002F dy**2\n\n    # 2D Laplacian via Kronecker product\n    Ix = eye(n_interior_x)\n    Iy = eye(n_interior_y)\n    L = kron(Iy, Dxx) + kron(Dyy, Ix)\n\n    # Source term on interior\n    if source_func is None:\n        source_func = lambda x, y: -2 * np.pi**2 * np.sin(np.pi*x) * np.sin(np.pi*y)\n\n    x_int = x[1:-1]\n    y_int = y[1:-1]\n    X_int, Y_int = np.meshgrid(x_int, y_int)\n    f = source_func(X_int, Y_int).ravel()\n\n    # Solve\n    u_int = spsolve(L, f)\n\n    # Reconstruct full solution (with BCs = 0)\n    u = np.zeros((Ny + 1, Nx + 1))\n    u[1:-1, 1:-1] = u_int.reshape(n_interior_y, n_interior_x)\n\n    return X, Y, u\n\nX, Y, u = solve_poisson_2d()\n\nfig, ax = plt.subplots(figsize=(8, 7))\ncf = ax.contourf(X, Y, u, levels=30, cmap='RdBu_r')\nplt.colorbar(cf, ax=ax, label='u(x,y)')\nax.set_xlabel('x')\nax.set_ylabel('y')\nax.set_title(r'2D Poisson Equation: $\\nabla^2 u = f(x,y)$')\nax.set_aspect('equal')\nplt.savefig('poisson_2d.png', dpi=150, bbox_inches='tight')\n```\n\n### 3. Wave Equation (Spectral Method)\n\n```python\ndef solve_wave_1d_spectral(L=2*np.pi, T=10, N=128, c=1.0, dt=0.01):\n    \"\"\"\n    Solve 1D wave equation u_tt = c^2 u_xx using pseudospectral method.\n    Periodic boundary conditions.\n    \"\"\"\n    dx = L \u002F N\n    x = np.linspace(0, L, N, endpoint=False)\n    k = np.fft.fftfreq(N, d=dx) * 2 * np.pi  # wavenumbers\n\n    # Initial conditions\n    u = np.exp(-((x - L\u002F2)**2) \u002F 0.1)  # Gaussian pulse\n    v = np.zeros_like(u)  # zero initial velocity\n\n    Nt = int(T \u002F dt)\n    u_hat = np.fft.fft(u)\n    v_hat = np.fft.fft(v)\n\n    # Stormer-Verlet in Fourier space\n    # u_tt = -c^2 k^2 u (in Fourier space)\n    omega2 = (c * k)**2\n\n    snapshots = [(0, u.copy())]\n    for n in range(Nt):\n        # Leapfrog: v_hat += dt * (-omega2 * u_hat)\n        v_hat -= dt * omega2 * u_hat\n        u_hat += dt * v_hat\n\n        t = (n + 1) * dt\n        if (n + 1) % (Nt \u002F\u002F 10) == 0:\n            snapshots.append((t, np.real(np.fft.ifft(u_hat))))\n\n    return x, snapshots\n\nx, snaps = solve_wave_1d_spectral()\n\nfig, ax = plt.subplots(figsize=(10, 6))\nfor t, u in snaps:\n    ax.plot(x, u, label=f't = {t:.1f}')\nax.set_xlabel('x')\nax.set_ylabel('u(x,t)')\nax.set_title('1D Wave Equation (Spectral Method, Periodic BC)')\nax.legend(ncol=2)\nax.grid(True, alpha=0.3)\nplt.savefig('wave_spectral.png', dpi=150, bbox_inches='tight')\n```\n\n### 4. Physics-Informed Neural Networks (DeepXDE)\n\nFor inverse problems or complex domains, use PINNs:\n\n```bash\npip install deepxde  # uses TensorFlow or PyTorch backend\n```\n\n```python\nimport deepxde as dde\nimport numpy as np\n\n# Example: solve u_xx + u_yy = 0 on unit square\n# BC: u = sin(pi*x) on y=0, u = 0 elsewhere\n\ndef pde(x, y):\n    \"\"\"Laplace equation: u_xx + u_yy = 0\"\"\"\n    dy_xx = dde.grad.hessian(y, x, i=0, j=0)\n    dy_yy = dde.grad.hessian(y, x, i=1, j=1)\n    return dy_xx + dy_yy\n\ngeom = dde.geometry.Rectangle([0, 0], [1, 1])\n\n# Boundary conditions\ndef bc_bottom(x, on_boundary):\n    return on_boundary and np.isclose(x[1], 0)\n\ndef bc_func(x):\n    return np.sin(np.pi * x[:, 0:1])\n\nbc1 = dde.icbc.DirichletBC(geom, bc_func, bc_bottom)\nbc2 = dde.icbc.DirichletBC(geom, lambda x: 0, lambda x, on_boundary: on_boundary and not np.isclose(x[1], 0))\n\ndata = dde.data.PDE(geom, pde, [bc1, bc2],\n                     num_domain=2000, num_boundary=200)\n\nnet = dde.nn.FNN([2] + [64]*3 + [1], \"tanh\", \"Glorot uniform\")\nmodel = dde.Model(data, net)\n\nmodel.compile(\"adam\", lr=1e-3)\nmodel.train(epochs=10000)\nmodel.compile(\"L-BFGS\")\nmodel.train()\n```\n\n### 5. Method of Lines (MOL) for Time-Dependent PDEs\n\nConvert PDE to system of ODEs, then use `solve_ivp`:\n\n```python\nfrom scipy.integrate import solve_ivp\n\ndef heat_equation_mol(L=1.0, alpha=0.01, Nx=100, T=0.5):\n    \"\"\"\n    Heat equation via Method of Lines: spatial finite differences → ODE system.\n    Solves with adaptive RK45 — no CFL restriction!\n    \"\"\"\n    dx = L \u002F Nx\n    x = np.linspace(0, L, Nx + 1)\n\n    def rhs(t, u_interior):\n        u = np.zeros(Nx + 1)\n        u[1:-1] = u_interior  # BCs: u[0] = u[-1] = 0\n        dudt = alpha * (u[2:] - 2*u[1:-1] + u[:-2]) \u002F dx**2\n        return dudt\n\n    u0 = np.sin(np.pi * x \u002F L)\n    sol = solve_ivp(rhs, (0, T), u0[1:-1],\n                    method='RK45', rtol=1e-8, atol=1e-10,\n                    t_eval=np.linspace(0, T, 100))\n\n    return x, sol\n\nx, sol = heat_equation_mol()\n```\n\n## Stability Reference\n\n| Method | Stability Condition | Notes |\n|---|---|---|\n| Explicit Euler (heat) | r = αΔt\u002FΔx² ≤ 0.5 | Simple but restrictive |\n| Implicit Euler (heat) | Unconditionally stable | Requires linear solve per step |\n| Crank-Nicolson (heat) | Unconditionally stable | 2nd order in time |\n| Explicit (wave) | CFL: cΔt\u002FΔx ≤ 1 | |\n| Spectral + leapfrog | CFL with max wavenumber | Very restrictive for small Δx |\n| MOL + adaptive RK | Automatic | Best general approach |\n| PINN | N\u002FA (optimization) | No stability constraint |\n\n## Validation Checklist\n\nAfter solving any PDE:\n- [ ] Verify against analytical solution (if known)\n- [ ] Run mesh convergence study (halve Δx, check solution doesn't change)\n- [ ] Check boundary conditions are satisfied\n- [ ] For conservation PDEs: verify total conserved quantity\n- [ ] For time-dependent: check CFL condition (explicit methods)\n- [ ] Plot residual of the PDE at the solution\n\n## Troubleshooting\n\n| Symptom | Cause | Fix |\n|---|---|---|\n| Solution blows up | CFL violation | Reduce Δt or use implicit method |\n| Oscillations near boundaries | Numerical dispersion | Use higher-order scheme or finer grid |\n| Slow convergence (PINN) | Bad architecture or learning rate | Try deeper network, reduce LR, use L-BFGS |\n| Sparse solver fails | Matrix too large | Use iterative solver (CG, GMRES) |\n| Wrong steady state | BC not properly enforced | Double-check BC implementation |\n","# PDE Solver\n\n## Overview\n\nSolve partial differential equations using finite differences, spectral methods, or physics-informed neural networks (PINNs). Covers elliptic (Laplace, Poisson), parabolic (heat, diffusion), and hyperbolic (wave) equations in 1D, 2D, and 3D.\n\n## When to Use\n\n- Solving any PDE in physics (heat equation, wave equation, Navier-Stokes, Schrodinger, etc.)\n- Steady-state or time-dependent problems\n- Problems on simple geometries (rectangles, circles, boxes)\n- Inverse problems (discovering parameters from data)\n\n## Do NOT Use When\n\n- Complex 3D geometries with unstructured meshes (use FEniCS — `pip install fenics-dolfinx`)\n- Turbulent fluid dynamics on periodic domains (use `fluidsim`)\n- Already know it's an ODE system (use `ode-solver`)\n\n## Method Selection\n\n| PDE Type | Simple Geometry | Complex Geometry | Inverse Problem |\n|---|---|---|---|\n| 1D steady | Finite differences | FEM (FEniCS) | PINN (DeepXDE) |\n| 1D transient | MOL + `solve_ivp` | FEM | PINN |\n| 2D steady | Finite differences \u002F spectral | FEM | PINN |\n| 2D transient | MOL or ADI | FEM | PINN |\n| 3D | Spectral if periodic | FEM (Modal GPU) | PINN (Modal GPU) |\n\n## Core Workflows\n\n### 1. 1D Heat Equation (Finite Differences)\n\n$$\\frac{\\partial u}{\\partial t} = \\alpha \\frac{\\partial^2 u}{\\partial x^2}$$\n\n```python\nimport numpy as np\nimport matplotlib.pyplot as plt\n\ndef solve_heat_1d(L=1.0, T=0.5, alpha=0.01, Nx=100, Nt=5000,\n                  u_left=0.0, u_right=0.0, u0_func=None):\n    \"\"\"\n    Solve 1D heat equation with Dirichlet BCs using explicit finite differences.\n    Method of Lines approach: discretize space, integrate in time.\n    \"\"\"\n    dx = L \u002F Nx\n    dt = T \u002F Nt\n\n    # CFL stability check\n    r = alpha * dt \u002F dx**2\n    if r > 0.5:\n        raise ValueError(f\"CFL violated: r = {r:.4f} > 0.5. Reduce dt or increase Nx.\")\n    print(f\"Grid: Nx={Nx}, Nt={Nt}, dx={dx:.4e}, dt={dt:.4e}, CFL r={r:.4f}\")\n\n    x = np.linspace(0, L, Nx + 1)\n    u = u0_func(x) if u0_func else np.sin(np.pi * x \u002F L)\n\n    # Enforce BCs\n    u[0] = u_left\n    u[-1] = u_right\n\n    # Time stepping (explicit Euler)\n    u_history = [u.copy()]\n    t_history = [0.0]\n\n    for n in range(Nt):\n        u_new = u.copy()\n        u_new[1:-1] = u[1:-1] + r * (u[2:] - 2*u[1:-1] + u[:-2])\n        u_new[0] = u_left\n        u_new[-1] = u_right\n        u = u_new\n\n        if (n + 1) % (Nt \u002F\u002F 10) == 0:\n            u_history.append(u.copy())\n            t_history.append((n + 1) * dt)\n\n    return x, u_history, t_history\n\n# Solve and plot\nx, u_hist, t_hist = solve_heat_1d()\n\nfig, ax = plt.subplots(figsize=(10, 6))\nfor u, t in zip(u_hist, t_hist):\n    ax.plot(x, u, label=f't = {t:.3f}')\nax.set_xlabel('x')\nax.set_ylabel('u(x,t)')\nax.set_title('1D Heat Equation')\nax.legend()\nax.grid(True, alpha=0.3)\nplt.savefig('heat_1d.png', dpi=150, bbox_inches='tight')\n\n# Validate against analytical solution\n# u(x,t) = sin(πx\u002FL) * exp(-α(π\u002FL)²t)\nu_exact = np.sin(np.pi * x) * np.exp(-0.01 * (np.pi)**2 * t_hist[-1])\nerror = np.max(np.abs(u_hist[-1] - u_exact))\nprint(f\"Max error vs analytical: {error:.2e}\")\n```\n\n### 2. 2D Poisson Equation (Finite Differences)\n\n$$\\nabla^2 u = f(x,y)$$\n\n```python\ndef solve_poisson_2d(Nx=50, Ny=50, Lx=1.0, Ly=1.0,\n                     source_func=None, bc_func=None):\n    \"\"\"\n    Solve 2D Poisson equation using direct sparse solver.\n    Dirichlet BCs on all boundaries.\n    \"\"\"\n    from scipy.sparse import diags, kron, eye\n    from scipy.sparse.linalg import spsolve\n\n    dx = Lx \u002F Nx\n    dy = Ly \u002F Ny\n    x = np.linspace(0, Lx, Nx + 1)\n    y = np.linspace(0, Ly, Ny + 1)\n    X, Y = np.meshgrid(x, y)\n\n    # Interior points only\n    n_interior_x = Nx - 1\n    n_interior_y = Ny - 1\n    N = n_interior_x * n_interior_y\n\n    # 1D Laplacian operators\n    Dxx = diags([1, -2, 1], [-1, 0, 1], shape=(n_interior_x, n_interior_x)) \u002F dx**2\n    Dyy = diags([1, -2, 1], [-1, 0, 1], shape=(n_interior_y, n_interior_y)) \u002F dy**2\n\n    # 2D Laplacian via Kronecker product\n    Ix = eye(n_interior_x)\n    Iy = eye(n_interior_y)\n    L = kron(Iy, Dxx) + kron(Dyy, Ix)\n\n    # Source term on interior\n    if source_func is None:\n        source_func = lambda x, y: -2 * np.pi**2 * np.sin(np.pi*x) * np.sin(np.pi*y)\n\n    x_int = x[1:-1]\n    y_int = y[1:-1]\n    X_int, Y_int = np.meshgrid(x_int, y_int)\n    f = source_func(X_int, Y_int).ravel()\n\n    # Solve\n    u_int = spsolve(L, f)\n\n    # Reconstruct full solution (with BCs = 0)\n    u = np.zeros((Ny + 1, Nx + 1))\n    u[1:-1, 1:-1] = u_int.reshape(n_interior_y, n_interior_x)\n\n    return X, Y, u\n\nX, Y, u = solve_poisson_2d()\n\nfig, ax = plt.subplots(figsize=(8, 7))\ncf = ax.contourf(X, Y, u, levels=30, cmap='RdBu_r')\nplt.colorbar(cf, ax=ax, label='u(x,y)')\nax.set_xlabel('x')\nax.set_ylabel('y')\nax.set_title(r'2D Poisson Equation: $\\nabla^2 u = f(x,y)$')\nax.set_aspect('equal')\nplt.savefig('poisson_2d.png', dpi=150, bbox_inches='tight')\n```\n\n### 3. Wave Equation (Spectral Method)\n\n```python\ndef solve_wave_1d_spectral(L=2*np.pi, T=10, N=128, c=1.0, dt=0.01):\n    \"\"\"\n    Solve 1D wave equation u_tt = c^2 u_xx using pseudospectral method.\n    Periodic boundary conditions.\n    \"\"\"\n    dx = L \u002F N\n    x = np.linspace(0, L, N, endpoint=False)\n    k = np.fft.fftfreq(N, d=dx) * 2 * np.pi  # wavenumbers\n\n    # Initial conditions\n    u = np.exp(-((x - L\u002F2)**2) \u002F 0.1)  # Gaussian pulse\n    v = np.zeros_like(u)  # zero initial velocity\n\n    Nt = int(T \u002F dt)\n    u_hat = np.fft.fft(u)\n    v_hat = np.fft.fft(v)\n\n    # Stormer-Verlet in Fourier space\n    # u_tt = -c^2 k^2 u (in Fourier space)\n    omega2 = (c * k)**2\n\n    snapshots = [(0, u.copy())]\n    for n in range(Nt):\n        # Leapfrog: v_hat += dt * (-omega2 * u_hat)\n        v_hat -= dt * omega2 * u_hat\n        u_hat += dt * v_hat\n\n        t = (n + 1) * dt\n        if (n + 1) % (Nt \u002F\u002F 10) == 0:\n            snapshots.append((t, np.real(np.fft.ifft(u_hat))))\n\n    return x, snapshots\n\nx, snaps = solve_wave_1d_spectral()\n\nfig, ax = plt.subplots(figsize=(10, 6))\nfor t, u in snaps:\n    ax.plot(x, u, label=f't = {t:.1f}')\nax.set_xlabel('x')\nax.set_ylabel('u(x,t)')\nax.set_title('1D Wave Equation (Spectral Method, Periodic BC)')\nax.legend(ncol=2)\nax.grid(True, alpha=0.3)\nplt.savefig('wave_spectral.png', dpi=150, bbox_inches='tight')\n```\n\n### 4. Physics-Informed Neural Networks (DeepXDE)\n\nFor inverse problems or complex domains, use PINNs:\n\n```bash\npip install deepxde  # uses TensorFlow or PyTorch backend\n```\n\n```python\nimport deepxde as dde\nimport numpy as np\n\n# Example: solve u_xx + u_yy = 0 on unit square\n# BC: u = sin(pi*x) on y=0, u = 0 elsewhere\n\ndef pde(x, y):\n    \"\"\"Laplace equation: u_xx + u_yy = 0\"\"\"\n    dy_xx = dde.grad.hessian(y, x, i=0, j=0)\n    dy_yy = dde.grad.hessian(y, x, i=1, j=1)\n    return dy_xx + dy_yy\n\ngeom = dde.geometry.Rectangle([0, 0], [1, 1])\n\n# Boundary conditions\ndef bc_bottom(x, on_boundary):\n    return on_boundary and np.isclose(x[1], 0)\n\ndef bc_func(x):\n    return np.sin(np.pi * x[:, 0:1])\n\nbc1 = dde.icbc.DirichletBC(geom, bc_func, bc_bottom)\nbc2 = dde.icbc.DirichletBC(geom, lambda x: 0, lambda x, on_boundary: on_boundary and not np.isclose(x[1], 0))\n\ndata = dde.data.PDE(geom, pde, [bc1, bc2],\n                     num_domain=2000, num_boundary=200)\n\nnet = dde.nn.FNN([2] + [64]*3 + [1], \"tanh\", \"Glorot uniform\")\nmodel = dde.Model(data, net)\n\nmodel.compile(\"adam\", lr=1e-3)\nmodel.train(epochs=10000)\nmodel.compile(\"L-BFGS\")\nmodel.train()\n```\n\n### 5. Method of Lines (MOL) for Time-Dependent PDEs\n\nConvert PDE to system of ODEs, then use `solve_ivp`:\n\n```python\nfrom scipy.integrate import solve_ivp\n\ndef heat_equation_mol(L=1.0, alpha=0.01, Nx=100, T=0.5):\n    \"\"\"\n    Heat equation via Method of Lines: spatial finite differences → ODE system.\n    Solves with adaptive RK45 — no CFL restriction!\n    \"\"\"\n    dx = L \u002F Nx\n    x = np.linspace(0, L, Nx + 1)\n\n    def rhs(t, u_interior):\n        u = np.zeros(Nx + 1)\n        u[1:-1] = u_interior  # BCs: u[0] = u[-1] = 0\n        dudt = alpha * (u[2:] - 2*u[1:-1] + u[:-2]) \u002F dx**2\n        return dudt\n\n    u0 = np.sin(np.pi * x \u002F L)\n    sol = solve_ivp(rhs, (0, T), u0[1:-1],\n                    method='RK45', rtol=1e-8, atol=1e-10,\n                    t_eval=np.linspace(0, T, 100))\n\n    return x, sol\n\nx, sol = heat_equation_mol()\n```\n\n## Stability Reference\n\n| Method | Stability Condition | Notes |\n|---|---|---|\n| Explicit Euler (heat) | r = αΔt\u002FΔx² ≤ 0.5 | Simple but restrictive |\n| Implicit Euler (heat) | Unconditionally stable | Requires linear solve per step |\n| Crank-Nicolson (heat) | Unconditionally stable | 2nd order in time |\n| Explicit (wave) | CFL: cΔt\u002FΔx ≤ 1 | |\n| Spectral + leapfrog | CFL with max wavenumber | Very restrictive for small Δx |\n| MOL + adaptive RK | Automatic | Best general approach |\n| PINN | N\u002FA (optimization) | No stability constraint |\n\n## Validation Checklist\n\nAfter solving any PDE:\n- [ ] Verify against analytical solution (if known)\n- [ ] Run mesh convergence study (halve Δx, check solution doesn't change)\n- [ ] Check boundary conditions are satisfied\n- [ ] For conservation PDEs: verify total conserved quantity\n- [ ] For time-dependent: check CFL condition (explicit methods)\n- [ ] Plot residual of the PDE at the solution\n\n## Troubleshooting\n\n| Symptom | Cause | Fix |\n|---|---|---|\n| Solution blows up | CFL violation | Reduce Δt or use implicit method |\n| Oscillations near boundaries | Numerical dispersion | Use higher-order scheme or finer grid |\n| Slow convergence (PINN) | Bad architecture or learning rate | Try deeper network, reduce LR, use L-BFGS |\n| Sparse solver fails | Matrix too large | Use iterative solver (CG, GMRES) |\n| Wrong steady state | BC not properly enforced | Double-check BC implementation |\n",{"name":5,"tags":46,"author":54,"license":15,"version":55,"category":32,"description":7,"dependencies":56},[47,48,49,50,51,52,53],"PDE","Finite Difference","Spectral Methods","PINN","DeepXDE","Simulation","Physics","Synthetic Sciences","1.0.0",[57,58,59],"scipy>=1.11.0","numpy>=1.24.0","matplotlib>=3.7.0","main","4aa39efd1cdab0b4657ecee16c92a92011a5b10f","openscience\u002Fbackend\u002Fcli\u002Fskills\u002Fphysics\u002Fpde-solver","https:\u002F\u002Fgithub.com\u002Ffadrienne\u002FMyGitHub","https:\u002F\u002Fgithub.com\u002Ffadrienne","2026-10-28 00:43:09",{"source":8,"skillName":5,"commands":67,"prompt":77,"zipAvailable":78},[68,71,74],{"tool":69,"command":70},"npx","npx skills add fadrienne\u002FMyGitHub --skill pde-solver",{"tool":72,"command":73},"bunx","bunx skills add fadrienne\u002FMyGitHub --skill pde-solver",{"tool":75,"command":76},"pnpm","pnpm dlx skills add fadrienne\u002FMyGitHub --skill pde-solver","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Ffadrienne\u002FMyGitHub\u002Fblob\u002Fmain\u002Fopenscience\u002Fbackend\u002Fcli\u002Fskills\u002Fphysics\u002Fpde-solver\u002FSKILL.md",true,[],[81,111,137,171,198,225],{"skillNo":82,"name":83,"nameZh":6,"description":84,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":85,"categories":86,"keywords":92,"publishedAt":41},"01M7167B28PK20HP7R7ZED2DY0","statistical-power","Sample size calculation, power analysis, and effect size conversion for scientific studies. Use BEFORE data collection (a priori) to determine required N, or after (post-hoc) to compute achieved power. Covers parametric tests (t-test, ANOVA, chi-square, proportions, correlation, regression), simulation-based power for complex\u002Fclustered\u002Fnested designs, and power curves. Use this skill when someone asks 'how many samples do I need', 'what is my power', 'what effect size can I detect', or any variant. Pairs with \u002Fexperimental-design (choose design first, then compute power) and \u002Fstatistical-analysis (analyze data after collection).","https:\u002F\u002Fgithub.com\u002Ffadrienne\u002FMyGitHub\u002Fblob\u002Fmain\u002Fscientific-agent-skills\u002Fskills\u002Fstatistical-power\u002FSKILL.md",[87],{"categoryNo":88,"categoryName":89,"taxonomyType":90,"taxonomyTypeDesc":91},"01JBSEEDCAT000000000000023","Skill与智能体开发","SCENARIO","使用场景",[93,94,95,33,96,97,98,99,100,101,102,103,104,105,106,107,108,109,38,110],"power","statistical power","effect","regression","choose","design","uv","when","Bash","collection","analysis","calculation","ANOVA","conversion","analyze","t-test","chi-square","sample",{"skillNo":112,"name":113,"nameZh":6,"description":114,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":115,"categories":116,"keywords":120,"publishedAt":41},"01M71677EBCM8EPCE9BZCK8505","statistical-analysis","Guided statistical analysis with test selection and reporting. Use when you need help choosing appropriate tests for your data, assumption checking, power analysis, and APA-formatted results. Best for academic research reporting, test selection guidance. For implementing specific models programmatically use statsmodels.","https:\u002F\u002Fgithub.com\u002Ffadrienne\u002FMyGitHub\u002Fblob\u002Fmain\u002Fscientific-agent-skills\u002Fskills\u002Fstatistical-analysis\u002FSKILL.md",[117],{"categoryNo":118,"categoryName":119,"taxonomyType":90,"taxonomyTypeDesc":91},"01JBSEEDCAT000000000000008","测试与质量",[103,121,93,122,123,124,100,125,126,127,128,129,130,28,131,132,133,134,135,136],"statistical analysis","academic research","implementing","selection","you","reporting","data","for","tests","use","test","research","results","statsmodels","models","help",{"skillNo":138,"name":139,"nameZh":6,"description":140,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":141,"categories":142,"keywords":152,"publishedAt":41},"01M71673R93XAHFH81DBNVNG7H","scientific-writing","Core skill for the deep research and writing tool. Write scientific manuscripts in full paragraphs (never bullet points). Use two-stage process with (1) section outlines with key points using research-lookup then (2) convert to flowing prose. IMRAD structure, citations (APA\u002FAMA\u002FVancouver), figures\u002Ftables, reporting guidelines (CONSORT\u002FSTROBE\u002FPRISMA), for research papers and journal submissions.","https:\u002F\u002Fgithub.com\u002Ffadrienne\u002FMyGitHub\u002Fblob\u002Fmain\u002Fscientific-agent-skills\u002Fskills\u002Fscientific-writing\u002FSKILL.md",[143,146,147],{"categoryNo":144,"categoryName":145,"taxonomyType":90,"taxonomyTypeDesc":91},"01JBSEEDCAT000000000000018","写作与文案",{"categoryNo":88,"categoryName":89,"taxonomyType":90,"taxonomyTypeDesc":91},{"categoryNo":148,"categoryName":149,"taxonomyType":150,"taxonomyTypeDesc":151},"01JBSEEDCAT000000000000036","内容创作者","PROFESSION","适用职业",[153,154,155,156,157,158,159,160,161,162,101,163,164,165,166,167,168,169,126,170],"writing","scientific","scientific writing","Citations","deep","deep research","never","papers","journal","false","api","prisma","structure","openrouter","Outlines","core skill","read","features",{"skillNo":172,"name":173,"nameZh":6,"description":174,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":175,"categories":176,"keywords":181,"publishedAt":41},"01M7166ZPKXBF4EBPHVTJPQBB1","scientific-visualization","Meta-skill for publication-ready figures. Use when creating journal submission figures requiring multi-panel layouts, significance annotations, error bars, colorblind-safe palettes, and specific journal formatting (Nature, Science, Cell). Orchestrates matplotlib\u002Fseaborn\u002Fplotly with publication styles. For quick exploration use seaborn or plotly directly.","https:\u002F\u002Fgithub.com\u002Ffadrienne\u002FMyGitHub\u002Fblob\u002Fmain\u002Fscientific-agent-skills\u002Fskills\u002Fscientific-visualization\u002FSKILL.md",[177,180],{"categoryNo":178,"categoryName":179,"taxonomyType":90,"taxonomyTypeDesc":91},"01JBSEEDCAT000000000000013","分析与可视化",{"categoryNo":88,"categoryName":89,"taxonomyType":90,"taxonomyTypeDesc":91},[182,154,183,184,185,186,187,188,189,161,100,190,191,192,193,194,195,196,128,197],"visualization","scientific visualization","error","ready","quick","exploration","meta-skill","Meta","safe","plotly","annotations","formatting","Publication","figures","panel","submission",{"skillNo":199,"name":200,"nameZh":6,"description":201,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":202,"categories":203,"keywords":210,"publishedAt":41},"01M7166VXJWQSSC3RQZP60WBGR","research-code","Debug, profile, review, and restructure Python research and analysis code. Use when analysis scripts crash, produce wrong results, run too slowly, or need a correctness review. Covers: reading tracebacks and diagnosing root causes, hypothesis-driven debugging, reviewing code for common statistical\u002Fnumerical errors, profiling data pipelines, improving reproducibility (seeds, environments, determinism), and structuring analysis scripts for sharing. Distinct from \u002Fexploratory-data-analysis (which understands data) and \u002Fstatistical-analysis (which chooses and runs tests) — this skill focuses on the code itself.","https:\u002F\u002Fgithub.com\u002Ffadrienne\u002FMyGitHub\u002Fblob\u002Fmain\u002Fscientific-agent-skills\u002Fskills\u002Fresearch-code\u002FSKILL.md",[204,207],{"categoryNo":205,"categoryName":206,"taxonomyType":90,"taxonomyTypeDesc":91},"01JBSEEDCAT000000000000021","资料检索与研究",{"categoryNo":208,"categoryName":209,"taxonomyType":150,"taxonomyTypeDesc":151},"01JBSEEDCAT000000000000030","开发工程师",[211,212,132,213,214,215,216,99,217,100,101,103,218,219,220,221,222,223,169,224],"code","research code","which","memory","data-analysis","errors","debugging","common","review","data pipelines","run","scripts","line","write",{"skillNo":226,"name":227,"nameZh":6,"description":228,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":229,"licenseFileUrl":6,"sourceHtmlUrl":230,"categories":231,"keywords":238,"publishedAt":41},"01M7166CF5HSR7SVZYZFWTDX55","markdown-mermaid-writing","Comprehensive markdown and Mermaid diagram writing skill. Use when creating any scientific document, report, analysis, or visualization. Establishes text-based diagrams as the default documentation standard with full style guides (markdown + mermaid), 24 diagram type references, and 9 document templates.","Apache-2.0","https:\u002F\u002Fgithub.com\u002Ffadrienne\u002FMyGitHub\u002Fblob\u002Fmain\u002Fscientific-agent-skills\u002Fskills\u002Fmarkdown-mermaid-writing\u002FSKILL.md",[232,235,236,237],{"categoryNo":233,"categoryName":234,"taxonomyType":90,"taxonomyTypeDesc":91},"01JBSEEDCAT000000000000002","文档处理",{"categoryNo":144,"categoryName":145,"taxonomyType":90,"taxonomyTypeDesc":91},{"categoryNo":88,"categoryName":89,"taxonomyType":90,"taxonomyTypeDesc":91},{"categoryNo":148,"categoryName":149,"taxonomyType":150,"taxonomyTypeDesc":151},[153,239,240,241,242,243,182,244,245,100,101,103,246,247,248,249,250,251,154,169],"markdown mermaid writing","mermaid","markdown","community","diagrams","project","default","team","guides","text","documentation","references","diagram"]