Sei sulla pagina 1di 50

Customiza*on

of LES turbulence model


in OpenFOAM

yotakagi77
Open CAE Local User Groups in Japan
@Kansai
June 13, 2015, Osaka University
Agenda
Basic informa*on on turbulence model
Tensor mathema*cs
Exercise 1: Compiling and execu*on of WALE
model
Exercise 2: Implementa*on of coherent
structure Smagorisky model
Addi*onal works
Basic informa*on on turbulence model

Turbulent ow simula*on
DNS LES RANS
Modeling No Subgrid scale Reynolds average
Accuracy
Cost

Vortex (eddy) eld Reynolds average 4


Turbulent ow simula*on
DNS LES RANS
Modeling No Subgrid scale Reynolds average
Accuracy
Cost

DNS grid, u Reynolds average 5


Turbulent ow simula*on
DNS LES RANS
Modeling No Subgrid scale Reynolds average
Accuracy
Cost

LES grid, u = u u Reynolds average 6


Turbulent ow simula*on
DNS LES RANS
Modeling No Subgrid scale Reynolds average
Accuracy
Cost

Filtering approach Reynolds average 7


Detached-eddy simula*on (DES)
P. R. Spalart (1997):
We name the new approach Detached-Eddy
Simula8on (DES) to emphasize its dis8nct treatments of
a?ached and separated regions.

Spalart (2001)

Super-Region Region
Euler (ER)
RANS (RR) Viscous (VR)
Outer (OR)
LES (LR) Viscous (VR)
Focus (FR)
Departure (DR) 8
Detached-eddy simula*on (DES)
P. R. Spalart (1997):
We name the new approach Detached-Eddy
Simula8on (DES) to emphasize its dis8nct treatments of
a?ached and separated regions.

Spalart (2001)

Super-Region Region
Euler (ER)
RANS (RR) Viscous (VR)
Outer (OR)
LES (LR) Viscous (VR)
Focus (FR)
Departure (DR) 9
Coupling with momentum equa*on
through viscosity
RANS
U
t ( (
+ (UU) ( + t ) U + (U)T )) = p
Turbulent viscosity

LES
U
t ( (
+ (UU) ( + SGS ) U + (U)T )) = p
Sub-grid scale viscosity

Only change viscosity!


10
Signicant problem:
dierence of ltering (average) approaches
LES Filtering Reynolds average

Spa*al Temporal

Inconsistency at the interface between LES and RANS regions


11
Standard SGS model in OpenFOAM

Library name Note


Smagorinksy Smagorinsky model
Smagorinksy2 Smagorinsky model with 3-D lter
homogeneousDynSmagor Homogeneous dynamic Smagorinsky model
insky
dynLagragian Lagrangian two equa*on eddy-viscosity model
scaleSimilarity Scale similarity model
mixedSmagorinsky Mixed Smagorinsky / scale similarity model
homogeneousDynOneEqE One Equa*on Eddy Viscosity Model for incompressible
ddy ows
laminar Simply returns laminar proper*es
kOmegaSSTSAS k- SST scale adap*ve simula*on (SAS) model
Standard SGS model in OpenFOAM

Library name Note


oneEqEddy k-equa*on eddy-viscosity model
dynOneEqEddy Dynamic k-equa*on eddy-viscosity model
spectEddyVisc Spectral eddy viscosity model
LRDDiStress LRR dieren*al stress model
DeardorDiStress Deardor dieren*al stress model
SpalartAllmaras Spalart-Allmaras model
SpalartAllmarasDDES Spalart-Allmaras delayed detached eddy simula*on
(DDES) model
SpalartAllmarasIDDES Spalart-Allmaras improved DDES (IDDES) model
vanDriestDelta Simple cube-root of cell volume delta used in
incompressible LES models
Tensor mathema*cs
Tensor
Rank 0: scalar, e.g. volume V, pressure p.
Rank 1: vector, e.g. velocity vector u, surface
vector S. Descrip*on: a = ai = (a1, a2, a3).
Rank 2: tensor, e.g. strain rate tensor Sij,
rota*on tensor ij.
Descrip*on: !T11 T12 T13 $
# &
T = Tij = #T21 T22 T23 &
#T T T &
" 31 32 33 %
Symmetric/an*symmetric tensor
Velocity gradient tensor is decomposed into
strain rate tensor (symmetric) and vor*city
tensor (an*symmetric, skew).
ui 1 " ui u j % 1 " ui u j %
Dij = , Sij = $$ + '', ij = $$ ''
x j 2 # x j xi & 2 # x j xi &

