A diverging CFD run has a cause, and lowering under-relaxation rarely finds it. Work through seven checks in order, from units and boundaries to numerics.

DEEB-FLOW illustration of a velocity field in a spray-drying chamber
Concept illustration from the DEEB-FLOW case library. It is not a result from this article.

Why turning the solver down rarely finds the cause

Iteration 214. The residuals, which had been falling steadily, turn upward. By iteration 230 they have reached 10⁵, and the console prints a divergence warning, a floating point exception or, in OpenFOAM, a column of numbers ending in "nan".

The instinct is to open the solver controls and turn everything down. Lower the under-relaxation factors, halve the time step, run again. Sometimes that works. More often it delays the crash by a few hundred iterations and teaches you nothing.

A diverging CFD simulation is a symptom with a cause, and the cause is usually found faster by looking than by tuning. Below is the order I check things in. The cheap checks come first, and each one narrows the next.

1. Find where it started

Before changing any setting, find the cells where the solution first went wrong. Load the last data saved before the crash, or rerun with frequent saves. Look at the minimum and maximum of pressure, velocity, temperature and, for compressible flow, Mach number. A temperature of 5,000 K in an air duct or a velocity fifty times the inlet value sits in a specific place. Go and look at that place.

Most solvers can also report which cells have the largest residuals. Everything after this step is easier once you know whether the trouble is at an inlet, at an outlet, in a thin gap or inside a boundary layer.

2. Check units and scale

It sounds too simple, and it is the cause more often than people admit. A geometry drawn in millimetres and read as metres is a thousand times too large in every direction. Your 50 mm pipe is now 50 m across, the Reynolds number is a thousand times higher, and a mesh that was adequate is hopeless. Compare the domain extents the solver reports with what you expect.

While you are there, check the material properties and the operating pressure. Gauge and absolute pressure confused in a compressible case produce densities that are physically absurd.

3. Check the boundary conditions

Ask whether the problem you posed has a solution at all.

  • Mass conservation. A fixed velocity at every inlet and every outlet over-constrains an incompressible flow. At least one boundary has to let the pressure float.
  • Backflow at an outlet. If a recirculation zone crosses a pressure outlet, the solver has to invent the properties of the fluid coming back in. Move the outlet further downstream, or set sensible backflow values.
  • Inlet position. An inlet placed immediately upstream of a bend or a step forces a uniform profile where the real flow is far from uniform.
  • Conditions that match the model. A turbulent inlet with the turbulence intensity left at zero, or a supersonic inlet without a static pressure, will misbehave.

Reversed flow reported at an inlet is nearly always a setup error and deserves attention before anything else.

4. Look at the mesh where it failed

Now the mesh, and specifically the mesh at the location from step 1. Check skewness, orthogonality and aspect ratio. A few badly shaped cells in a thin gap or at a sharp trailing edge are enough, because highly skewed cells distort the fluxes between neighbours and feed oscillations into the solution. Check also for sudden jumps in cell size. If the divergence started in the worst cells of the mesh, repair the mesh there. A solver setting would only hide the problem.

A finer mesh can diverge where a coarse one ran. The coarse mesh was smearing a feature, such as vortex shedding or a shock, that the fine mesh resolves. That is information about the flow, and it usually means the case should be run as a transient.

5. Give it a better start

A solver starting from a uniform field at inlet velocity has a long way to go, and the first iterations are violent. Three things make the start gentler.

  • Use the solver’s own initialisation from a potential-flow or hybrid solution if it has one.
  • Start at a fraction of the flow rate, or at a lower pressure ratio for compressible flow, and ramp up.
  • Run a few hundred iterations with first-order discretisation, then switch to second order.

6. Add the physics in stages

If the case has heat transfer, species, combustion or more than one phase, avoid switching everything on at iteration one. Get the cold flow converged first. Then add energy, then species without reaction, then the reactions. Each step starts from a sensible field, and when something goes wrong you know which model caused it.

7. Now adjust the numerics

Only here do the solver controls come in, and by now you know what you are treating. For steady pressure-based solvers, lower the under-relaxation factors for pressure and momentum moderately. For coupled or density-based solvers, lower the Courant number. A pseudo-transient approach is often more stable than plain under-relaxation.

For transient runs, check the Courant number directly. It is the number of cells the flow crosses in one time step. Take cells of 0.5 mm in a jet at 40 m/s with a time step of 10⁻⁴ s.

CFL = u × Δt / Δx = 40 × 0.0001 / 0.0005 = 8

The fluid crosses eight cells per step. For an explicit scheme or a sharp free surface that is far too many. A time step of 1.25 × 10⁻⁵ s brings it to 1.

If the run only survives with very low relaxation or a tiny time step, go back to steps 1 to 4. The numerics are compensating for something.

Why the checks go in this order

Steps 1 to 3 take minutes and need no rerun. Step 4 may need a remesh, which is why you want the location first. Steps 5 to 7 change how the solver approaches the answer, which only helps if an answer exists. The usual order in practice is the reverse, with numerics first, mesh second and setup last, and that is how a two-hour problem becomes a two-day one.

Common mistakes

  • Turning relaxation down until it runs, then leaving it there. A heavily under-relaxed solution converges very slowly and can look finished when it is still changing.
  • Refining the whole mesh in response to a local problem. The cell count grows, and the badly shaped cells stay badly shaped.
  • Forbidding backflow at an outlet that is simply too close. The warning disappears and the error stays in the solution.
  • Ignoring warnings. Messages about reversed flow on hundreds of faces or limited turbulent viscosity in thousands of cells are the solver telling you where to look.

When it still will not run

Strip the case down. Remove models until it runs, then add them back one at a time. If a laminar, isothermal, single-phase version of your geometry diverges, the problem is in the mesh or the boundaries, and you have removed a great deal of noise from the search. If you have spent two days on it, show it to someone else, because a fresh pair of eyes often finds a millimetre and metre mix-up in minutes.

Sources & further reading

Related service

Model review & custom studies

Know what the model supports, where uncertainty remains and what needs checking.

Explore services
All articles