OpenFOAM-version-9/C3/Simulating-Natural-Convection-in-a-Cavity/English
Title of the script: Simulating Natural Convection in a Cavity
Author: Divyesh Variya
Keywords: OpenFOAM, ParaView, CFD, computational fluid dynamics, blockMesh, buoyancy driven flow, heat transfer, natural convection, buoyantSimpleFoam, thermophysical properties, FOSSEE, spoken tutorial, video tutorial.
Visual Cue | Narration |
Slide:
Opening Slide |
Welcome to the spoken tutorial on Simulating Natural Convection in a Cavity. |
Slide:
Learning Objective |
In this tutorial, we will learn to:
|
Slide:
System Specifications |
To record this tutorial, I am using,
However, you may use any other editor of your choice. |
Slide:
Prerequisites
|
As a prerequisite:
|
Slide:
Code Files |
|
Slide:
Natural Convection in a Cavity |
We will be solving a 2D flow in a square cavity.
|
Slide:
Natural Convection in a Cavity |
|
Slide:
Natural Convection in a Cavity |
|
Only Narration | Let’s simulate this problem in OpenFOAM. |
CTRL + ALT + T | Open the terminal by pressing Ctrl, Alt and T keys. |
[Terminal] Type:
cd $FOAM_RUN |
Type the following command and press Enter to move into the run directory. |
Only Narration | Please remember to press the Enter key after typing each command in the terminal. |
[Terminal] Type: cp -r ~/Downloads/cavityConvection . | Let’s copy the case folder that is downloaded and extracted into the run directory. |
[Terminal] Type:
cd cavityConvection |
Let’s change the directory to cavityConvection using the cd command. |
Slide:
Geometry |
In this simulation, we consider a square cavity with an edge length of 1 m. |
Slide:
Boundaries |
The computational domain has 4 boundaries, namely top, bottom, left, and right.
|
[Terminal] Type:
gedit system/blockMeshDict |
Type the following command to open the blockMeshDict file in a text editor. |
[gedit blockMeshDict]:
Only Narration |
We have a cubical geometry with a single block and four walls. |
[Terminal] Type:
Ctrl + Q |
Close this file by pressing Ctrl + Q |
Slide: Boundary Conditions | Let’s look at the boundary conditions in this simulation.
|
Slide:
Boundary Conditions |
The boundary conditions used in the simulation are as shown in the table. |
[Terminal] Type:
ls 0 |
The boundary conditions are defined in the 0 folder.
|
[Terminal] Highlight:
p p_rgh T U |
You will see two pressure files along with the temperature and the velocity files.
|
Slide:
p_rgh
Highlight >> p_rgh = p – rho*g*h
|
p_rgh = p - rho*g*h
|
[Terminal] Type: gedit 0/T | Let’s first open the temperature file, T. |
[gedit - T] Highlight:
internalField uniform 1 |
The domain is initialized with 1 K. |
[gedit - T] Highlight:
bottom boundary condition |
The bottom wall is maintained at a constant temperature of 1 K. |
[gedit - T] Highlight:
top boundary condition |
The top wall is maintained at a temperature of 0 K. |
[gedit - T] Highlight:
left & right boundary condition |
The left and right walls have zero gradient temperature boundary condition. |
[gedit - T] Close the window | Close the temperature file. |
[Terminal] Type: gedit 0/p_rgh | Let’s open the p_rgh file. |
[gedit - p_rgh] Highlight:
all walls boundary condition |
All 4 walls have been assigned the fixedFluxPressure boundary condition. |
Slide:
fixedFluxPressure |
The fixedFluxPressure boundary condition is:
|
[gedit - p_rgh] Highlight:
all walls boundary condition |
Our simulation takes gravitational force into consideration.
|
[gedit - p_rgh] Close the window | Close the p_rgh file. |
[Terminal] Type: gedit 0/p | Let’s open the pressure file, p. |
[gedit - p] Highlight:
all walls boundary condition |
The pressure values at the boundaries are calculated from the p_rgh values.
|
[gedit - p] Highlight:
value $internalField; |
The value has been specified to be the same as the internalField. |
[gedit - p] Close the window | Close the p file. |
[Terminal] Type:
ls constant |
Let’s now see the contents of the constant folder using the ls command. |
[Terminal] Highlight:
g momentumTransport thermophysicalProperties |
We see that there are 3 files in the constant folder. |
[Terminal] Type: gedit constant/g | Let’s open the g file. |
[gedit - g] Highlight:
dimensions [0 1 -2 0 0 0 0] |
The dimension of g is m/s2. |
[gedit - g] Highlight:
|
The magnitude of g is 10 m/s2. |
[gedit - g] Close the window | Close the g file. |
[Terminal] Type: gedit constant/momentumTransport | Let’s open the momentumTransport file. |
[gedit - momentumTransport] Highlight: simulationType laminar | Our simulation will be a laminar one. |
[gedit - momentumTransport] Close the window | Close the momentumTransport file. |
[Terminal] Type: gedit constant/thermophysicalProperties | Next, let’s open the thermophysicalProperties file. |
[gedit - thermophysicalProperties]:
Only Narration |
In this file, the properties of the fluid used in our simulation are specified.
|
[gedit - thermophysicalProperties] Highlight: thermoType field | OpenFOAM contains various thermophysical modelling packages.
|
Only Narration | The additional reading material has more details on the thermophysical modelling packages.
|
Slide:
Fluid Properties |
The various properties used in this simulation are shown in the table. |
[gedit - thermophysicalProperties] Highlight: equationOfState Boussinesq | We’ll be using the Boussinesq approximation for the equation of state. |
Slide: Boussinesq Approximation
|
The Boussinesq approximation is:
|
Slide:
Boussinesq Approximation |
Where, the reference density and coefficient of volumetric expansion are properties of fluid. |
Slide:
Reference Temperature |
The reference temperature is taken to be the average of hot and cold wall temperatures.
|
Only Narration | The additional reading material has more details on the Boussinesq approximation.
|
[gedit - thermophysicalProperties] Highlight: molWeight 28.9 | The molecular weight of the fluid is specified as 28.9 g/mol. |
[gedit - thermophysicalProperties] Highlight: rho0 1;
T0 0.5; |
For the fluid in our simulation, the reference density is specified to be 1 kg/m3.
|
[gedit - thermophysicalProperties] Highlight: beta 3.4e-02 | The coefficient of volumetric expansion is 3.4X10-2 K-1. |
[gedit - thermophysicalProperties] Highlight: Cp 1000 | The specific heat at constant pressure is taken to be 1000 kJ/kg-K. |
[gedit - thermophysicalProperties] Highlight: Hf 0 | Since no phase change is considered in this simulation, the heat of fusion is 0. |
[gedit - thermophysicalProperties] Highlight: transport
{ mu 4.91e-03; Pr 0.71; } |
For transport properties, dynamic viscosity and Prandtl number are to be specified.
|
[gedit - thermophysicalProperties] Close the window | Close the thermophysicalProperties file. |
[Terminal] Type: Ctrl + L | Clear the screen by pressing Ctrl and L keys together. |
[Terminal] Type: blockMesh | Let’s mesh the geometry using the blockMesh command. |
Slide:
buoyantSimpleFoam |
We will be using the buoyantSimpleFoam solver in this simulation.
|
[Terminal] Type: buoyantSimpleFoam | Let’s start the simulation using the following command. |
Only Narration | The simulation may take some time to complete. |
[Terminal] Highlight: End | The simulation is now complete. |
[Terminal] Type: paraFoam | Let’s view the simulated results in ParaView. |
[ParaView] Properties Tab
|
Click on the Apply button to view the geometry. |
[ParaView] Active Variable Controls
|
Let’s view the velocity contours for the simulation.
|
[ParaView] VCR Controls
|
Let’s view the contours at the end of the simulation.
|
[ParaView]
|
Click on the Rescale to Visible Data Range. |
[ParaView] Layout Window
|
We can see the steady-state circulation in the cavity.
|
[ParaView] Close ParaView | Close the ParaView window. |
Only Narration | We have come to the end of the tutorial.
|
Slide:
Summary |
In this tutorial, we have learnt to:
|
Slide: Assignment | As an assignment:* Increase the length of the cavity in the x-direction to 2 m
|
Slide: About the Spoken Tutorial Project | The video at the following link summarises the Spoken Tutorial project.
|
Slide: Spoken Tutorial Workshops | We conduct workshops using Spoken Tutorials and give certificates.
|
Slide: Spoken Tutorial Forum | Please post your timed queries in this forum. |
Slide: FOSSEE Forum | * Do you have any general/technical questions?
|
Slide: FOSSEE Case Study Project | * The FOSSEE team coordinates solving feasible CFD problems of reasonable complexity using OpenFOAM.
|
Slide: Acknowledgements | The Spoken Tutorial project was established by the Ministry of Education, Govt. of India. |
Only Narration | This tutorial is contributed by Diveysh variya, Aabhushan Regmi, Biraj Khadka, and Payel Mukharjee.
|