OpenFOAM-version-7/C3/Heat-source-addition-in-a-simulation-using-buoyantSimpleFoam/English

From Script | Spoken-Tutorial
Revision as of 16:20, 8 January 2024 by Biraj (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Title of the script: Heat source addition to buoyantSimpleFoam

Author: Mano Prithvi Raj, Binayak Lohani, Biraj Khadka

Keywords: OpenFOAM, ParaView, CFD, computational fluid dynamics, blockMesh, buoyancy driven flow, heat transfer, heat source, topoSetDict, fvModels, buoyantSimpleFoam, thermophysical properties, FOSSEE, spoken tutorial, video tutorial

Visual Cue Narration
Slide:

Opening Slide

Welcome to the spoken tutorial on Heat source addition to buoyantSimpleFoam.

Slide:

Learning Objective

In this tutorial, we will learn to:

  • Set up a case of heat transfer in OpenFOAM

  • Simulate a buoyancy-driven flow with a heat source, and

  • Set up topoSetDict and fvModels in OpenFOAM

Slide:

System Specifications

To record this tutorial, I am using,

  • Ubuntu Linux OS version 22.04

  • OpenFOAM version 9

  • ParaView version 5.6.0, and

  • gedit Text editor

However, you may use any other editor of your choice

Slide:

Prerequisites

As a prerequisite:

  • You should have basic knowledge of convective heat transfer

  • You should be familiar with setting up a case in OpenFOAM

  • If not, please go through the prerequisite OpenFOAM tutorials on this website

Slide:

Code Files

  • The files used in this tutorial are available in the Code Files link on this tutorial page

  • Please download and extract them

  • Make a copy and then use them while practicing

Slide:

Problem Statement

We will be solving a 2D flow in a square cavity

Top wall is moving other 3 walls of the cavity are fixed

Slide:

Problem Statement

  • Bottom wall is maintained at a higher temperature compared to the top wall

  • The side walls are adiabatic

Slide:

Problem Statement

  • A 2D rectangular heat source of 100 Watts is added in the middle of the cavity

Slide:

Problem Statement

  • Gravity is acting downwards, in the negative y-direction

  • Inside the cavity, the fluid close to the hot wall at the bottom is lighter

  • Fluid close to the cold wall on the top is heavier

  • Moving top wall creates circulation in cavity due to density and shear flow difference

  • The addition of heat source and its magnitude affects the circulation of fluid

Only Narration Let’s simulate this problem in OpenFOAM
CTRL + ALT + T Open the terminal by pressing Ctrl, Alt and T keys together

[Terminal] Type:

cd $FOAM_RUN

Type this command and press Enter to move into the run directory
[Terminal] Type: cp -r ~/Downloads/sourceAddition

I have downloaded and extracted the case folder to the Downloads folder

Let’s copy it into the run directory

[Terminal] Type:

cd sourceAddition

Let’s move into the case folder using the cd command

Slide:

Geometry

  • In this simulation, we consider a square cavity with an edge length of 1 m

  • There will be a heat source in the middle of the square cavity

  • The magnitude of power Q is 100 Watts

Slide: Boundaries The computational domain has 4 boundaries,

Slide:

Boundary Conditions

The boundary conditions used in the simulation are as shown in the table
Only Narration Let’s see how the boundary conditions are defined.

[Terminal] Type:

ls 0

The boundary conditions are defined in 0 folder

Let’s view its contents

[Terminal] Highlight:

p p_rgh T U

You will see two pressure files along with temperature and velocity files

One is the pressure file, p and other is modified pressure file, p_rgh

The significance of p_rgh has been explained earlier.

[Terminal] Type: gedit 0/T Let’s first open the temperature file, T

[gedit - T] Highlight:

internalField uniform 1 Link

The domain is initialised with 1 K

[gedit - T] Highlight: Link

bottom boundary condition

The bottom wall is maintained at a constant temperature of 1 K

[gedit - T] Highlight: Link

top boundary condition

The top wall is maintained at a temperature of 0 K

[gedit - T] Highlight: Link

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: Link

all walls boundary condition

All 4 walls have been assigned the fixedFluxPressure boundary condition

[gedit - p_rgh] Highlight: Link

all walls boundary condition

Our simulation takes gravitational force into consideration

Therefore, we will be using the fixedFluxPressure condition at the walls

[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: Link

all walls boundary condition

The pressure values at the boundaries are calculated from the p_rgh values

Therefore, all 4 walls have been assigned the calculated boundary condition

[gedit - p] Highlight: Link

value $internalField;

The type calculated, value is just a placeholder for the first time-step

This value has been specified to be the same as the internalField

[gedit - p] Close the window Close the p file

[Terminal] Type:

ls system

Let’s now see the contents of the system folder using the ls command

[Terminal] Highlight:

topoSetDict

We see the topoSetDict file in the system folder

Slide:

topoSetDict

  • topoSetDict is used to select cells, faces or points in the computational domain

  • topoSetDict is used to select a set of cells to define the location of heat source

[Terminal] Type: gedit system/topoSetDict Let’s open the topoSetDict file

[gedit - topoSetDict] Highlight:

Actions Link

  • addedHeatSource is the name of the cellSet

  • The dimensions of the box for the boxToCell option are defined under sourceInfo

  • Let’s see how the box dimensions are defined

Slide:

boxToCell

  • Here, we can see the domain, and the region where heat source is to be applied

  • boxToCell option chooses all the cells inside the box region for the cellSet

Slide:

boxToCell

Box is defined as below

Smallest coordinates are mentioned first followed by the greatest coordinates

[gedit - topoSetDict] Highlight:

actions Link

  • In our case, the coordinates would be (0.4 0.4 -0.1) followed by (0.6 0.6 0.1)

[gedit - topoSetDict] Close the window Close the topoSetDict 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 4 files in the constant folder

Slide:

constant Folder

  • fvModels file contains the source term type and magnitude

  • The g file contains the details of the gravitational force

  • The momentumTransport file contains the details of turbulence properties

  • The thermophysicalProperties file contains the properties of the fluid used

Slide:

fvModels

  • fvModels file is used to add source terms to the governing equations of solvers

  • The source term can be a heat source, a mass source, a damping source etc.

  • Here, the fvModels file is used to add a heat source

[Terminal] Type: gedit constant/fvModels Let’s open the fvModels file

[gedit - fvModels] Highlight:

source Link

  • heatSource is the type of the source term

  • addedHeatSources is the cellSet previously assigned in topoSetDict

  • The magnitude of Q is 100 Watts

[gedit - fvModels] Close the window Close the fvModels file
[Terminal] Type: gedit constant/g Let’s open the g file

[gedit - g] Highlight:

value (0 -10 0) Link

Since g is a vector, its velocity and magnitude have to be specified

In this case, the magnitude of g is 10 m/s2

Its direction is in the negative y-direction

[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 Link 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
Only Narration

In this file, properties of the fluid used in our simulation are specified

We’ll be simulating the flow inside the cavity

[gedit - thermophysicalProperties] Highlight: thermoType field Link

OpenFOAM contains various thermophysical modeling packages

The thermoType assembles the various thermophysical modeling packages

Only Narration

The additional reading material has more details on the thermophysical modeling packages

Please refer to it

Slide: Fluid Properties The various properties used in this simulation are shown in the table
[gedit - thermophysicalProperties] Highlight: equationOfState Boussinesq Link We will be using the Boussinesq approximation for the equation of state
[gedit - thermophysicalProperties] Highlight: molWeight 28.9 Link The molecular weight of the fluid is specified as 28.9 g/mol
Only Narration Reference density and coefficient of volumetric expansion are fluid properties

Slide:

Reference Temperature

The reference temperature depends on the problem being solved

In our case, it is taken as the average of hot and cold wall temperatures

Therefore, the reference temperature for our simulation is 0.5 K

Only Narration

The additional reading material has more details on the Boussinesq approximation

Please refer to it

[gedit - thermophysicalProperties] Highlight: rho0 1;

T0 0.5; Link

For the fluid in our simulation, reference density is specified as 1 kg/m3

This is the reference density at a reference temperature of 0.5 K

[gedit - thermophysicalProperties] Close the window Close the thermophysicalProperties file
[Terminal] Type: blockMesh Let’s mesh the geometry using the blockMesh command
[Terminal] Type: topoSet Let’s create the heat source cell set using the topoSet command
[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 Apply

Click on the Apply button to view the geometry

[ParaView] Active Variable Controls

Click on vtkBlockColors >> Click on T Link

Let’s view the temperature contours for the simulation

Click the vtkBlockColors dropdown in the Active Variable Controls and select T

[ParaView] VCR Controls

Click on Last Frame Link

Let’s view the contours at the end of the simulation

Click on the Last Frame button in the VCR Controls

[ParaView]

Click on Rescale to Visible Data Range Link

Click on Rescale to Visible Data Range

[ParaView] Active Variable Controls

Click on vtkBlockColors >> Click on U Link

Let’s view the velocity contours for the simulation

Click the vtkBlockColors dropdown in the Active Variable Controls and select U

Ensure that you click on U option with a point icon and not the box icon

[ParaView] Layout Window

Point to Circulation

We can see the steady-state circulation in the cavity
[ParaView] Close ParaView Close the ParaView window
Only Narration

With this we have come to the end of the tutorial

Let’s summarize

Slide:

Summary

In this tutorial, we have learnt to:

  • Set up a case of heat transfer in OpenFOAM

  • Simulate a buoyancy-driven flow with a heat source, and

  • Set up topoSetDict and fvModels in OpenFOAM

Slide:

Assignment

As an assignment:

  • Increase the length of the cavity in the x-direction to 2 m

  • Change the magnitude of heat source to 200 Watts

  • Simulate the buoyancy driven flow in a rectangular cavity

Slide:

About the Spoken Tutorial Project

The video at the following link summarizes the Spoken Tutorial project

Please download and watch it

Slide:

Spoken Tutorial Workshops

We conduct workshops using Spoken Tutorials and give certificates

Please contact us

Slide:

Spoken Tutorial Forum

Please post your timed queries in this forum

Slide:

FOSSEE Forum

  • Do you have any general/technical questions?

  • Please visit the forum given in the link

Slide:

FOSSEE Case Study Project

  • The FOSSEE team coordinates solving feasible CFD problems of reasonable complexity using OpenFOAM

  • We give honorarium and certificates to those who do this

  • For more details, please visit these sites

Slide:

Acknowledgements

The Spoken Tutorial Project was established by the Ministry of Education, Govt. of India
Only Narration This tutorial is contributed by Mano Prithvi Raj, Binayak Lohani, Biraj Khadka and Payel Mukherjee from IIT Bombay Thanks for joining

Contributors and Content Editors

Biraj