---
title: "Tutorial: laminar plane duct flow in OpenFOAM from a template"
url: "https://tryreynolds.com/docs/tutorials/duct"
description: "Mesh, dress, solve and measure a plane duct with OpenFOAM from a single template, check it against the exact parabola and pressure gradient, and learn what one factor of two in the Reynolds number does."
---

**[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/tutorials/duct. It lives at https://tryreynolds.com/docs/tutorials/duct.md, and
[tryreynolds.com/llms.txt](https://tryreynolds.com/llms.txt) indexes every one of them.

OpenFOAM cases

# A plane duct in OpenFOAM

Mesh, dress, solve and measure a plane duct with OpenFOAM from a single template, check it against the exact parabola and pressure gradient, and learn what one factor of two in the Reynolds number does.

The first OpenFOAM case is the same parabola as [the channel](https://tryreynolds.com/docs/tutorials/poiseuille.md), but this time with a mesh, boundary conditions, a solver log and four independent readings of the wall shear.

**You will learn** the template route from a Python file to a solved case, the 2D recipe, and how to read a duct with the toolbox.

**You need** an OpenFOAM. In practice that is the workspace image, through the agent or in Docker. The mesh has 1,000 cells, so the solve is quick.

## The physics

A 0.10 m by 0.02 m duct with a uniform 1 m/s inlet develops a parabola. For `H = 0.02 m`:

| Quantity | Exact |
|---|---|
| peak over mean | 1.5 |
| kinematic pressure gradient | `-12 nu u_mean / H^2` = -120 m/s2 |
| wall shear over density | `6 nu u_mean / H` = 1.2 m2/s2 |

The Reynolds number is 10 on the **hydraulic diameter** `2H = 0.04 m`, so `nu = 1 * 0.04 / 10 = 4e-3 m2/s`. Using `H` in place of `2H` halves `nu` and moves every number above by a factor of two while the case looks entirely reasonable.

## Steps

### Open a shell with OpenFOAM in it

**Let the agent do it**

```
Copy duct2d.py from the toolbox templates into a new directory, run it, then dress the case with case_gen.py at 1 m/s and Re 10 on a length of 0.04 m. Solve with simpleFoam and compare the peak velocity, the pressure gradient and the wall shear with exact plane Poiseuille flow.
```

**In Docker**

```bash
git clone https://github.com/InviscidAI/OpenReynolds && cd OpenReynolds
docker run --rm -it -v "$PWD:/src" -w /src \
  -e LD_PRELOAD=/usr/local/lib/libfoamnotadmin.so \
  ghcr.io/inviscidai/reynolds-workspace:2512 bash -l
```

This is the invocation the repository's own CI uses. Inside it, OpenFOAM is sourced and your checkout is `/src`. The container is removed when you leave, so copy a case from `/tmp` to `/src` to keep it. Run the templates by their path in `/src` so they find `mesh_look.py` beside the toolbox.

### Build the mesh

```bash
mkdir -p /tmp/duct && cd /tmp/duct
python3 /src/openreynolds/toolbox/templates/duct2d.py
```

It meshes with gmsh, converts with `gmshToFoam`, retypes the walls and the `empty` faces, runs `checkMesh` and draws the result as `look.png`. The dictionaries it writes are stubs: enough for `checkMesh`, and meant to be overwritten.

### Dress and solve

```bash
python3 /src/openreynolds/toolbox/case_gen.py . --study steady \
  --speed 1 --reynolds 10 --length 0.04 --iterations 2000 --yplus --force
simpleFoam | tee log.simpleFoam
```

### Measure

```bash
python3 /src/openreynolds/toolbox/balance.py . --sections 0.01 0.09
python3 /src/openreynolds/toolbox/probe.py . --line 0.09 0 0.09 0.02 --field U --n 201
python3 /src/openreynolds/toolbox/wall.py .
python3 /src/openreynolds/toolbox/log_digest.py log.simpleFoam
```

## Read the result

These are the recorded readings from the repository's own journey test, which builds, solves and checks this case on every pull request. They are not a run made for this page.

| Quantity | Exact | Measured |
|---|---|---|
| peak of the sampled profile | 1.5 m/s | 1.4863, a per cent low because nodes average two cells |
| peak over mean of the same samples | 1.5 | 1.532 |
| pressure gradient, x = 0.06 to 0.09 m | -120 m/s2 | +2.9% |
| the solver's continuity error | 0 | -9.04e-08 against a 4e-05 m3/s throughflow |
| wall shear from four y+ sources | 1.2 m2/s2 | -9.7% and -8.7% from `yPlus`, +10.8% and +13.5% from `wallShearStress` |
| the two walls against each other | equal | 0.6% apart |

Ten cells across a half-height parabola is coarse, and it shows most at the wall. The four wall-shear readings bracket the exact answer, so the truth is inside the range rather than at one of them.

## Check it

- **Two walls must agree**, by symmetry. They are 0.6% apart.
- **The developed length.** Below `x = 0.06 m` the profile is still developing.
- **Refine.** Edit `CELL_SIZE_M` in a copy of the template and repeat the pressure gradient.

## Try next

1. Change `HEIGHT_M` and confirm `u_max / u_mean` stays at 1.5.
2. Run `--reynolds 2000` with a longer duct and read where the profile develops.
3. Feed the three meshes to [the convergence lesson](https://tryreynolds.com/docs/tutorials/mesh-convergence.md).

## When it goes wrong

### gmshToFoam is not on PATH

The shell has no OpenFOAM. The template says so, names what it has already written, and stops. Use the image or `openreynolds --local`.

### cannot find file system/controlDict

`gmshToFoam` builds a `Foam::Time` first. The template writes the stubs; run it in an empty directory.

### y+ from the prediction does not match y+ from the run

The cell size given to gmsh is a background size and not a count of divisions. The first measured run came out at 1.491 mm for a 2 mm request. Measure with `layer_report.py` or `wall.py`.

### Pressure and force look wrong by a factor of density

`simpleFoam` solves `p / rho` in m2/s2. Convert before comparing with a datasheet in pascals.

## Next

[The backward-facing step](https://tryreynolds.com/docs/tutorials/backward-facing-step.md).

## 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.
