differentiation-schemes

Generate finite-difference stencils and estimate truncation errors for PDE discretization.

61|4|Updated Dec 24, 2025
One-click install
npx skills add https://github.com/HeshamFS/materials-simulation-skills --skill differentiation-schemes
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: differentiation-schemes
Source: https://github.com/HeshamFS/materials-simulation-skills/tree/main/skills/core-numerical/differentiation-schemes
Command: npx skills add https://github.com/HeshamFS/materials-simulation-skills --skill differentiation-schemes

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) and references (resource) components.

What problem does it solve?

Select differentiation schemes for discretization, generate stencils, and assess accuracy for simulation discretization.

Core Features & Use Cases

  • Stencil generation: create finite-difference coefficients for requested order/accuracy.
  • Scheme selection: recommend appropriate scheme given smoothness and boundaries.
  • Error estimation: estimate truncation error and bound stability implications.

Quick Start

Generate a 4th-order central second-derivative stencil: python3 scripts/stencil_generator.py --order 2 --accuracy 4 --scheme central --dx 0.01 --json

Frequently Asked Questions about differentiation-schemes

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I generate finite-difference stencil coefficients for my PDE discretization?

Finite-difference stencils are numerical approximations of derivatives on discrete grids. Use the stencil generator to specify derivative order, desired accuracy order, scheme type (central, forward, backward), and grid spacing to produce stencil offsets and coefficients optimized for your discretization.

What's the best way to choose between finite-difference, finite-volume, and spectral differentiation schemes?

Scheme selection depends on field smoothness, boundary conditions, and accuracy requirements. This Skill recommends appropriate schemes by analyzing your grid type, boundary treatment needs, and smoothness characteristics, then outputs truncation-error estimates and dispersion/dissipation analysis to guide your choice.

How do I handle boundary conditions when generating differentiation stencils?

Boundaries require specialized stencils since standard interior schemes cannot extend beyond the domain. Specify your boundary type during stencil generation; the Skill constructs one-sided or modified stencils at edges while maintaining accuracy and estimating truncation error near boundaries.

Can I estimate truncation error and stability implications of my differentiation scheme?

Truncation-error estimation quantifies the discretization accuracy loss. The Skill computes error bounds for your selected scheme, analyzes dispersion and dissipation across smooth and non-smooth fields, and outputs validation data to assess stability implications before deploying your discretization.

What Python dependencies and environment do I need to generate differentiation stencils?

Differentiation-scheme generation requires Python 3.8 or later and NumPy; no additional heavy dependencies are needed. The Skill outputs results via scripted JSON, making integration straightforward in any Python-based simulation or discretization workflow.

How do I generate higher-order accuracy stencils for smoother solution fields?

Higher accuracy orders reduce truncation error but require wider stencils and smoother input data. Specify your target accuracy order and field smoothness to the generator; it constructs wider stencils with optimized coefficients and returns error metrics showing accuracy gain versus computational cost.