Download as pdf or txt
Download as pdf or txt
You are on page 1of 11

D

r
a
f
t
V
e
r
s
i
o
n
F
o
r
p
e
r
s
o
n
a
l
u
s
e
c

C
o
p
y
r
i
g
h
t
2
0
1
1
-
M

r
t
o
n
L
O
H

S
Z
Tutorial for Channel Flow by LES using Open
Source CFD
Mt Mrton Lohsz
February 2011
i
D
r
a
f
t
V
e
r
s
i
o
n
F
o
r
p
e
r
s
o
n
a
l
u
s
e
c

C
o
p
y
r
i
g
h
t
2
0
1
1
-
M

r
t
o
n
L
O
H

S
Z
CONTENTS ii
Contents
1 Overview 1
2 Set up your environment 1
3 Very short intro to OpenFOAM 1
3.1 Simulation set-up . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
3.1.1 Timestep directories . . . . . . . . . . . . . . . . . . . . . . 2
3.1.2 constant directory . . . . . . . . . . . . . . . . . . . . . . . . 2
4 Meshing 2
5 Physical parameters 2
6 Inlet condition 2
7 Model parameters 2
8 Numerical settings 3
9 Time step 3
10 Simulation of the temporal transition 3
11 Time averaging 4
12 Validation 6
13 Using the cluster 7
14 Content of the LESchannel package 9
D
r
a
f
t
V
e
r
s
i
o
n
F
o
r
p
e
r
s
o
n
a
l
u
s
e
c

C
o
p
y
r
i
g
h
t
2
0
1
1
-
M

r
t
o
n
L
O
H

S
Z
NOMENCLATURE 1
1 Overview
2 Set up your environment
Login to our small cluster.
ssh 152.66.21.39
If you login rst time, you have to answer some (3) questions by ENTER. Login to a
compute node using an interactive job.
qlogin -P LEScourse
Set up the OpenFOAM environmental variables
OF17
Create your working directory:
mkdir -p $FOAM_RUN
Go to your working (run) directory:
run
Check the path of your directory!
pwd
cd ..
Download the prepared case data.
wget http://www.ara.bme.hu/~lohasz/LEScourse/package_post.tar.gz
Extract the package.
tar -Pxvf package_post.tar.gz
3 Very short intro to OpenFOAM
Amuch better intro can be found on the webpage of the code: http://www.openfoam.
org. A course is given every autumn at Chalmers University: http://www.tfd.
chalmers.se/~hani/teaching.html.
OpenFOAM is a open-source environment for solving PDEs by nite volume tech-
niques. In many aspects is very similar to ANSYS-Fluent. The biggest difference is
that is only available for Linux, it is free to use, but it has no GUI. It is written in C++
(Fluent is written in C), so it is object oriented. In some cases the source code can be
consider as easy to read.
3.1 Simulation set-up
The simulation settings are not saved in some les as in Fluent but in a directory struc-
ture.
D
r
a
f
t
V
e
r
s
i
o
n
F
o
r
p
e
r
s
o
n
a
l
u
s
e
c

C
o
p
y
r
i
g
h
t
2
0
1
1
-
M

r
t
o
n
L
O
H

S
Z
4 MESHING 2
3.1.1 Timestep directories
The 0 directory contains the initial and the boundary conditions. The results of the
simulations are also saved in directories named after the actual time. For our case the
boundary conditions will be always the same there no further explanation is given.
3.1.2 constant directory
This directory contains important settings
4 Meshing
run
cd LESchannel
Modify the mesh if needed:
vi constant/polyMesh/blockMeshDict
Create the mesh
blockMesh
5 Physical parameters
Check the transport properties
vi constant/transportProperties
6 Inlet condition
Create the "turbulent" initial condition
perturbU
7 Model parameters
Edit the LES properties
vi constant/LESProperties
Check the SGS model
//LESModel Smagorinsky;
LESModel dynamicSmagorinsky;
The rst (Smagorinsky) is commented above.
Check the evaluation of the lter width:
delta dummy;
Since the use of dummy you will have an error message, where you will see the avail-
able options for delta. This can be used everywhere in OF. Set it to cubeRootVol.
D
r
a
f
t
V
e
r
s
i
o
n
F
o
r
p
e
r
s
o
n
a
l
u
s
e
c

C
o
p
y
r
i
g
h
t
2
0
1
1
-
M

r
t
o
n
L
O
H

