Numerical Integration logo

Numerical Integration

Community
HeshamFS
numerical-integration

Select and configure time integration methods for ODE and PDE simulations — choose among explicit Runge-Kutta, BDF, Rosenbrock, and Adams families, set relative and absolute error tolerances, implement adaptive step-size control with P/PI step-size controllers, plan IMEX operator splitting for mixed stiff and non-stiff terms, and estimate splitting errors. Use when picking an integrator for a new simulation, diagnosing step rejections or tolerance failures, setting up operator splitting for phase-field or reaction-diffusion problems, or deciding between explicit and implicit time marching, even if the user only says "my solver keeps rejecting steps" or "which ODE method should I use."

Overview

PublisherHeshamFS
Repositorymaterials-simulation-skills
Skill namenumerical-integration
Stars
83
Forks
6
Bundled files
13
LicenseApache-2.0
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • 13 bundled files

    Scripts, templates, and references the model can read while it works. Files are read-only and never executed.

  • Open source

    Published by HeshamFS on GitHub. Read the source before you install it.

Installation

Install the Numerical Integration AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/HeshamFS/materials-simulation-skills/tree/main/skills/core-numerical/numerical-integration
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/HeshamFS/materials-simulation-skills.git /tmp/materials-simulation-skills
mkdir -p .claude/skills
cp -r /tmp/materials-simulation-skills/skills/core-numerical/numerical-integration .claude/skills/numerical-integration
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Numerical Integration in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Numerical Integration on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Numerical Integration is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

Numerical Integration

Goal

Provide a reliable workflow to select integrators, set tolerances, and manage adaptive time stepping for time-dependent simulations.

Requirements

  • Python 3.10+
  • NumPy (for some scripts)
  • No heavy dependencies for core functionality

Inputs to Gather

InputDescriptionExample
Problem typeODE/PDE, stiff/non-stiffstiff PDE
Jacobian availableCan compute ∂f/∂u?yes
Target accuracyDesired error level1e-6
ConstraintsMemory, implicit allowed?implicit OK
Time scaleCharacteristic time1e-3 s

Decision Guidance

Choosing an Integrator

Is the problem stiff?
├── YES → Is Jacobian available?
│   ├── YES → Use Rosenbrock or BDF
│   └── NO → Use BDF with numerical Jacobian
└── NO → Is high accuracy needed?
    ├── YES → Use RK45 or DOP853
    └── NO → Use RK4 or Adams-Bashforth

Stiff vs Non-Stiff Detection

SymptomLikely StiffAction
dt shrinks to tiny valuesYesSwitch to implicit
Eigenvalues span many decadesYesUse BDF/Radau
Smooth solution, reasonable dtNoStay explicit

Script Outputs (JSON Fields)

ScriptKey Outputs
scripts/error_norm.pyerror_norm, scale_min, scale_max
scripts/adaptive_step_controller.pyaccept, dt_next, factor
scripts/integrator_selector.pyrecommended, alternatives, notes
scripts/imex_split_planner.pyimplicit_terms, explicit_terms, splitting_strategy
scripts/splitting_error_estimator.pyerror_estimate, substeps

Workflow

  1. Classify stiffness - Check eigenvalue spread or use stiffness_detector
  2. Choose tolerances - See references/tolerance_guidelines.md
  3. Select integrator - Run scripts/integrator_selector.py
  4. Compute error norms - Use scripts/error_norm.py for step acceptance
  5. Adapt step size - Use scripts/adaptive_step_controller.py
  6. Plan IMEX/splitting - If mixed stiff/nonstiff, use scripts/imex_split_planner.py
  7. Validate convergence - Repeat with tighter tolerances

Conversational Workflow Example

User: I'm solving the Allen-Cahn equation with a stiff double-well potential. What integrator should I use?

Agent workflow:

  1. Check integrator options:
    bash
    python3 scripts/integrator_selector.py --stiff --jacobian-available --accuracy high --json
  2. Plan the IMEX splitting (diffusion implicit, reaction explicit):
    bash
    python3 scripts/imex_split_planner.py --stiff-terms diffusion --nonstiff-terms reaction --coupling weak --json
  3. Recommend: Use IMEX-BDF2 with diffusion term implicit, double-well reaction explicit.

Pre-Integration Checklist

  • Identify stiffness and dominant time scales
  • Set rtol/atol consistent with physics and units
  • Confirm integrator compatibility with stiffness
  • Use error norm to accept/reject steps
  • Verify convergence with tighter tolerance run

