OpenClaw-Medical-Skills convergence-study
Spatial and temporal convergence analysis with Richardson extrapolation and Grid Convergence Index (GCI) for solution verification
install
source · Clone the upstream repo
git clone https://github.com/FreedomIntelligence/OpenClaw-Medical-Skills
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/FreedomIntelligence/OpenClaw-Medical-Skills "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/convergence-study" ~/.claude/skills/freedomintelligence-openclaw-medical-skills-convergence-study && rm -rf "$T"
OpenClaw · Install into ~/.openclaw/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/FreedomIntelligence/OpenClaw-Medical-Skills "$T" && mkdir -p ~/.openclaw/skills && cp -r "$T/skills/convergence-study" ~/.openclaw/skills/freedomintelligence-openclaw-medical-skills-convergence-study && rm -rf "$T"
manifest:
skills/convergence-study/SKILL.mdtags
source content
Convergence Study
Goal
Provide script-driven convergence analysis for verifying that numerical solutions converge at the expected rate as the mesh or timestep is refined.
Requirements
- Python 3.8+
- NumPy (not required; scripts use only math stdlib)
Inputs to Gather
| Input | Description | Example |
|---|---|---|
| Grid spacings | Sequence of mesh sizes (coarse to fine) | |
| Timestep sizes | Sequence of dt values | |
| Solution values | QoI at each refinement level | |
| Expected order | Formal order of the numerical scheme | |
| Safety factor | GCI safety factor (1.25 default) | |
Script Outputs (JSON Fields)
| Script | Key Outputs |
|---|---|
| , , , |
| Same as h_refinement but for temporal convergence |
| , , |
| , , , , |
Workflow
- Run grid/timestep refinement study with at least 3 levels
- Compute observed convergence order with
orh_refinement.pydt_refinement.py - Compare observed order to expected order of the scheme
- Estimate discretization error via Richardson extrapolation
- Report GCI for formal solution verification using
gci_calculator.py - Document convergence results and any anomalies
Decision Guidance
Do you have 3+ refinement levels? +-- YES --> Run h_refinement.py or dt_refinement.py | +-- Observed order matches expected? --> Solution verified | +-- Order too low? --> Check: pre-asymptotic, coding error, insufficient resolution | +-- Order too high? --> Check: superconvergence or cancellation effects +-- NO (only 2 levels) --> Use richardson_extrapolation.py with assumed order (less reliable without order verification)
CLI Examples
# Spatial convergence with 4 grid levels python3 scripts/h_refinement.py --spacings 0.4,0.2,0.1,0.05 --values 1.16,1.04,1.01,1.0025 --expected-order 2.0 --json # Temporal convergence with 3 timestep levels python3 scripts/dt_refinement.py --timesteps 0.04,0.02,0.01 --values 2.12,2.03,2.0075 --expected-order 2.0 --json # Richardson extrapolation with assumed 2nd-order python3 scripts/richardson_extrapolation.py --spacings 0.02,0.01 --values 1.0032,1.0008 --order 2.0 --json # GCI for 3-mesh verification python3 scripts/gci_calculator.py --spacings 0.04,0.02,0.01 --values 1.0128,1.0032,1.0008 --json
Error Handling
| Error | Cause | Resolution |
|---|---|---|
| Mismatched input arrays | Provide equal-length lists |
| Too few data points | Add more refinement levels |
| GCI needs 3 levels | Provide fine/medium/coarse |
| Non-monotone convergence | Check mesh quality or scheme |
Interpretation Guidance
| Scenario | Meaning | Action |
|---|---|---|
| Observed order matches expected | Solution in asymptotic range | Report GCI, extrapolate |
| Observed order < expected | Pre-asymptotic or coding bug | Refine further or debug |
| Negative observed order | Solution diverging | Check implementation |
| GCI asymptotic ratio near 1.0 | Grids in asymptotic range | Results are reliable |
| GCI asymptotic ratio far from 1.0 | Not in asymptotic range | Refine further |
References
- Formal convergence order, log-log analysis, asymptotic rangereferences/convergence_theory.md
- Roache's GCI method, ASME V&V 20, safety factorsreferences/gci_guidelines.md