S
Z
8 NUMERICAL SETTINGS 3
8 Numerical settings
Set the numerical parameters. Edit (check) the fvSchemes le.
Time advancement (similar to the second order of Fluent)
ddtSchemes
{
default backward;
}
Momentum convection scheme (corresponds to second order central scheme):
divSchemes
{
div(phi,U) Gauss linear;
}
The solution of the linearised equation system is set in fvSolution, also the param-
eters of the pressure-velocity coupling (PISO in our case) are dened here.
9 Time step
The timestep can be set in the controlDict le
vi system/controlDict
deltaT 0.2;
10 Simulation of the temporal transition
When simulating the temporal laminar-turbulent transition prior to a turbulent LES
simulation some quantities needs to be selected to be plotted during the simulation to
determine the required simulation time. Since the turbulent kinetic energy (TKE) has
specic temporal character during transition it is useful to plot it. But generally TKE
is difcult to plot since we are not in the position of the average velocities, i.e. the
uctuations can not be determined.
For the channel ow the average velocity in the span-wise and in the wall-normal
component is zero, i.e. the corresponding uctuations can be computed easily.
Set the endTime of your simulation for the time you expect transition. During this
time there will be no time averaging.
Set 500 for the present setting
vi system/controlDict
endTime 500;
Run the simulation (in this case interactively)
LMchannelFoam >> log &
Check the "tail" of the log le to see the progress of the simulation.
D
r
a
f
t
V
e
r
s
i
o
n
F
o
r
p
e
r
s
o
n
a
l
u
s
e
c

C
o
p
y
r
i
g
h
t
2
0
1
1
-
M

r
t
o
n
L
O
H

S
Z
11 TIME AVERAGING 4
tail -n20 log
Check if transition is nished. For this purpose post-process the log le.
foamLog log
cd logs
gnuplot
plot "volavUy2_0", "volavUz2_0"
exit
cd ..
Normally you should see
1
the peak in the two "components" of TKE and than the
uctuation around a value. If this is not the case continue the simulation as required.
The plotting (saving the gures in png format) can be done using the provided
script:
gnuplot trans.gnuplot
11 Time averaging
After the temporal transition you should carry out temporal simulation to determine
the statistical averages of the ow. In this case the streamwise velocity prole and the
proles of Reynolds stress tensor.
Modify the controDict to switch on the averaging.
functions
{
fieldAverage1
{
type fieldAverage;
functionObjectLibs ( "libfieldFunctionObjects.so" );
enabled false;
}
}
Insert some probes to see the temporal convergence of velocities and the Reynolds
stress tensor. The following function should be embedded to the functions section,
inside the curly brackets.
probes
{
type probes;
functionObjectLibs ("libsampling.so");
1
If you are not in a graphical session you can not plot obviously, download the les and plot it on your
local machine
D
r
a
f
t
V
e
r
s
i
o
n
F
o
r
p
e
r
s
o
n
a
l
u
s
e
c

C
o
p
y
r
i
g
h
t
2
0
1
1
-
M

r
t
o
n
L
O
H

S
Z
11 TIME AVERAGING 5
enabled true;
outputControl timeStep;
outputInterval 1;
probeLocations
(
( 1 1 1 )
( 2 1 1 )
( 1 0.1 1 )
);
fields
(
U
UPrime2Mean
UMean
);
}
Modify the endTime variable (in controlDict) to a higher value, i.e. 2000.
Continue the simulation
LMchannelFoam >>log &
Plot the convergence of your simulation
cd probes/AAAA
gnuplot
Here AAAA stand for the last time-step of your directory. You can list them by typing
ls
Use the following commands in gnuplot!
First plot the time signal of the wall normal velocity at the three different points.
plot "< tr ( < U" using 1:3 , "< tr ( < U" \
using 1:6 , "< tr ( < U" using 1:9
You can see which signal is at different y position, i.e. wall distance, since the uctua-
tion close to the wall is higher.
Now plot the time average (always until the actual plotted time instance) of these
velocities.
plot "< tr ( < UMean" using 1:3 , "< tr ( \
< UMean" using 1:6 , "< tr ( < UMean" using 1:9
It is also very important to plot the Reynolds stress components. The streamwise
uctuation square in the rst probe location, (1 1 1) in our example is plotted as follows:
plot "< tr ( < UPrime2Mean" using 1:2
The other locations can plotted by adding 6 to the last number:
D
r
a
f
t
V
e
r
s
i
o
n
F
o
r
p
e
r
s
o
n
a
l
u
s
e
c

C
o
p
y
r
i
g
h
t
2
0
1
1
-
M

r
t
o
n
L
O
H

