LargeEddy Simulation & DetachedEddy Simulations and
Machine Learning using a Python CFD code
The traditional method for CFD in industry and universities is ReynoldsAveraged NavierStokes (RANS). It is a fast method and
mostly rather accurate. However, in flows involving large separation regions, wakes and transition it is inaccurate. The reason
is that all turbulence is modeled with a turbulence model. For predicting aeroacoustic, RANS is even more unreliable.
For these flow, LargeEddy Simulation (LES) and DetachedEddy Simulations (DES) is a suitable option although it is much more
expensive. Still, in many industries (automotive, aerospace, gas turbines, nuclear reactors, wind power) DES is used as an alternative to RANS.
In universities, extensive research has been carried out during the last decade(s) on LES and DES.
Unfortunately, most engineers and many researchers have limited knowledge of what a LES/DES CFD code is doing. The object of this
online course is to close that knowledge gap. During the course, the participants will learn and work with an inhouse LES/DES code called
pyCALCLES, written by the
lecturer. It is a finite volume CFD code written in Python.
The numerical procedure is based on an implicit, fractional step technique with pyamg [17] 
an AMG multigrid pressure Poisson solver  and a nonstaggered grid arrangement. If your computer has a compatible Nvidia
graphics card, you can choose so solve the on the graphics card using pyamgx [17]
The last day of the course will be dedicated to Machine Learning. Support Vector Regression, SVR (available in Python), will
be used for developing new wall functions [20,21] and optimizing coefficient in
turbulence models. In the workshop the participants
will be guided on how to use the Python package SVR.
The Python CFD code is fully vectorized.
It is reasonably fast. Below I list some of the flows that have been computed using pyCALCLES (see some figures below):
 Windtunnel flow with a noise reducing fairing, U_{in}=16m/s (air). LES, WALE model. Domain 1X0.25X0.25 m^{3}.
