Flow solvers¶
Once the machine geometry is generated, and the fluid domain discretised using a suitable mesh, the next step is to predict the flow field and hence aerodynamic performance using a computational fluid dynamics (CFD) solver.
turbigen is solver-agnostic: either the built in CFD solver or an interface to an external code can be used for flow field prediction; pre- and post-processing is done in common, native Python code. Adding a new external solver only requires implementing functions to save input files, execute the solver, and then read back the output file into turbigen’s internal data structures. See the Custom solvers section for more details.
Select which solver to use by setting the type key under the solver section of the configuration file. Valid choices are:
ember: Enhanced Multi-Block solvER
ts3: Turbostream 3
ts4: Turbostream 4
Each CFD solver accepts different configuration options. Solver options and their default values are listed below; override the defaults using the solver section of the configuration file. For example, to use the built-in ember solver, with a reduced damping factor:
solver:
type: ember
n_step: 1000 # Case-dependent
n_step_avg: 250 # Typically ~1/4 of n_step
damping_factor: 10. # Override default value of 25.0
Every solver accepts a soft_start flag, which runs a precursor simulation with more robust settings before running the actual simulation. Enabling this option should be the first step when a simulation fails to converge. If a design does not run with soft_start enabled, this suggests the mesh is poor quality, or the aerodynamic design itself is not feasible.
ember¶
ember is the ‘Enhanced MultiBlock flow solvER’ built into turbigen. It is a hybrid Python–Fortran reimplementation of the classic Denton [1992], Denton [2017] algorithms for compressible turbomachinery flows, with a few enhancements.
To use this solver, add the following to your configuration file:
solver:
type: emb
n_step: 2000 # Case-dependent
n_step_avg: 500 # Typically ~0.25 n_step
Configuration options¶
Name |
Type |
Default |
Description |
---|---|---|---|
|
|
|
Courant–Friedrichs–Lewy number, time step normalised by local wave speed and cell size. |
|
|
|
Relaxation factor for outlet boundary. |
|
|
|
Relaxation factor for inlet boundary. |
|
|
|
Relaxation factor for mixing plane. |
|
|
|
Turbulent Prandtl number. |
|
|
|
Force area-averaged outlet pressure to target, otherwise use uniform outlet pressure. |
|
|
|
Negative feedback to damp down high residuals. Smaller values are more stable. |
|
|
|
Factor scaling the multigrid residual. |
|
|
|
Viscous loss model. 0: inviscid, 1: viscous. |
|
|
|
Which time-stepping scheme to use. 0: scree, 1: super. |
|
|
|
Number of cells forming each multigrid level. (2, 2, 2) gives coarse cells of side length 2, 4, and 8 fine cells. |
|
|
|
Number of time steps between viscous force updates. |
|
|
|
Total number of time steps to run. |
|
|
|
Number of final time steps to average over. |
|
|
|
Number of time steps between updates of the local time step. |
|
|
|
Number of time steps between log prints. |
|
|
|
Number of time steps between mixing plane updates. |
|
|
|
Number of inital time steps to ramp smoothing and damping down. |
|
|
|
Number of steps to apply damping, -1 for all steps. |
|
|
|
Precision of the solver. 1: single, 2: double. |
|
|
|
Print convergence history in the log. |
|
|
|
Smoothing factor for uniform enthalpy and entropy downstream of mixing plane. |
|
|
|
Second-order smoothing factor, adaptive on pressure. |
|
|
|
Second-order smoothing factor, constant throughout the flow. |
|
|
|
Fourth-order smoothing factor. |
|
|
|
Largest directional reduction in smoothing on a non-isotropic grid. Unity disables directional scaling. |
|
|
|
Maximum mixing length as a fraction of row pitch. |
Turbostream 3¶
Turbostream 3 is a multi-block structured, GPU-accelerated Reynolds-averaged Navier–Stokes code developed by Brandvik and Pullan [2011].
To use this solver, add the following to your configuration file:
solver:
type: ts3
nstep: 10000 # Case-dependent
nstep_avg: 2500 # Typically ~0.25 nstep
Configuration options¶
Name |
Type |
Default |
Description |
---|---|---|---|
|
|
|
Mixing length characteristic dimension, “pitch” or “span”. |
|
|
|
Absolute tolerance on drift in isentropic efficiency. |
|
|
|
Courant–Friedrichs–Lewy number, reduce for more stability. |
|
|
|
Negative feedback factor, reduce for more stability. |
|
|
|
Setup environment shell script to be sourced before running. |
|
|
|
Fourth-order smoothing feedback factor, increase for more stability. |
|
|
|
Multigrid factor, reduce for more stability. |
|
|
|
Viscous model, 0 for inviscid, 1 for mixing-length, 2 for Spalart-Allmaras. |
|
|
|
At start of simulation, ramp smoothing and damping over this many time steps. |
|
|
|
Number of time steps. |
|
|
|
Average over the last nstep_avg steps of the calculation. |
|
|
|
Number of steps for soft start precursor simulation. |
|
|
|
Inlet relaxation factor, reduce for low-Mach flows. |
|
|
|
Mixing plane relaxation factor. |
|
|
|
Relative tolerance on mass flow conservation error and drift. |
|
|
|
Convert the configuration to a dictionary. |
|
|
|
Spalart–Allmaras turbulence model helicity correction. |
|
|
|
Proportion of second-order smoothing, increase for more stability. |
|
|
|
Initial guess of turbulent viscosity ratio. |
|
|
|
Mixing length limit as a fraction of characteristic dimension. |
Turbostream 4¶
Turbostream 4 is an unstructured, GPU-accelerated Reynolds-averaged Navier–Stokes code developed by Turbostream Ltd.
To use this solver, add the following to your configuration file:
solver:
type: ts4
nstep: 10000 # Case-dependent
nstep_avg: 2500 # Typically ~0.25 nstep
Real gas tables generation¶
For real gas simulations, working fluid property tables must be
pre-generated before the calculation. This can be done using the
turbigen.tables.make_tables()
function following the example script below:
from turbigen.tables import make_tables
fluid_name = "water" # Fluid name in CoolProp
smin = 7308.0 # Minimum entropy in J/kg/K
smax = 7600.0 # Maximum entropy in J/kg/K
Pmin = 37746.0 # Minimum pressure in Pa
Tmax = 550.0 # Maximum temperature in K
ni = 200 # Number of interpolation points in each direction
new_npz_path = "water_new.npz" # Path to save the new tables
make_tables(fluid_name, smin, smax, Pmin, Tmax, ni, new_npz_path)
The enthalpy and entropy datums are those used by CoolProp, so in general
This means that the correct numerical values for the entropy limits are not immediately obvious. turbigen will print out numerical values for the limits calculated from the nominal mean-line design. These should be, however, extended by some margin of safety. It is vital that the limits of the tables are wide enough to cover fluid property values over the entire flow field, including local features like the suction peak, shock waves and boundary layers.
Finally, in the configuration file, specify the path to the tables:
solver:
type: ts4
tables_path: water_new.npz
Some notes on real gas calculations:
The real gas working fluid is less stable than the ideal gas, so take care with mesh generation and avoid racy solver settings.
There is no handling of phase changes in the tables, so the fluid must remain a single phase for accurate results.
Of order 1000 points may be required in each direction to get discretisation-independent results.
Configuration options¶
Name |
Type |
Default |
Description |
---|---|---|---|
|
|
|
Allow non-uniform outlet pressure, force area-average to target. |
|
|
|
Courant–Friedrichs–Lewy number setting the time step. |
|
|
|
Ramp the CFL number up over this many initial time steps. |
|
|
|
Starting value for CFL ramp. |
|
|
`` `` |
Specify a custom pipeline to convert Turbostream 3 to 4 input file. Should run using pvpython and take two command-line arguments like pvpython custom_pipeline.py input_ts3.hdf5 input_ts4 |
|
|
|
Setup shell script to be sourced before running. |
|
|
|
1: implicit, 0: explicit time marching. |
|
|
|
Explicit with a slow CFL ramp. |
|
|
|
Number of time steps for the calculation. |
|
|
|
Number of final time steps to average over. |
|
|
|
Number of time steps for soft start. |
|
|
|
Number of steps to run a Turbostream 3 initial guess |
|
|
|
String to identify the outlet boundary condition in the TS4 input file. Only requires changing for custom pipelines. |
|
|
`` `` |
Path to gas tables npz for real working fluids. See Real gas tables generation. |
|
|
|
Turbulence model, 0: inviscid, 1: laminar, 2: Spalart-Allmaras, 3: k-omega. |
Custom solvers¶
To add a new solver, create a new Python module in the user-defined plugin
directory, say ./plug/my_solver.py and set plugdir: ./plug in the
configuration file. Write a new class that inherits from
turbigen.solvers.base.BaseSolver
and implement the following
methods:
run()
: Run the solver on the given grid and machine geometry.robust()
: Create a copy of the config with more robust settings.restart()
: Create a copy of the config with settings to restart from converged solution.
turbigen.solvers.base.BaseSolver
is a dataclass, so has an automatic constructor and
useful built-in methods. The configuration file solver section
is fed into the constructor as keyword arguments and becomes attributes of
the instance.