time-stepping
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseTime Stepping
时间步规划
Goal
目标
Provide a reliable workflow for choosing, ramping, and monitoring time steps plus output/checkpoint cadence.
为时间步的选择、渐变和监控,以及输出/检查点节奏提供可靠的工作流。
Requirements
要求
- Python 3.10+
- No external dependencies (uses stdlib)
- Python 3.10+
- 无外部依赖(使用标准库)
Inputs to Gather
需要收集的输入
| Input | Description | Example |
|---|---|---|
| Stability limits | CFL/Fourier/reaction limits | |
| Target dt | Desired time step | |
| Total run time | Simulation duration | |
| Output interval | Time between outputs | |
| Checkpoint cost | Time to write checkpoint | |
| 输入项 | 描述 | 示例 |
|---|---|---|
| 稳定性限制 | CFL/傅里叶/反应限制 | |
| 目标dt值 | 期望的时间步 | |
| 总运行时间 | 仿真时长 | |
| 输出间隔 | 两次输出的时间间隔 | |
| 检查点成本 | 写入检查点所需时间 | |
Decision Guidance
决策指南
Time Step Selection
时间步选择
Is stability limit known?
├── YES → Use min(dt_target, dt_limit × safety)
└── NO → Start conservative, increase adaptively
Need ramping for startup?
├── YES → Start at dt_init, ramp to dt_target over N steps
└── NO → Use dt_target from start已知稳定性限制?
├── 是 → 使用min(dt_target, dt_limit × safety)
└── 否 → 从保守值开始,自适应增大
启动阶段需要渐变策略?
├── 是 → 从dt_init开始,经过N步渐变到dt_target
└── 否 → 从一开始就使用dt_targetRamping Strategy
渐变策略
| Problem Type | Ramp Steps | Initial dt |
|---|---|---|
| Smooth IC | None needed | Full dt |
| Sharp gradients | 5-10 | 0.1 × dt |
| Phase change | 10-20 | 0.01 × dt |
| Cold start | 10-50 | 0.001 × dt |
| 问题类型 | 渐变步数 | 初始dt值 |
|---|---|---|
| 平滑初始条件 | 无需渐变 | 完整dt值 |
| 尖锐梯度 | 5-10 | 0.1 × dt |
| 相变 | 10-20 | 0.01 × dt |
| 冷启动 | 10-50 | 0.001 × dt |
Script Outputs (JSON Fields)
脚本输出(JSON字段)
| Script | Key Outputs |
|---|---|
| |
| |
| |
output_schedule.pycountt_startt_endcount = number_of_intervals + 1t=0..50.05| 脚本 | 关键输出 |
|---|---|
| |
| |
| |
output_schedule.pycountt_startt_endcount = 间隔数 + 1t=0..50.05Workflow
工作流
- Get stability limits - Use numerical-stability skill
- Plan time stepping - Run
scripts/timestep_planner.py - Schedule outputs - Run
scripts/output_schedule.py - Plan checkpoints - Run
scripts/checkpoint_planner.py - Monitor during run - Adjust dt if limits change
- 获取稳定性限制 - 使用数值稳定性工具
- 规划时间步 - 运行
scripts/timestep_planner.py - 规划输出 - 运行
scripts/output_schedule.py - 规划检查点 - 运行
scripts/checkpoint_planner.py - 运行期间监控 - 若限制变化则调整dt值
Conversational Workflow Example
对话式工作流示例
User: I'm running a 10-hour phase-field simulation. How often should I checkpoint?
Agent workflow:
- Plan checkpoints based on acceptable lost work:
bash
python3 scripts/checkpoint_planner.py --run-time 36000 --checkpoint-cost 120 --max-lost-time 1800 --json - Interpret: Checkpoint every 30 minutes, overhead ~6.7% (Acceptable per the interpretation table), max 30 min lost work on crash.
用户:我正在运行一个10小时的相场仿真,应该多久设置一次检查点?
Agent工作流:
- 根据可接受的工作损失规划检查点:
bash
python3 scripts/checkpoint_planner.py --run-time 36000 --checkpoint-cost 120 --max-lost-time 1800 --json - 解读:每30分钟设置一次检查点,开销约6.7%(符合解读表中的可接受范围),崩溃时最多损失30分钟的工作。
Pre-Run Checklist
运行前检查清单
- Confirm dt limits from stability analysis
- Define ramping strategy for transient startup
- Choose output interval consistent with physics time scales
- Plan checkpoints based on restart risk
- Re-evaluate dt after parameter changes
- 确认稳定性分析得出的dt限制
- 为瞬态启动阶段定义渐变策略
- 选择与物理时间尺度一致的输出间隔
- 根据重启风险规划检查点
- 参数变更后重新评估dt值
CLI Examples
CLI示例
bash
undefinedbash
undefinedPlan time stepping with ramping
规划带渐变策略的时间步
python3 scripts/timestep_planner.py --dt-target 1e-4 --dt-limit 2e-4 --safety 0.8 --ramp-steps 10 --json
python3 scripts/timestep_planner.py --dt-target 1e-4 --dt-limit 2e-4 --safety 0.8 --ramp-steps 10 --json
Schedule output times
规划输出时间
python3 scripts/output_schedule.py --t-start 0 --t-end 10 --interval 0.1 --json
python3 scripts/output_schedule.py --t-start 0 --t-end 10 --interval 0.1 --json
Plan checkpoints for long run
为长时间运行任务规划检查点
python3 scripts/checkpoint_planner.py --run-time 36000 --checkpoint-cost 120 --max-lost-time 1800 --json
undefinedpython3 scripts/checkpoint_planner.py --run-time 36000 --checkpoint-cost 120 --max-lost-time 1800 --json
undefinedError Handling
错误处理
| Error | Cause | Resolution |
|---|---|---|
| Invalid time step | Use positive value |
| Invalid time range | Check time bounds |
| Checkpoint too expensive | Reduce checkpoint size |
| 错误 | 原因 | 解决方法 |
|---|---|---|
| 时间步无效 | 使用正值 |
| 时间范围无效 | 检查时间边界 |
| 检查点成本过高 | 减小检查点大小 |
Interpretation Guidance
解读指南
dt Behavior
dt行为
| Observation | Meaning | Action |
|---|---|---|
| dt stable at target | Good | Continue |
| dt shrinking | Stability issue | Check CFL, reduce target |
| dt oscillating | Borderline stability | Add safety factor |
| 观察结果 | 含义 | 操作 |
|---|---|---|
| dt稳定在目标值 | 状态良好 | 继续运行 |
| dt持续缩小 | 稳定性问题 | 检查CFL,降低目标值 |
| dt振荡 | 临界稳定性 | 添加安全系数 |
Checkpoint Overhead
检查点开销
| Overhead | Acceptability |
|---|---|
| < 1% | Excellent |
| 1-5% | Good |
| 5-10% | Acceptable |
| > 10% | Too frequent, increase interval |
| 开销占比 | 可接受性 |
|---|---|
| < 1% | 优秀 |
| 1-5% | 良好 |
| 5-10% | 可接受 |
| > 10% | 过于频繁,增大间隔 |
Verification checklist
验证清单
- Recorded and
dt_recommendedfromdt_limitand confirmedtimestep_planner.pywith no "Recommended dt exceeds stability limit" note in thedt_recommended <= dt_limitfield.notes - Captured the actual value from the stability analysis (numerical-stability skill: CFL/Fourier/reaction limit) that was fed to
dt_limit, rather than guessing — and re-ran the planner after any parameter change.--dt-limit - Confirmed was applied (a margin below the limit), and logged the
safety <= 1.0array (e.g. "Recommended dt reduced by stability limit", min/max clamps) so the binding constraint is known.notes - Recorded the
output_schedule.pyand verified it is endpoint-inclusive (count, bothcount = intervals + 1andt_startpresent), so frame counts and post-processing indices are not off-by-one.t_end - Recorded the checkpoint ,
interval(methodvsdaly), andcapfromoverhead_fraction, and confirmedcheckpoint_planner.py(nooverhead_fraction <= 0.10entry) against the overhead acceptability table.warnings - Confirmed every script exited 0 (not exit 2 / stderr ) and that quoted dt/interval/checkpoint values come from the JSON
ValueError, not from a run that printed a validation error.results
- 记录输出的
timestep_planner.py和dt_recommended,并确认dt_limit,且dt_recommended <= dt_limit字段中没有“推荐dt超过稳定性限制”的提示。notes - 获取输入到的、来自稳定性分析(数值稳定性工具:CFL/傅里叶/反应限制)的实际
--dt-limit值,而非猜测——参数变更后重新运行规划器。dt_limit - 确认已应用(低于限制的余量),并记录
safety <= 1.0数组(例如“推荐dt因稳定性限制降低”、最小/最大值限制),以便明确约束条件。notes - 记录的
output_schedule.py值,并验证它包含端点(count,同时包含count = 间隔数 + 1和t_start),确保帧计数和后处理索引没有差一错误。t_end - 记录输出的检查点
checkpoint_planner.py、interval(methodvsdaly)和cap,并对照开销可接受表确认overhead_fraction(无overhead_fraction <= 0.10条目)。warnings - 确认所有脚本均以状态码0退出(而非状态码2/标准错误输出),且引用的dt/间隔/检查点值来自JSON
ValueError,而非输出验证错误的运行实例。results
Common pitfalls & rationalizations
常见误区与合理化建议
| Tempting shortcut | Why it's wrong / what to do |
|---|---|
"Implicit scheme, so any dt is fine — skip | Unconditional stability is not accuracy; a large dt still ruins temporal error and resolves no transient. Still pass a physics-based |
"Set | |
| "It ran without crashing, so the dt is valid." | Run completion is not correctness. Verify |
"The output | |
| "Checkpoint every step to never lose work." | That drives |
| "Reuse last week's dt/checkpoint plan; the model is basically the same." | Stability and optimal checkpoint interval depend on current |
| 诱人的捷径 | 错误原因/正确做法 |
|---|---|
“隐式格式,所以任何dt都没问题——跳过 | 无条件稳定不等于准确;过大的dt仍会破坏时间精度,无法解析瞬态过程。仍需传入基于物理的 |
“将 | |
| “运行没有崩溃,所以dt是有效的。” | 运行完成不代表结果正确。验证 |
“输出 | |
| “每一步都设置检查点,绝不损失工作。” | 这会使 |
| “复用上周的dt/检查点规划;模型基本相同。” | 稳定性和最优检查点间隔取决于当前的 |
Security
安全性
Input Validation
输入验证
- All numeric parameters (,
dt-target,dt-limit,safety,t-start,t-end,interval,run-time,checkpoint-cost) are validated as finite positive numbers (non-finite values such asmax-lost-time/infare rejected)nan - is bounded to
safety(a safety factor is a stability margin at or below the limit; values above 1.0 are rejected)<= 1.0 - and
ramp-stepsare validated as non-negative integers with an upper bound of 1,000,000; only the previewed slice of the ramp is materialized to bound memory usepreview-steps - Time range consistency is enforced (must exceed
t-end;t-startmust be less thancheckpoint-cost)run-time
- 所有数值参数(、
dt-target、dt-limit、safety、t-start、t-end、interval、run-time、checkpoint-cost)均验证为有限正数(拒绝max-lost-time/inf等非有限值)nan - 限制为
safety(安全系数是等于或低于限制的稳定性余量;大于1.0的值会被拒绝)<= 1.0 - 和
ramp-steps验证为非负整数,上限为1,000,000;仅实例化渐变的预览片段以限制内存使用preview-steps - 强制时间范围一致性(必须大于
t-end;t-start必须小于checkpoint-cost)run-time
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
- 脚本不读取外部文件;所有输入通过CLI参数提供
- 脚本仅向标准输出写入(JSON输出);除非Agent明确使用Write工具,否则不会创建文件
Tool Restrictions
工具限制
- Read: Used to inspect script source, references, and user configuration files
- Bash: Used to execute the three Python planning scripts (,
timestep_planner.py,output_schedule.py) with explicit argument listscheckpoint_planner.py - Write: Used to save generated time-step plans or checkpoint schedules; writes are scoped to the user's working directory
- Grep/Glob: Used to locate relevant files and search references
- 读取:用于检查脚本源码、参考资料和用户配置文件
- Bash:用于执行三个Python规划脚本(、
timestep_planner.py、output_schedule.py),并传入明确的参数列表checkpoint_planner.py - 写入:用于保存生成的时间步规划或检查点计划;写入范围限定在用户的工作目录
- Grep/Glob:用于定位相关文件并搜索参考资料
Safety Measures
安全措施
- No ,
eval(), or dynamic code generationexec() - All subprocess calls use explicit argument lists (no )
shell=True - Scripts use only Python standard library; no pickle loading or deserialization of untrusted data
- All output is deterministic JSON with no shell-interpretable content
- 不使用、
eval()或动态代码生成exec() - 所有子进程调用使用明确的参数列表(不使用)
shell=True - 脚本仅使用Python标准库;不加载pickle或反序列化不可信数据
- 所有输出为确定性JSON,无可被Shell解析的内容
Limitations
局限性
- Not adaptive control: Plans static schedules, not runtime adaptation
- Assumes constant physics: If parameters change, re-plan
- 非自适应控制:规划静态计划,而非运行时自适应调整
- 假设物理参数恒定:若参数变更,需重新规划
References
参考文献
- - Combining multiple stability limits
references/cfl_coupling.md - - Startup policies
references/ramping_strategies.md - - Cadence rules
references/output_checkpoint_guidelines.md
- - 组合多种稳定性限制
references/cfl_coupling.md - - 启动策略
references/ramping_strategies.md - - 节奏规则
references/output_checkpoint_guidelines.md
Version History
版本历史
- v1.2.2 (2026-06-24): Added Verification checklist and Common pitfalls & rationalizations sections grounded in the three planning scripts' actual outputs
- v1.2.0 (2026-06-23): Corrected overhead/frame-count docs and evals, removed output-time float drift, hardened input validation (checkpoint-cost < run-time, safety <= 1.0, bounded ramp/preview steps, finite checks)
- v1.1.0 (2024-12-24): Enhanced documentation, decision guidance, examples
- v1.0.0: Initial release with 3 planning scripts
- v1.2.2 (2026-06-24):新增验证清单和常见误区与合理化建议章节,内容基于三个规划脚本的实际输出
- v1.2.0 (2026-06-23):修正开销/帧计数文档和评估逻辑,消除输出时间浮点漂移,强化输入验证(检查点成本<运行时间、safety<=1.0、渐变/预览步数上限、有限值检查)
- v1.1.0 (2024-12-24):增强文档、决策指南和示例
- v1.0.0:初始版本,包含3个规划脚本