skills/core-numerical/numerical-integration/SKILL.md
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 I/PI/PID 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."
npx skillsauth add HeshamFS/materials-simulation-skills numerical-integrationInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Provide a reliable workflow to select integrators, set tolerances, and manage adaptive time stepping for time-dependent simulations.
| Input | Description | Example |
|-------|-------------|---------|
| Problem type | ODE/PDE, stiff/non-stiff | stiff PDE |
| Jacobian available | Can compute ∂f/∂u? | yes |
| Target accuracy | Desired error level | 1e-6 |
| Constraints | Memory, implicit allowed? | implicit OK |
| Time scale | Characteristic time | 1e-3 s |
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
| Symptom | Likely Stiff | Action | |---------|--------------|--------| | dt shrinks to tiny values | Yes | Switch to implicit | | Eigenvalues span many decades | Yes | Use BDF/Radau | | Smooth solution, reasonable dt | No | Stay explicit |
| Script | Key Outputs |
|--------|-------------|
| scripts/error_norm.py | error_norm, scale_min, scale_max |
| scripts/adaptive_step_controller.py | accept, dt_next, factor |
| scripts/integrator_selector.py | recommended, alternatives, notes |
| scripts/imex_split_planner.py | implicit_terms, explicit_terms, splitting_strategy |
| scripts/splitting_error_estimator.py | error_estimate, substeps |
references/tolerance_guidelines.mdscripts/integrator_selector.pyscripts/error_norm.py for step acceptancescripts/adaptive_step_controller.pyscripts/imex_split_planner.pyUser: I'm solving the Allen-Cahn equation with a stiff double-well potential. What integrator should I use?
Agent workflow:
python3 scripts/integrator_selector.py --stiff --jacobian-available --accuracy high --json
python3 scripts/imex_split_planner.py --stiff-terms diffusion --nonstiff-terms reaction --coupling weak --json
rtol/atol consistent with physics and units# 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 | Cause | Resolution |
|-------|-------|------------|
| rtol and atol must be positive | Invalid tolerances | Use positive values |
| error-norm must be positive | Negative error norm | Check error computation |
| Unknown controller | Invalid controller type | Use i, pi, or pid |
| Splitting requires at least one term | Empty term list | Specify stiff or nonstiff terms |
| Error Norm | Meaning | Action | |------------|---------|--------| | < 1.0 | Step acceptable | Accept, maybe increase dt | | ≈ 1.0 | At tolerance boundary | Accept with current dt | | > 1.0 | Step rejected | Reject, reduce dt |
| Controller | Properties | Best For | |------------|------------|----------| | I (integral) | Simple, some overshoot | Non-stiff, moderate accuracy | | PI (proportional-integral) | Smooth, robust | General use | | PID | Aggressive adaptation | Rapidly varying dynamics |
| Coupling | Strategy | |----------|----------| | Weak | Simple operator splitting | | Moderate | Strang splitting | | Strong | Fully coupled IMEX-RK |
dt, rtol, atol, error_norm, stiffness_ratio, commutator_norm, etc.) are validated as finite numbers at the function boundaryimex_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 listsdimension capped at 10 billion, order at 20, stiffness_ratio at 1e30--controller is validated against a fixed allowlist (i, pi, pid)--scheme is validated against known splitting schemes (lie, strang)allowed-tools excludes Bash to prevent the agent from executing arbitrary commands when processing user-provided inputseval(), exec(), or dynamic code generationshell=True)references/method_catalog.md - Integrator options and propertiesreferences/tolerance_guidelines.md - Choosing rtol/atolreferences/error_control.md - Error norm and adaptation formulasreferences/imex_guidelines.md - Stiff/non-stiff splittingreferences/splitting_catalog.md - Operator splitting patternsreferences/multiphase_field_patterns.md - Phase-field specific splitsdevelopment
Plan 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.
testing
Map computational materials tasks onto workflow engines such as atomate2, jobflow, AiiDA, pyiron, or a simple one-off script. Use when deciding how to structure a reproducible campaign, DAG, restart strategy, provenance record, storage layout, or migration path from ad hoc scripts to managed workflows.
development
Plan 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.
development
Triage cross-code simulation failures and propose safe retry ladders for nonconvergence, NaN/Inf, exploding energies, unstable timesteps, pressure blow-up, missing potentials, bad pseudopotentials, corrupted output, and incomplete runs. Use when an agent sees a failed or suspicious materials simulation and needs a defensible first response.