CLI Examples

bash
# Select integrator for stiff problem with Jacobian
python3 scripts/integrator_selector.py --stiff --jacobian-available --accuracy high --json

# Compute scaled error norm
python3 scripts/error_norm.py --error 0.01,0.02 --solution 1.0,2.0 --rtol 1e-3 --atol 1e-6 --json

# Adaptive step control with PI controller
python3 scripts/adaptive_step_controller.py --dt 1e-2 --error-norm 0.8 --order 4 --controller pi --json

# Plan IMEX splitting
python3 scripts/imex_split_planner.py --stiff-terms diffusion,elastic --nonstiff-terms reaction --coupling strong --json

# Estimate splitting error
python3 scripts/splitting_error_estimator.py --dt 1e-4 --scheme strang --commutator-norm 50 --target-error 1e-6 --json

Error Handling

ErrorCauseResolution
rtol must be a non-negative finite number / atol must be a non-negative finite numberInvalid tolerancesUse non-negative finite values
error_norm must be finite and non-negativeNegative or non-finite error normCheck error computation
scale must be positive; with min_scale=0 ensure atol>0 or rtol*|y|>0All scale entries collapsed to 0 (e.g. rtol=0, atol=0, default min_scale=0)Set atol>0, rtol>0, or --min-scale > 0
argument --controller: invalid choice: ... (choose from p, pi)Invalid controller typeUse p or pi
Provide at least one stiff or non-stiff termEmpty term listSpecify stiff or nonstiff terms

Interpretation Guidance

Error Norm Values

Error NormMeaningAction
< 1.0Step acceptableAccept, maybe increase dt
≈ 1.0At tolerance boundaryAccept with current dt
> 1.0Step rejectedReject, reduce dt

Controller Selection

ControllerCLI valuePropertiesBest For
P (elementary / integral)p (default)Simple, some overshootNon-stiff, moderate accuracy
PI (proportional-integral)piSmooth, robust (requires --prev-error)General use

PID control is described in references/error_control.md for reference only; the adaptive_step_controller.py CLI implements p and pi controllers.

IMEX Strategy

CouplingStrategy
WeakSimple operator splitting
ModerateStrang splitting
StrongFully coupled IMEX-RK

Verification checklist

  • Recorded the scaled error_norm (and scale_min/scale_max) from scripts/error_norm.py and confirmed scale_min > 0, so no component reduced to atol-only scaling by accident.
  • Confirmed each accepted step has error_norm <= accept_threshold (default 1.0) per scripts/adaptive_step_controller.py; logged any accept: false steps and the resulting dt_next/factor rather than forcing the step through.
  • For the PI controller, supplied --prev-error and verified controller_used reported pi (not the silent p fallback that occurs when --prev-error is omitted).
  • Ran scripts/integrator_selector.py with the actual --stiff/--jacobian-available/--accuracy flags matching the problem and recorded recommended plus the notes (e.g. the "expect smaller dt" warning for stiff-without-implicit).
  • For operator splitting, recorded error_estimate, substeps, and dt_effective from scripts/splitting_error_estimator.py and confirmed error_estimate <= target-error after substepping, using the correct --scheme order (lie=1, strang=2).
  • Ran the convergence validation (Workflow step 7): repeated with tighter rtol/atol and confirmed the solution change is below the target accuracy, rather than trusting a single tolerance run.

Common pitfalls & rationalizations

Tempting shortcutWhy it's wrong / what to do
"I picked an implicit/BDF method, so any dt is fine."Unconditional stability is not accuracy; large dt still inflates temporal error. Check error_norm against the accept threshold and run the tighter-tolerance convergence check (Workflow step 7).
"error_norm came back < 1, so the step and the whole run are correct."The norm only certifies the local step under the chosen rtol/atol. A loose tolerance passes every step while the global solution is wrong — tighten tolerances and confirm convergence before trusting results.
"I'll use the PI controller for smoother stepping" but omit --prev-error.Without --prev-error the script silently falls back to the P controller (controller_used: p). You get no PI benefit. Pass the previous accepted error_norm and verify controller_used: pi.
"Strang vs Lie splitting won't matter much here."Splitting error scales as commutator_norm * dt^(order+1) with order 1 (lie) vs 2 (strang). For a nonzero commutator the schemes differ by a full power of dt — run splitting_error_estimator.py with the actual --commutator-norm and --target-error instead of guessing.
"The selector recommended IMEX/RK-Chebyshev, so I'll just run explicitly without a Jacobian."That branch fires only for stiff problems without implicit solves and the script warns "expect smaller dt." Read the notes: provide a Jacobian/Jv product and use BDF/Radau if implicit solves are feasible.
"It ran to the final time without crashing, so the integration is valid."Completion is not correctness. Verify step acceptance (error_norm <= threshold), splitting error within target-error, and convergence under tighter tolerances; for conservative problems pass --conservative to imex_split_planner.py and check conserved quantities.

