Loading...
Loading...
Analyze and enforce numerical stability for time-dependent PDE simulations. Use when selecting time steps, choosing explicit/implicit schemes, diagnosing numerical blow-up, checking CFL/Fourier criteria, von Neumann analysis, matrix conditioning, or detecting stiffness in advection/diffusion/reaction problems.
npx skill4agent add heshamfs/materials-simulation-skills numerical-stabilityscripts/requirements.txt| Input | Description | Example |
|---|---|---|
Grid spacing | Spatial discretization | |
Time step | Temporal discretization | |
Velocity | Advection speed | |
Diffusivity | Thermal/mass diffusivity | |
Reaction rate | First-order rate constant | |
| Dimensions | 1D, 2D, or 3D | |
| Scheme type | Explicit or implicit | |
Is the problem stiff (fast + slow dynamics)?
├── YES → Use implicit or IMEX scheme
│ └── Check conditioning with matrix_condition.py
└── NO → Is CFL/Fourier satisfied with reasonable dt?
├── YES → Use explicit scheme (cheaper per step)
└── NO → Consider implicit or reduce dx| Physics | Number | Explicit Limit (1D) | Formula |
|---|---|---|---|
| Advection | CFL | C ≤ 1 | |
| Diffusion | Fourier | Fo ≤ 0.5 | |
| Reaction | Reaction | R ≤ 1 | |
Fo ≤ 1/(2d)| Script | Key Outputs |
|---|---|
| |
| |
| |
| |
scripts/cfl_checker.pydtscripts/stiffness_detector.pyscripts/von_neumann_analyzer.pyscripts/matrix_condition.pypython3 scripts/cfl_checker.py --dx 0.01 --dt 1e-4 --diffusivity 1e-3 --dimensions 2 --jsonFo = 1e-3 × 1e-4 / (0.01)² = 1.0Fo ≤ 0.252.5e-5cfl_checker.pydt# Check CFL/Fourier for 2D diffusion-advection
python3 scripts/cfl_checker.py --dx 0.1 --dt 0.01 --velocity 1.0 --diffusivity 0.1 --dimensions 2 --json
# Von Neumann analysis for custom 3-point stencil
python3 scripts/von_neumann_analyzer.py --coeffs 0.2,0.6,0.2 --dx 1.0 --nk 128 --json
# Detect stiffness from eigenvalue estimates
python3 scripts/stiffness_detector.py --eigs=-1,-1000 --json
# Check matrix conditioning for implicit system
python3 scripts/matrix_condition.py --matrix A.npy --norm 2 --json| Error | Cause | Resolution |
|---|---|---|
| Zero or negative values | Provide valid positive numbers |
| Missing velocity/diffusivity | Provide at least one physics parameter |
| Invalid path | Check matrix file exists |
| Singular or ill-formed matrix | Check matrix validity |
| Scenario | Meaning | Action |
|---|---|---|
| All checked criteria satisfied | Proceed with simulation |
| At least one limit violated | Reduce dt or change scheme |
| No criteria could be applied | Provide more physics inputs |
| Stiffness ratio > 1000 | Problem is stiff | Use implicit integrator |
| Condition number > 10⁶ | Ill-conditioned | Use scaling/preconditioning |
references/stability_criteria.mdreferences/common_pitfalls.mdreferences/scheme_catalog.md