Dij = Sij + ij

In turbulence modeling, Sij and ij are usually


used.
Opera*ons exclusive to tensors of rank 2

1 T 1 T
T = (T + T ) + (T T ) = symm T + skewT,
2 2
tr T = T11 + T22 + T33,
diag T = (T11,T22 ,T33 ),
1 1
T = T (tr T)I + (tr T)I = dev T + hyd T,
3 3
T11 T12 T13
det T = T21 T22 T23
T31 T32 T33
OpenFOAM tensor classes
Opera2on Mathema2cal Class
Addi*on a + b a + b
Subtrac*on a b a b
Scalar mul*plica*on sa s * a
Scalar division a / s a / s
Outer product a b a * b
Inner product a b a & b
Double inner product a : b a && b
Cross product a b a ^ b
Square a2 sqr(a)
Magnitude squared |a|2 magSqr(a)
Magnitude |a| mag(a)
Power an pow(a, n)
OpenFOAM tensor classes
Opera2on Mathema2cal Class
Transpose TT T.T()
Diagonal diag T diag(T)
Trace tr T tr(T)
Deviatoric component dev T dev(T)
Symmetric component symm T symm(T)
Skew-symmetric skew T skew(T)
component
Determinant det T det(T)
Cofactors cof T cof(T)
Inverse inv T inv(T)
Exercise 1: Compiling and execu*on of
WALE model

Governing equa*on for incompressible LES

Filtered con*nuity and Navier-Stokes equa*ons


ui
= 0,
xi
ui ui 1 p
+ uj = + ( ij + 2 Sij )
t x j xi xi
where
ij = ui u j ui u j
SGS eddy viscosity model

Decomposi*on of kine*c energy