7500 timesteps (3 750 to reach fullydeveloped conditions
+ 3 750 for timeaveraging). Mesh 256x200x200 (10M cells).
The computation time (pressure equation is solved on the GPU) on an Alienware x17 R1 laptop is 40 hours.
 Channel flow. x^{+}=65, z^{+}=16 (domain 6.4 x 2 1.6). LES (Re_{τ}=2000) using a 196x196x196 mesh. 7 500 timesteps (3 750 to reach fullydeveloped conditions
+ 3 750 for timeaveraging). The solution time (both the pressure and the momentum equations are solved on the GPU) on a PC with a
graphics card with large 16 GB memory is 21 hours (more than four times faster than on the CPU).
 Channel flow. x^{+}=17, z^{+}=8. DNS (Re_{τ}=500) using a 96x96x96 mesh. 20 000 timesteps (10 000 to reach fullydeveloped conditions
+ 10 000 for timeaveraging). The CPU time on a PC is 11 hours. It's more than twice as fast when solving all equations on the GPU.
 Channel flow. DES ((Re_{τ}=5200) with a komegaDES model using a 32x96x32 mesh.
15000 timestep (7 500 + 7 500). The CPU time is 1.1 hours on an Alienware x17 R1 laptop.
 Periodic hill flow. DES (Re=10500) wtth a komegaDES model using a 160x80x32 mesh. 20000 timestep (10000 + 10000).
The CPU time on a PC is 8 hours.
 Channel flow with inlet and oulet. Δx^{+}=40, Δz^{+}=20. LES (Re_{τ}=395)
using a 96x96x32 mesh. 20 000 timesteps (10 000 to reach fullydeveloped conditions
+ 10 000 for timeaveraging). Anisotropic synthetic fluctuations [7,9] are prescribed at the inlet. The
WALE model is used. The CPU time on a PC is 8 hours
 Flatplate boundary layer. Δx^{+}=104, Δz^{+}=30. Re_{θ,inlet;}=2 400.
keps IDDES using a 700x105x128 mesh.
3 750 timesteps (3 750 to reach fullydeveloped condition
+ 3 750 for timeaveraging). Anisotropic synthetic fluctuations are prescribed at the inlet.
The efficient AMGX sparsematrix solver (pyamgx) is employed for all variables using the GPU.
The CPU time on a PC is 62 hours
 Channel flow with inlet and oulet. x^{+}=400, z^{+}=200. LES (Re_{τ}=5200)
using a 96x96x32 mesh. 15 000 timesteps (7500 to reach fullydeveloped conditions
+ 7500 for timeaveraging). Anisotropic synthetic fluctuations [7,9] are prescribed at the inlet. The
komega DES model is used. The CPU time on a PC is 13 hours
 Hump flow using a 582x128x32 mesh. Re=9.36E+5. 7 500 timesteps (3 750 to reach fullydeveloped conditions
+ 3 750 for timeaveraging). Anisotropic synthetic fluctuations [7,9] are prescribed at the inlet. The
komega DES model is used. The CPU time on a PC is 39 hours (pressure is solved on the GPU)
 CouettePoiseuille flow. x^{+}=14, z^{+}=7. DNS (Re_{ΔU2h}=40000)
using a 288x240x288 mesh. 15 000 timesteps (7500 to reach fullydeveloped conditions
+ 7500 for timeaveraging). All eqyations are solved on the GPU (GeForce RTX 3090).
The CPU time on a PC is 63 hours
THE ONLINE COURSE
The course includes lectures (12 hours) and workshops (12 hours) learning and using pyCALCLES. The
course is given 3, 5, 7 July 2023.
The lectures will be given online (Live) using Zoom. During the workshops, the participants will get
supervision in a joint Zoom room which will enable participants to learn from each others questions. Part of the supervision
may also be given in individual breakout Zoom rooms.
Zoom
In the lectures we will address:
 finite volume discretization
 Smagorinsky model
 WALE model
 the keps DES model
 twoequation PANS model (k and epsilon)
 wall and periodic boundary conditions
 how to prescribe turbulent inlet boundary conditions
 how to generate inlet anisotropic synthetic turbulent fluctuations
 Machine Learning
 Use Support Vector Regression (SVR) for improving wall functions [20,21] and turbulence models
 Import the developed SVR model into pyCALCLES
 Carry out simulations with pyCALCLES using the improved models
In the workshops, the participants will use pyCALCLES.
The participants will get the pyCALCLES source CFD code and install it on their laptop or desktop.
The following Python packages are used
 Python 3.8
 from scipy import sparse
 import numpy as np
 import pyamg
from scipy.sparse import spdiags,linalg
Some results are shown below obtained with pyCALCLES.
 DNS at Re_{τ} = 500 of fully developed channel flow.
Periodic boundary conditions in streamwise and
spanwise directions.
Instantaneous w' fluctuations at y^{+}=9
 komega DES of the hill flow. Periodic boundary conditions in streamwise and
spanwise directions.
Instantaneous spanwise fluctuation
 komega DES of the channel flow at Re_{τ} = 5200.
Periodic boundary conditions in streamwise and
spanwise directions.
Resolved (blue) and modeled (red) shear stresses compared with DNS (markers)
 WALE Channel flow with inletoutlet Re_{τ} = 395. Periodic boundary conditions in
spanwise direction.
Predicted friction velocity vs. x. Target value is one
Shear stresses compared with fully developed DES and inlet synthetic fluctuations (markers)
 komega DES Channel flow with inletoutlet Re_{τ} = 5200. Periodic boundary conditions in
spanwise direction.
Predicted friction velocity vs. x. Target value is one
Shear stresses compared with DNS and synthetic inlet fluctuations (markers)
 Flatplate boundary layer. Δx^{+}=40, Δz^{+}=104. LES (Re_{θ,inlet;}=2 400)
Predicted skin friction vs. Re_{θ}. Markers: expts
Shear stresses compared with DNS and inlet synthetic fluctuations (markers)
 Hump flow, Re=9.36E+5)
The grid (every 8th grid line is shown)
Predicted skin friction. Markers: expts
 CouettePoiseuille flow, DNS (Re_{ΔU2h}=40000)
