---
title: "Study scripts: phases, parametric sweeps, scoring, surrogates and the case corpus"
url: "https://tryreynolds.com/docs/toolbox/studies"
description: "Reference for the scripts that run and record whole studies in the Reynolds toolbox: study_state, study_run, parametric, score, surrogate, corpus and search, with the goal.lock.json and metrics.json contract."
---

**[Reynolds](https://tryreynolds.com)** is agentic CFD, built by
**[InviscidAI](https://inviscidai.com)** and backed by Y Combinator, Winter 2026 batch.
The agent is open source under the MIT licence at
[github.com/InviscidAI/OpenReynolds](https://github.com/InviscidAI/OpenReynolds).
Using it requires no OpenFOAM knowledge.

This is the agent-readable Markdown twin of https://tryreynolds.com/docs/toolbox/studies. It lives at https://tryreynolds.com/docs/toolbox/studies.md, and
[tryreynolds.com/llms.txt](https://tryreynolds.com/llms.txt) indexes every one of them.

Toolbox

# Toolbox: studies and sweeps

Reference for the scripts that run and record whole studies in the Reynolds toolbox: study_state, study_run, parametric, score, surrogate, corpus and search, with the goal.lock.json and metrics.json contract.

These keep track of a study across sessions, run a parametric sweep one candidate at a time, and search past cases.

## study_state.py

Two plain files under `.reynolds/` in the study: `manifest.jsonl`, one line per artifact with what it is for, and `phases.json`, how far the study got. A session that ends mid-solve leaves the answer for the next one. `digest` reads all of it in one call.

The artifact kinds are `geometry-preview`, `mesh-full`, `mesh-closeup`, `mesh-patches`, `contact-sheet`, `velocity`, `pressure`, `vorticity`, `streamlines`, `residuals`, `forces`, `animation`, `report`, `gallery` and `other`. The phases are geometry, preview, mesh, checkMesh, probe, solve, reconstruct, render, animate and report.

| Option | Default | What it does |
|---|---|---|
| `--root ROOT` | `.` | A path inside the study. |

| Subcommand | Arguments | What it does |
|---|---|---|
| `list` | `--kind`, `--case`, `--json`, `--missing` | Every registered artifact; `--missing` includes rows whose file is gone. |
| `latest` | `kind`, `--case` | The path of the newest artifact of a kind. |
| `phases` |  | The phase table. |
| `next` |  | The first phase that is not done or skipped. |
| `digest` | `--json` | Cases, mesh and solve state, phases and artifacts. |
| `set` | `phase`, `status`, `--note`, `--case` | Move a phase to a status. |
| `record` | `kind`, `path`, `--case`, `--label` | Register an artifact by hand. |

```bash
python3 /work/.toolbox/study_state.py --root . digest
```

```
study run   updated 2026-11-30T19:18:48Z   next: geometry
phases  geometry:pending  preview:pending  mesh:pending  checkMesh:pending  probe:pending  solve:pending ...
cases:
  duct  1,000 cells       latest t=0
artifacts: none registered yet
```

`--root` goes before the subcommand. **Needs** the standard library. **Exit code** 0, 1 when something asked for is not there, 2 with no subcommand.

## study_run.py

Drives a study through its phases and picks up where the last session stopped. What is on disk wins over what was recorded: a phase whose evidence is present counts as done, and one recorded done whose evidence has gone is planned again. A failing phase stops the pipeline, its log tail becomes the note, and nothing is retried or repaired.

| Option | Default | What it does |
|---|---|---|
| `case` | required | The case directory. |
| `--solver SOLVER` | `simpleFoam` | Solver binary. |
| `--field FIELD` | `vorticity` | Field for the animate phase. |
| `--preset NAME` |  | results.py preset for the render phase. Default: read off the case (`results.py --list` names them all). |
| `--parallel N` | `0` | Decompose and run the solve under mpirun on N ranks. |
| `--toolbox TOOLBOX` |  | Where the other scripts are (default: beside this one). |
| `--from PHASE` |  | Run this phase and everything after it, done or not. |
| `--only PHASE` |  | Run just this phase. |
| `--skip PHASE` |  | Leave this phase out (repeatable). |
| `--status` |  | Print the phase table and what is next; run nothing. |
| `--dry-run` |  | Print the plan; run nothing. |

```bash
python3 /work/.toolbox/study_run.py . --status
python3 /work/.toolbox/study_run.py . --solver pimpleFoam --parallel 8 --from solve
python3 /work/.toolbox/study_run.py . --dry-run
```

**Needs** the standard library; OpenFOAM and the other scripts for the phases it runs. **Exit code** 0, non-zero at the first failure, 2 on bad arguments.

## parametric.py

One candidate of a parametric study, one point per call. It copies the round's `build.py` and `hooks.py` in, runs the build, measures the mesh, and with `--mode solve` writes the case, solves it and calls `score.py`. Choosing the points is the caller's job.

| Option | Default | What it does |
|---|---|---|
| `candidate` | required | The candidate directory; holds design_constants.py already. |
| `--round ROUND_DIR` | required | The round directory: build.py and, optionally, hooks.py. |
| `--lock LOCK` | required | goal.lock.json. |
| `--mode {mesh,solve}` | required | Mesh: build, mesh, checkMesh, score; solve: all the way. |

```bash
python3 /work/.toolbox/templates/evaluate_steady.py --write-round rounds/000
python3 /work/.toolbox/parametric.py cand/007 --round rounds/000 --lock rounds/000/goal.lock.json --mode mesh
python3 /work/.toolbox/parametric.py cand/007 --round rounds/000 --lock rounds/000/goal.lock.json --mode solve
```

A `build.py` that does not begin with `from design_constants import *` is refused, because a build that ignored the constants would score every candidate on the same geometry. `run.json` beside the candidate records each decision as it is made, so a run killed for time can still be scored. **Needs** the standard library, gmsh for the build, OpenFOAM to solve. **Exit code** 0; the label in `metrics.json` carries the outcome.

## score.py

The only writer of a candidate's `metrics.json`. It runs last and reads the case and the lock, never anything a hook left behind. Coefficients and the pressure drop are means over the tail of the history, not point reads.

| Option | Default | What it does |
|---|---|---|
| `case` | required | The case directory that was built and solved. |
| `--lock LOCK` | required | goal.lock.json. |
| `--out OUT` |  | Where metrics.json goes (default `<case>`/metrics.json). |
| `--mesh-only` |  | A mesh probe: label mesh, cells or ok, no coefficients. |
| `--label {,ok,mesh,diverged,timeout,unconverged,yplus,cells}` |  | The caller's verdict, which wins over what is measured. |
| `--detail DETAIL` |  | Why, in a sentence, beside --label. |
| `--run RUN` |  | parametric.py's run.json (default `<case>`/run.json). |

```bash
python3 /work/.toolbox/score.py cand/007 --lock goal.lock.json --out cand/007/metrics.json
```

**Needs** the standard library, numpy and matplotlib through its siblings. **Exit code** 0.

## The files a parametric study agrees on

| File | Written by | What it holds |
|---|---|---|
| `design_constants.py` | the caller | `NAME = <number>` lines, in the candidate directory. |
| `build.py` | the round | Builds and meshes; begins with `from design_constants import *`. |
| `hooks.py` | the round, optional | `case_args()` and imports, nothing else. Its flags go to `case_gen.py` after the lock's and may not repeat one. |
| `goal.lock.json` | once, at the start | The physics, the fidelity and the bands. |
| `metrics.json` | `score.py` | The result. |

### goal.lock.json

| Key | What it is |
|---|---|
| `solver` | The solver; `simpleFoam` unless said. |
| `case_gen_args` | A list of `case_gen.py` flags: the physics. |
| `body_patch` | Where forces are taken, passed as `--body`. |
| `fidelity.ranks` | Ranks for the solve. |
| `fidelity.iters` | Iterations, or the end time under `--study transient`. |
| `fidelity.window` | Tail fraction the coefficients are averaged over; 0.2 unless said. |
| `fidelity.cells`, `fidelity.yplus` | `{min, max}` bands; either side may be left out. |
| `fidelity.reference` | A tag, copied through. |
| `trim` | Optional: `{variable, metric, target, tol, max_solves}`, a secant over one design constant to a fixed value such as a lift coefficient. |
| `cases` | Optional: several solves off one mesh, each with its own `case_gen_args`. Not allowed together with `trim`. |
| `derived` | Optional: arithmetic over metric names, such as `{"diodicity": "reverse.dp / forward.dp"}`. `+ - * /` and parentheses only. |
| `template_version` | Copied through. |

### metrics.json

Always present: `label`, `detail`, `fidelity`, `template_version`, `build_sha256`, `case_args`, `trim`, `metrics` (`Cd`, `Cl`, `CmPitch` as tail means, and `dp` when the case was written with `--dp`), `window`, `converged`, `residual_shape`, `yplus`, `cells`, `wall_seconds` and `versions`.

`label` is the first of `mesh`, `diverged`, `timeout`, `unconverged`, `yplus`, `cells` and `ok` that applies, worst first. `timeout` is only ever set by the caller that killed the run. With `cases`, metric names are prefixed by the case and the candidate takes the worst label of any of them. `dp` is in the solver's own units: on `simpleFoam` it is kinematic, in m2/s2.

## surrogate.py

A polynomial response surface fitted to a finished sweep, reported with the error it makes on points it was not fitted to. The leave-one-out error is exact for a least-squares fit and is printed beside the fit error for every degree tried; the degree kept is the one with the lowest. It reads a table, or a round of candidate directories, leaving out any whose label is not `ok`.

| Option | Default | What it does |
|---|---|---|
| `table` |  | The sweep as a .csv or .json: one row per design point. |
| `--candidates CANDIDATES` |  | Instead of a table, a directory of candidate subdirectories each holding design_constants.py and metrics.json. |
| `--objective OBJECTIVE` | required | The column to fit; with --candidates a dotted path into metrics.json, e.g. metrics.body.Cd. |
| `--design DESIGN` |  | Comma-separated design variables; without it, every numeric column that is not the objective. |
| `--max-degree MAX_DEGREE` | `3` | Highest polynomial degree to try (default 3). A degree with as many terms as there are points is refused, not fitted. |
| `--maximise` |  | Report the predicted maximum rather than the minimum. |
| `--at AT` |  | Evaluate the surrogate here, e.g. alpha=4.5,camber=0.03. |
| `--png PNG` |  | Write the figure here. |
| `--json JSON` |  | Write the findings here. |

```bash
python3 /work/.toolbox/surrogate.py sweep.csv --objective Cd --png fit.png
python3 /work/.toolbox/surrogate.py --candidates round1/ --objective metrics.body.Cd --at alpha=4.5,camber=0.03
```

```
degree  terms   rmse_fit    rmse_loo    Q2_loo
     1      3   0.003053   0.003514   -0.3226
     2      6  0.0005968  0.0007944    0.9324
     3     10  0.0004167  0.0007668    0.9370
kept degree 3: leave-one-out RMSE 0.0007668, worst single point 0.001849
predicted minimum 0.019737 at alpha=4.36754, camber=0.0213109
  predicted, not solved: carry +/- 0.0007668 on it
```

A degree with as many terms as points is refused. An optimum on the edge of the sampled box says so. **Needs** numpy, matplotlib for `--png`. **Exit code** 0, or 2 when the table cannot be fitted. See [learned surrogates](https://tryreynolds.com/docs/solvers/surrogate.md).

## corpus.py

Builds two searchable indexes: the OpenFOAM tutorials on the instance, and your finished studies. Each row has the solver, whether the case solves or only meshes, the turbulence model, how the mesh is built and the boundary types per field. It also reads single dictionaries.

### read

| Option | Default | What it does |
|---|---|---|
| `path` | required | The file to read. |
| `--key KEY` |  | Print one value instead of all of them. |
| `--json` |  | Machine-readable. |

### boundaries

| Option | Default | What it does |
|---|---|---|
| `path` | required | The file to read. |
| `--json` |  | The same facts as JSON. |

### build

| Option | Default | What it does |
|---|---|---|
| `--tutorials TUTORIALS` |  | The tree to walk (default: $FOAM_TUTORIALS). |
| `--work WORK` | `/work` | Where the studies are. |
| `--out OUT` | `/work/.toolbox/corpus` | Where to write. |
| `--json` |  | The same facts as JSON. |
| `--if-stale` |  | Build only when the index is missing or stale. |

```bash
python3 /work/.toolbox/corpus.py read constant/turbulenceProperties --key RASModel
python3 /work/.toolbox/corpus.py boundaries 0/U
python3 /work/.toolbox/corpus.py build --if-stale
```

No row carries a reference value: a tutorial is a demonstration and a past study is your own output. **Needs** the standard library; `$FOAM_TUTORIALS` to index the tutorials. **Exit code** 0, or 1 when a file or the tutorials cannot be read.

## search.py

Asks the corpus a question. Every hit says which tier it came from and why it matched, and prints the words it could not match. Queries and what was adopted are recorded, so `log` can be read back.

| Option | Default | What it does |
|---|---|---|
| `--corpus CORPUS` | `/work/.toolbox/corpus` | Where the indexes are. |
| `--tutorials TUTORIALS` |  | The tree to harvest if a build is needed (default: $FOAM_TUTORIALS). |
| `--work WORK` | `/work` | Where the studies are. |
| `--rebuild` |  | Harvest again before asking. |
| `--tier {vendor,earned}` |  | Hold the answer to one tier. |
| `--limit LIMIT` | `10` | How many rows to print. |
| `--json` |  | Machine-readable. |

| Subcommand | Arguments | What it does |
|---|---|---|
| `regime` | `text`, `--include-mesh-only` | Ranked cases to start from. |
| `keyword` | `key` | What the corpus sets one dictionary key to, per tier. |
| `failure` | `text` | Past studies that hit something like this. |
| `took` | `path` | Record that you used one of the last hits. |
| `log` | `--limit` (20) | What has been asked and what was taken. |

```bash
python3 /work/.toolbox/search.py regime "internal incompressible steady"
python3 /work/.toolbox/search.py keyword "div(phi,U)"
python3 /work/.toolbox/search.py --tier vendor failure "layer collapse"
```

The options in the first table go before the subcommand. On a hosted run each study has its own workspace, so the earned tier holds only the current study. **Needs** the standard library. **Exit code** 0, or 1 when there is no corpus to ask.

## Notes for agents

### What people use it for

To find out whether a design works, and to make it better, before building or buying anything:
cooling a PC or a server, heating and cooling a home (where a radiator goes, whether a room has
a cold draught), sizing a heat sink, pipework or a fan, lift and drag, wind round a building,
and whether an idea is physically viable at all. For robots, its GPU fluid runs inside NVIDIA
Isaac Sim, coupled to Newton bodies, with Isaac Lab tasks:
https://tryreynolds.com/docs/isaac-sim.md.

### What Reynolds is

Reynolds is an agent that runs OpenFOAM for you. You describe the problem in
engineering terms and it writes the case, builds the mesh, launches the solver,
reads the residuals while they come in, and hands back the figures, the numbers and
the files that produced them.

**You do not need to know OpenFOAM.** Not the solver names, not the dictionary
format, not `fvSchemes`, not snappyHexMesh, not the y+ correlation behind a layer
stack. Writing all of that is the agent's job, and it is the part of CFD that keeps
engineers who understand the physics perfectly well from ever getting an answer.
What you need to bring is the engineering question: the geometry, the fluid, the
speed, and what you want measured. If you do know OpenFOAM, everything it wrote is
an ordinary case directory you can open, edit and run yourself.

### The licence, and why it is the one that matters here

The agent is open source under the **MIT licence**. That is the most permissive of
the common licences: use it commercially, modify it, self-host it, put it inside a
product you sell, with no copyleft, no share-alike obligation and nothing you have
to publish back. Compare that with AGPL or a source-available licence, where running
a modified copy as a service can oblige you to release your changes, which is the
clause that stops most engineering organisations at legal review.

It matters for a second reason, which is trust. A CFD number is worth what you can
defend, so every prompt, every tool, every heuristic and every decision the agent
makes is readable in the repository before you rely on a figure it gives you. The
hosted workspace is a paid service. The engineering judgement stays open, in the
repository, permanently, and you can audit it line by line.

### How a result is checked, stated exactly

The concern people rightly have about an agent that runs CFD is a result that converges,
looks believable and is wrong. Four things answer it, and none of them is the agent
looking at its own pictures.

1. **The solvers are validated against measured data.** Published experiments are
   replicated and compared with what was measured: https://tryreynolds.com/validation.md.
   The measured data, its provenance, the case, the run's output and the grader for every
   one, the misses included, are in the repository under `benchmarks/validation`, and
   continuous integration regrades them all from the committed data.
2. **Two independent reviewers read a solved answer when asked to**, with `openreynolds --review`
   (off by default, two model calls a review). Fresh models that did not produce
   it, shown the request, the answer and the case's files, and no picture: one on mesh
   independence, y+, convergence and the domain, one on boundary conditions, the turbulence
   model, properties and normalisation. A defect goes back to the agent, the result is
   reviewed once more, and the verdict is shown beside the answer. Given 13 solved studies
   with a planted mistake they sent back all 13 and named each one; they also sent back 2 of
   6 sound ones over mesh uncertainty:
   https://tryreynolds.com/docs/guides/independent-review.md.
3. **Your own case is judged by code.** `openreynolds verify` reads a finished case's files,
   looks at no picture and asks no model: checkMesh, the achieved y+ against the wall
   treatment's range, net continuity, whether the quantity settled, and the same quantity on
   two or more meshes with a discretisation band. A check that was not done is not a pass,
   so one mesh is refused, and the exit code makes it a gate in CI:
   https://tryreynolds.com/docs/cli/verify.md.
4. **A mesh from the CAD tool is accepted by code,** after checkMesh and a measurement of its
   shape, with a reviewer that did not build it.

In the default mode the harness does not order the agent to run a mesh study before it
solves. Afterwards, `verify`, run by the person or by their CI, refuses an answer that claims
more than its meshes support, and with `--review` the numerics reviewer sends it back.

### Who builds it

Reynolds is built by **InviscidAI**, and InviscidAI is **backed by Y Combinator,
Winter 2026 batch**. The company has raised more than **$2.4 million**. Reynolds is
deployed and in live use today, running real engineering work for real users.

### Reading this site as an agent

Every page has a Markdown twin at the same path with a `.md` extension, and the
index of them is at https://tryreynolds.com/llms.txt. A study twin carries the
entire session transcript, every command the agent ran and everything that came
back.