1 1 1
k = uk uk = uk uk + (uk uk uk uk )
2 2 2
kGS kSGS
Conserva*on of GS energy kGS
kGS kGS # pu j kGS &
+ uj = ij Sij GS + %% ui ij + ((
t x j xi $ x j '

Conserva*on of SGS energy kSGS


kSGS kSGS # 1 pu j pu j kSGS &
+ uj = ij Sij SGS + %ui ij (ui ui u j + u j ui ui ) + (
t x j xi %$ 2 x j ('
Smagorinsky model
Local equilibrium between SGS produc*on
rate and SGS energy dissipa*on:
$ u u u u '
SGS && i i i i )) = ij Sij
% x j u j x j x j (

Eddy viscosity approxima*on:


aij = 2v SGS Sij
Aper dimensional analysis and scaling,
SGS = (CS )2 | S |, | S |= 2Sij Sij , CS : Smagorinsky constant
WALE model
(Nicoud and Ducros, 1999)
Traceless symmetric part of the square of the
velocity gradient tensor:
1 1
Sijd = (Dij2 + D 2ji ) ij Dkk2
2 3
1
= Sik Skj + ik kj ij #$Smn Smn mnmn %&
3
1 2
Sijd Sijd = (S 2 S 2 + 22 ) + S 22 + 2IVS,
6 3
S 2 = Sij Sij , 2 = ij ij , IVS = Sik Skj jl li
Eddy viscosity of WALE model:
(Sijd Sijd )3 / 2
SGS = (Cw)2
(Sij Sij )5 / 2 + (Sijd Sijd )5 / 4
Model parameters of WALE model
(Nicoud and Ducros, 1999)
Field a Field b Field c Field d Field e Field f
Cw2/Cs2 10.81 10.52 10.84 10.55 10.70 11.27

If CS = 0.18, 0.55 CW 0.6.


If CS = 0.1, 0.32 CW 0.34.

Model parameter Cw is dependent on Smagorinsky


constant CS.
Source code of WALE model
V&V working group, Open CAE Society of Japan
hsps://github.com/opencae/VandV/tree/master/
OpenFOAM/2.2.x/src/libraries/incompressibleWALE

OpenFOAM-dev
hsps://github.com/OpenFOAM/OpenFOAM-dev/tree/
master/src/TurbulenceModels/turbulenceModels/LES/WALE


Download and compile

1. Download the source code of WALE model from the V&V


repository, and compile the WALE model library.
$ mkdir p $FOAM_RUN
$ cd
$ git clone https://github.com/opencae/VandV
$ cd VandV/OpenFOAM/OpenFOAM-BenchmarkTest/
channelReTau110
$ cp r src $FOAM_RUN/..
$ run
$ cd ../src/libraries/incompressibleWALE
$ wmake libso
$ ls $FOAM_USER_LIBBIN
Simula*on of channel ow
2. The standard tutorial case of channel ow at Re = 395:
copy the tutorial case le into your run directory.
$ run
$ cp r $FOAM_TUTORIALS/incompressible/pimpleFoam/
channel395/ ./ReTau395WALE
$ cd ReTau395WALE

3. Edit constant/LESProper*es and system/controlDict


$ gedit constant/LESProperties

LESModel WALE;
printCoeffs on;
delta cubeRootVol;
...
Simula*on of channel ow
$ gedit system/controlDict

...
libs ("libincompressibleWALE.so");

This line is necessary to call the new WALE library in solver.


4. Aper checking other numerical condi*ons and parameter,
run the solver.
$ ./Allrun

5. If the solver calcula*on is normally nished, you check the


logs and visualize the ow eld with ParaView, and plot the
elds prole generated by postChannel.
Simula*on of channel ow at Re = 110
6. If you use the test case of channel ow supplied in the V&V
repository, copy the template case and edit the seung.
$ run
$ cp r ~/VandV/OpenFOAM/OpenFOAM-BenchmarkTest/
channelReTau110/template $FOAM_RUN/ReTau110WALE
$ cd ReTau110WALE
$ gedit caseSettings

controlDict
{
deltaT 0.002;
endTime 0.022;
libs "libincompressibleWALE.so";
}
Simula*on of channel ow at Re = 110
turbulenceProperties
{
simulationType LESModel;
}

LESProperties
{
LESModel WALE;
delta cubeRootVol;
}

The original caseSeungs is for DNS simula*on on large parallel


machine. You had beser to change other parameters in
blockMeshDict and decomposeParDict.
Simula*on of channel ow at Re = 110
7. Aper checking other numerical condi*ons and parameter,
run the solver.
$ ./Allrun

8. If the solver calcula*on is normally nished, you check the


logs and visualize the ow eld with ParaView. If the
integra*on *me is not sucient for the ow eld to become
fully developed state, run longer simula*ons.
Exercise 2: Implementa*on of coherent
structure Smagorisky model
Original source codes for SGS model
1. Check the original source code for SGS model.
$ src
$ cd turbulenceModels/incompressible/LES/
$ ls
2. Glance the codes of Smagorinsky model.
$ gedit Smagorinsky/Smagorinsky.*

3. In this exercise, we look the codes of dynamic models.


$ ls *[Dd]yn*

4. Compare the structures and statements of the related codes


(*.C and *.H).
Private member func*ons:
updateSubGridScaleFields
In Smagorinsky.C
void Smagorinsky::updateSubGridScaleFields
(const volTensorField& gradU)
{ nuSgs_ = ck_*delta()*sqrt(k(gradU));
nuSgs_.correctBoundaryConditions(); }

In dynLagrangian.C
void dynLagrangian::updateSubGridScaleFields
(const tmp<volTensorField>& gradU)
{ nuSgs_ = (flm_/fmm_)*sqr(delta())*mag(dev(symm(gradU)));
nuSgs_.correctBoundaryConditions(); }

In dynOneEqEddy.C
void dynOneEqEddy::updateSubGridScaleFields
( const volSymmTensorField& D,
const volScalarField& KK )
{ nuSgs_ = ck(D, KK)*sqrt(k_)*delta();
nuSgs_.correctBoundaryConditions(); }
Understanding formula*on with codes

What calcula*on, mathema*cal opera*on, and variable are


necessary for coherent structure Smagosinsky model (CSM)?
Compare the formula*on of models with the related source
codes.
In CSM, the second invariant of velocity gradient is used:
1 1 u j ui
( )
Q = ij ij Sij Sij =
2 2 xi x j

where

1 # ui u j & 1 # ui u j &
Sij = %% + ((, ij = %% ((
2 $ x j x i ' 2 $ x j x i '
Coherent structure Smagorinsky model for non-
rota*ng ow (NRCSM)
Smagorinsky model (SM) based on an eddy-viscosity,
aij = 2C2 | S | Sij
(aij = 2t Sij , t = C2 | S |)
The model parameter C is determined as follows:
C = C1 | FCS |3 / 2

with
1 Q
C1 = , FCS =
20 E
where 2
1 $
1 ui '
E = ( ij ij + Sij Sij )
= && ))
2 2 % x j (

NRCSM model is invalid for rota*ng ow.



Coherent structure Smagorinsky model (CSM)

Smagorinsky model (SM) based on an eddy-viscosity,


aij = 2C2 | S | Sij
(aij = 2t Sij , t = C2 | S |)
The model parameter C is determined as follows:
C = C2 | FCS |3 / 2 F

with
1 Q
C2 = , FCS = , F = 1 FCS
22 E
where 2
1 $
1 ui '
(
E = ij ij + Sij Sij ) = && ))
2 2 % x j (

Improved CSM model is valid for rota*ng ow.

Seung for making new library
1. Copy the source code of WALE model. Compile them.
$ run
$ cd ../src/libraries
$ cp -r incompressibleWALE/WALE/ ./NRCSM
$ cp r incompressibleWALE/Make ./NRCSM
$ cd NRCSM
$ rename WALE NRCSM *
$ rm r NRCSM.dep
$ rm rf Make/linux64Gcc47DPOpt
$ gedit Make/files

NRCSM.C
LIB = $(FOAM_USER_LIBBIN)/libNRCSM

$ sed i s/WALE/NRCSM/g NRCSM.C


$ sed i s/WALE/NRCSM/g NRCSM.H
Seung for making new library
$ wmake libso
$ ls $FOAM_USER_LIBBIN

If you nd the renamed and recompiled library (libNRCSM.so),


you are ready to make a new library for the NRCSM.

2.You can easily learn the codes for calcula*ng the Q and E
terms from the postProcessing u*li*es.
$ util
$ cd postProcessing/velocityField/Q
$ gedit Q.C &

There are two ways of calcula*ng Q, that is, with velocity
gradient tensor and with SS and terms.
Introducing model coecient C1
3. Replace all cw with c1 (gedit or sed), and change the value
to 0.05.
$ run
$ cd ../src/libraries/NRCSM/
$ gedit NRCSM.C NRCSM.H
NRCSM.C
c1_
(
dimensioned<scalar>::lookupOrAddToDict
(
"c1",
coeffDict_,
0.05
)
)

$ wmake libso
Q and E calcula*ons
4. In NRCSM.C, insert the calcula*on of Q and E. Copy&Paste
the corresponding sec*on from Q.C. Save and Compile them.
$ gedit NRCSM.C
NRCSM.C
volScalarField Q
(
0.5*(sqr(tr(gradU)) - tr(((gradU)&(gradU))))
);
volScalarField E
(
0.5*(gradU && gradU)
);

$ wmake libso
FCS and C calcula*ons
5. In NRCSM.C, insert the calcula*on of FCS and C (coecient
of eddy viscosity model). Save and Compile them.
$ gedit NRCSM.C
NRCSM.C
volScalarField Fcs
(
Q/
max(E,dimensionedScalar("SMALL",E.dimensions(),SMALL))
);
volScalarField ccsm_
(
c1_*pow(mag(Fcs),1.5)
);

$ wmake libso
SGS calcula*on
6. In NRCSM.C, modify the nuSGS_ calcula*on. Look the other
updateSubGridScaleFields func*ons in the dynamic models.
$ gedit NRCSM.C
NRCSM.C
nuSgs_ = ccsm_*sqr(delta())*mag(dev(symm(gradU)));

Save and compile them.


$ wmake libso

7. Finally, comment out or delete unnecessary statements (the


calcula*ons for WALE model). Save and compile them.
$ wmake libso
kSGS calcula*on
8. The calcula*on of kSGS is invalid, but the value of kSGS is not
actually used in LES with NRCSM model. If you requires a
proper kSGS, consult the paper of Kobayashi (PoF, 2005).
NRCSM.H
//- Return SGS kinetic energy
// calculated from the given velocity gradient
tmp<volScalarField> k(const tmp<volTensorField>& gradU) const
{
return (2.0*c1_/ce_)*sqr(delta())*magSqr(dev(symm(gradU)));
}
Valida*on with channel ow
9. The standard tutorial case of channel ow at Re = 395:
copy the tutorial case le into your run directory.
$ run
$ cp r $FOAM_TUTORIALS/incompressible/pimpleFoam/
channel395/ ./ReTau395NRCSM
$ cd ReTau395NRCSM

10.Edit constant/LESProper*es and system/controlDict


$ gedit constant/LESProperties

LESModel NRCSM;
printCoeffs on;
delta cubeRootVol;
...
Valida*on with channel ow
$ gedit system/controlDict

...
libs ("libNRCSM.so");

This line is necessary to call the new NRCSM library in solver.


11.Aper checking other numerical condi*ons and parameter,
run the solver.
$ ./Allrun

12.If the solver calcula*on is normally nished, you check the


logs and visualize the ow eld with ParaView, and plot the
elds prole generated by postChannel.
Addi*onal works
1. Compile and test the WALE model supplied from
openfoam-dev. Prepare a Make directory by
yourself.
2. Implementa*on of CSM model. Add F term and C2
coecient.
3. Calcula*on of Q and E terms with SS and terms.
Compare the results with the solu*on of Exercise 2.
4. Valida*on of customized model with other ow
elds such pipe, backstep, cylinder, and rota*ng
ow.
References
OpenFOAM User Guide
OpenFOAM Programmers Guide
, , (2014).
P. R. Spalart et al., Comments on the Feasibility of LES for
Wings, and on a Hybrid RANS/LES Approach, 1st ASOSR
CONFERENCE on DNS/LES (1997).
P. R. Spalart, Young-Persons Guide to Detached-Eddy
Simula*on Grids, NASA CR-2001-211032 (2001).
F. Nicoud and F. Ducros, Subgrid-scale modelling based on
the square of velocity gradient tensor, Flow, Turbulence and
Combus*on, 62, pp.183-200 (1999).
References
,
, , 29, pp.157-160 (2010).
H. Kobayashi, The subgrid-scale models based on coherent
structures for rota*ng homogeneous turbulence and
turbulent channel ow, Phys. Fluids, 17, 045104 (2005).
H. Kobayashi, F. Ham and X. Wu, Applica*on of a local SGS
model based on coherent structures to complex geometries,
Int. J. Heat Fluid Flow, 29, pp.640-653 (2008).

Potrebbero piacerti anche