46 0 4MB
HELYX-OS OpenFOAM Tutorial: How to make your first simulation
Designed for engineering students who took the fluid dynamics class
Carlos Silva Rocha Department of Chemical and Materials Engineering University of Nevada, Reno 1
Table of Contents 1.
Computational Fluid Dynamics Introduction ......................................................... 4 1.1.
Mathematical background: PDEs and B.C.s..................................................... 5
1.1.1.
Continuity Equation ................................................................................... 5
1.1.2.
Momentum Equations ................................................................................ 6
1.1.3.
Energy Equation......................................................................................... 7
1.1.4.
Turbulence Equations ................................................................................. 7
1.1.5.
Boundary Conditions ................................................................................. 9
1.2. 1.2.1.
CFD Solution ................................................................................................ 9 Domain ..................................................................................................... 9
1.2.2. Meshing.................................................................................................... 10 1.2.3. Boundary and Initial Conditions ................................................................ 10 1.2.4. Solution Methods ...................................................................................... 10 2.
3.
Pre-requisites ...................................................................................................... 12 2.1.
Linux Environment ...................................................................................... 12
2.2.
SALOME ..................................................................................................... 12
2.3.
OpenFOAM ................................................................................................. 13
2.4.
ParaView ...................................................................................................... 13
2.5.
HELYX-OS .................................................................................................. 14
OpenFOAM set up with HELYX-OS ................................................................... 20 3.1.
Geometry Creation ...................................................................................... 20
3.2.
Meshing ...................................................................................................... 24
3.3.
Steady State Laminar Isothermal Pipe Flow ................................................... 27
3.3.1. Solver Setup ............................................................................................. 27 3.3.2. Results and post-processing........................................................................ 31 3.4.
Steady State Laminar Non-Isothermal Pipe Flow ........................................... 36
3.4.1. Solver Setup ............................................................................................. 36 3.4.2. Results and Post-processing ...................................................................... 40
2
3.5.
Steady State Turbulent Isothermal Pipe Flow ................................................. 41
3.5.1. Solver Setup .............................................................................................. 41 3.5.2. Results and post-processing........................................................................43 4.
Final Remarks .....................................................................................................45
References ................................................................................................................. 46
3
1. Computational Fluid Dynamics Introduction Fluid dynamics (FD) is a discipline used in many engineering fields. Professional engineers in mechanical, chemical, environmental, civil, and many other engineering fields use fluid mechanics calculations to predict or understand the behavior of fluidic systems. Chemical engineers use FD to predict reactor performance (Gunjal et al., 2003). Mechanical engineers use FD to design new parts like mixers (Mohammadi et al., 2015). Environmental engineers use FD to understand and predict nutrient flows in open water bodies (Collivignarelli et al., 2020). While introductory FD are present in undergraduate engineering courses, practical 3D calculations are not usually presented to students. Such computations are time consuming and not practical in a classroom setting. Real FD problems usually don’t have analytical solutions and involves the use of mathematical techniques to obtain an approximate solution to the problem. While the computation by hand of approximate solutions is only possible for very simple problems, computers can deal with them much more efficiently. This fact led to the development of the field know as Computational Fluid Dynamics, commonly abbreviated as CFD (Versteeg & Malalasekera, 2007). CFD tools facilitate computations by providing computer software packages that solve complicated non-ideal problems. Computer power was a strong constraint in the past century. However, with the advancement of computer engineering, most personal computers (PC) are powerful enough to run CFD codes. This allows for the ability to solve real problems in hours or days instead of years. As of 2022, there are many CFD software packages available. Examples include ANSYS Fluent and CFX, COMSOL, OpenFOAM, and MFiX. In this tutorial, OpenFOAM which is a free open-source CFD tool was used. The goal of this paper is to introduce the engineering student to CFD by providing a procedure that will allow for the effective use of a free CFD tool to solve a general problem. In this tutorial, students will perform a fluid dynamic simulation in a simple straight pipe.
4
1.1.
Mathematical background: PDEs and B.C.s
Although complicated, fluid flow theory comes from a solid physical-mathematical foundation. Several Partial Differential Equations (PDEs) govern the fluid flow dynamics. The governing equations were derived from mass, energy, and force balances done around a fluid volume, illustrated by Figure 1 (Versteeg & Malalasekera, 2007). They represent the conservation of mass, momentum, and energy, concepts thoroughly explored in thermodynamics. There are several textbooks on this subject, some focused on analytical solutions (Bird et al., 2001; Bergman, 2011; Fox et al., 2011; Potter et al., 2012; Morrison, 2013; Plawsky, 2014), others on numerical methods around computational fluid dynamics (Versteeg & Malalasekera, 2007; Biringen & Chow, 2011; Moukalled et al., 2016; Pozrikidis, 2017; Tu et al., 2018). The resulting general equations are detailed in the next sections.
Figure 1 - Fluid element illustration (Versteeg & Malalasekera, 2007).
1.1.1.
Continuity Equation
One fundamental assumption in fluid dynamics is the continuum. If a pipe has a fluid passing through it, the fluid occupies all the pipe volume continuously. Thus, there are no empty spaces inside the tube. To carry out calculations in space, one can divide the pipe into a set of very small volumes. Then a mass balance can be made for every single volume which will result in the definition of the continuity equation, represented by: 𝜕𝜌 𝜕(𝜌𝑢) 𝜕(𝜌𝑢) 𝜕(𝜌𝑢) + + + =0 𝜕𝑡 𝜕𝑥 𝜕𝑦 𝜕𝑧
(1)
5
Where 𝑥, 𝑦, and 𝑧 are the system coordinates, and 𝜌, 𝑢, and t are the fluid density, velocity, and time respectively. The equation above represents the conservation of mass. Combining the derivatives in space, we get: 𝜕𝜌 + 𝑑𝑖𝑣(𝜌𝑢) = 0 𝜕𝑡
(2)
Or intuitively: 𝑅𝑎𝑡𝑒 𝑜𝑓 𝑐ℎ𝑎𝑛𝑔𝑒 𝑁𝑒𝑡 𝑟𝑎𝑡𝑒 [ 𝑜𝑓 𝑚𝑎𝑠𝑠 𝑖𝑛 ] = [ 𝑜𝑓 𝑓𝑙𝑜𝑤 𝑜𝑓 𝑚𝑎𝑠𝑠 ] 𝑖𝑛𝑡𝑜 𝑓𝑙𝑢𝑖𝑑 𝑒𝑙𝑒𝑚𝑒𝑛𝑡 𝑡ℎ𝑒 𝑓𝑙𝑢𝑖𝑑 𝑣𝑜𝑙𝑢𝑚𝑒 For a more detailed information on the continuity equation derivation, see Versteeg and Malalasekera (2007). 1.1.2.
Momentum Equations
Using the same fluid volume discussed above, one can perform a force balance around the fluid element. This mathematical treatment will result in the moment equation which is expressed for each Cartesian component as: 𝜕𝑢𝑥 𝜕𝑝 𝜕𝜏𝑥𝑥 𝜕𝜏𝑦𝑥 𝜕𝜏𝑧𝑥 =− + + + + 𝑆𝑀𝑥 𝜕𝑡 𝜕𝑥 𝜕𝑥 𝜕𝑦 𝜕𝑧 𝜕𝑢𝑦 𝜕𝑝 𝜕𝜏𝑥𝑦 𝜕𝜏𝑦𝑦 𝜕𝜏𝑧𝑦 𝜌 =− + + + + 𝑆𝑀𝑦 𝜕𝑡 𝜕𝑦 𝜕𝑥 𝜕𝑦 𝜕𝑧 𝜕𝑢𝑧 𝜕𝑝 𝜕𝜏𝑥𝑧 𝜕𝜏𝑦𝑧 𝜕𝜏𝑧𝑧 𝜌 =− + + + + 𝑆𝑀𝑧 𝜕𝑡 𝜕𝑧 𝜕𝑥 𝜕𝑦 𝜕𝑧 𝜌
(3) (4) (5)
Where 𝑝, 𝜏, and 𝑆𝑀 are the pressure, viscous stresses, and extra source terms that may be included in the mathematical statement. Intuitively the momentum equation represents (Versteeg & Malalasekera, 2007): 𝑅𝑎𝑡𝑒 𝑜𝑓 𝑐ℎ𝑎𝑛𝑔𝑒 𝑆𝑢𝑚 𝑜𝑓 𝑓𝑜𝑟𝑐𝑒𝑠 𝑜𝑛 𝑡ℎ𝑒 [𝑜𝑓 𝑚𝑜𝑚𝑒𝑛𝑡𝑢𝑚 𝑖𝑛 ] = [ ] 𝑓𝑙𝑢𝑖𝑑 𝑣𝑜𝑙𝑢𝑚𝑒 𝑡ℎ𝑒 𝑓𝑙𝑢𝑖𝑑 𝑣𝑜𝑙𝑢𝑚𝑒 6
1.1.3.
Energy Equation
Like what has been done to derive the continuity and momentum equations, one can perform an energy balance around the same fluid element and find: 𝐷(𝜌𝑐𝑇) = 𝑑𝑖𝑣(𝑘 ∙ 𝑔𝑟𝑎𝑑(𝑇)) − 𝑑𝑖𝑣(𝑝𝑢) + Φ𝑢𝑥 + Φ𝑢𝑦 + Φ𝑢𝑧 + 𝑆𝐸 𝐷𝑡
(6)
Where c is fluid heat capacity, 𝑘 is the fluid thermal conductivity coefficient, S is a source term, and Φi is defined as: 𝜕(𝑢𝑥 𝜏𝑥𝑥 ) 𝜕(𝑢𝑥 𝜏𝑦𝑥 ) 𝜕(𝑢𝑥 𝜏𝑧𝑥 ) + + 𝜕𝑥 𝜕𝑦 𝜕𝑧 𝜕(𝑢𝑦 𝜏𝑥𝑦 ) 𝜕(𝑢𝑦 𝜏𝑦𝑦 ) 𝜕(𝑢𝑦 𝜏𝑧𝑦 ) Φ 𝑢𝑦 = + + 𝜕𝑥 𝜕𝑦 𝜕𝑧 𝜕(𝑢𝑧 𝜏𝑥𝑧 ) 𝜕(𝑢𝑧 𝜏𝑦𝑧 ) 𝜕(𝑢𝑧 𝜏𝑧𝑧 ) Φ 𝑢𝑧 = + + 𝜕𝑥 𝜕𝑦 𝜕𝑧 Φ 𝑢𝑥 =
(7) (8) (9)
The equations above are complex mathematical statements of the principle of energy conservation. Thus, it is useful to see them intuitively as (Versteeg & Malalasekera, 2007): 𝑅𝑎𝑡𝑒 𝑜𝑓 𝑐ℎ𝑎𝑛𝑔𝑒 𝑁𝑒𝑡 𝑟𝑎𝑡𝑒 𝑜𝑓 ℎ𝑒𝑎𝑡 𝑁𝑒𝑡 𝑟𝑎𝑡𝑒 𝑜𝑓 [𝑜𝑓 𝑒𝑛𝑒𝑟𝑔𝑦 𝑖𝑛 𝑡ℎ𝑒 ] = [ 𝑎𝑑𝑑𝑒𝑑 𝑡𝑜 𝑡ℎ𝑒 ] + [ 𝑤𝑜𝑟𝑘 𝑑𝑜𝑛𝑒 𝑜𝑛 ] 𝑓𝑙𝑢𝑖𝑑 𝑣𝑜𝑙𝑢𝑚𝑒 𝑡ℎ𝑒 𝑓𝑙𝑢𝑖𝑑 𝑣𝑜𝑙𝑢𝑚𝑒 𝑓𝑙𝑢𝑖𝑑 𝑣𝑜𝑙𝑢𝑚𝑒 1.1.4.
Turbulence Equations
When the Reynolds number is above 4000, the fluid flow in pipes becomes chaotic and fluid properties fluctuate in time (Fox et al., 2011). Thus, each velocity component now has some variability or variance associated with it. A common way to deal with this scenario consists in defining each velocity component as a sum of two terms, one associated with the smooth flow of fluid and another associated with turbulence. This definition is shown below (Bird et al., 2001). 𝑢𝑖 = 𝑈𝑖 + 𝑢𝑖′
(10) 7
Where 𝑢𝑖 is the velocity component in the direction 𝑖 , 𝑈𝑖 is the steady velocity component, and 𝑢𝑖′ is the unsteady velocity component. If one decides to perform the same balances applied in sections 1.1.1 and 1.1.2, extra terms will appear due to the inclusion of the turbulent velocity components. The extra terms are called Reynolds stresses and are mathematically similar to viscosity. Thus, to solve the turbulent conservation equations, extra equations are needed (Versteeg & Malalasekera, 2007). Several models have been proposed in the literature (Versteeg & Malalasekera, 2007; Biringen & Chow, 2011; Moukalled et al., 2016; Pozrikidis, 2017; Tu et al., 2018). One popular model is the k-e model. In this approach, two extra equations are added to the turbulence problem. The additional mathematical statements help to describe the turbulent viscosity. The k-e equations are shown below. 𝜕(𝜌𝑘) 𝜇𝑡 + 𝑑𝑖𝑣(𝑝𝑘𝑈) = 𝑑𝑖𝑣 ( 𝑔𝑟𝑎𝑑(𝑘)) + 2μt 𝑆𝑖𝑗 𝑆𝑖𝑗 − 𝜌𝜖 𝜕𝑡 𝜎𝑘
(11)
𝜕(𝜌𝜖) 𝜇𝑡 𝜖 𝜖2 + 𝑑𝑖𝑣(𝑝𝜖𝑈) = 𝑑𝑖𝑣 ( 𝑔𝑟𝑎𝑑(𝜖)) + 𝐶1𝜖 ∙ 2μt 𝑆𝑖𝑗 𝑆𝑖𝑗 − 𝐶2𝜖 𝜌 ∙ 𝜕𝑡 𝜎𝜖 𝑘 𝑘
(12)
Where 𝜇𝑡 is the turbulent viscosity also known as eddy viscosity, and 𝑆𝑖𝑗 is the rate of deformation. 𝜎𝑘 , 𝜎𝜖 , 𝐶1𝜖 , 𝑎𝑛𝑑 𝐶2𝜖 are constants. Intuitively equations 11 and 12 can be read as: 𝑅𝑎𝑡𝑒 𝑜𝑓 𝑐ℎ𝑎𝑛𝑔𝑒 𝑇𝑟𝑎𝑛𝑠𝑝𝑜𝑟𝑡 𝑜𝑓 𝑇𝑟𝑎𝑛𝑠𝑝𝑜𝑟𝑡 𝑜𝑓 𝑁𝑒𝑡 𝑟𝑎𝑡𝑒 𝑜𝑓 [ 𝑜𝑓 𝒌 𝑜𝑟 𝝐 𝑖𝑛 𝑡ℎ𝑒 ] + [𝒌 𝑜𝑟 𝝐 𝑏𝑦 𝑐𝑜𝑛𝑣𝑒𝑐𝑡𝑖𝑜𝑛] = [ 𝒌 𝑜𝑟 𝝐 𝑏𝑦 𝑑𝑖𝑓𝑓𝑢𝑠𝑖𝑜𝑛 ] + [ 𝒌 𝒐𝒓 𝝐 𝑎𝑑𝑑𝑒𝑑 𝑡𝑜 ] 𝑡ℎ𝑒 𝑓𝑙𝑢𝑖𝑑 𝑣𝑜𝑙𝑢𝑚𝑒 𝑓𝑙𝑢𝑖𝑑 𝑣𝑜𝑙𝑢𝑚𝑒 𝑖𝑛 𝑡ℎ𝑒 𝑓𝑙𝑢𝑖𝑑 𝑣𝑜𝑙𝑢𝑚𝑒 𝑖𝑛 𝑡ℎ𝑒 𝑓𝑙𝑢𝑖𝑑 𝑣𝑜𝑙𝑢𝑚𝑒
It is important pointing that turbulence problems will also require special treatment of fluid layers around walls. Commercial CFD packages will provide wall functions along with the turbulence models (Versteeg & Malalasekera, 2007; Biringen & Chow, 2011; Moukalled et al., 2016; Pozrikidis, 2017; Tu et al., 2018).
8
1.1.5.
Boundary Conditions
To solve PDEs, boundary and initial conditions are needed. They inform what is happening at the system boundaries. Mathematically, there are three types of BCs, Dirichlet, Neumann, and Robin. They represent a defined constant scalar, rate, and property flux, at some boundary, respectively. The use of boundary conditions in CFD is briefly discussed in section 1.2.3. More detailed explanations are provided by Potter et al. (2017).
1.2.
CFD Solution
To set up a fluid dynamics problem, CFD software packages require the user to specify the physical constraints that define the problem. Generally, those characteristics are: -
physical scenario, known in the field as computational domain.
-
computation grid, known as mesh.
-
physical conditions such as type of regime, states of boundaries like walls, inlets,
and outlets. -
solution methods.
In the next sections, a summary of each step will be presented. 1.2.1.
Domain
The first step in a CFD analysis is the specification of the physical problem. In this step, a 1D, 2D, or 3D CAD (Computer Aided Design) drawing must be provided. Stereolithography (STL) files are usually used in this step. This will inform the CFD package where calculations will be carried out. Depending on the software package, the user may be required to also specify where the main boundaries are in the CAD drawing.
9
1.2.2.
Meshing
Similar to what was done to derive the continuity and momentum equations, to solve a CFD problem, the solver algorithm needs a set of volumes to work on. The division of a 3D volume into smaller 3D volumes, or cells, is called meshing. The set of volumes generated forms a numerical grid where equations can be solved at each central position. 1.2.3.
Boundary and Initial Conditions
As illustrated in section 1.1, fluid dynamics problems involve the solution of PDEs. Such mathematical formulas require the specification of boundary states. If the problem is transient or evolves on time, initial conditions also need to be specified. Mathematically speaking, PDEs solutions start to be computed on the boundaries and evolve in time starting from the initial conditions. Without boundaries and initial information, PDEs cannot be solved. 1.2.4.
Solution Methods
1.2.4.1.
Discretization
CFD based on the finite volume method solves the relevant equations at the volume/cell center. However, neighboring cells influence each other. Thus, a method to compute those influences must be devised. The main question here is: if one knows a property value at a cell center, what would be the property value at each cell face or wall? In simple terms, solutions calculated at the cell center are interpolated to provide solutions to walls or faces. This allows for the computation of the next cell’s central value taking into account the effect of all neighbor cells. There are many interpolation schemes available. The most common for fluid flow is the upwind scheme. Most CFD packages will recommend the best scheme to use. ANSYS and OpenFOAM provide useful information on details of the schemes they provide. There are also excellent videos about discretization schemes on YouTube.
10
1.2.4.2.
Numerical solution
The numerical solution of the partial differential equations involves the solution of equations in matrixial forms. For more information on the numerical procedure, see the videos provided by Dr. Aidan Wimshurst on YouTube. The video about residuals illustrates how most CFD software deal with the relevant equations. Other useful literature resources include Versteeg and Malalasekera (2007), Biringen (2011), and Moukalled et al. (2016).
11
2. Pre-requisites Now that the CFD basics have been presented, the reader is ready to run a CFD simulation. If the use of a free CFD package is desired, a Linux environment is recommended. To complete this tutorial the user needs to install Ubuntu, SALOME, OpenFOAM, HELYX, and ParaView. In the following sections, the steps to install all the required computational tools will be presented. Illustrative images will also be provided.
2.1.
Linux Environment
To run OpenFOAM with the free version of HELYX-OS, a Linux operating system is required. Any distribution will work. However, you are advised to use Ubuntu. If you already have a personal computer running Linux, go ahead and use it. Otherwise, you will need to set up a virtual machine (VM) and install Ubuntu. There are several videos on YouTube on how to install Linux on a Windows environment. You will need at least 20 GB of free disk space to install the virtual machine. This tutorial uses the username “VML”. To facilitate the procedure, make sure your VM username is VML. Otherwise, you will need to modify the commands to reflect your specific user name. Once you have a working Linux virtual machine, proceed to step 2.
2.2.
SALOME
SALOME is an open-source software that offers many CAD functionalities. Here it will be used to generate the geometry used in OpenFOAM and HELYX-OS. To install Salome on your Windows machine, follow the steps below (inside the virtual machine): -
Go to the SALOME download page and click on the link to the windows installation package.
12
Figure 2 - SALOME download page.
-
Execute the installation package on Windows and follow the installation prompts. Once the installation is complete, open SALOME. If you successfully open the software without any errors, you are ready to install OpenFOAM.
2.3.
OpenFOAM
OpenFOAM (Open-source Field Operation And Manipulation) is a free CFD software package. To install OpenFOAM on your Ubuntu virtual machine, open the “Terminal” application and execute the following commands: wget -q -O - https://dl.openfoam.com/add-debian-repo.sh | sudo bash sudo apt-get install -y openfoam2112-default
2.4.
ParaView
ParaView (PV) is a free data analysis and visualization software. It is needed to postprocess OpenFOAM results (.foam files). PV installation is straightforward using the “Ubuntu Software” app. The installation steps are shown below. -
First open the “Ubuntu Software” app.
-
Click on the search icon
, type “paraview”, then hit Enter. 13
Figure 3 - ParaView installation windows.
-
Select the package whose description is “Data analysis and visualization”.
-
On the next screen, hit install. The system will ask for your user password. Type it and click on “Authenticate”.
-
Once the installer finishes, ParaView will be installed in the VM. No additional configuration is needed.
2.5.
HELYX-OS
HELYX-OS is an open-source Graphical User Interface for OpenFOAM. The free version is limited but greatly facilitates the setup of CFD simulations. Beginners will find HELYX very helpful. To install the package, go to the official download page and download the files to your virtual machine “Downloads” folder. To install the binary files, follow the steps below. -
Select the downloaded .bin file, right-click on it, and a properties window will appear. Click on the “Permissions” tab and check the “Allow executing file as program” checkbox. Close the window. 14
Figure 4 - Permission window on Ubuntu.
-
Then, right-click again on the installation .bin file, and on the menu that appears, select “Run as a Program”.
Figure 5 - .bin file right-click menu.
-
A terminal window will appear, type 1, and hit Enter to start the installation.
15
Figure 6 - HELYX-OS confirmation prompt.
-
The user license agreement will appear on the terminal window, hit the Enter key to read through the agreement. Once you finish, you will see the program asking if you agree. Type 1 and hit Enter.
Figure 7 - Terms of agreement prompt.
-
The installer will ask for the components you want to install, type 2, and hit Enter.
Figure 8 - Components to install selection.
-
Now, you need to specify where to install HELYX, type /home/user. REPLACE “user” with your username in your VM! Then hit Enter.
16
Figure 9 - Destination folder selection.
-
Next, the installer will ask what Linux distribution you are using. In this tutorial, Ubuntu 21.10 was used, thus type 1, and hit the Enter key. Then, type your Ubuntu account password and hit Enter.
Figure 10 - Linux distribution selection.
-
Finally, the installer will ask for permission to add the necessary repositories and download the required files. Hit the Enter key to confirm. Once the installation is complete, you should see the message “Installation completed!”.
Figure 11 - Repository installation confirmation message.
-
Now, go to your home folder and navigate to the folder located in “Engys/HELYX-OS/v.2.4.0”. Right-click on the file HELYX-OS.sh and select “Run as Program”.
17
Figure 12 - How to open HELYX-OS.
-
The HELYX-OS interface will show up and require some extra settings for the first run. Hit “OK” on the warning window.
Figure 13 - Warning screen on the first execution of HELIX-OS.
-
On the next window, hit “New”, then “OK”.
18
Figure 14 - HELIX-OS welcome screen.
-
On the top left corner, select “Edit”.
-
HELYX will require you to provide the OpenFOAM installation folder and ParaView location. Type: /usr/lib/openfoam/openfoam2112 /usr/share/applications/paraview.desktop
Your configuration window should look like the one illustrated below.
Figure 15 - HELYX-OS Preferences window.
19
3. OpenFOAM set up with HELYX-OS This section will guide the user through the setup process. For each step, a figure illustrating the command will be provided.
3.1.
Geometry Creation
Before setting up the problem, we need to provide a geometry that contains all the regions required by OpenFOAM. Thus, it is necessary to create a 3D object that contains all the boundary regions needed. Each region needs an object which will describe it. In this case, a pipe will be created containing a wall, inlet, and outlet. To create the required file, open SALOME, and create the pipe geometry as follows: 1) Create the base cylinder -
Go to the drop-down box and choose “Geometry”. This command will activate the geometry module and new options will appear on the SALOME window.
Figure 16 - SALOME window.
-
On the menu bar, go to: “New Entity” -> “Primitives” -> “Cylinder”.
20
Figure 17 - SALOME "Primitives" menu.
-
Set “Radius” to 0.00159 and “Height” to 0.2.
Figure 18 - SALOME cylinder construction window.
2) Now, create the boundary regions by breaking the cylinder geometry into its faces. -
Go to “New Entity” -> “Explode”.
21
Figure 19 - SALOME explode command.
-
Click on the “Main Object” box, and then click on the cylinder object created in step 1.
Figure 20 - SALOME object browser window.
-
On the “Sub-shapes Type” option, choose “Face”.
-
Hit “Apply and Close”.
22
Figure 21 - SALOME sub shape selection window.
-
Rename each face according to its position. First, center the geometry on the screen by clicking on the buttons
. Make sure all faces are visible. Then,
locate the highest face in the Z direction by clicking on the available faces. Rename the face to “outlet”. The chosen objects will be shown on the viewer with white edges. Rename the other faces following the schematics below.
Figure 22 - 3D drawing schematics.
-
At this point, all needed objects have been created. Export the inlet, wall, and outlet faces as STL files by choosing the objects and going to “File” -> “Export” -> “STL”. Save the STL files in your documents folder. 23
3.2.
Meshing
The mesh file here will be done by algorithms provided by OpenFOAM. The GUI provided by HELYX-OS will be used to “mesh” the 3D domain using blockMesh. -
First, open HELYX-OS, in the welcome window, choose “New”, and type the case name and number of processors as desired. Note that in the “Hierarchy” boxes the user can set the order of the domain decomposition in each direction for parallel execution. Leave in the default option defined by HELIX, no need to change them.
Figure 23 - HELIX-OS welcome screen.
-
Load the STL files created previously by clicking on “Geometry”, then “STL”. A selection window will show up. Select the STL files you have saved previously.
24
Figure 24 - HELIX-OS geometry options.
-
Setup the meshing properties. Click on “Base Mesh”, then on “Base Mesh Type” select “User Defined”. Then, click on the “Fit Bounding Box” button
. Set
the number of elements in the X and Y direction to 10, and Z to 100. Click on the “Reset zoom” button to check the meshing prediction
. Adjust the zoom
until you can see the prediction. The expected result is shown below.
Figure 25 - HELIX-OS meshing.
-
Tell the software where your geometry is by setting the “Material Point”. As the pipe was draw at the origin, the point (x = 0, y = 0, z = 0.1) is inside the domain.
25
Thus, set material point to 0.0, 0.0, 0.1. You could also move the material point indicator by clicking on it the moving it inside the domain.
Figure 26 - Material point definition.
-
Click in “Mesh” and select “Create”. Once the process finishes, you should see the message “Finished meshing without errors” on the terminal window integrated on HELYX-OS screen.
Figure 27 - HELIX-OS meshing screen after meshing operation.
26
3.3.
Steady State Laminar Isothermal Pipe Flow
3.3.1.
Solver Setup
Now that your mesh is ready, we need to set up the solver by telling it what type of problem we want to solve. To set up this case, follow the steps below: -
Set the time to “Steady”, flow to “Incompressible”, and turbulence model to “Laminar”.
Figure 28 - HELIX-OS solution modeling.
-
Set the material to “Water”.
27
Figure 29 - Material selection window.
-
In the “Boundary Conditions” option: a. Set inlet as: Patch Type: Patch Velocity Type: Surface Normal Fixed Value Velocity Magnitude [m/s]: -0.11335 Pressure Type: Zero Gradient
Figure 30 - Inlet boundary condition specifications.
28
b. Set outlet as: Patch Type: Patch Velocity Type: Pressure Inlet Outlet Velocity Pressure Type: Total Pressure Pressure [m2/s2]: 0.0 Gamma: 1.0
Figure 31 - Outlet boundary condition specifications.
29
c. Set wall as: Patch Type: Wall Type: Fixed Wall Wall-Type: No-slip
Figure 32 - Wall boundary conditions specifications.
-
In “Solver Settings”, set “Non-orthogonal Correctors” to 1.
Figure 33 - Solver settings tab.
-
In “Fields Initialization”, set “Type” to “Potential Flow”, and the “NonOrthogonal Correctors” to 10. Then click on “Initialize”. 30
Figure 34 - Fields initialization option.
-
Go to the “Solver” tab and click on “Run”.
3.3.2.
Results and post-processing
After a successful run, a results file is created by OpenFOAM. To access the results file, click on the
button on the “Solver” tab.
Figure 35 - ParaView button location.
31
Once ParaView opens, go to the “Properties\Case Type” and choose “Decompose Case”, then hit “Apply”.
Figure 36 - ParaView welcome screen.
Figure 37 - Setting up a .foam file in ParaView.
Now, all the data is ready to be processed. In the next sections, the reader will be introduced to two different data visualization tools. 3.3.2.1.
Contours
Contours are used to visualize variable values over a surface. This type of visualization is useful to see general patterns in the variable of interest field. Virtually, any variable field can be visualized with a contour plot. 32
By default, when HELYX-OS opens ParaView, a pressure contour plot is done on the domain walls. To visualize it, follow the steps below. -
Click on the “Set View Direction to X” button
. Note that there is a color
legend for the pressure, represented by “p”. In the case displayed in the image below, the highest-pressure values occur in the red regions.
Figure 38 - Pressure contour plot on ParaView.
Contours at specific locations can also be created. To do so, click on the .foam file in ParaView. Then select “Add Filter/Common/Slice”. The user can choose the location of the slice and visualize any domain property. 3.3.2.2.
Plots
To generate plots, follow the steps below. -
Right-click on the .foam file in ParaView. Then select “Add Filter/Data Analysis/Plot Over Line”. By default, a line in the Z direction is created. Change 33
the direction to X by clicking on the “X Axis” button. Then click on the “Apply” button.
Figure 39 - Default plot generated by the option "Plot Over Line".
Note that a plot of the pressure and velocity (u_magnitude) has been created over the X Axis located at Z = 0.19 m. Let’s modify this plot to show the position on the yaxis and velocity on the x-axis. Follow the steps below: -
Click on the tab “Properties (PlotOverLine)”, this command will bring the “Display (XYChartRepresentation)” tab up.
-
Change “X Array Name” to “U_Magnitude”. Scroll down and find the “Series Parameters” table. Unmark all checkboxes and mark the “Points_X” check box.
-
Click on the tab “Display (XYChartRepresentation)”, this command will bring the “View (LineChartView)” tab up. In the “Chart Title”, type: “Velocity Profile at z = 0.19 m”. Unmark the “Show Legend” check box. In the “Left Axis Title” type: “x (m)”. In the “Bottom Axis Title” type: “Velocity (m/s)”.
The result is illustrated in the figure below.
34
Figure 40 - Velocity profile plot.
Several data visualization and analysis operations can be done in ParaView. Here, only the pressure contour and velocity profile were presented. The reader is encouraged to explore all features ParaView offers. 3.3.2.3.
Validation
CFD simulations contain errors due to several things. For instance, common sources of errors are the simplifications imposed on the physical problem, insufficient number of cells, leading to gross interpolation, unknown physical phenomena happening at specific regions, inappropriate models and/or discretization techniques, and so on. Since errors are unavoidable, it is usually a good practice to compare CFD solutions to experimental data, when available. This process is called validation. Usually, experimental data is acquired for one convenient measurement like pressure drops, temperature gradients along with a few points, and so on. Sometimes, validation is not possible at all, and users should follow the best practices available in the literature (JFE, 2022). This tutorial was built upon the simple pipe case which has a known analytical solution. The validation plot is shown below. Note that the simple mesh produced here gave reasonable results. The profiles generated by more refined meshes are displayed for reference.
35
Figure 41 - Validation of the numerical solution.
The refined meshes were done as part of the refinement study. It illustrates how to verify numerical errors due to an insufficient number of cells. A formal refinement study consists in increasing the number of cells by 20 %, re-running the simulations, and verifying if a variable of interest (VI) changed significantly (for instance, more than 5%) in the new simulation. The process is repeated until the VI stops changing. The main message here is that even a simple CFD simulation with a coarse mesh can give reasonable results. Thus, CFD is a useful tool for professional engineers even in scenarios where equipment sizes would require theoretically an enormous number of cells (Templeton et al., 2006). Reasonable approximations can always be made.
3.4.
Steady State Laminar Non-Isothermal Pipe Flow
After running a first laminar flow simulation, the reader may find useful to learn how to calculate temperature changes inside the pipe domain. Problems involving heat transfer are very common, thus CFD can come in handy in real-life situations. In this section, you will learn how to activate the energy equation and calculate the temperature profile inside a simple pipe with a constant temperature applied on the wall. 3.4.1.
Solver Setup
To activate the energy equation and set up the new boundary conditions, follow the steps below. 36
-
Click on the tab “Case Setup”, then “Solution Modelling”, and enable the “Energy” checkbox in the “Thermal” section.
Figure 42 - Enabling the energy equation.
-
Click on “Materials”. Notice HELYX-OS will display a warning, hit “OK” and click on “Materials” again.
-
Once you see the “Materials” panel, click on the button “Change Material”. A new window will appear. Click on “Water”, then hit “Ok”. The figure below illustrates this step.
Figure 43 - Material selection window.
37
-
Set the energy boundary conditions by clicking on “inlet”, then the sub-tab “Thermal”. Set the type to “Inlet Outlet” and the “Temperature Value [K]” to 300 as illustrated below.
Figure 44 - Inlet thermal boundary condition.
-
Repeat the step above for the outlet boundary condition, as illustrated below.
Figure 45 - Outlet thermal boundary condition.
-
Configure the wall thermal boundary condition by clicking on “Wall”, then on the sub-tab “Thermal”. Set the type to “Fixed Temperature”, and the “Temperature Value [K]” to 330.
38
Figure 46 - Wall thermal boundary condition.
-
Click on “Numerical Schemes” and set the “Advection” to “Bounded Linear Upwind – 2nd Order”.
Figure 47 - Numerical Schemes Selection
-
Initialize the solution by clicking on “Fields Initialization”, then on the button “Initialize”.
39
Figure 48 – Solution initialization.
-
Now, the solver is ready to run. Click on the tab “Solver”, then on the button “Run”.
Figure 49 - Solver section.
3.4.2.
Results and Post-processing
To post process your results, follow the same steps presented in the section 3.1.4. The figures below illustrate the expected result for a low-resolution mesh.
40
Figure 50 – Temperature profiles on ParaView.
3.5.
Steady State Turbulent Isothermal Pipe Flow
3.5.1.
Solver Setup
To run a turbulent flow simulation, follow the same steps as presented in section 3.3. There are only a few settings to be changed, the “Turbulence Model” in the solutions modeling sections, “Velocity Magnitude”, “K”, and “Epsilon” in the boundary conditions section. To modify those parameters, go to the HELYX-OS window, and follow the steps below: -
Go to the “Case Setup” tab, click on “Solution Modelling”, then on the drop box next to the option “Turbulence Model”. Choose Realizable k-e.
41
Figure 51 – HELYX-OS Case setup tab location.
Figure 52 – Turbulence model selection location.
-
Now that the turbulence model has changed, new settings will appear in the boundary conditions section. Click on the “inlet” option inside the “Boundary Conditions” section. Then, hit the “Momentum” sub-tab. Set the “Velocity Magnitude [m/s]” to -1.5. The Reynolds number corresponding to this inlet velocity is about 7000.
-
Since the turbulence model has changed, new settings will appear in the boundary conditions section. Click on the “inlet” option inside the “Boundary Conditions” section. Then, hit the “Turbulence” sub-tab.
42
Figure 53 – Turbulence model boundary conditions.
-
Set “K [m2/s2]” to 0.015, and “Epsilon [m2/s2]” to 1.368. Those parameters were estimated using the inlet velocity.
Details on how to estimate k-e
parameters can be found in OpenFOAM User Guide, and on CFD online Wiki page. -
Now, all the needed modifications have been done, and you can go to the “Solver” tab and hit the button “Run”.
3.5.2.
Results and post-processing
To post-process your results, follow the same steps presented in section 3.1.4. The figures below illustrate the expected result for a low-resolution mesh, and the comparison to the laminar velocity profile also in low-resolution.
43
Figure 54 – ParaView velocity profile plot.
Figure 55 – Comparison between the laminar and turbulent profiles obtained for a low-resolution mesh.
Note that better results can be achieved by increasing the number of divisions in each direction during the meshing step. Such action will effectively increase the number of cells in the computational domain. However, in this tutorial, only a simple case is presented. The goal is to introduce the engineering professional to CFD. It is worth noticing that even with a low-resolution mesh, valuable information can be estimated.
44
4. Final Remarks The successful completion of this tutorial gives the reader the ability to perform CFD simulations using free, open-source tools. Students are encouraged to visit cited literature for more specific details or a more thorough fluid dynamics refresher when needed. The simulations presented here are simple and some have analytical solutions available like the laminar velocity profile. However, the user can simulate any problem whether a solution or experimental data are available or not. Professionals working in the design of new plant equipment will find CFD an extremely useful tool to predict fluid behavior in their new designs before implementation. The cases presented in this tutorial illustrate that even course meshing leads to reasonable approximations useful in field studies, equipment troubleshooting, and/or design. It is worth pointing that the free-version of HELYX-OS has limited access to OpenFOAM functions. If the reader wishes to use all OpenFOAM capabilities, using it directly is recommended. However, OpenFOAM does not have a graphical interface, and might be challenging to CFD beginners. The free HELYX-OS version is still powerful enough to run a wide set of problems.
45
References Bergman, T; Lavine, Adrienne; Incropera, Frank; Dewitt, D. (2011). Fundamentals of Heat and Mass Transfer. John Wiley & Sons, Inc. Bird, R. Byron; Stewart, Warren E.; Lightfoot, Edwin, N. (2001). Transport Phenomena (2nd ed.). John Wiley & Sons, Inc. Biringen, S.; Chow, C. Y. (2011). An introduction to computational fluid mechanics. John Wiley & Sons, Inc. Biringen, S.; Chow, C. Y. (2011). An introduction to computational fluid
mechanics. John Wiley & Sons, Inc. Collivignarelli, M. C., Carnevale Miino, M., Manenti, S., Todeschini, S., Sperone, E., Cavallo, G., & Abbà, A. (2020). Identification and Localization of Hydrodynamic Anomalies in a Real Wastewater Treatment Plant by an Integrated Approach: RTD-CFD Analysis. Environmental Processes, 7(2), 563–578. https://doi.org/10.1007/s40710-020-00437-4 Fox, Robert; McDonald, Alan; Pritchard, P. (2011). Introduction to Fluid Mechanics (8th ed.). John Wiley & Sons, Inc. Gunjal, P. R., Ranade, V. v., & Chaudhari, R. v. (2003). Liquid distribution and RTD in trickle bed reactors: Experiments and CFD simulations. Canadian Journal
of Chemical Engineering, 81(3–4), 821–830. https://doi.org/10.1002/cjce.5450810365 Journal of Fluids Engineering (JFE). Editorial Policy Statement on the Control of
Numerical Accuracy. American Nuclear Society. Retrieved April 20, 2022, from https://www.nrc.gov/docs/ML0907/ML090780152.pdf Mohammadi, A., Moghaddas, J., & Ariamanesh, A. (2015). Residence Time and Concentration Distribution in a Kenics Static Mixer. Chemical Engineering
Communications, 202(2), 144–150. https://doi.org/10.1080/00986445.2013.832225 Morrison, F. A. (2013). An Introduction to Fluid Mechanics. Cambridge University Press.
46
Moukalled, F., Mangani, L., & Darwish, M. (2016). Fluid Mechanics and its Applications: An Advanced Introduction with OpenFOAM and Matlab (Vol. 113). Springer International. Moukalled, F., Mangani, L., & Darwish, M. (2016). Fluid Mechanics and its
Applications: An Advanced Introduction with OpenFOAM and Matlab (Vol. 113). Springer International. https://doi.org/10.1007/978-3-319-16874-6 Plawsky, J. L. (2014). Transport phenomena fundamentals, third edition. In Transport Phenomena Fundamentals, Third Edition. Potter, M. C., Wiggert, D. C., Shih, T. I.-P., Ramadan, B., & Chhabra, R. P. (2017). Mechanics of Fluids. Cengage Learning. Potter, M., Wiggert, D., & Ramadan, B. (2012). Mechanics of Fuids. Pozrikidis, C. . (2017). Fluid Dynamics: Theory, Computation, and Numerical Simulation (3rd ed.). Springer. Templeton, M. R., Hofmann, R., Andrews, R. C. (2006). Case study comparisons of computational fluid dynamics (CFD) modeling versus tracer testing for determining clear well residence times in drinking water treatment. Journal of
Environmental Engineering and Science, 5 (6), 529–536. https://doi.org/10.1139/S06-007 Tu, Jiyuan; Yeoh, Guan-Heng; Liu, C. (2018). Computational Fluid Dynamics: A practical Approach (3rd ed.). Elsevier Ltd. Versteeg, H., K.;Malalasekera, W. . (2007). An Introduction to Computational Fluid Dynamics: The Finite Volume Method. Pearson Prentice Hall.
47