Selects and applies numerical differentiation schemes for PDE/ODE discretization — generates finite-difference stencils at arbitrary order, handles central/upwind/compact/spectral methods, boundary stencils, and truncation error estimation.
Ships in full. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them; scripts run unread.
Provide a reliable workflow to select a differentiation scheme, generate stencils, and assess accuracy for simulation discretization.
| Input | Description | Example |
|---|---|---|
| Derivative order | First, second, etc. | 1 or 2 |
| Target accuracy | Order of truncation error | 2 or 4 |
| Grid type | Uniform, nonuniform | uniform |
| Boundary type | Periodic, Dirichlet, Neumann | periodic |
| Smoothness | Smooth or discontinuous | smooth |
Is the field smooth?
├── YES → Is domain periodic?
│ ├── YES → Use central differences or spectral
│ └── NO → Use central interior + one-sided at boundaries
└── NO → Are there shocks/discontinuities?
├── YES → Use upwind, TVD, or WENO
└── NO → Use central with limiters
| Situation | Recommended Scheme |
|---|---|
| Smooth, periodic | Central, spectral |
| Smooth, bounded | Central + one-sided BCs |
| Advection-dominated | Upwind |
| Shocks/fronts | TVD, WENO |
| High accuracy needed | Compact (Padé), spectral |
| Script | Key Outputs |
|---|---|
scripts/stencil_generator.py | offsets, coefficients, order, accuracy, scheme |
scripts/scheme_selector.py | recommended, alternatives, notes |
scripts/truncation_error.py | error_scale, order, reduction_if_halved |
scripts/scheme_selector.pyscripts/stencil_generator.pyscripts/truncation_error.pyUser: I need to discretize a second derivative for a diffusion equation on a uniform grid. I want 4th-order accuracy.
Agent workflow:
--boundary to surface one-sided/ghost-cell
guidance, or ask the user):
python3 scripts/scheme_selector.py --smooth --order 2 --accuracy 4 --json
python3 scripts/stencil_generator.py --order 2 --accuracy 4 --scheme central --json
[-1/12, 4/3, -5/2, 4/3, -1/12] / dx².# Select scheme for smooth periodic problem
python3 scripts/scheme_selector.py --smooth --periodic --order 1 --accuracy 4 --json
# Generate central difference stencil for first derivative
python3 scripts/stencil_generator.py --order 1 --accuracy 2 --scheme central --json
# Generate 4th-order second derivative stencil
python3 scripts/stencil_generator.py --order 2 --accuracy 4 --scheme central --json
# Estimate truncation error
python3 scripts/truncation_error.py --dx 0.01 --accuracy 2 --scale 1.0 --json
| Error | Cause | Resolution |
|---|---|---|
order must be positive | Invalid derivative order | Use 1, 2, 3, ... (max 6) |
order must be <= 6 | Derivative order too large | Use 1–6 |
accuracy must be even for central | Odd accuracy requested for central scheme | Use 2, 4, 6, ... |
scheme must be central, forward, or backward | Invalid --scheme value | Use central, forward, or backward |
| Property | Meaning |
|---|---|
| Symmetric offsets | Central scheme (no directional bias) |
| Asymmetric offsets | One-sided or upwind scheme |
| More points | Higher accuracy but wider stencil |
| Accuracy Order | Error Scales As | Refinement Factor |
|---|---|---|
| 2nd order | O(dx²) | 2× refinement → 4× error reduction |
| 4th order | O(dx⁴) | 2× refinement → 16× error reduction |
| 6th order | O(dx⁶) | 2× refinement → 64× error reduction |
| Derivative | Accuracy | Points | Coefficients (× 1/dx or 1/dx²) |
|---|---|---|---|
| 1st | 2 | 3 | [-1/2, 0, 1/2] |
| 1st | 4 | 5 | [1/12, -2/3, 0, 2/3, -1/12] |
| 2nd | 2 | 3 | [1, -2, 1] |
| 2nd | 4 | 5 | [-1/12, 4/3, -5/2, 4/3, -1/12] |
Before trusting a generated stencil or accepting a scheme recommendation, record concrete evidence for each item below:
stencil_generator.py --json and confirmed results.accuracy matches the requested order AND that len(results.offsets) equals the expected stencil width (e.g. 5 points for a 4th-order central second derivative); for a central scheme also verified the offsets are symmetric about 0.coefficients against references/stencil_catalog.md: confirmed they sum to ~0 (consistency: the operator annihilates a constant) and reproduce a known catalog stencil for at least one standard case (e.g. 2nd-order d²/dx² gives [1, -2, 1]/dx²).central scheme, confirmed --accuracy is even (odd values exit 2 with accuracy must be even for central); recorded the actual exit code rather than assuming the requested order was achieved.error_scale, order, and reduction_if_halved from truncation_error.py and confirmed reduction_if_halved == 2**accuracy, then compared error_scale against the smallest physical feature size (dx/L_feature from references/error_guidance.md) to confirm the grid actually resolves the physics.p_obs = log(e_h/e_{h/2})/log(2) is within ~10% of the formal accuracy before quoting that order.--scheme forward|backward or --boundary guidance) per references/boundary_handling.md, since the interior stencil alone does not define the scheme order at the boundary.scheme_selector.py did NOT recommend high-order central FD and that a limiter/WENO/upwind path was chosen instead.| Tempting shortcut | Why it's wrong / what to do |
|---|---|
| "The stencil generator returned coefficients, so the scheme is the order I asked for." | The accuracy field just echoes your request; it is not measured. Verify the achieved order with a grid-refinement study and confirm the coefficients match a catalog stencil and sum to ~0. |
"I asked for 4th order on a central scheme with --accuracy 3, it'll just round up." | It will not — central schemes reject odd accuracy with accuracy must be even for central (exit 2). Pass an even accuracy; an odd request is an error, not a silent upgrade. |
| "Higher accuracy order always means lower error here." | truncation_error.py reports asymptotic scaling (scale * dx**accuracy); for a coarse grid or under-resolved feature the higher-order term need not dominate, and roundoff (O(ε/dx^p)) can win on very fine grids. Compare error_scale to the feature size, do not assume monotone improvement. |
| "Two grids agree closely, so it's converged." | Two grids cannot estimate observed order or confirm the asymptotic range. Use >=3 grids and compute p_obs before claiming the formal order (see references/error_guidance.md). |
| "The interior stencil is 4th order, so my whole solve is 4th order." | The generator emits interior stencils only; boundary closures often limit the global order. Generate one-sided/ghost-cell stencils explicitly and verify the boundary does not drop the observed order (references/boundary_handling.md). |
| "The field has a shock but a wide central stencil is more accurate, so use it." | High-order central FD oscillates (Gibbs) at discontinuities. scheme_selector.py recommends FV with limiter/WENO or upwind for --discontinuous; follow it rather than maximizing formal order. |
"Custom --offsets let me build any stencil I want." | Offsets must be distinct, length-capped (51), and number more than the derivative order, or the script exits 2. A valid run still does not guarantee the intended accuracy — verify the coefficients and observed order. |
--order (derivative order) is validated as a positive integer with an upper bound (order <= 6)--accuracy is validated as a positive integer (<= 8), and additionally must be even for central schemes--scheme is validated against a fixed allowlist (central, forward, backward)--offsets (custom stencil) is length-capped (max 51), parsed as distinct integers, and must exceed the derivative order--dx and --scale are validated as finite, non-negative numbers (--dx strictly positive)stencil_generator.py, scheme_selector.py, truncation_error.py) with explicit argument listseval(), exec(), or dynamic code generationshell=True)references/stencil_catalog.md - Common stencilsreferences/boundary_handling.md - One-sided schemesreferences/scheme_selection.md - FD/FV/spectral comparisonreferences/error_guidance.md - Truncation error scalingCHANGELOG.md (opens in a new tab)evals/evals.json (opens in a new tab)references/boundary_handling.md (opens in a new tab)references/error_guidance.md (opens in a new tab)references/scheme_selection.md (opens in a new tab)references/stencil_catalog.md (opens in a new tab)scripts/scheme_selector.py (opens in a new tab)scripts/stencil_generator.py (opens in a new tab)scripts/truncation_error.py (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
/full:differentiation-schemesfrom full
npx claudepluginhub heshamfs/materials-simulation-skills --plugin full23 skills in this plugin
/benchmark-and-mms-plannerPlan verification and validation campaigns for simulation codes using manufactured solutions, canonical benchmark problems, grid/time refinement, uncertainty propagation, and pass/fail acceptance criteria. Use when an agent needs to prove a solver, model, or result is trustworthy rather than only plausible.
/convergence-studyPerform spatial and temporal convergence analysis for solution verification — compute observed convergence orders from grid or timestep refinement studies, apply Richardson extrapolation to estimate discretization error, and calculate the Grid Convergence Index (GCI) per ASME V&V 20 standards. Use when verifying that a numerical solution converges at the expected rate, estimating the error on the finest mesh, checking whether grids are in the asymptotic range, or preparing formal verification reports, even if the user only asks "is my mesh fine enough" or "how accurate is my solution."
/fair-simulation-packagerCreate FAIR-minded reproducibility bundles for materials simulations by collecting input/output file inventories, hashes, units, engine versions, structure identifiers, provenance, and NOMAD/OPTIMADE/Materials Project friendly metadata. Use before publishing, sharing, archiving, or handing simulation results to another agent.
/hpc-runtime-doctorDiagnose HPC runtime and scheduler problems for materials simulations, including MPI/OpenMP/GPU layout, modules, CUDA/Kokkos hints, scratch paths, walltime, job arrays, restart strategy, scheduler portability, and resource mismatch. Use when an ALREADY-SUBMITTED job failed, ran slowly, got killed, or behaved differently on a cluster than on a workstation. To author or vet a NEW submission script before running, use slurm-job-script-generator instead.
/linear-solversSelect and configure linear solvers for Ax=b systems arising in numerical simulations — choose between direct (LU, Cholesky) and iterative (CG, GMRES, BiCGSTAB, MINRES) methods, analyze sparsity patterns and matrix conditioning, recommend preconditioners (AMG, ILU, IC), apply row/column scaling, and diagnose convergence stagnation from residual histories. Use when setting up a linear solve for FEM/FVM assembly, debugging slow or stalled Krylov iterations, choosing a preconditioner for SPD or nonsymmetric systems, or investigating ill-conditioning, even if the user only says "my solver is slow" or "GMRES won't converge."
/md-analysis-plannerPlan molecular dynamics post-processing for materials simulations, including RDF, MSD and diffusion, VACF/VDOS, coordination numbers, bond-angle distributions, stress-strain curves, equilibration detection, PBC unwrapping, and trajectory format choices. Use before writing MD analysis scripts or trusting trajectory-derived results.
2 plugins ship this exact skill · first indexed Jun 25, 2026
Other plugins' skills for the same job