investigation-loop
Pattern for iterative investigations (calibration, parameter sweeps, sensitivity, etc.) using record_attempt and write_report
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Pattern for iterative investigations (calibration, parameter sweeps, sensitivity, etc.) using record_attempt and write_report
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
High-level Fimbul workflow, geothermal case factories, and result inspection
High-level JutulDarcy workflow, example discovery, and result unpacking
High-level Mocca workflow for adsorption-based CO2 capture simulations
Persistent Julia REPL workflow and live runtime introspection for Jutul-based work
How to plot with plot_julia: native plotters, live windows, and seeing your own plots
Choose and customize BattMo cell parameter sets and cycling protocols
| name | investigation-loop |
| description | Pattern for iterative investigations (calibration, parameter sweeps, sensitivity, etc.) using record_attempt and write_report |
Use this when an investigation involves repeatedly running a simulation, tweaking inputs, observing how outputs change, and eventually summarising what happened. Examples: matching a model to data, parameter sweeps, sensitivity analyses, comparing approaches, hunting a regression.
record_attempt logs one step of the investigation to the session
trace — a rationale, optional metrics, optional plot path, and the
parent step's id when this is a branch or refinement. It returns a
status line ending in id=<uuid>; pass that as
parent_attempt_id next time so the trace builds a tree.write_report(narrative, output_path=...) writes a self-contained
HTML report at the given path. The narrative markdown is yours to
write; the rendered HTML also embeds the attempt tree, metrics, and
any plots referenced by record_attempt.Both are optional. Use them when they help, skip them when they don't.
Record every meaningful run as its own record_attempt — not one
combined entry at the end. The baseline is itself an attempt (the
"root"); every parameter change you actually evaluate is a child.
For a typical calibration this means:
record_attempt(rationale="baseline", metrics=..., plot_artifact_path=...)
→ keep its id as baseline_id.record_attempt(rationale=..., metrics=..., plot_artifact_path=..., parent_attempt_id=baseline_id).The report's "Exploration map" relies on this tree — collapsing every hypothesis into one final "summary" attempt loses it.
A single scalar (rmse, end-time, end-voltage) rarely tells the full story — a calibration that lowers RMSE can still look obviously wrong on the curve. Plot every attempt that you record. A good pattern:
slot argument so the file name is descriptive
(slot="baseline", slot="thinner_coating", …). Slots overwrite
on reuse, so a refined attempt can keep the same slot.A typical evaluation cycle:
include("candidate.jl")
t, y = run_candidate()
rmse = sqrt(mean((interp(obs.t, t, y) .- obs.y).^2))
plot_julia(
code="""
fig = Figure()
ax = Axis(fig[1, 1], xlabel="time (s)", ylabel="V")
lines!(ax, obs.t, obs.y, label="observed")
lines!(ax, baseline_t, baseline_y, label="baseline", linestyle=:dash)
lines!(ax, t, y, label="candidate")
axislegend(ax)
fig
""",
slot="thinner_coating", # → artifacts/thinner_coating.png
)
record_attempt(
rationale="reduce positive-electrode coating thickness by 0.5%",
metrics={"rmse_V": rmse, "t_end_s": t[end]},
plot_artifact_path="artifacts/thinner_coating.png", # match the slot
parent_attempt_id=baseline_id,
)
When you set slot="…" on plot_julia the artifact path is
artifacts/<slot>.<format>. Pass that exact string to
record_attempt(plot_artifact_path=…) — the report locates the file
relative to the session and embeds it next to the attempt's metrics.
Don't wait to be asked. The report degrades gracefully when a plot is missing, but it's much more useful when every attempt has one.
CSV, DataFrames, Statistics, and Interpolations are in
the simulator Julia env. The persistent REPL keeps loaded packages and
defined helpers across calls — define helpers once.