Velocity
OBJECT
The object is that the participants should learn how a CFD code for LES/DES works. It will give them
increased knowledge, confidence and knowhow when using commercial CFD codes.
PARTiCiPANTS
The participants are expected to hold a MSC degree or PhD degree related to fluid mechanics. They are expected
to have at least a basic knowledge in LES and DES. Programming skills in Pythons is recommended.
The course is expected to be valuable also for researchers
with extensive knowledge in LES and/or DES. The participants may continue to use pyCALCLES
after the course, in their daily work and/or research.
Participant who are reasonable good at programming can rather easy convert the Python CFD code to their favorite
language (C, C++, Fortan95).
LECTURER
The lecturer at the course (both during lectures and workshops) will be Prof. Lars Davidson,
Chalmers University of Technology.
homepage
COURSE MATERiAL
COURSE LANGUAGE
The course material is in English and the lectures will be given in English.
DATE & LOCATiON
The course will be held 3, 5, 7 July 2023 online at Zoom
Zoom
REGiSTRATiON
Registration form should be submitted no later than June 9, 2023.
The price is 16,300 SEK (excl. VAT). No refunding after June 9.
The number of participants is limited to 16.
registration form
PROGRAM
DAY 1, Monday, 7 hours, 11.0019.00, Swedish time
 General structure of pyCALCLES
 Discretization in pyCALCLES
 Compute geometrical quantities
 Studying Test Case 1 (channel flow)
 Studying Test Case 2 (atmospheric boundary layer)
 WORKSHOP
 Fullydeveloped channel flow simulations using PANS
 Channel flow simulations with inletoutlet using PANS
 Investigation of different synthetic fluctuating inlet fluctuations. For example, change the prescribed
integral length scale, the integral time scale, the anisotropy ...
Tueday (no teaching). Participants can work on pyCALCLES
DAY 2, Wednesday, 7 hours, 11.0019.00, Swedish time
 Implicit RhieChow interpolation in pyCALCLES
 TDMA solver
 Implementation of Zero equation models
 Implementation of the PANS model in pyCALCLES
 Studying Test Case 3 (hill flow)
 WORKSHOP
 Implementing a oneequation hybrid LESRANS model
 Implementing a DES model (keps and/or komega)
 Implementing a DDES model (keps and/or komega)
Thursday (no teaching). Participants can work on pyCALCLES
DAY 3, Friday, 7 hours, 11.0019.00, Swedish time
 How to implement a new turbulence model in pyCALCLES
 How to generate anisotropic turbulent fluctuations in pyCALCLES
 How to write Machine Learning scripts in Python using SVR for improving wall functions
[20,21] and turbulence models
 How to export and import SVR models
 Precursor RANS (using a 1D solver written in Python)
as input to synthetic turbulence generator
 WORKSHOP, see Section workshop in
the report on pyCALCLES
 Implement an IDDES model (keps and/or komega)
 Implement the SAS model (komega)
 Write Machine Learning scripts in Python using SVR for improving wall functions [20,21] and
turbulence models
 Export SVR model; import them into pyCALCLES
 Make CFD simulations with pyCALCLES using MachineLearningimproved turbulence models
Above, we give examples on what turbulence models and Machine Learning rotuines
to implement in the workshops. Participants may of course propose
to implement other turbulence models and Machine Learning rotuines.
QUESTiONS & FURTHER iNFORMATiON
Please contact
 Lars Davidson
 tel. +46 (0) 730791 161
 Email: lada@flowsim.se, lada@chalmers.se
REFERENCES
 P. Emvin, The Full Multigrid Method Applied to Turbulent Flow in Ventilated