S
Z
12 VALIDATION 6
plot "< tr ( < UPrime2Mean" using 1:2, "< tr ( \
< UPrime2Mean" using 1:8
If you plot also the third location, you will more clearly the importance of your
variation.
plot "< tr ( < UPrime2Mean" using 1:2, "< tr ( \
> < UPrime2Mean" using 1:8, "< tr ( < \
UPrime2Mean" using 1:14
The plotting (saving the gures in png format) can be done using the provided script
(you should edit the script if needed):
gnuplot conv.gnuplot
We should see in any case some type of convergence to an unknown (or known)
value. In some cases this value is known to be zero, which facilitates the judgement.
If you decide that your simulation is not converged enough, continue it!
12 Validation
The results can be validated by comparing them to know proles. Before doing this a
spatial averaging can be carried out to improve the condence of the statistical conver-
gence.
Carry out the spatial averaging and the extraction of the proles.
postChannel -latestTime
Enter the latest time-step directory
cd AAAA
gnuplot
Plot the Reynolds stress normal components.
plot "u.xy", "v.xy", "w.xy"
Plot the logarithmic velocity prole.
plot "Uf.xy"
set log x
plot "Uf.xy"
unset log x
The plotting (saving the gures in png format) can be done using the provided script
(you should edit the script if needed):
gnuplot valid.gnuplot
D
r
a
f
t
V
e
r
s
i
o
n
F
o
r
p
e
r
s
o
n
a
l
u
s
e
c

C
o
p
y
r
i
g
h
t
2
0
1
1
-
M

r
t
o
n
L
O
H

S
Z
13 USING THE CLUSTER 7
13 Using the cluster
For running a long simulation you have to divide your simulation in multiple parts. The
cluster management (queuing system) only allows a maximum 24 hours long simula-
tion time.
Your simulation is dived into at least two parts, rst the simulation of the transition.
We estimate the length of the transition to be 1000 sec, and we hope that it will be
possible to simulate it in a shorter time than 24 hours. During this part of the simulation
nighters the averaging nor the probes are enabled.
The second part of the simulation is the time averaging. We can not be sure that
this simulation is shorter than 24 hours, so we divide our simulation into some hours
(e.g. 3600 sec) of simulation, which will follow each-other, in this case we don not
specify the endTime of the simulation explicitly but save our date after e.g. 3600 sec of
simulation time.
The two steps described before can be efciently carried out when we comment out
the setting for the not used simulation in the controlDict le as shown below.
application LMchannelFoam;
startFrom latestTime;
startTime 0;
//stopAt endTime;
stopAt nextWrite;
endTime 1000;
deltaT 0.2;
//writeControl timeStep;
writeControl clockTime;
//writeInterval 200;
writeInterval 3600;
purgeWrite 3;
writeFormat binary;
writePrecision 6;
writeCompression compressed;
timeFormat general;
timePrecision 6;
runTimeModifiable yes;
The actual setting corresponds to the averaging.
D
r
a
f
t
V
e
r
s
i
o
n
F
o
r
p
e
r
s
o
n
a
l
u
s
e
c

C
o
p
y
r
i
g
h
t
2
0
1
1
-
M

r
t
o
n
L
O
H

S
Z
13 USING THE CLUSTER 8
You can do the simulation by typing the following command (you should be at the
simulation directory):
qsub LES.run
LES.run is is script le, which looks like:
#!/bin/bash
#$ -cwd
#$ -S /bin/bash
#$ -m aes
#$ -M hbamba@gmail.com
#$ -j y
#$ -P LEScourse
#$ -V
. /share/apps/usr/OpenFOAM/OpenFOAM-1.7.1/etc/bashrc
LMchannelFoam >> log
This le species that you want to run the command LMchannelFoam log. It
set up a email address where information will be sent. The previous line set up the
environmental variables needed by the code.
In the case you are running the averaging, you have to submit more jobs which
follow each-other after the previous one nished execution. This can be done easily:
[lohasz@kovasznayl LESchannel_DMS]$ qsub LES.run
Your job 1492 ("LES.run") has been submitted
[lohasz@kovasznayl LESchannel_DMS]$ qsub -hold_jid 1492 LES.run
Your job 1493 ("LES.run") has been submitted
[lohasz@kovasznayl LESchannel_DMS]$ qsub -hold_jid 1493 LES.run
Your job 1498 ("LES.run") has been submitted
In this case you specify the previous job by the -hold_jid AAA ag, where AAA is
job id of your previous job. So if your job nished the next one will start immediately.
You have to specify so many consecutive jobs, that you averaging time is enough, you
can also increase the length of the jobs by changing writeInterval 3600; to a higher
value below 82800.
D
r
a
f
t
V
e
r
s
i
o
n
F
o
r
p
e
r
s
o
n
a
l
u
s
e
c

C
o
p
y
r
i
g
h
t
2
0
1
1
-
M

r
t
o
n
L
O
H

S
Z
14 CONTENT OF THE LESCHANNEL PACKAGE 9
14 Content of the LESchannel package
~/.foamLog.db
$FOAM_RUN/LESchannel/
$FOAM_RUN/../src/

You might also like