Skip to content

docs: add Newton-cooling calibration skill example (Modelica + brent)#66

Merged
yannrichet-asnr merged 1 commit into
mainfrom
docs/newton-cooling-skill-example
Jun 14, 2026
Merged

docs: add Newton-cooling calibration skill example (Modelica + brent)#66
yannrichet-asnr merged 1 commit into
mainfrom
docs/newton-cooling-skill-example

Conversation

@yannrichet-asnr

Copy link
Copy Markdown
Member

Adds the first worked fz skill example: an AI agent solving a real engineering inverse problem end to end by discovering two ready-made fz packages rather than building from scratch.

The example

skills/examples/newton-cooling-calibration.md — calibrate the cooling coefficient k of a Newton's-law-of-cooling model (dT/dt = -k·(T − T_env)) against a single measurement (T = 40 °C at t = 600 s), using:

  • fz install model modelica — the Modelica wrapper (OpenModelica forward simulation);
  • fz install algorithm brent — a 1-D root-finder for the calibration loop.

It leads with the one-shot natural-language ask, then walks the path the agent follows (discover wrappers → parameterize .mo → add a scalar output → verify the forward run → fzd + brent root-finding), with a checkable analytic outcome (k ≈ 0.002088 1/s).

Also adds a "Worked examples" pointer in skills/howto.md and lists code-wrapper.md there.

Validated end to end

Ran against OpenModelica 1.26.1 with the real installed packages: brent.R recovered k = 0.002088 (8 iterations, converged) — the exact analytic value. The doc reflects the verified reality, in particular:

  • the installed brent is brent.R, an R root-finder (options ytarget/ytol/xtol), so the objective is the raw residual T_final − 40, not a squared error;
  • the Modelica calculator is auto-discovered from the model id (no --calculators);
  • the wrapper's single res output flattens to res_<Model>_<col> trajectory arrays, so a scalar T_final output is added for the objective.

Depends on #65

Validating this example is what surfaced the fzd CLI bug fixed in #65. The CLI calibration step here requires that fix to run; #65 should merge first.

🤖 Generated with Claude Code

New skills/examples/ walkthrough showing the fz skill solving a one-parameter
engineering inverse problem end to end: an AI agent discovers the ready-made
Modelica wrapper (fz install model modelica) and the brent algorithm
(fz install algorithm brent) to calibrate the cooling coefficient k of a
Newton's-law-of-cooling model against a single temperature measurement.

Leads with the one-shot natural-language ask, then breaks down the path the
agent follows (discover wrappers -> parameterize .mo -> scalar output -> verify
forward run -> fzd+brent root-finding), with a checkable analytic outcome
(k ~ 0.002088 1/s).

Validated end to end against OpenModelica 1.26.1: brent.R recovers k = 0.002088.
Doc reflects the verified reality (brent is an R root-finder with ytarget/ytol/
xtol; calculator auto-discovery; the wrapper's res output flattens to
res_<Model>_<col> trajectory arrays, so a scalar T_final output is added).

Also add a "Worked examples" pointer and list code-wrapper.md in skills/howto.md.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings June 13, 2026 21:18

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds the first end-to-end “worked example” for the fz agent skill, showing how an agent can solve a simple inverse problem (Newton cooling coefficient calibration) by discovering and reusing existing fz wrappers/algorithms rather than building everything from scratch.

Changes:

  • Add a new worked example walkthrough: Newton’s-law-of-cooling calibration using the Modelica wrapper + brent.
  • Add a “Worked examples” section to the skill how-to, linking to the new example.
  • Update the “What’s in the skill” list to include code-wrapper.md and refine the algorithm-wrapper description.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
skills/howto.md Adds a “Worked examples” section and updates the skill contents list.
skills/examples/newton-cooling-calibration.md New detailed tutorial for Modelica forward simulation + fzd/brent calibration with a checkable analytic result.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +40 to +42
- **R with rpy2** — the installed `brent` algorithm is implemented in R (`brent.R`), so fz
evaluates it through rpy2; it also needs the R package `base64enc`. (`pip install rpy2`,
and an R install; fz auto-installs `base64enc` via its `#require` header on first use.)
Comment on lines +169 to +174
> Note the `fzd` CLI quirks: unlike `fzi`/`fzc`/`fzr` (which take `--input_path` and
> `--input_variables`), `fzd` names these `--input_dir`/`-i` and `--input_vars`/`-v`, and
> it has no `--format` flag — it prints a convergence summary and writes the design and
> final analysis under `results_fzd/` (override with `--results_dir`). `--input_dir`
> accepts a single input file as well as a directory. Like `fzr`, it auto-discovers the
> installed calculator, so no `--calculators` is required.
@yannrichet-asnr yannrichet-asnr merged commit 0e41d3a into main Jun 14, 2026
39 checks passed
@yannrichet-asnr yannrichet-asnr deleted the docs/newton-cooling-skill-example branch June 14, 2026 09:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants