This is the project I’m working on. The issue is: Maximum number of iterations exceeded when calculating temperature from a thermodynamic potential. This may be caused by low-quality mesh producing unrealistic pressure in a few cells or inappropriate boundary conditions, fluid properties or time step. Inspect fields for large values in the last time step. However, I believe the mesh is fine and I know the B.C are quite extreme but this is just the physics of the system. Thank you in advance.
@marcocortecchia I copied your project and went through both setups. The solver is not failing on the mesh, and the boundary conditions are not “wrong” either. It is failing because the geometry is a converging-diverging nozzle with an area ratio of about 64, driven to a 170:1 pressure ratio, in a steady pressure-based solver. That is the one thing that solver cannot do, and no mesh fixes it.
What is in flusschoked: 50 mm pipe, converging cone to a 6.26 mm throat, diverging cone back to 50 mm over 25 mm, then a cone into a 160 mm duct that runs 44.8 m to the outlet at 1 atm. Hydrogen at 45 C, inlet total pressure ramped by table from 2 atm to 250 atm over 500 iterations, outlet 1 atm, 25.8 million cells (the mesh job itself restarted on out-of-memory). The run died at iteration 349, where the ramp was at about 175 atm.
Why it dies there (I read the solver log, not just the event log): once the throat chokes (above 1.9:1) the divergent cone takes the flow supersonic and a normal shock sits inside it. At 175:1 the flow ahead of that shock is around Mach 4, static temperature around 80 K, with a 17x pressure jump across the shock. SimScale’s Compressible analysis is pressure-based and their own people quote roughly Mach 0.8 as its comfortable limit. “Maximum number of iterations exceeded when calculating temperature” is just the iteration where the energy field went non-finite. The ramp was the right instinct, it only moves the crash to the ratio where the formulation gives up. The 25.8 million cells did nothing except make every iteration cost 8 seconds.
What you get without any CFD: with the throat choked, mass flow depends only on p0, T0 and the throat area:
mdot = Cd A* p0 sqrt(gamma / (R T0)) (2/(gamma+1))^((gamma+1)/(2(gamma-1)))
For hydrogen (gamma 1.405, R 4124 J/kg K) at 45 C through 6.26 mm that is 1.87 g/s per atm of total pressure, so about 470 g/s at 250 atm, times Cd (about 0.95 for a smooth convergent), and about 7 % less again for real-gas Z at 250 bar. Nothing downstream of the throat changes that number. The 160 mm duct carries it at Mach 0.2 with 4fL/D about 3, so it is nowhere near choking and sits at about 1.1 atm. The 45 m of duct contributes nothing to the answer and costs you the whole mesh.
Where CFD is actually needed, if at all: the shock position, the temperatures and the wall loads in the divergent cone and the first metre after it. That needs a density-based transient solver: OpenFOAM rhoCentralFoam on a 2D axisymmetric wedge from the pipe to about 1 m past the nozzle, a few hundred thousand cells, or SimScale’s Multi-purpose solver, which has a supersonic CD nozzle validation case but needs a paid plan. The steady Compressible type only works where the flow stays subsonic everywhere, and here it does not.
If you want to stay in the steady solver to measure a discharge coefficient: run the nozzle at just above critical, 2.2 atm total in and 1 atm out. Throat exit around Mach 1.1 with a weak shock, which it can hold. Put a “surface data, mass flow” result control on the inlet and the outlet. Neither of your simulations has any result control, so neither run gives you a number you can check. Cd is mdot_sim over mdot_formula, and it stays constant at these Reynolds numbers, so everything at 250 atm follows from the formula. Cut the domain about 1 m after the nozzle with the outlet at 1.1 atm, set the initial temperature to 45 C rather than 19.85, and half a million cells is plenty.
On the 4 mm case: 5 bar to 1.5 bar is also choked and also a C-D nozzle (0.48 mm throat, area ratio 69). It reached iteration 10,000 but it did not converge. In the last 109 iterations the pressure limiter clipped negative pressures (down to minus 6 bar) on 73 of them, the continuity error is sitting at 7 to 23 where a healthy run shows 1e-5, and the pressure residual is still at 1e-2. Reaching end time is not the same as a solution, and that run cost you 200 core hours. Same formula gives 0.054 g/s times Cd for that throat. Add the mass-flow result control and check against it.
For what it is worth, the actual OpenFOAM error behind the message you got is “Negative initial temperature T0” in the thermo T(h) call. The solver had been clamping pressures of minus 20 to minus 170 bar for at least 45 iterations before that. The crash is the end of a run that had already stopped being physical.