---
title: "Tutorial: thermal stress in a constrained bar with solidDisplacementFoam"
url: "https://tryreynolds.com/docs/tutorials/thermal-stress"
description: "Heat a bar that cannot expand and compare its stress with the closed form under plane stress and plane strain. The ratio of the two is 1/(1-nu) and nothing else, which makes it the one number a solver cannot fit its way into."
---

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

OpenFOAM cases

# Thermal stress in a constrained bar

Heat a bar that cannot expand and compare its stress with the closed form under plane stress and plane strain. The ratio of the two is 1/(1-nu) and nothing else, which makes it the one number a solver cannot fit its way into.

A heated bar that cannot expand has an exact stress. You will solve it twice, in plane stress and in plane strain, and use the ratio between the two as the check.

**You will learn** to choose a plane state, why a ratio can be a stronger check than a value, and where a mesh error shows in a linear problem.

**You need** an OpenFOAM or the agent. The published study made eight solves in 5.5 s of solver time.

## The physics

A steel bar 0.04 m by 0.02 m is hot on one face by 100 K and held between two frictionless rigid walls. With `E = 2.0e11 Pa`, `alpha = 1.1e-5 /K` and `nu = 0.3`, and `T(y) = dT (1 - y/H)`:

| State | Axial stress | On the hot face |
|---|---|---|
| plane stress | `-E alpha T(y)` | -220.0000 MPa |
| plane strain | `-E alpha T(y) / (1 - nu)` | -314.2857 MPa |
| ratio | `1 / (1 - nu)` | 1.428571 |

The plane-stress value contains `E` and `alpha` only as their product and no `nu` at all, so it cannot tell a wrong `nu`. The ratio contains nothing else.

The bar's thermal e-folding time is 2.2834 s for this steel, and the case runs to 100 s, which is about 44 of them.

## Steps

### Build and solve

In an OpenFOAM shell ([the plane duct](https://tryreynolds.com/docs/tutorials/duct.md) has the Docker command):

```bash
mkdir -p /tmp/bar && cd /tmp/bar
python3 /src/openreynolds/toolbox/templates/thermal_stress.py
solidDisplacementFoam > log.solidDisplacementFoam
postProcess -func 'components(sigma)' -noZero
postProcess -func singleGraph -noZero
```

For plane strain, set `PLANE_STRESS = False` near the top of the template and repeat in a second directory.

### Grade it

```bash
python3 /src/benchmarks/thermal_stress/grade.py bar /tmp/bar
```

Every constant is read out of the case's own dictionaries, so it grades a bar you have edited as well. Exit status 0 means every check passed, 1 that one failed, 2 that the case could not be read.

### Or ask the agent

```
Solve a bar heated on one face and not allowed to expand. Compare the axial stress against the exact plane-stress and plane-strain values, and report the ratio of the two against its exact value.
```

## Read the result

Recorded by the repository's own CI run of the template:

| Quantity | Exact | Measured |
|---|---|---|
| axial stress against `-E alpha T` at the solver's own T, plane stress | 0 | RMS 0.094% of the peak, max 0.300% |
| the same, plane strain | 0 | RMS 0.162%, max 0.556% |
| hot face, extrapolated | -220.0000 and -314.2857 MPa | -220.2858 and -314.6932 MPa, +0.130% both |
| ratio | 1.428571 | 1.429471, +0.063% |

The [published study](https://tryreynolds.com/studies/constrained-bar-thermal-stress.md) used a structured mesh, found 1.4285714, and fitted the ratio through the thickness as 1.42709, 1.42817, 1.42847 and 1.42855 on 10, 20, 40 and 80 cells, with the error shrinking about four times per halving.

![The published run. Left: axial stress through the bar for both plane states, solver points on the exact lines. Right: their ratio through the thickness for 10 to 80 cells across, against 1.42857.](https://tryreynolds.com/assets/bar-stress-thickness-C8SRq_uH.png)

The published run. Left: axial stress through the bar for both plane states, solver points on the exact lines. Right: their ratio through the thickness for 10 to 80 cells across, against 1.42857.

All of the remaining error is the mesh. A uniform `blockMesh` grid reproduces the peak to 0.00%. The template's recombined quads are mildly non-orthogonal and the displacement gradient on them is least squares.

Taking the ratio **point by point** fails in the cell beside the cold face: 1.516 on every mesh, because the stress there is about 2% of its peak and dividing two small numbers amplifies their errors. Fit the ratio over the profile.

## Check it

- **Temperature is linear in y.** It needs no knowledge of the mesh or the stress.
- **`sigma_yy` is zero** away from the boundary cells. What is left there halves with each refinement.
- **The two halves separately.** The grader compares stress with the solver's own temperature, so an unconverged conduction cannot hide an elasticity error.

## Try next

1. Change `nu` to 0.2 and predict the ratio before running.
2. Double `DELTA_T_K` and confirm both stresses double.
3. Change `BAR_HEIGHT_M`. The hot-face stress should not move.

## When it goes wrong

### The answer is 43% off

You compared plane stress with plane strain. That is exactly `1 / (1 - nu)` for this steel.

### The mesh is prisms

One published run found 1,600 prisms and added a structured setting. The stresses it found were exact on both meshes, so the plane state and the sampling are the first things to check, not this.

### The stress has not settled

Read the temperature residual. If the run was stopped before several e-folding times the profile is still curved, and the stress follows it.

## Next

[Hartmann flow](https://tryreynolds.com/docs/tutorials/hartmann.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.