Enclosures Using Structured and Unstructured Grids. PhD thesis, Dept. of
Thermo and Fluid Dynamics, Chalmers University of Technology, Göteborg,
1997.
 L. Davidson, Large eddy simulations: how to evaluate resolution. International Journal of Heat and Fluid Flow, 30(5):10161025, 2009.
 L. Davidson, The PANS kε model in a zonal hybrid RANSLES formulation. International Journal of Heat and Fluid Flow, 46:112126, 2014.
 L. Davidson, Zonal PANS: evaluation of different treatments of the RANSLES interface. Journal of Turbulence, 17(3):274307, 2016.
 A. Altintas and L. Davidson, Direct numerical simulation analysis of spanwise oscillating lorentz force in turbulent channel flow at low Reynolds number. Acta Mechanica, pages 118, 2016.
 J. Ma, S.H. Peng, L. Davidson, and F. Wang, A low Reynolds number variant of PartiallyAveraged NavierStokes model for turbulence. International Journal of Heat and Fluid Flow, 32(3):652669, 2011.10.1016/j.ijheatfluidflow.2011.02.001.
 L. Davidson, Using isotropic synthetic fluctuations as inlet boundary conditions for unsteady simulations. Advances and Applications in Fluid Mechanics, 1(1):135, 2007.
 L. Davidson and S.H. Peng, Embedded largeeddy simulation using the partially averaged NavierStokes model. AIAA Journal, 51(5):10661079, 2013.
 L. Davidson, Twoequation hybrid RANSLES models: A novel way to treat k and ω at inlets and at embedded interfaces. Journal of Turbulence, 18(4):291315, 2017.
 B. Nebenfuhr, L. Davidson, LargeEddy Simulation Study of Thermally Stratified Canopy Flow, BoundaryLayer Meteorology, Vol. 156, number 2 , pp. 253276, 2015
 B. Nebenfuhr, L. Davidson, Prediction of windturbine fatigue loads in forest regions based on turbulent LES inflow fields, Volume 20, Issue 6 pp. 10031015, Wind Energy, 2017.
 L. Davidson and C. Friess,
The PANS and PITM model: a new formulation of f_k,
Proceedings of 12th International ERCOFTAC Symposium on Engineering Turbulence Modelling and Measurements (ETMM12), Montpelier,
France 2628 September, 2018
 L. Davidson, Zonal Detached Eddy Simulation coupled with steady RANS in the wall region,
ECCOMAS MSF 2019 Thematic Conference, 1820 September 2019, Sarajevo, BosniaHerzegovina
 L. Davidson, inlet boundary conditions.
 L. Davidson, "NonZonal Detached Eddy Simulation coupled with a steady RANS solver in the wall region",
ERCOFTAC Bullentin 120, Special Issue on Current trends in
RANSbased scaleresolving simulation methods, pp 4348, 2019.
 L.M. Olson abd J.B. Schroder, PyAMG: Algebraic Multigrid Solvers in Python v4.0,
Release 4.0, 2018

L. Davidson and Ch. Friess, "Detached Eddy Simulations: Analysis of a limit on the dissipation term for reducing spectral
energy transfer at cutoff",
ETMM13: The 13th International ERCOFTAC symposium on engineering, turbulence, modelling
Rhodes, Greece, 1517 September, 2021
View PDF file

L. Davidson
"Detached Eddy Simulation coupled with steady RANS in the wall region",
ETMM13: The 13th International ERCOFTAC symposium on engineering, turbulence, modelling
Rhodes, Greece, 1517 September, 2021
View PDF file

L. Davidson,
"NonZonal Detached Eddy Simulation coupled with a steady RANS solver in the wall region",
International Journal of Heat and Fluid Flow, Vol.92, 108880, 2021
Get article at publisher

L. Davidson
"Using Machine Learning for formulating new wall functions for Large Eddy Simulation: A First Attempt",
Div. of Fluid Dynamics, Mechanics and Maritime Sciences,
Chalmers University of Technology, 2022.
View PDF file

L. Davidson
"Using Machine Learning for formulating new wall functions for Large Eddy Simulation: A Second Attempt",
Div. of Fluid Dynamics, Mechanics and Maritime Sciences,
Chalmers University of Technology, 2022.
View PDF file

L. Davidson
"pyCALCLES: A Python Code for DNS, LES and Hybrid LESRANS"
Div. of Fluid Dynamics, Mechanics and Maritime Sciences,
Chalmers University of Technology, 2022.
view PDF file

L. Davidson
"Using Machine Learning for formulating new wall functions for Detached Eddy Simulation",
ERCOFTAC symposium on Engineering, Turbulence, Modelling and Measurements (ETMM14),
in MiniSymposium: Machine learning for turbulence, Barcelona, Spain 6th  8th September 2023;
Chalmers University of Technology, 2022.
View PDF file

L. Davidson
"Using Machine Learning for Improving a NonLinear keps Model: A First Attempt",
Div. of Fluid Dynamics, Mechanics and Maritime Sciences,
Chalmers University of Technology, 2023.
View PDF file