Security

Input Validation

  • All numeric inputs (dt, rtol, atol, error_norm, stiffness_ratio, commutator_norm, etc.) are validated as finite numbers at the function boundary
  • imex_split_planner.py validates term names against [a-zA-Z_][a-zA-Z0-9_ -]* with length and count limits, preventing injection payloads in user-supplied term lists
  • Comma-separated value lists are capped at 100,000 entries to prevent resource exhaustion
  • Numeric bounds enforced: dimension capped at 10 billion, order at 20, stiffness_ratio at 1e30
  • --controller is validated against a fixed allowlist (p, pi)
  • --scheme is validated against known splitting schemes (lie, strang)

File Access

  • Scripts read no external files; all inputs are provided via CLI arguments
  • Scripts write only to stdout (JSON output); no files are created unless the agent explicitly uses the Write tool

Tool Restrictions

  • Read: Used to inspect script source, references, and user configuration files
  • Write: Used to save integrator recommendations or splitting plans; writes are scoped to the user's working directory
  • Grep/Glob: Used to locate relevant files and search references
  • The skill's allowed-tools excludes Bash to prevent the agent from executing arbitrary commands when processing user-provided inputs

Safety Measures

  • No eval(), exec(), or dynamic code generation
  • All subprocess calls use explicit argument lists (no shell=True)
  • Reduced tool surface (no Bash) limits the agent to read/write operations only
  • Term names are sanitized before use, preventing shell metacharacter injection

Limitations

  • No automatic stiffness detection: Use stiffness_detector from numerical-stability
  • Splitting assumes separability: Terms must be cleanly separable
  • Jacobian requirement: Some methods need analytical or numerical Jacobian

References

  • references/method_catalog.md - Integrator options and properties
  • references/tolerance_guidelines.md - Choosing rtol/atol
  • references/error_control.md - Error norm and adaptation formulas
  • references/imex_guidelines.md - Stiff/non-stiff splitting
  • references/splitting_catalog.md - Operator splitting patterns
  • references/multiphase_field_patterns.md - Phase-field specific splits

Version History

  • v1.2.3 (2026-10-19): Compute Euclidean error norms without avoidable squaring overflow or underflow.

  • v1.2.2 (2026-06-24): Added Verification checklist and Common pitfalls & rationalizations sections grounding step acceptance, PI controller usage, integrator selection, and splitting-error checks in the scripts' actual outputs

  • v1.2.0 (2026-06-23): Fixed PI controller coefficient/sign to standard form, fixed error_norm scale-collapse crash, corrected error-message and controller documentation to match the scripts

  • v1.1.0 (2024-12-24): Enhanced documentation, decision guidance, examples

  • v1.0.0: Initial release with 5 integration scripts

Bundled files

The model reads these on demand while the skill is loaded. They are exposed as readable files and are never executed.

Frequently asked questions

What does the Numerical Integration AI skill do?

Select and configure time integration methods for ODE and PDE simulations — choose among explicit Runge-Kutta, BDF, Rosenbrock, and Adams families, set relative and absolute error tolerances, implement adaptive step-size control with P/PI step-size controllers, plan IMEX operator splitting for mixed stiff and non-stiff terms, and estimate splitting errors. Use when picking an integrator for a new simulation, diagnosing step rejections or tolerance failures, setting up operator splitting for phase-field or reaction-diffusion problems, or deciding between explicit and implicit time marching,...

Why use Numerical Integration on TypingMind?

Because you install it once and use it with any model. Numerical Integration is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Numerical Integration in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/HeshamFS/materials-simulation-skills/tree/main/skills/core-numerical/numerical-integration. TypingMind reads its SKILL.md and bundles its files and installs it as a skill you can enable per chat.

Which AI models can use Numerical Integration?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Numerical Integration?

As many as you like. As long as a model supports skills, you can use Numerical Integration with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Numerical Integration AI skill free?

Yes. It is published on GitHub by HeshamFS under the Apache-2.0 license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