205-00718 study for the computational resolution of

82
. Grau En Enginyeria en Tecnologies Industrials Andreu Queralt McBride 205-00718 Study for the computational resolution of conservation equations of mass, momentum and energy. Possible application to different aeronautical and industrial engineering problems: Case 60A Asensio Oliva Llena C.D.Perez-Segarra September 2020

Upload: others

Post on 31-May-2022

2 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: 205-00718 Study for the computational resolution of

.

Grau En Enginyeria en Tecnologies Industrials

Andreu Queralt McBride

205-00718 Study for the computationalresolution of conservation equations ofmass, momentum and energy. Possible

application to different aeronauticaland industrial engineering problems:

Case 60A

Asensio Oliva Llena

C.D.Perez-Segarra

September 2020

Page 2: 205-00718 Study for the computational resolution of

I declare that, the work in this Degree Thesis is completely my own work,no part of this Degree Thesis is taken from other people’s work without givingthem credit,all references have been clearly cited.I understand that an infringement of this declaration leaves me subject tothe foreseen disciplinary actions by The Universitat Politecnica de Catalunya- BarcelonaTECH.

Andreu Queralt McBride, september 2020

Page 3: 205-00718 Study for the computational resolution of

Acknowledgements

I would like to thank the people who work at CTTC for giving me theopportunity to do this exciting project, specifically Dr Assensi Oliva and DrCarles-David Perez Segarra, who tutored this project.I would also like to thank Dani Santos Serrano, who in these difficult timeshelped me find and correct errors in my code, as well as shearing results hehad obtained with me so that I could verify mine.

Page 4: 205-00718 Study for the computational resolution of

Contents

1 Project Charter 1

2 Theoretical Background 102.1 Numerical Methods . . . . . . . . . . . . . . . . . . . . . . . . 10

2.1.1 The Need For Numerical Methods . . . . . . . . . . . . 102.1.2 Solving PDEs with Numerical Methods . . . . . . . . . 102.1.3 Discretizing PDEs . . . . . . . . . . . . . . . . . . . . 102.1.4 Types of Mesh and Mesh generation . . . . . . . . . . 122.1.5 Boundary Conditions . . . . . . . . . . . . . . . . . . . 172.1.6 The Gauss-Seidel Method . . . . . . . . . . . . . . . . 182.1.7 The Tri-Diagonal-Matrix-Algorithm [TDMA] Method . 192.1.8 The Line-By-Line-Method . . . . . . . . . . . . . . . . 212.1.9 Other Methods . . . . . . . . . . . . . . . . . . . . . . 22

2.2 Physical Phenomena . . . . . . . . . . . . . . . . . . . . . . . 232.2.1 Steady state Heat Conduction . . . . . . . . . . . . . . 232.2.2 Discretizing the Steady-State Heat Conduction Equation 242.2.3 Transient Heat Conduction . . . . . . . . . . . . . . . . 252.2.4 Convection . . . . . . . . . . . . . . . . . . . . . . . . 272.2.5 Generic Convection Diffudion equation . . . . . . . . . 282.2.6 Two-dimensional coefficients . . . . . . . . . . . . . . . 312.2.7 The Navier-Stokes equation . . . . . . . . . . . . . . . 312.2.8 Radiation . . . . . . . . . . . . . . . . . . . . . . . . . 39

3 The Code 433.1 Functionality . . . . . . . . . . . . . . . . . . . . . . . . . . . 433.2 The general algorithm . . . . . . . . . . . . . . . . . . . . . . 44

3.2.1 Steady-State algorithm . . . . . . . . . . . . . . . . . . 443.2.2 Transient Algorithm . . . . . . . . . . . . . . . . . . . 46

3.3 Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 473.3.1 Material . . . . . . . . . . . . . . . . . . . . . . . . . . 483.3.2 Control Volume . . . . . . . . . . . . . . . . . . . . . . 483.3.3 Mesh . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48

4 Results 484.1 2-D General Convection-Diffusion equation . . . . . . . . . . . 48

4.1.1 1-D case . . . . . . . . . . . . . . . . . . . . . . . . . . 484.1.2 False Diffusion . . . . . . . . . . . . . . . . . . . . . . 494.1.3 The Smith-Hutton Case . . . . . . . . . . . . . . . . . 50

4.2 Navier-Stokes Transient Compressible flow for Newtonian fluids 54

i

Page 5: 205-00718 Study for the computational resolution of

4.2.1 The Couette Flow . . . . . . . . . . . . . . . . . . . . . 554.2.2 Lid-Driven Cavity . . . . . . . . . . . . . . . . . . . . . 60

5 Budget 665.1 Hardware . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 665.2 Work hours . . . . . . . . . . . . . . . . . . . . . . . . . . . . 675.3 Electricity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67

6 Environmental Impact 686.1 Motivation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 686.2 Climate Change in the past . . . . . . . . . . . . . . . . . . . 686.3 Simulation versus experimentation . . . . . . . . . . . . . . . 686.4 This project . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69

7 Future Improvements and Expansions 697.1 Numerical Methods . . . . . . . . . . . . . . . . . . . . . . . . 697.2 Physical Phenomena . . . . . . . . . . . . . . . . . . . . . . . 70

8 Tools used for this project 718.1 Hardware . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 718.2 Software . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71

8.2.1 For Coding . . . . . . . . . . . . . . . . . . . . . . . . 718.2.2 For The Report . . . . . . . . . . . . . . . . . . . . . . 728.2.3 Other . . . . . . . . . . . . . . . . . . . . . . . . . . . 72

ii

Page 6: 205-00718 Study for the computational resolution of

List of Figures

1 Gantt Chart . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9

2 Simple mesh, with nodes at the center of each Control Volume 11

3 piecewise variation . . . . . . . . . . . . . . . . . . . . . . . . 11

4 linear variation . . . . . . . . . . . . . . . . . . . . . . . . . . 12

5 Uniform mesh and one of its control volumes . . . . . . . . . . 13

6 Uniform mesh with nodes at the walls . . . . . . . . . . . . . . 14

7 A non-uniform mesh . . . . . . . . . . . . . . . . . . . . . . . 15

8 Numbering system for each node in the mesh . . . . . . . . . . 16

9 Uniform Mesh (left) Uniform Mesh with nodes at the wall(center) and non-uniform mesh (right) . . . . . . . . . . . . . 17

10 4 ways to sweep a uniform mesh with a line by line solver.Columns right lo left (top left), columns right lo left (topright), rows top to bottom (bottom left) and rows bottomto top (bottom right) . . . . . . . . . . . . . . . . . . . . . . . 22

11 Two-dimensional CV . . . . . . . . . . . . . . . . . . . . . . . 25

12 The implicit, explicit and Crank-Nicolson schemes . . . . . . . 28

13 1-D non-uniform pressure field . . . . . . . . . . . . . . . . . . 32

14 2-D non uniform pressure field . . . . . . . . . . . . . . . . . . 33

15 The staggered mesh. Black dots represent the Pressure nodes,blue arrows the x-velocity nodes, green arrows the y-velocitynodes and the red dots represent the i,j coordinates used inthe program later . . . . . . . . . . . . . . . . . . . . . . . . . 33

16 Stagg-x mesh CV P and it’s neighbouring E,W,N and S nodes.Red dots represent the nodes of the stag-y mesh and blue dotsthe nodes of the main mesh . . . . . . . . . . . . . . . . . . . 37

17 One of the main Mesh CVs. Blue dots represent the nodesfor the stagg-y mesh and red dots represent the nodes of thestagg-x mesh . . . . . . . . . . . . . . . . . . . . . . . . . . . 38

18 Radiation reaching a body and being transmitted, reflectedand absorbed . . . . . . . . . . . . . . . . . . . . . . . . . . . 39

19 An enclosure . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43

20 The steady state algorithm . . . . . . . . . . . . . . . . . . . . 44

21 The transient algorithm . . . . . . . . . . . . . . . . . . . . . 47

22 Comparison of the results with different schemes for P = 5 . . 49

23 Parallel flow without diffusion (left) and with diffusion (right) 50

24 Diagonal flow without diffusion, 100x100 mesh . . . . . . . . . 53

25 Diagonal flow without diffusion, 1000x1000 mesh . . . . . . . . 54

26 The right side of the domain . . . . . . . . . . . . . . . . . . . 54

iii

Page 7: 205-00718 Study for the computational resolution of

27 The velocity for the Smith-Hutton case along the x-axis (left)and y-axis (right) . . . . . . . . . . . . . . . . . . . . . . . . . 55

28 Velocity profile of a Couette flow . . . . . . . . . . . . . . . . 5629 Comparison between the analytical results and the numerical

simulation for the Couette flow for Re = 0.1 . . . . . . . . . . 5630 Top row of the staggered mesh. The green dots are the nodes

of the main mesh, the blue arrows the nodes of the stagg-ymesh and the red arrows the nodes of the stagg-x mesh . . . . 58

31 Starting point for different values of Ny . . . . . . . . . . . . . 5932 Lid-Driven cavity schematic . . . . . . . . . . . . . . . . . . . 6033 Comparison for Re = 100 . . . . . . . . . . . . . . . . . . . . 6134 Comparison for Re = 400 . . . . . . . . . . . . . . . . . . . . 6335 Comparison for Re = 1000 . . . . . . . . . . . . . . . . . . . . 6336 Benckmark results for Re = 100, Re = 400 and Re = 1000 . . 6437 Numerical for Re = 100, Re = 400 and Re = 1000 . . . . . . . 6438 Benckmark, old results and new results for Re = 400 . . . . . 6539 Benckmark, old results and new results for Re = 1000 . . . . . 66

iv

Page 8: 205-00718 Study for the computational resolution of

List of Tables

1 List of Tasks . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53 Boundary conditions for the Smith-Hutton case . . . . . . . . 514 Comparison between the expected and the calculated results . 522 Parameters for the different False diffusion cases . . . . . . . . 535 Results for the Couette flow . . . . . . . . . . . . . . . . . . . 566 Maximum error for different values of Ny . . . . . . . . . . . . 597 Simulation time for different values of Ny for Nx = 3 . . . . . 598 Results for the lid-driven cavity at various Re . . . . . . . . . 629 The cost of the different hardware elements used for this project 6710 Electrical cost of the project . . . . . . . . . . . . . . . . . . 67

v

Page 9: 205-00718 Study for the computational resolution of

1 Project Charter

TFG Project Charter – List of Contents

TFG TITLE: 205-00718 Study for the computational resolution of conser-vation equations of mass, momentum and energy. Possible application todifferent aeronautical and industrial engineering problems: Case 60A

STUDENTS FULL NAME: Andreu Queralt McBride

DIRECTOR FULL NAME: Oliva Llena, Asensio

CO-DIRECTOR FULL NAME: C.D.Perez-Segarra

DELIVERY DATE: 20th March 20201

AIM: The aim of this project is to develop a code capable of solving cer-tain basic problems of heat transfer and computational fluid dynamics in anengineering application.

SCOPE:

• An understanding of the mathematical models that describe the phys-ical phenomena is needed to develop the program. Said phenomenainclude heat transfer by conduction, convection and radiation, andeach will be discussed. How in-depth each is discussed and weatheror not codes are developed to solve particular cases will depend on therelevance each phenomena have on the chosen engineering application.

• In order to write the code, an understanding of numerical methods isalso needed, therefore they will also be discussed.

• A state-of-the-art section will be included, were more advanced con-cepts will be acknowledged, however, they will not be discussed in-depth or used in any of the programs. The goal of this section is toprovide a general idea of what lies beyond the scope of this project.

• Codes will be developed first for simple cases and later improved orgeneralized fit a wider range of cases.

1Pushed back to the 3rd of April 2020 due to the SARS-CoV-2 outbreak of 2019-2020

1

Page 10: 205-00718 Study for the computational resolution of

• Documentation will be provided for all the classes developed for theprogram.

• The environmental impact of this project will be discussed.

• A budget for this project will be provided.

REQUIREMENTS:

• The need to solve problems with numerical methods and a brief historyof computational fluid dynamics will be provided.

• At least two ways to solve partial differential equations numerically willbe introduced, however, only one is required to be implemented.

• The final program will be coded in the C++ programming language.

• The program[s] will require the user to input geometric, physical andnumeric data to solve the given problem.

• The manner in which the data is introduced is left to the author’sdiscretion and may vary depending on the nature of the problem andof the data that is introduced. Examples of how data can be introducedare via console applications, .txt, .csv, .pbm, .ppm files or any otherway the author deems necessary.

• Similarly, the manner in which the results are presented is left to theauthor’s discretion.

• Different classes will be created and used.

• The classes will be separated into two distinct groups, some will haveattributes and methods related to the physical aspects of the problemsand others to the numeric aspects of the problems. 2

• An annexe to the report will include documentation for all the classesdeveloped for the final program.

• All codes developed for this project will be verified by comparing theresults obtained with known analytical solutions when possible or bychecking if certain properties are conserved.

2This is done so that the same code can be reused multiple times, for instance to solve asystem of equations, situation that is will be encountered in most if not all of the problems

2

Page 11: 205-00718 Study for the computational resolution of

• All classes created for this project will be new, and no pre-made algo-rithms may be used except to verify the newly written code.

• Pre-made algorithms that do not directly solve the problems are al-lowed. 3

• Efforts will be made to make all codes as efficient as possible whilealso making them as clear and easy-to-understand as possible. Carefulplanning of each class or function will be done beforehand and if differ-ent options are considered, a justification will be provided on why onewas chosen over the other.

• All assumptions made in each case will be clearly stated at the begin-ning of the section in which they are discussed.

• All figures, graphs, tables and other graphic elements included in thefinal report and the annexes will be created specifically for this projectexcept for comparison purposes or otherwise stated.

• As well as the bibliography and the lists of figures and tables, a list ofall the computer programs used to make this project will be included.What each program was used for will also be specified.

BACKGROUND: As will be discussed in further detail later on, it iscurrently impossible to solve most partial differential equations, especiallythose that are non-linear. Unfortunately, those are the kind of equationsthat describe the world around us, and therefore their resolution is key toscience and engineering. Numerical methods are a way around this problem,and offer solutions to specific problems. Unfortunately, these methods areusually iterative and take a long time to provide a solution. It is also veryhard to find the optimal solution to a given problem.

Many efforts have been made to make the numerical resolution of problemsas quick and precise as possible, and many commercial products exist ded-icated to simulating different systems. They offer the possibility to solve awide range of problems in many different fields.This project will centre around heat transfer and one specific application.The usefulness of the project is rather limited in terms of offering an efficientway to solve the problems that will be considered, and is centred more onfurthering the authors knowledge and understanding of the studied concepts.

3Examples of libraries or functions that are allowed are math.h, vector, hashmap inC++ or quiver in Matlab. An example of a function that is not allowed is ode45 in Matlab

3

Page 12: 205-00718 Study for the computational resolution of

This project is, in a way, a continuation of a project the author did previ-ously4. That project, however, consisted only in solving the two-dimensionalheat conduction steady-state problem with several materials. That projectused a Gauss-Seidel solver. The data input was made via three text doc-uments named ”fis”, ”num” and ”mat” located in the same folder as theprogram. The first listed the physical properties of the materials and bound-ary conditions (with constant and known heat transfer coefficient) as wellas the length of the wall (which due to an unfortunate error in the programhad to be a square). The second had numerical data (such as the numberof nodes, which due to the same unfortunate error as before had to be thesame in the x and y axis), the maximum number of iterations allowed therelaxation factor and the desired accuracy from the solutions. The last filehad a series of characters each one corresponding to a node on the mesh anda material was assigned to the mesh in function of what the character was.That program was poorly designed and inefficient in many aspects. No classeswhere used and all functions where declared, defined, and used in the samefile.Needless to say, considerable effort will be put into ensuring that the newproject is better in every possible way to the last.

CALENDAR: Due to the nature of the project, it is complicated to definea calendar with much precision. However, an effort will be made to identifythe tasks that are to be completed and their duration.In general, the tasks can be divided into three categories, theoretical back-ground, programming and making of the report. The theoretical backgroundtasks will be mostly focused on studying the laws that govern the physicalphenomena and the numerical methods used to solve them. The program-ming tasks will involve initial planning of the program, writing the code,debugging the code and verifying the code. The making of the report willconsist in writing the report and all other necessary documents from thefindings in the previous categories, editing the report and other documentsto ensure clarity and the corrections of any errors that may have made theirway into it and as many revisions as necessary to ensure all documents areerror free.

4For the compulsory course 220111 - Termotecnia

4

Page 13: 205-00718 Study for the computational resolution of

Specifically, the tasks will be:

Table 1: List of Tasks

Tasks to be Completed

Task Category Task IDComesAfter

Description TimeEstimate

SourceGathering

General Task GT1 –

Gathering all thenecessary sources

necessary to completethe project, both inphysical and digital

medium.

Durationof the

Project

TheoreticalHeat Con-

duction

TheoreticalBackground

TB1 –

Compiling all therelevant informationabout the topic ofheat conduction.

One week

TheoreticalConvec-

tion

TheoreticalBackground

TB2 TB1

Compiling all relevantinformation on

convection. This is avery wide category,

and many topics willhave to be studied,

and only thoserelevant to the chosen

engineeringapplication (and any

necessary tounderstand those)will be considered.

FourWeeks

TheoreticalRadiation

TheoreticalBackground

TB3 TB2

Compiling all relevantinformation on

radiation. Only thosespecific topic that arerelevant to the chosen

engineeringapplication will be

considered.

ThreeWeeks

5

Page 14: 205-00718 Study for the computational resolution of

TheoreticalNumericalMethods

TheoreticalBackground

TB4 –

Compiling all relevantinformation on thenumerical methods

used to solve partialdifferential equations.

ThreeWeeks

Planningclasses 1

Programming P1 TB4

Planning all classes,with their attributesand methods neededto solve a system o

equations numerically

One Week

Coding 1 Programming P2 TB4Code and test the

classes planned out inthe previous task.

One Week

Debugging1

Programming P3 TB4Debug the methods

and test functions forthe classes.

One Week

Planningclasses 2

Programming P4

P3,TB1,

TB2 &TB3

Planning all classes,with their attributesand methods neededto generate a systemof equations for heatconduction, differentconvection problems

and radiation

SevenWeeks

Coding 2 Programming P5

P3,TB1,

TB3 &TB1

Code and test theclasses planned out in

the previous task.

SevenWeeks

Debugging2

Programming P6

P3, ,TB1,

TB2 &TB3

1 Debug the methodsand test functions for

the classes.

SevenWeeks

6

Page 15: 205-00718 Study for the computational resolution of

Planningclasses 3

Programming P7 P6

If necessary existingclasses will be

modified and newclasses have to becreated in order to

code the finalprogram for the

chosen engineeringapplication

ThreeWeeks

Coding 3 Programming P7 P6Code and test the

final program.ThreeWeeks

Debugging3

Programming P8 P6Debug the final

program.ThreeWeeks

EnvironmentalImpact

General Task GT2 P6

Once the project iscompleted it’s

environmental impactwill be assessed

Durationof the

Project

Budget General Task GT3 P6Once the project iscompleted a budgetwill be calculated

Durationof the

Project

First Draft Writing W1 –

Writing the reportwith all the necessary

theoreticalbackground,

definition of theproblems, to solve,state-of-the-art and

commenting theresults

Durationof the

Project

7

Page 16: 205-00718 Study for the computational resolution of

Revision Writing W2 W1

Correction of any andall mistakes present

in the report prior toits completion. Thistask will be repeated

as many times asnecessary to ensure

all mistakes are foundand corrected

FinalWeeks

ClassDocumen-

tationWriting W3 P3

Documentation for allclasses created for the

project will bewritten, specifyingthe attributes and

methods of theclasses as well as their

visibility

Fromcompletionof P3 anduntil theproject iscomplete

While not specified, many tasks can be done simultaneously. The Ganttchart in figure 1 shows how the project has been scheduled . It is worthnoting that task TB1 is not present, and tasks TB2 and TB4 have a shorteramount allocated to them than what has been established in table 1. That isbecause those tasks have begun or been completed as of the 20th5 of March2020. Likewise, week one corresponds to the week of the 30th of march. Theproject’s deadline is June 30th, which is the Tuesday of the 15th week. Sincethat week only has two days, it was not included in the chart.

5The original delivery date of the project charter, pushed back to the 3rd of April dueto the SARS-CoV-2 pandemic of 2019-20

8

Page 17: 205-00718 Study for the computational resolution of

Figure 1: Gantt Chart

9

Page 18: 205-00718 Study for the computational resolution of

2 Theoretical Background

2.1 Numerical Methods

2.1.1 The Need For Numerical Methods

Most physical phenomena are modelled with partial differential equations(PDEs) or systems of PDEs. Unfortunately, those equations are often im-possible to solve analyticity, except for simple geometries, and that is notenough for most of the problems in science and engineering. These problemsencompass a wide range of topics in engineering alone, such as heat transferand fluid flow (which is what this project will focus on), structural analysis,circuit analysis, electromagnetic analysis and many others. Beyond engineer-ing there is no shortage of topics that suffer the same problem.With the impossibility to solve problems analytically, two options arise: toeither solve the problems experimentally (which can become very expensivevery quickly, and due to the ”trial and error” nature of the experimentation,results are not guaranteed) or try to find an alternative way to solve thePDEs that define the problem. The finite element method (FEM). FEM waspioneered in the 1950s, mostly by the aerospace industry. Initially it was metwith scepticism, and it wasn’t until the 1960s that mathematicians provedthat the solutions to obtained with FEM converged to the actual solutionsof the PDEs, if implemented correctly[11].

2.1.2 Solving PDEs with Numerical Methods

Put simply, four steps are necessary to solve a PDE or a system of PDEswith FEM. Those steps are discretization the equations, generating a mesh,generating a system of linear equations and finally implementing a solver tosolve said system. The problems in most applications tend to have a greatnumber of equations in the system, thus the only way to solve it is with acomputer.

2.1.3 Discretizing PDEs

The approach used to solve a PDE that models the behaviour of a certainproperty of interest (temperature, pressure, species concentration...) for agiven geometry is to ”slice” the geometry in small parts, called control vol-umes. To illustrate this concept, most figures in this section will considertwo-dimensional cases, however it’s important to note that the same prin-ciples can be extended easily into three dimensions. To start, a simple ge-ometry will be considered, namely a rectangle. Despite it’s simplicity, many

10

Page 19: 205-00718 Study for the computational resolution of

problems cannot be solved analytically for a two-dimensional rectangle, suchas the temperature distribution, even if only conduction is present. Therectangle in figure 2 has been divided into smaller rectangles. The PDE orPDEs are then integrated for each control volume. A node is located at thecentre of each Control Volume (for now) the property of interest at each ofthe nodes will be the unknowns in the system of equations that will have tobe solved. An important consideration when discretising the PDE is how the

Figure 2: Simple mesh, with nodes at the center of each Control Volume

property of interest varies between nodes. One possible assumption is thatthe value of the property is constant throughput the entire control volume, sothat when represented in a graph it appears to be defined piecewise. Figure14 shows such a case. Another possible assumption is that the property willvary in a linear fashion between one node and the next see figure ??. Manyother assumptions are possible and will be discussed later. That will becomerelevant when evaluation Φ at the wall between two CVs in the convectiveterm of the general convection-diffusion equation.

Figure 3: piecewise variation

11

Page 20: 205-00718 Study for the computational resolution of

Figure 4: linear variation

There are two other important things to note, first, that the equations arediscretised not only for the geometry (for the mesh shown in figure 2 thatwould mean the x and y axis) but also in time, if unsteady terms are presentin the PDE. The second important thing to note is that different assumptionscan be made for different terms of the PDE. For example, in equation 1 itwould be valid that the generic property Φ is constant for all the ControlVolume in the x direction, changes linearly in the y direction and changes insome other fashion in time.

αδΦ

δt+ β

δΦ

δx+ γ

δΦ

δy= f(x, y, t) (1)

2.1.4 Types of Mesh and Mesh generation

Broadly speaking there are two types of mesh, structured meshes (uses forcomputational fluid dynamics) and unstructured meshes (useful for compu-tational solid dynamics). The first type will be used throughout this project.Some of the main features of a mesh are discussed in the following examples:

1. Uniform Mesh:Figure 1 shows a simple, uniform mesh. Each of the black dots repre-sents a node, which is the point were the properties of interest will beevaluated. Each node is located at the centre of a square. That squareis the control volume. When studying one node in particular, that nodeis usually referred to as node P. Since the control volume is square eachnode will have up to four neighbouring control volumes (unless is thecontrol volume is located at one of the four edges or corners of thedomain). These control volumes are usually referred to as the north,south, east and west control volumes. The node at the centre of eachof those CVs are referred to as N, S, E and W. The surfaces of CV P

12

Page 21: 205-00718 Study for the computational resolution of

are named n, s, e and w. The mesh from figure 1 has length L and

Figure 5: Uniform mesh and one of its control volumes

height H, which are shown to be the same, however that need not bethe case. Let Nx be the number of nodes along the x-axis and Ny bethe number of nodes along the y-axis, then the separation between twoneighbouring nodes ∆x and ∆y is:

∆x = LNx

∆y = HNy

(2)

In a uniform mesh those values will be constant. Each of the surfacesat the faces of the CV will also be ∆x or ∆y.While the uniform mesh is the simplest possible two-dimensional meshit will not be used in this project. A variation of it will be used for themajority of the problems, and is discussed below.

2. Uniform Mesh With Nodes at the Walls:This mesh is similar to the uniform mesh, but additional nodes havebeen added at the walls of the domain. For this project, these nodes willbe used to establish the boundary conditions of each problem. Threetypes of boundary conditions will be used, all of which will be discussedat a later time. The main difference of this mesh with respect to the

13

Page 22: 205-00718 Study for the computational resolution of

one previously discussed is that ∆x and ∆y are now not the same forall nodes, and may not be the same in every direction (that is, thevalue for ∆x from P to E is not necessary the same as it is betweenW and P) additionally, the surface of each face will also be different.When writing a code to generate a mesh, if else statements or a switchcases will be necessary to compute them.

Figure 6: Uniform mesh with nodes at the walls

3. The Staggered Mesh:Sometimes one mesh is not enough to solve a problem. One such caseis the transient Navier-Stokes equation for incompressible Newtonianfluids. This case (which will be solved later on) requires not one, butthree meshes, all coexisting within the same domain. Why this mesh isnecessary and how exactly it is defined will be discussed when discussingthe Navier-Stokes equation.

4. Non-Uniform Meshes:In CFD, two distinct flows appear. One is the flow near a wall or solid,there a boundary layer is formed and the fluid behaves differently. Thefree flow occurs when the fluid is far from any solid. In the formerscenario a finer mesh is desirable, where as in the latter a coarse meshwill yield satisfactory solutions 6. If both flows coexist in one problem

6Except for high Reynolds numbers, in which case turbulence appears and a much finer

14

Page 23: 205-00718 Study for the computational resolution of

then one must face the choice to either have a coarse mesh that willnot provide good results or use a finer mesh that will inevitably resultin a longer computation time. A fairly straightforward solution exists:Make a mesh such that ∆x and ∆y are not the same for all CVs. Thatis done with a stretching function. An example of a stretching functionwill be provided later. Figure 4 shows a mesh where the nodes alongthe x-axis have a non uniform distribution, concentrated mostly at thewalls, leaving the centre of the mesh with a coarser grid.

Figure 7: A non-uniform mesh

5. General Comments: When solving a problem it is important to knownot only the number of CVs and each of their surfaces and distanceto their neighbouring nodes but also the position of each node. Forthat, Cartesian coordinates are used in this project. A pair of numbersi, j is also assigned to each CV, as shown in figure 5. For uniformmeshes (including those with nodes at the walls), this calculation isvery straightforward. Assuming node (0, 0) is located at point (x0, y0)

mesh is needed.

15

Page 24: 205-00718 Study for the computational resolution of

Figure 8: Numbering system for each node in the mesh

then each node (i, j) will be located at the following position:

x(i,j) = x0 + 2i−12

∆x ∀i ∈ (0, Nx)

y(i,j) = y0 + 2j−12

∆y ∀j ∈ (0, Ny)

x(i,j) = x0 ∀(i = 0, j)

x(i,j) = x0 + L ∀(i = Nx, j)

y(i,j) = y0 ∀(i, j = 0)

y(i,j) = y0 +H ∀(i, j = Ny)

(3)

For non-uniform meshes, a stretching function is used. Consider all thenodes along the x-axis, from (i = x0, j) to (i = xNx , j). To distributeall each node i between the two positions i = 0 and i = Nx a stretchingfunction s takes the form is:

xi = x1 + si(x1 − x2) (4)

An example of a stretching function is shown in equation 5.

si = 1 +tanh[k(i/Nx − 1)]

tanh(k)(5)

Where k is a factor that determines how concentrated the nodes are onone side or another.

16

Page 25: 205-00718 Study for the computational resolution of

6. Non-Carteesian Meshes:Until now, all discussion on meshes has been applied to meshes inCartesian coordinates, however other types of meshes also exist, suchas meshes in cylindrical coordinates. All of the principles discussedpreviously still apply (uniform, with nodes at the edges, staggered,non uniform). Figure 9 shows said meshes.

Figure 9: Uniform Mesh (left) Uniform Mesh with nodes at the wall (center)and non-uniform mesh (right)

2.1.5 Boundary Conditions

Boundary conditions are necessary to solve any problem with a numericalmethod. In this project thee types of boundary conditions will be imple-mented, Dirilecht boundary conditions, Neumann and parallel flow. Bound-ary conditions will be given at each wall of the domain (in the meshes shownin the previous section those would correspond to i=0, i = Nx, j = 0 and j= Ny). Additional boundary conditions will be necessary if there is a solidsummered in a fluid.

1. Dirilecht Boundary Conditions:The simplest boundary conditions possible, the value of the variablebeing solved (generically Φ) is known at the boundary in question. Theprogram will then use these known values to calculate the distributionof Φ within the domain.

2. Neumann Boundary Conditions: The Neumann boundary have a knownflux of Φ. That flux can then be used to calculate the value of Φ atthe wall. Sometimes the flux is known directly and other times it hasto be calculated.

3. Parallel Flow:In this case, the flow of Φ is normal to the wall. To ensure that, Φwall

is set to be equal to Φwall−1.

17

Page 26: 205-00718 Study for the computational resolution of

How each condition is implemented in the code will be discussed when theequations are discretized, since enforcing these restrictions results in alteringthe value of certain coefficients.

2.1.6 The Gauss-Seidel Method

In two-dimensional problems, we often encounter the following system oflinear equations:

apφp = aeφe + awφp + anφn + asφs + bp (6)

The easiest way to solve this system is the Gauss Seidel method. This methodrequires the user to enter an initial value of φ at each node, as well as aconvergence criteria for the solution. Then each node has to be visited andits value of φ updated as follows:

φp =aeφe + awφp + anφn + asφs + bp

ap(7)

Each time the value of a node is updated the absolute value of the differencebetween the new φ and the old φ must be evaluated. Once all the nodesin the mesh have been visited, the maximum difference is compared to theconvergence criteria of the results. If it is smaller, then the results are satis-factory. If, however, the difference is larger, the mesh has to be revisited overand over again until the difference becomes lower than the precision. Manyiterations may be necessary to reach the desired result.Each ”sweep” of the mesh is called an iteration. It is desirable to solve aproblem with the least amount of iterations possible. There are several waysto ensure the problem is solved quicker.

• The first and most obvious way is to make a coarser mesh, that isto reduce the number of nodes. That will make the sweeps across itquicker. However, one must be careful, since the mesh has to be fineenough to ensure satisfactory results. A coarse mesh however can haveits benefits, since it can be used to get a ”feel” for what the solutionmight be and to check if the program is good. Additionally, theseresults can be used to set the initial conditions for later simulations.

• Chose a ”good” starting point. The choice of initial φ can be donearbitrarily, however, if some thought is put into what value will be thebest, the system can be solved much quicker. For instance, one coulduse the value of φ at the one of the boundary conditions as the initialvalue, or perhaps the average value of all surrounding initial conditions.

18

Page 27: 205-00718 Study for the computational resolution of

Another option is to take that average value as a starting point and thenmodify it. For example, in a heat condition problem with an internalheat source a higher temperature could be an option. It is also worthremembering that not all nodes need to have the same initial value, aweight average of the boundary conditions could be used, setting theweight of each boundary condition to be proportional to the distanceto the node.

• Reduce the convergence criteria of the results. If for the purpose of theproblem an accuracy of 10−5 is ”good enough” don’t set the accuracyto 10−10, since computational time increases greatly for each order ofmagnitude the convergence criteria is reduced.

• Specify a maximum number of iterations. If the input data is somehowflawed, or the program has an error in it, the desired precision is justtoo much or other similar problems occur, this number will preventthe program from running indefinitely. If this number of iterations isreached then the program stops and presents the results as they are,even if the required precision is not met (obviously that fact must bemade clear to the user).

2.1.7 The Tri-Diagonal-Matrix-Algorithm [TDMA] Method

In one-dimensional systems, a typical system of linear equations to be solvedwill be:

apφp = aeφe + awφw + bp (8)

Where φn is the property of interest and node n and all four coefficientsare known. Equation 8 is written assuming the φ varies in the x direction. Ifφ were to change in the y direction the equations would be the same exceptthat nodes n and s would be considered instead of nodes e and w. For now,we assume a variation in the x direction. It’s important to note that forthe first node of the domain, aw = 0, and similarly in the last node of thedomain ae = 0. In later sections, when specific equations are discretised, itwill become apparent why. However means that if equation 8 is rewrittenin matrix form and consider the matrix of coefficients A for a system of 5nodes:

ap1 ae1 0 0 0aw2 ap2 ae2 0 00 aw3 ap3 aw3 00 0 aw4 ap4 ae40 0 0 aw5 ap5

(9)

19

Page 28: 205-00718 Study for the computational resolution of

Which has non-zero value on the main diagonal as well as the diagonalsimmediately above and below it. All the other terms are zero. Such a systemcan be solved with the Tri-Diagonal-matrix-Algorithm, explained below.With equation 8 we need to know the value of φ at either side of the currentnode to solve φ for that node, however, it would be continent if we couldsolve for φ knowing its value on one of it’s neighbouring nodes, as seen in 10.

φp = Ppφe +Qp (10)

From equation 10 it follows that:

φw = Pwφp +Qp (11)

Combining equations 8 and 11 results in:

apφp = aw(Pwφp +Qp) + aeφe + bp (12)

Which can be easily rearranged into:

φp =ae

ap − awPwφe +

awQp + bpap − awPw

(13)

Comparing 13 with 10, we realize that:

Pp =ae

ap − awPw(14)

and

Qp =awQp + bpap − awPw

(15)

We notice that Pp depends on Pw and that Qp depends on both Pw andQw, however, since the first node has no western node, equations 14 and 15become 16 and 17 respectably.

Pp =aeap

(16)

and

Qp =bpap

(17)

Since all coefficients are known, Pp1 and Qp1 can be calculated. From there,the coefficients for all the other nodes can also be calculated.Now that all the coefficients are known, notice the last node. Since that nodehas no eastern node, equation 10 becomes:

φp = Qp (18)

20

Page 29: 205-00718 Study for the computational resolution of

Since all coefficients are known and φp for the last point is also known.Equations 10 can be solved for the penultimate node, and then the onebefore that and all the way to the first node, and thus the system is solved.Unlike the Gauss-Seidel method, TDMA does not require an initial map forφ, and it solves the system directly, no iterations are required. Additionally,the system is solved with machine precision. The obvious drawback is thatit only works for one dimensional systems.

2.1.8 The Line-By-Line-Method

The line by line method is a way an extension of the TDMA method, butused in two dimensional meshes (or three dimensional, but that case won’tbe considered). Since direct methods in two and three dimensional cases arecomplicated and require a lot of memory, yet iterative methods are very timeconsuming, the line by line method offers somewhat of a compromise.The method solves the system defined in equation 6 for all the mesh, howeverit solves each line (which can be either rows or columns) with a TDMA.Assume a two dimensional problem need solving with the line by line method,specifically one column at a time. Then, assume that the values of φ for theeastern and western nodes of p are known (despite being initial guesses). bpfrom equation 8 becomes:

bpTDMA = bp + awφw + aeφe (19)

And the values of φ for that column are solved as described previously. Oncethe first column is solved then the next one is also solved and then the nextuntil all columns have been solved. However, since the initial values of φ wereassumptions, the next step is to check if the maximum difference betweenthe new φ and the old φ is smaller that the convergence criteria. If it is not,then the values of each column have to be recalculated again. However, thenext iteration does not have to be in the same direction as the last. Forexample, if in the first iteration the columns were solved from left to rightthen now perhaps they can be solved from right to left. Or instead of solvingby columns, the system can be solved by rows (which in turn can go eithertop to bottom or bottom to top). The question then is how to solve thesystem most efficiently. While it’s not always possible to know the best wayto ”sweep” the mesh, a good rule for systems involving fluid flow is to go frominlet to outlet, since the conditions at the inlet are known but at the outletthey are unknown. Figure 2.1.8 shows the four proposed sweep patters.

21

Page 30: 205-00718 Study for the computational resolution of

Figure 10: 4 ways to sweep a uniform mesh with a line by line solver. Columnsright lo left (top left), columns right lo left (top right), rows top to bottom(bottom left) and rows bottom to top (bottom right)

2.1.9 Other Methods

Since the resolution of systems of equations with many unknowns is so im-portant in many different fields, a lot of different solvers have been proposedto solve these systems in the most efficient way possible. One such method isthe conjugate-gradient method. The approach that method takes will now bedescribed, however the method itself will not be explained nor implemented.Consider the following function:

f(x) =1

2~xTA~x−~bT~x+ ~c (20)

And its derivative:

f ′(x) = A~x−~b (21)

Where x and b are vectors and A is a symmetric matrix. Equation 20 doesnot look familiar at all, however, equation 21 is the system of linear equationsto be solved. It can be shown[5] that if A is positive-define, then equation21 minimizes equation 20. To better visualize this consider the simple casewere a is a 2x2 matrix. Then the system describes a parabolic surface (if A

22

Page 31: 205-00718 Study for the computational resolution of

is positive define). Where as its minima will be located at the solution ofthe system of linear equations. Additionally, the derivative of a function isa vector in the direction of steepest increase. That means that if we set astarting position (x1, x2) and follow along the opposite direction of the vector,then we will get closer to the minima and thus to the solution of the system.Then another step can be taken in the direction pointed by the derivativeat that point and get even closer. The conjugate gradient method proposesa way to do that in the least amount of steps possible (for an MxM systemM steps would be required). Theoretically one each step has beet taken, thesolution is reached, needing only one iteration to solve the system.

2.2 Physical Phenomena

2.2.1 Steady state Heat Conduction

Transfer of energy in the form of heat conduction occurs whenever a physicalmedium is present, regardless of the state the matter is in, however, in liquidsand gasses convection is also present (and is more important) when there isa fluid flow in the domain (if the fluid was completely static there would onlybe conduction, however if there is a temperature gradient in the fluid therewill always be a flow in the presence of a gravitational field).The equation that describes heat conduction is Fourier’s law, which is basedon physical observations. The first of these observations is that heat flowsfrom regions at a higher temperature to regions at a lower temperature. Ad-ditionally, the heat flow is proportional to the temperature gradient, that isthe greater the temperature difference is the greater the heat flow magnitudewill be. Let q be the heat flow and ∇T the temperature gradient along adomain and k(T, x, y, z) the thermal conductivity.

~q = −k∇T (22)

While the equation is valid for three-dimensional cases, for this project onlyone and two dimensional cases will be considered.

1. A comment on the thermal conductivity:While the thermal conductivity can depend on the direction of the ma-terial, most materials are homogeneous, so those changes are insignifi-cant and thus only changes with temperature need be considered.As for the changes in temperature, most materials have different con-ductivity when their temperature changes. Finding an expression forhow it changes cannot be done analytically, and we must rely on labora-tory experiments to determine that temperature dependence. However,

23

Page 32: 205-00718 Study for the computational resolution of

the range of temperatures the solid can take in one specific problemmust also be considered.. For instance, imagine a two dimensionalsquare that does not have any internal heat sources or sinks, and issurrounded by gasses at 273K on two sides and 300K on the other twosides. Then, the temperature within the plane will be bounded betweenthese two values. That means that the model for the thermal conduc-tivity can be simpler. Perhaps it can be considered constant betweenthese two values. In other cases, a linear variation can be considered.

k(T ) = A+BT (23)

In fact, more complicated models will only be necessary if the thetemperature gradient is of hundreds of degrees. [1]

With Fourier’s law and the first that the heat conduction law becomes:

∇k∇T + q = ρcδT

δt(24)

However, if the variation of k with T is weak, it can be taken out, and thusequation 24 becomes:

k∇2T + q = ρcδT

δt(25)

However since for now only steady-state conduction is being considered, thetransient term is set to zero. And equation 25 becomes:

k∇2T + q = 0 (26)

2.2.2 Discretizing the Steady-State Heat Conduction Equation

In Cartesian coordinates, the two-dimensional version of equation 26 is:

k(δ2T

δx2+δ2T

δy2

)+ q = 0 (27)

Which has to be integrated along a generic control volume at one of thecentral nodes (see figure 11).

k∫Se

δT

δxdS + k

∫Sw

δT

δxdS + k

∫Sn

δT

δydS + k

∫Ss

δT

δydS + k

∫SqdS = 0 (28)

The result of the integration can be seen in equation 29, which assumes alinear variation of T along both directions.

kTe − Tp∆xp−e

Se + kTp − Tw∆xp−w

Sw + kTn − Tp∆yp−n

Sn + kTp − Ts∆yp−s

Ss + qSp = 0 (29)

24

Page 33: 205-00718 Study for the computational resolution of

Figure 11: Two-dimensional CV

Equation 29 can be rearranged into:

apTp = aeTe + awTw + anTn + asTs + bp (30)

Where:an = k Sn

∆xp−n

as = k Ss

∆xp−s

ae = k Se

∆yp−e

aw = k Sw

∆yp−w

ap = an + as + ae + aw

bp = qSp

(31)

Equation 29 can be solved with either the Gauss-Seidel or the Line-by-Linemethod. However, boundary conditions have to be considered, since thecoefficients shown in 31 will not be the valid for all nodes. In general, for atwo dimensional domain there are nine types of nodes. The northern nodes,the southern nodes, the eastern nodes, the western nodes, the north-eastnode, the north-west node, the south-east nod, the south-west node and thecentral nodes.

2.2.3 Transient Heat Conduction

Recalling equation 25:

k∇2T + q = ρcδT

δt(32)

25

Page 34: 205-00718 Study for the computational resolution of

Where only the transient term remains undiscretized. Since each term canbe discretized separately (and using different schemes) focus is now set onthat term which is integrated over time as well as the x and y directions.Afterwards, the remaining terms will be integrated over time.

ρc∫ n

s

∫ e

w

∫ t+∆t

t

δT

δtdtdxdy = ρc∆x∆y(Tp − T 0

p ) (33)

Where the superindex 0 represent the values of T at times n and no su-perindex represents the values of T at times n + 1. Time integration of thepreviously discretized k∇2T term is as follows:

∫ t+∆t

t

[keTE − TPdPE

− kwTP − TWdPW

+ knTN − TPdPN

− ksTP − TSdPS

]dt (34)

In general, each Ti will be integrated as follows:∫ t+∆t

tTidt = [fTi + (1− f)T 0

i ]∆t (35)

Where f can take any value from 0 to 1. And i represent each of the cardinalpoints N,S,E and W . The fully discretized equation is now:

ρc∆x∆y

∆t(Tp−T 0

p ) = f[keTE − TPdPE

−kwTP − TWdPW

+knTN − TPdPN

−ksTP − TSdPS

]+(1−f)

[keT 0E − T 0

P

dPE−kw

T 0P − T 0

W

dPW+kn

T 0N − T 0

P

dPN−ks

T 0P − T 0

S

dPS

](36)

By varying f the profile of temperature Ti from time t to time t+ ∆t changesto. Three such schemes are presented now:

1. Explicit Scheme (f = 0)Using this scheme, equation 36 becomes:

ρc∆x∆y

∆t(Tp−T 0

p ) = (1−f)[keT 0E − T 0

P

dPE−kw

T 0P − T 0

W

dPW+kn

T 0N − T 0

P

dPN−ks

T 0P − T 0

S

dPS

](37)

With the explicit scheme, temperature TP depends only of the tem-peratures T 0

P , T0N , T

0S , T

0E and T 0

W , which are all known. Thus one thetemperatures for the first instant are known, all others can be calcu-lated without an iterative process. Unfortunately, if the time step isto large, it can be shown [1] that the results can be physically unreal-istic. Criteria exist to set a time step such that results will always berealistic, however, when applying those criteria:

∆t ∝ ∆x2,∆y2 (38)

26

Page 35: 205-00718 Study for the computational resolution of

An unfortunate consequence of these criteria is that when increasingthe spatial resolution of the mesh, the temporal resolution is increasedby the square of the minimum spatial increment. The result is an in-crease in computing time.

2. Implicit Scheme (f = 1)Using this scheme, equation 36 becomes:

ρc∆x∆y

∆t(Tp−T 0

p ) = (1−f)[keTE − TPdPE

−kwTP − TWdPW

+knTN − TPdPN

−ksTP − TSdPS

](39)

In this scheme the temperature Tp at time n+1 depends on the temper-ature of the same node at time t and the temperature at time n+ 1 ofit’s four neighbouring nodes. This scheme requires an iterative methodto solve the system at every timestep. This scheme provides good re-sults even for larger Time steps. However, for small time steps theCrank Nicolson scheme gives better results.

3. Crank Nicolson Scheme (f = 0.5)This scheme uses the temperatures of node P and its neighbouringnodes at times n and n+. With small time steps it gives better results,however when the time step increases, the results are oscillations.

Figure 12 shows the evolution of T in time with the different schemes. Theexplicit scheme is equivalent to assuming the temperature of P is constanttrough the time steps and then suddenly changes. The implicit scheme as-sumes the change happens suddenly at the beginning of the time step andthen the temperature remains constant. The Crank-Nicolson scheme is equiv-alent to assuming a linear variation in time between the two temperatures.

2.2.4 Convection

Convection is the second method by which heat conduction occurs. Like con-duction it requires a solid medium. In this case however, heat is transporteddue to a flow of mass. The next sections present the generic convection dif-fusion equation, which allows to calculate the propagation of a property fora given fluid flow. Then the Navier-Stokes equation for incompressible New-tonian fluids will be solved using the fractional step method to find fluid’spressure velocity fields.

27

Page 36: 205-00718 Study for the computational resolution of

Figure 12: The implicit, explicit and Crank-Nicolson schemes

2.2.5 Generic Convection Diffudion equation

The generic convection diffusion equation is used to describe a wide varietyof physical phenomena. Propagation of chemical species, enthalpy and manyothers. Here the property that is being transmuted will be denoted by thegeneral variable φ

δ(ρφ)

δt+∇(ρ~vφ) = ∇(Γφ∇φ) + sφ (40)

Where Γφ is φ’s diffusion coefficient and sφ is its source term. Like the con-duction equation, the convection-diffusion equation also has a source term,a transient term and a diffusion term. This time, however, the convectionterm is added. The other three terms can be discretized the same way theywere in the previous case. The convective term however requires furtherstudy. First, with the continuity equation, equation 40 can be rewritten forincompressible flows to be:

ρδφ

δt+ ρ~v∇φ = ∇(Γφ∇φ) + sφ (41)

As is with most PDEs, the general convection diffusion does not have ananalytical solution except for very specific cases. One such case is the steadystate one-dimensional transport of φ in absence of a source. By computingsaid solution for certain values and comparing it to the results obtained usingdifferent discretization schemes, it is possible determine which schemes arebetter. Now, the exact solution and four different schemes will be presented.

28

Page 37: 205-00718 Study for the computational resolution of

1. The exact solution:The case which has an analytical solution is defined by the followingPDE:

ρvxδφ

δx= Γφ

δ2φ

δx2(42)

And it’s solution is:

φ− φ0

φL − φ0

=exp(Px

L)− 1

exp(P )− 1(43)

Where L is the length of the domain, 0 represents it’s origin and P isthe Peclet number, a dimensionless number that gives the ratio betweenthe strength of the convection and the diffusion. A value of 0 (whichcould logically only be caused by the absence of a flow) implies thatonly diffusion is present. Large positive or negative numbers on theother had indicate that the convection term is more relevant than thediffusion term.

2. The exponential Scheme:This scheme is based on the exact solution and yields the same result. Itpresents, however, many drawbacks which make it unfit for use in otherproblems. First of all, exponentials are required to calculate the ae andaw coefficients. Such an operation requires more time and memory onthe computer than simple multiplications and divisions. Additionally,the exponential scheme is tailored specifically for the one dimensional,steady-state with no source term problem. For any other problem, thisscheme will not be exact, thus neglecting its great advantage over otherschemes.

3. The central difference schemeThe discretization of the convection term is:

ρvδφ

δx= (ρvφ)e − (ρvφ)w (44)

The complications arise when trying to evaluate φ at the interfaces eand w. The central difference scheme proposes the simplest discretiza-tion of all by assuming that φ varies linearly from W to P and from Pto E, the value at the interfaces between each pair of grid points canbe easily computed with the weighed average of φ at both points. Inparticular, if the interface is located midway between the nodes (as willbe in this case), then the results are as follows:

φe =φP + φE

2;φw =

φW + φP2

; (45)

29

Page 38: 205-00718 Study for the computational resolution of

The diffusion term is discretised the same way it was for the conductioncase. By rearranging the resulting expression, we get to:

aPφP = aEφE + aWφW (46)

Where:aE = De − F

2

aW = Dw + F2

aP = aE + aW

(47)

Being:De = Γ

δxe

Dw = Γδxw

F = ρvx

(48)

While this scheme is very easy to understand, the results obtained whenusing it are very different from the exact solution for most values ofP. The root of the problem is that a linear variation of φ was assumedto evaluate φe and phiw. As was seen in with the exact solution, thevariation of φ along the x axis is certainly not linear. Other schemes tryto find a better approximation for φe and φw to obtain better solutions.

4. The upwind schemeThe upwind scheme proposes that the value of φ at the interface be-tween two nodes is equal to the value of φ at the node from which theflow is coming.

Φe = ΦP if vx > 0Φe = ΦE if vx < 0

Φw = ΦW if vx > 0Φw = ΦP if vx < 0

(49)

As a consequence of the scheme, there is not one way to calculate aeand aw, there are instead two ways, and which way should be used willdepend on weather P is positive or negative. In a computer programthis requires the use of an if statement, which is an extra operationthat takes time.There are other schemes which seek to improve the results by tryingto better model Φ between two grid points. Examples of such schemesare the second order upwind extrapolation or the quadratic upwindinterpolation for convective kinematics.

30

Page 39: 205-00718 Study for the computational resolution of

5. The hybrid schemeThe hybrid scheme takes a different approach to the problem that theother schemes. The approach it takes is that if the results for Φ are tobe as similar as possible to those obtained by the exact solution, thenthe coefficients aW , aE and aP must also be the same as those obtainedwith the exponential scheme, since the results for that scheme wherethe same as the exact solution.By plotting a dimensionless form of those coefficients versus P, a curvedescribing the evolution of the coefficients appear. Since the coefficientsare dimensionless, that curve can be approximated in many ways. Thehybrid scheme proposes a piecewise function formed by three segments.Since the formulation is dimensionless it can easily be adapted to thespecific problem to be solved.

−Pe for Pe < −2

aE =

1− Pe

2for −2 < Pe < 2

0 for Pe > 2

(50)

2.2.6 Two-dimensional coefficients

Using the hybrid scheme, the coefficients aN , aS, aE, aW and aP become:

aE =Γ∆y

δxemax

(0, 1− 1

2|Pe|

)+max(0,−Fe) (51)

aW =Γ∆y

δxwmax

(0, 1− 1

2|Pe|

)+max(0, Fw) (52)

aN =Γ∆x

δynmax

(0, 1− 1

2|Pe|

)+max(0, Fn) (53)

aS =Γ∆x

δysmax

(0, 1− 1

2|Pe|

)+max(0,−Fs) (54)

aP = aN + as + aE + aW (55)

2.2.7 The Navier-Stokes equation

The transient flow for incompressible Newtonian fluids is given by the fol-lowing equations:

∇v→ = 0ρdvdt

+ (ρv∇)v = µ∇2v −∇P (56)

31

Page 40: 205-00718 Study for the computational resolution of

As with previous cases only two-dimensional flow is considered. The un-knowns are x and y components of the velocity and the pressure. To solvethese equations numerically, first the Navier-Stokes equation will be decom-posed using the Helmholtz-Hodge theorem. A projected velocity will thenbe calculated. Afterwards, the pressure will be calculated numerically usinga solver. Once the pressure filed is known, the velocity field can be easilycalculated, however using the same meshes as before could yield physicallyunrealistic results. To avoid these results a staggered mesh is necessary.

1. The Checker-board problem and the Staggered MeshComparing the Navier-Stokes equation to the general convection-diffusionequation shows that the the Navier-Stokes equation has an additionalterm, the pressure gradient. Discretizing that term for a one-dimensionaluniform mesh gives the following result:

Pw − Pe =PW + PP

2− PP + PE

2=PW − PE

2(57)

Now, the pressure gradient for a certain grid point P depends on itsneighbouring nodes. If those nodes have the same pressure, then thepressure gradient would appear to be zero, however, the pressure atnode P might have a different value. Figure 13 shows one such case.The pressure gradient is clearly not zero, however it appears to be withthe chosen discretization, and then the pressure field would be uniform,when in fact it is clearly not. The same can happen in two and three-dimensional meshes. Figure 14 shows the two-dimensional situation.

Figure 13: 1-D non-uniform pressure field

The solution to this problem is the staggered mesh. Later, the pres-sure gradient will be used to calculate the velocity field. If instead ofcalculating the velocity field at the center of the CV it’s componentsare calculated at the walls between CV, the problem vanishes. Thewalls are now the center of new CV, so in a sense three meshes coexistwithin one. They are referred to as the main mesh (for the pressure)the stagg-X mesh (for the x component of the velocity field) and thestagg-Y mesh (for the y component of the velocity field).

32

Page 41: 205-00718 Study for the computational resolution of

Figure 14: 2-D non uniform pressure field

Figure 15: The staggered mesh. Black dots represent the Pressure nodes,blue arrows the x-velocity nodes, green arrows the y-velocity nodes and thered dots represent the i,j coordinates used in the program later

33

Page 42: 205-00718 Study for the computational resolution of

2. The Helmholtz-Hodge theoremThe Helmholtz-Hodge theorem states that a vector field ω defined ina bounded domain Ω with smooth boundary δΩ can be uniquely de-composed into a pure gradient field (∇φ and a divergence free vectora.Parallel to δΩ[6].

ω = a+∇φ (58)

Since a is divergence free, ∇a = 0 in all of the domain Ω, and since itis parallel to the boundary a ∗ n = 0 at said boundary.For convenience the convection and diffusion terms of the Navier-Stokesequation are grouped in a R(v) term:

R(v) = −(ρv∇)v + µ∇2v (59)

3. The projection operatorThe projection operator (Π) projects a vector field a into a divergence-free pace, such that ∇Π(a) = 0. If a itself is incompressible (∇a = 0)then the projection of a is a itself (Π(a) = a).Equation 58 can be rewritten as:

∇φ = ω − a (60)

Applying the projection operator to ω gives the divergence-free vectora. Applying the projection operator to 60:

Π(∇(φ)) = Π(ω)− Π(a) = 0 (61)

Since Π(a) is itself.

4. Applying the Helmholtz-Hodge theorem to the Navier-Stokes equations

Π(δv

δt

)+ Π(∇P ) = Π(R(v)) (62)

Since the flow is incompressible, the projection of the first term is itself.

Π(δv

δt

)=δv

δt(63)

From 61 the projection of the pressure field is zero.

Π(∇P ) = 0 (64)

Now, δvδt

and ∇P can be written as:

δv

δt= Π(R(v)) (65)

34

Page 43: 205-00718 Study for the computational resolution of

And

∇P = R(v)− δv

δt= R(v)− Π(R(v)) (66)

Since the Π operator projects the vector field to a divergence-free space,by applying the divergence operator to 66:

∇2P = ∇R(v)− 0 (67)

Equation 67 can be solved numerically to find the pressure field. Then,the velocity field can be found solving the following equation:

δv

δt= R(v)−∇P (68)

5. Discretizing the equationEach term is discretized using a different scheme (see [6]). The resultis as follows:

un+1 − un

∆t=

3

2R(vn)− 1

2R(vn−1)−∇P n+1 (69)

Which can be rearranged in the following manner:

vn+1 = vp −∇P (70)

Where:

vp = vn + ∆t

(3

2R(vn)− 1

2R(vn−1)

)(71)

And:

P = ∆tP (72)

Since the fluid is incompressible, the from the discretized continuityequation :

∇vn+1 = 0 (73)

When the divergence operator is applied to equation 70:

∇vp = ∇2P (74)

The projected velocity vp is easily calculated from equation 71. Thethe pressure field can be obtained by solving numerically equation 74.Finally, the velocity field can be obtained from equation 70. Thesesteps will now be explained in detail.

35

Page 44: 205-00718 Study for the computational resolution of

6. Finding vp

vp has two terms, vpx and vpy . The former is calculated in the stagg-xmesh, and the latter in the stagg-y mesh. First however, R(vx) andR(vy) must be evaluated. For the stagg-x mesh:∫

V Cx

R(vx)dV Cx =∫CVx

µ∆vxdCVx −∫CVx

(ρvx∇)vxdCVx (75)

The two terms in the right side are the diffusion and convection terms.Both of them are already familiar. The diffusion term is discretized asfollows: ∫

CVxµ∆vxdCVx = µvxE−vxP

dPEAe − µvxP−vxWdPW

Aw

+µvxN−vxPdPN

An − µvxP−vxSdPSAs

(76)

The convection term is:

−∫CVx

(ρvx∇)vxdCVx = −[ρvxeAevxe

−ρvxwAxwvxw + ρvynAnvxn − ρvysAsvxs](77)

In both cases Gauss’ theorem was applied . The diffusion terms offerno problem whatsoever, however, as in the general convection diffusionequation for the convective term a suitable scheme must be chosen toevaluate the velocity at the interfaces between two CVs. Additionally,since R(v) is being evaluated in the stagg-x mesh, no values for vy exist.They must be taken from the stagg-y mesh. Using the notation fromfigure 16 for the different nodes, the velocities at the interfaces usingan upwind scheme for vx:

vxe = vxE if vxE < 0vxe = vxP if vxP > 0

(78)

vxw = vxP if vxP < 0vxw = vxW if vxW > 0

(79)

vyN = vyAdAB

2+ vyA

dAB2

(80)

vyN = vyCdCD

2+ vyD

dCD2

(81)

Since the staggered mesh is uniform, for the velocities of the north andsouth walls, the result ends up being the average velocity of the two.

vyN =vyA + vyB

2(82)

36

Page 45: 205-00718 Study for the computational resolution of

Figure 16: Stagg-x mesh CV P and it’s neighbouring E,W,N and S nodes.Red dots represent the nodes of the stag-y mesh and blue dots the nodes ofthe main mesh

vyN =vyC + vyD

2(83)

R(vy) can be evaluated in a similar way using the stagg-y mesh. OnceR(vx) and R(vy) have been evaluated, the projected velocities can becalculated using equation 71.

7. Finding the Pressure fieldEquation 70 can be integrated in time, discretized and its terms rear-ranged to suit the form aPΦP = aEΦE + aWΦP + aWΦN + aNΦS +aPΦS + bP (see [6]). Where the coefficients take the following values:

aE =AedEP

(84)

aW =AwdWP

(85)

aN =AndNP

(86)

aS =AsdSP

(87)

aP = aN + aS + aE + aW (88)

bP = − 1

∆t[ρvpxEAe − ρv

pxWAw + ρvpxNAn − ρv

pxSAs] (89)

37

Page 46: 205-00718 Study for the computational resolution of

The coefficients are evaluated at the main mesh. Using the notation offigure 17, the velocities at the interfaces are:

ve = vxd (90)

vw = vxb (91)

vn = vya (92)

vs = vyc (93)

Figure 17: One of the main Mesh CVs. Blue dots represent the nodes forthe stagg-y mesh and red dots represent the nodes of the stagg-x mesh

8. Time step:To determine the time step used in the transient, the Courant-Friedrich-Levy) condition is used.

∆tc = min

(0.35

∆x

|v|

)(94)

∆td = min

(0.2

ρ∆x2

µ

)(95)

∆t = min(∆tc,∆td) (96)

The time step must be evaluated at each node to find the minimum andupdated at each time step. If the maximum velocity is known, thenthe two possible time steps can be calculated once and remain constantthought the simulation.

38

Page 47: 205-00718 Study for the computational resolution of

2.2.8 Radiation

Radiation is the third mechanism by of heat transfer. Unlike conduction andconvection it does not require matter to transfer heat. All solid bodies emitradiant energy. The intensity of the radiation depends on the body’s temper-ature and it’s surface. Except for very hot objects or in a vacuum radiativeheat transfer does not take an important role. Therefore, in most cases it canbe neglected with respect to conduction and convection. Concepts relevantto radiation will now be introduced:

• The electromagnetic spectrumRadiation is a form electromagnetic energy. The energy is transmittedin small indivisible amounts, called a quantum. Each quantum hasa certain wavelength λ and frequency ν. Thermal radiation coversthree orders of magnitude of λ of the 17 total orders of magnitude thatencompass the electromagnetic spectrum.

• Absorption, reflection and transmissionAll bodies emit radiation, and that radiation eventually reaches otherbodies. When it does, three things happen. Part of the incoming ra-diation is absorbed by the receiving body. Part of the radiation istransmitted trough the body and part of the radiation is reflected ofthe body’s surface.

Figure 18: Radiation reaching a body and being transmitted, reflected andabsorbed

The total energy of the incoming radiation must be conserved. Thefraction of incoming energy that is reflected ρ is called reflectance, thefraction that is absorbed α absorptance and the traction that is trans-mitted τ transmittance. For the energy to be conserved the following

39

Page 48: 205-00718 Study for the computational resolution of

has to be true:1 = α + ρ+ τ (97)

That is also true for the energy carried by each individual wavelength(a body will emit energy in many wavelengths). The different fractionsare then given the subindex λ ( αλ, ρλ and τλ).

• Black bodiesA black body is a model where all incoming radiation is absorbed, andnone is reflected or transmitted. α = 1, τ = 0, ρ = 0. It does howeveremit it’s own energy (since it must have a temperature). If the bodyhas a heigh temperature, the radiation it emits will be visible. Theenergy radiated by a black is given by the Stefan-Boltzmann law:

eb(T ) = σT 4 (98)

Where eb is the energy radiated by the black body at a certain wave-length. σ is the Stefan-Boltzmann constant, and T is the temperatureof the body, in K.Real bodies however, only emit a fraction of that energy. Let ελ be theemittance of a body, then the energy emitted by the real body will be:

e(T ) = ελσT4 (99)

In general, ελ depends on the wavelength. A gray body is defined asa body such that it’s emittance is constant such that ελ = ε for therange of λ that is being considered. From the earth, the sun is closeto a gray body. Unless a problem involves surfaces with very differenttemperatures they can be treated as gray bodies.

• Kirchhoff’s lawThe emittance of a body can be determined by it’s temperature andphysical properties, however the absorptance depends not only on thereceiving surface but also the emitting surface. It will also depend onthe wavelength and the direction the radiation is emitted. For graybody and assuming a diffuse body (energy is radiated equally in alldirections) Kirchhoff’s law states that:

ε(T ) = α(T ) (100)

Which can be derived from the laws of thermodynamics [10].

• radiant heat exchangeFigure 2.2.8 shows an a case where three surfaces are emitting and

40

Page 49: 205-00718 Study for the computational resolution of

receiving radiation. The net energy gained or lost by a surface will bethe difference between the energy it has emitted and the energy it hasreceived. For surface 1:

Q2−1 +Q3−1 −Q1−2 −Q1−3 = 0 (101)

Where Qi−j is the heat transferred from surface i to surface j. Thatenergy, is a fraction of the total energy emitted by surface i:

Qi−j = Fi−j[eb(T )]i (102)

Where Fi−j is the view factor. It represents the fraction of energyemitted by surface i that reaches surface j. Now, equation 101 can berewritten as:

F2−1ε2σT42 + F3−1ε3σT

43 − F1−2ε1σT

41 − F1−3ε1σT

41 (103)

• Properties of view factorIn a closed system all energy emitted by one surface eventually reachesanother surface. Thus all view factors originating at surface i will addup to one.

1 =n∑j=1

Fi−j (104)

Additionally, the following can also be shown to be true (see [10]):

SiFi−j = SjFj−i (105)

41

Page 50: 205-00718 Study for the computational resolution of

A surface can irradiate heat towards itself, for example if it is a curvedsurface.

• Irradiance and radisoityIrrandiance (I) is defined as the flux of energy that irradiates the sur-face, and radiosity (J) as the flux of energy that goes away from thesurface. The radiosity is the portion of energy that the surface reflectsplus the energy that the body itself emits.

J = ρI + eb(T ) (106)

• Solving for temperatures in an enclosed domainFigure 2.2.8 shows an enclosure. The goal is to find the temperaturesof each surface. To do so, the following assumptions are made:

1. All surfaces are diffuse, gray (ελ = ε) and opaque (τ = 0).

2. The temperature is uniform along a surface.

3. The medium within the enclosure is both completely transparentand its emittance is negligible, so τ = 1, ε = 0

4. Within the enclosure there is no heat transfer by conduction orconvection.

5. Either the temperature or the heat flux of the surfaces are known.

The net heat loss or gain of any surface is simply the difference betweenit’s radiosity minus it’s irradiation

qi = Ji − Ii (107)

Where:Ji = ρIi + εiei (108)

And:

Ii =n∑j=1

IjFj−i (109)

The result is an nxn system of linear equations that has to be solvednumerically. It’s worth noting that while in all previous systems oflinear equations the value for i depended only in it’s neighbouring valueshere all values depend on all other values, so numerical methods suchas the line-by-line solver may no longer work in this problem. A Gauss-Seidel algorithm would still work, but would require more coefficientsai than the examples provided previously.

42

Page 51: 205-00718 Study for the computational resolution of

Figure 19: An enclosure

3 The Code

3.1 Functionality

Since prior work was done with heat conduction, the code developed for thisproject does not include that case7 Since radiation is often negligible, it isexcluded from the problem. The codes that have been made can solve eitherthe steady-state general convection-diffusion equation or the transient NavierStokes equation for incompressible non Newtonian fluids. The code was madeusing object orientated programming, and three classes were created for eachproblem (one for the CV, one for the material and one for the Mesh), whichare described in-depth later. For the general conveciton-diffusion equariontwo cases were made, one for 1-D flow using different schemes and another for2-D flows using the hybrid scheme. The Navier Stokes equation was solvedonly in the 2-D case with the upwind scheme. First, however, the generalalgorithm is presented, for both transient and steady state problems.

7However, by setting the velocity field to 0 in the general convection-diffusion equation,simple steady-state conduction without a source can be calculated.

43

Page 52: 205-00718 Study for the computational resolution of

3.2 The general algorithm

3.2.1 Steady-State algorithm

Figure 20 shows the algorithm to solve a steady-state case, which was used forthe general convection diffusion equation. The actions taken in each ”box”are explained below.

Figure 20: The steady state algorithm

1. Input DataThe user introduces the data necessary to solve the case. That includesgeometric data (length and height of the mesh), numeric data (conver-gence criteria, NX ,NY , relaxation factor (not mandatory) and physicaldata regarding the material the domain is made of. The specific prop-erties will depend on the case, density, specific heat, conductivity andviscosity are examples of data that would fit under this category. Initialconditions must also be provided.

44

Page 53: 205-00718 Study for the computational resolution of

2. Mesh GenerationIn this step the data is loaded intro variables. From the data thatwas given, each of the nodes position is calculated, as well as the CVsurfaces. The initial values are assigned to each node.

3. Constant CalculationsThe last step before entering the loop. Here all values that remain thesame for each iteration is calculated. Doing these calculations insidethe loop would result in wasting time, since the values would remainunchanged. An example are the aN , aS, aE, aW , aP and bP coefficientsfor the general convection diffusion equation.

4. While loopThis loop goes on until the system satisfies the convergence criteria (ora maximum amount of iterations have taken place without reaching thecriteria).

5. Non-Constant CalculationsHere the parameters that change in each iteration are calculated. Ancan be found in the heat conduction case, when the physical propertiesare not constant. There, the coefficients aP and bP must be re-evaluatedat each iteration.

6. System ResolutionAt this point all the data necessary to define a system of linear equa-tions has been introduced. Now, it has to be solved. That can beaccomplished any of the solvers presented previously. Note that if aline-by line solver is employed, the Pi and Qi coefficients must be re-evaluated for each iteration. For each node, the difference betweenthe new value of the property being solved and the one it had in theprevious iteration is calculated.

7. Criteria CheckAt this point, the maximum difference between the current iterationand the previous iteration is compared to the convergence criteria. Itthe difference is smaller than the criteria, then the system has beensolved and the program can exit the loop, if it is larger, it has not anda new iteration begins.

8. Print final resultsOnce the system has been solved the results are presented to the user,for example they can be presented in a .txt file.

45

Page 54: 205-00718 Study for the computational resolution of

That is the basic algorithm that can be implemented, however some simpleadditions can be added. For example, instead of saving only the final results,the results at each iteration can be stored (if not for the entire mesh for onenode). That would allow the user to see how the results converge. Differentinitial positions can be used to determine smart initial conditions for latercases. Different solvers can also be compared, to see which one convergesfaster.

3.2.2 Transient Algorithm

This algorithm, presented in figure 21 is similar to the previous one, but has asecond loop, this one for time. The additions to the algorithm are explainedbelow.

1. Input dataIn addition to the data that had to be introduced in the steady-statealgorithm, data regarding time has to be introduced. Such data canbe the timestep ∆t, if it is not calculated within the program fromother data. A maximum number of timesteps can also be introduced.Finally, time criteria must be also be there, so that the program canexit the outer loop.

2. Timeless calculationsHere data remains constant for all time is calculated. An example arethe aN , aS, aE, aW and aP . bP on the other hand, falls under the”constant calculation” category, since it must be updated at each timestep.

3. Time criteria checkIn this step, different alternatives are possible. Either a steady statecriteria was introduced, which would work in a similar way to the con-vergence criteria but would be obtained by comparing the values fromthe current and previous time step instead of the values from the cur-rent and previous iteration, or the simulation is set to run for a limitednumber of time steps (either no steady-state exists or it is an aperiodicsteady state or it takes to long to reach the reach the steady state).

As before, this is a very simple algorithm a possible addition would be tosave the results every few time steps, to see how the system evolves troughtime. This was done for the Navier-Stokes problem.

46

Page 55: 205-00718 Study for the computational resolution of

Figure 21: The transient algorithm

3.3 Classes

The classes used for the program are briefly described. Full documentationis presented as an annex.

47

Page 56: 205-00718 Study for the computational resolution of

3.3.1 Material

The classes NS Material and ConvectionMaterial store the date regardingthe physical properties of the problem. They are very simple classes, havingfew attributes, and the methods they have are only setters and getters.

3.3.2 Control Volume

The classes NS CV, CD CV1D and ConvectoinCV are more complex. Theystore the geometric information of the control volume, as well as the coeffi-cients to solve the system numerically with either a Gauss-Seidel or a Line-by-Line method. Additionally they both have a material attribute where thephysical data is stored.

3.3.3 Mesh

These classes have the most complexity, since they not only hold all the in-formation but also the methods to solve the system. The classes are calledNS Mesh2D, CD M1D and ConvectionMesh2D. They store CV objects in astd::map whose key is an std::vector. Te vector simply stores i,j coordinatespositions.There are methods to set the boundary conditions, which can be eitherDirilecht or parallel flow. Once the simulation is completed a new folderis created in the same location as the program, and within that folder theresults can be found, as well as a report with the input data. The report alsospecifies weather the system was solved successfully or not.

4 Results

4.1 2-D General Convection-Diffusion equation

This subsection presents two cases solved with the general convection-diffusionequation. The first explores the problem of false diffusion. The second is awell known case, called the Smith-Hutton case. First, however, an appropri-ate scheme must be chosen for the convective term. That is done taking alook a the 1-D case.

4.1.1 1-D case

Figure 22 shows the results for the case of a 1 unit of length and values ofΦ ranging from 0 to 10. For this figure ρ/Γ = 5. The results clearly showthat the central difference scheme is the one that least accurately describes

48

Page 57: 205-00718 Study for the computational resolution of

Figure 22: Comparison of the results with different schemes for P = 5

Φ. In fact, the results given by this scheme are the same regardless of P.Te upwind scheme gives a more accurate result, but its error grows as theabsolute value of Φ increases. Of the schemes presented, the hybrid schemeis the one that is closer to the exact solution, and it’s the one that will beused henceforth with the two-dimensional mesh.

4.1.2 False Diffusion

The concept of false diffusion is fairly easy to understand. It occurs wheneverthe case is solved but the effects of diffusion are not accurate to the physicalreality. An example of this unfortunate reality is presented below, as well asa brief explanation of why such errors occur.Imagine a scenario where there is a certain velocity field. Additionally, thediffusion coefficient is zero (Γ = 0). If Φ has distinct values, then thosevalues will remain constant throughout entire streamlines. A simple case ofthis can be seen in figure 4.1.2, where there is a simple velocity field suchthat vx = constant; vy = 0. For the upper half of the domain Φ has one valueand for the lower half a different one. The border between the two is crisp,no diffusion -false or otherwise- is present. In contrast, figure 4.1.2 shows thesame case but with diffusion present. The order between the two regions isnow blurred.Another case where false diffusion could be found is in a diagonal flow. Ifthe velocity field is at an angle of 45o from the x-axis, then the x and y

49

Page 58: 205-00718 Study for the computational resolution of

component are the same. That condition is very easily added to the code.For the boundary conditions a certain value of Φ is imposed to the southand east walls of the domain and a different value to the north and the west.With Γ = 0, the results can be seen in figure 4.1.2. Surprisingly, the borderbetween both regions ins not crisp at all. Another simulation with more CVsis presented in figure 4.1.2. Again, the border is not crisp ans it should be inabsence of diffusion.

Figure 23: Parallel flow without diffusion (left) and with diffusion (right)

The reason false diffusion occurs is fairly simple to understand, howeverthere is no straightforward solution to prevent it. The fluid flow is diagonal,whereas for the CV we consider that at each face the velocity is normal tosaid face. That produces an error, which manifests as false diffusion. It is atits worst when the velocity field forms an angle of 45 degrees with the CV.While reducing the size of the CV does somewhat mitigate the error, it willalways be there. The other option is to orientate the grid in a way that eachCV is parallel to the velocity field or forms a very small angle.

4.1.3 The Smith-Hutton Case

This is a well-known case, that seeks to find the distribution of Φ for a specificset of boundary conditions and velocity field. The domain of the mesh is from-1 to 1 along the x-axis and from 0 to 1 along the y-axis. The velocity fieldis and boundary conditions are:

vx = 2y(1− x2)vy = −2x(1− y2)

(110)

50

Page 59: 205-00718 Study for the computational resolution of

North Φ = 1− tanh(10)East Φ = 1− tanh(10)West Φ = 1− tanh(10)

South x <= 0 Φ = 1 + tanh(10(2x+ 1))South x > 0 Outlet dΦ/dy = 0

Table 3: Boundary conditions for the Smith-Hutton case

The mesh used in the program has nodes on the sides. The results of theSmith-Hutton case presented in [4] are for nodes located at the following x-positions x = 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1. Unfortunately, the codecannot compute the values of Φ at those points. Figure 26 shows the lastthree positions of the results found in [4]. In the mesh created by the program,there are a CVs between positions x = 0.8 and x = 0.9. Between x = 0.9and x = 1 however there are a + 1/2 CVs. Thus to find the correct valueof ∆x to solve the case for the desired positions comes from the followingsystem of equations:

0.9− 0.8 = a∆x1− 0.9 = a(a+ 1/2)∆x

(111)

Which has no real solution. The best way to compare the results is then tomake the mesh as fine as possible, to ensure that the x-positions will be asclose to the benchmark results as possible. The results can be seen in table4.

x-position [4] calculated x-position [4] Φ Calculated Φ

ρ/Γ = 100.0 0.0025 1.989 20.1 0.1025 1.402 20.2 0.2025 1.146 1.99910.3 0.3025 0.946 1.994010.4 0.4025 0.755 1.82190.5 0.5025 0.621 0.9105650.6 0.6025 0.480 0.1282210.7 0.7025 0.349 0.004941360.8 0.8025 0.227 00.9 0.9025 0.111 01.0 1.0 0.000 0

ρ/Γ = 103

0.0 0.005 2.0000 20.1 0.105 1.9990 2

51

Page 60: 205-00718 Study for the computational resolution of

0.2 0.205 1.9997 1.999730.3 0.305 1.9850 1.981550.4 0.405 1.8410 1.7140.5 0.505 0.9510 0.8620040.6 0.605 0.1540 0.1711540.7 0.705 0.0010 0.011480.8 0.805 0.0000 0.0002614040.9 0.905 0.0000 2.11773e-61.0 1.0 0.0000 0

ρ/Γ = 106

0.0 0.0 2.000 20.1 0.105 2.000 20.2 0.205 2.000 1.999730.3 0.305 1.999 1.981550.4 0.405 1.694 1.7140.5 0.505 1.000 0.08620040.6 0.605 0.036 0.1711540.7 0.705 0.001 0.01148710.8 0.805 0.000 0.0002614040.9 0.905 0.000 2.1177e-61.0 1.0 0.000 0

Table 4: Comparison between the expected and the cal-culated results

The results obtained with the program are very different to those of thebenchmark case, in some cases by some orders of magnitude. That cannot beexplained entirely by the issue regarding the position of the studied nodes.Other issues that should be considered are weather the mesh is too coarseand weather the convective scheme used is good for 2-D cases as well as 1-D cases (it is not known what scheme was used to obtain the benchmarkresults). false diffusion may also play a role.However tests have been conducted on the program setting the velocity fieldto zero for all nodes. Then a heat balance was done with the results for eachnode, and that verified that the diffusive terms are calculated correctly. Theconvective term was verified in the one dimensional case, and with the 2-Dmesh the same results can be obtained (by setting parallel flow boundaryconditions and a constant velocity in one Additionally, the results obtainednumerically for the Smith-Hutton case are ”within reason”, as in the rangebetween the range of expected results.

52

Page 61: 205-00718 Study for the computational resolution of

Figure 24: Diagonal flow without diffusion, 100x100 mesh

Parameter Parallel Flowwithout Diffu-sion

Parallel flowwith diffusion

Diagonal flow100x100

Diagonal flow1000x1000

nx 100 100 100 1000ny 100 100 100 1000Length 0.1 0.1 2 0.1Height 0.1 0.1 2 0.1Max IT 1000 1000 1000 1000IT to solve 1000 1000 2 2Desired acy 1e-7 1e-7 1e-7 1e-7Final acy 9.41e-5 0.0006 0 0System Solved NO NO YES YESDensity 1 1 1 1Diffusion Coeffi-cient

0.0001 1 0 0

Table 2: Parameters for the different False diffusion cases

53

Page 62: 205-00718 Study for the computational resolution of

Figure 25: Diagonal flow without diffusion, 1000x1000 mesh

Figure 26: The right side of the domain

4.2 Navier-Stokes Transient Compressible flow for New-tonian fluids

The code developed to solve this case was verified with two problems. Thefirst is a simple Couette flow, and the results are compared to the knownanalytical solution. The second is a lid-driven cavity, and the results arecompared with a benchmark case. Regrettably, while the results obtainedare good the simulation time is excessive requiring an unreasonable amount

54

Page 63: 205-00718 Study for the computational resolution of

Figure 27: The velocity for the Smith-Hutton case along the x-axis (left) andy-axis (right)

of timesteps to reach the steady state. This problem is discussed and asolution is proposed.

4.2.1 The Couette Flow

The Couette flow is a simple case of one dimensional flow for which an an-alytical solution of the Navier-Stokes equation exists. Such a flow occurswhenever there are two parallel very long surfaces, with a Newtonian fluidbetween them. Each surface has a constant velocity. Figure 28 shows thisset up. The velocity profile between the surfaces when the steady-state isreached is:

vx(y) =u1

hy − u2 (112)

Figure 29 shows a comparison between the expected results and the obtainednumerical solution. Table 5 shows the same results. Two issues arise.

55

Page 64: 205-00718 Study for the computational resolution of

Figure 28: Velocity profile of a Couette flow

Figure 29: Comparison between the analytical results and the numericalsimulation for the Couette flow for Re = 0.1

Table 5: Results for the Couette flow

Couette Flow Re = 0.1y Numeric vx Exact vx1 – 1

0.9875 1 0.98750.9625 0.974154 0.96250.9375 0.948319 0.93750.9125 0.922494 0.91250.8875 0.89668 0.8875

56

Page 65: 205-00718 Study for the computational resolution of

0.8625 0.870876 0.86250.8375 0.845082 0.83750.8125 0.8193 0.81250.7875 0.793528 0.78750.7625 0.767766 0.76250.7375 0.742016 0.73750.7125 0.716276 0.71250.6875 0.690548 0.68750.6625 0.66483 0.66250.6375 0.639123 0.63750.6125 0.613427 0.61250.5875 0.587742 0.58750.5625 0.562068 0.56250.5375 0.536405 0.53750.5125 0.510753 0.51250.4875 0.485112 0.48750.4625 0.459482 0.46250.4375 0.433863 0.43750.4125 0.408255 0.41250.3875 0.382658 0.38750.3625 0.357071 0.36250.3375 0.331496 0.33750.3125 0.305932 0.31250.2875 0.280379 0.28750.2625 0.254836 0.26250.2375 0.229305 0.23750.2125 0.203784 0.21250.1875 0.178274 0.18750.1625 0.152775 0.16250.1375 0.127286 0.13750.1125 0.101808 0.11250.0875 0.0763403 0.08750.0625 0.0508832 0.06250.0375 0.0254365 0.03750.0125 0 0.01250 – 0

1. From looking at the result it is apparent that the results are differentclose to the edges. In the center, the numerical solution and the ana-

57

Page 66: 205-00718 Study for the computational resolution of

lytical solution are in agreement. Therefore there is a problem in thecode. It has however a simple explanation.It is helpful to take a closer look at the staggered mesh. Figure 30 showsthe top row of the staggered mesh. From a quick visual inspection itbecomes apparent that vx is not calculated (or given as a BC) for thetop of the domain (nor it is for the bottom). Instead, the given velocityis enforced at y = h−∆y/2. So the problem being solved numericallyis not exactly the same as the one solved analytically. The error willbe smaller if a finer mesh is used but will still be present. To eradicatethe error entirely additional nodes for the stagg-x mesh would have tobe added ad heights y = 0 and y = h. The same issue occurs withvy at x = 0 and x = l, and the solution is to add additional nodes atthe stagg-y mesh. As long as the error is not corrected it will have tobe taken into consideration for whenever a simulation is run with thiscode.

Figure 30: Top row of the staggered mesh. The green dots are the nodes ofthe main mesh, the blue arrows the nodes of the stagg-y mesh and the redarrows the nodes of the stagg-x mesh

But how harmful is it to continue using this code without applying thecorrection? To determine that the maximum relative error must beevaluated. Said error is located at y = 0 and y = h. Table 6 showsthe error for different numbers of nodes along the y axis. These resultsclearly show that the error becomes exponentially larger as the numberof nodes decrees. If the mesh is very coarse it is worth using a finermesh since results for coarse meshes might not be particularly accurate.However, if the mesh is already fine and the error is unacceptable fixingthe code may be the only answer.It must be noted that the results shown in figure 6 are only valid forthe Couette flow. Other cases might have higher errors. Consideringthe scope of this project, it is more interesting to continue with othercases than to fix this error, since it might take too much time whichcould be invested elsewhere. However, this problem will have to be

58

Page 67: 205-00718 Study for the computational resolution of

considered for the lid driven cavity, discussed later.

Ny 10 20 30 40 50 75 100Error (in %) 5 2.5 1.667 1.25 1 0.667 0. 5

Table 6: Maximum error for different values of Ny

Figure 31: Starting point for different values of Ny

Figure 31 shows the value at y = 0 for different Ny. Again, the errorincreases exponentially as Ny grows.

2. The second issue is the computational time it took to get these results,which was surprisingly high considering the simplicity of the problemand the low number of nodes. Table 7 shows the time it took to runsimulations for different values of Ny. Nx was 3 in all cases (1 would beenough, but 3 was chosen to verify that the velocity profile was indeedconstant along the x-axis). In all cases Re = 0.1.

Ny 10 20 30 40Time 1 minute 6 minutes 18 minutes 29 minutes

Table 7: Simulation time for different values of Ny forNx = 3

This second issue will become very problematic when solving the lid

59

Page 68: 205-00718 Study for the computational resolution of

driven cavity problem. A hypothesis as to why it occurs and a possi-ble solution are proposed. The solution however does not work whenapplied to the Couette flow. Other cases would cave to be analysedindividually to determine weather the program is useful or not.

4.2.2 Lid-Driven Cavity

The set-up for this case is similar to the Couette flow in terms of program,however the results are radically different since this is a 2-D case. The dif-ference is that now the east and west walls are solid (in the previous case,parallel flow was forced as a BC in the inlet and outlet). No analytical solu-tion exists for this problem, so results will be compared to results obtainedby others. Simulations will be conducted for various Re. Since the bench-mark case and the solved case may not have nodes at the same locations, theresults will be compared on a graph. The results obtained numerically willbe presented on a table (for coarse meshes, for finer meshes that would notbe practical and only the figures will be provides. Complete results are inthe annexes) for the benchmark case, see [15].

Figure 32: Lid-Driven cavity schematic

• Finding a mesh and criteriaBefore running a simulation it is important to find the correct meshand steady-state convergence criteria. However, the second problemdiscussed in the Couette flow becomes very serious now. In order to

60

Page 69: 205-00718 Study for the computational resolution of

achieve a steady state solution in a reasonable time, a 20x20 mesh hasto be used. Such a mesh in too coarse to capture the change in velocityfor this problem. An attempt to solve the problem with a 30x30 meshwas made, however after over a day of calculations it became apparentthat the evolution of the system was very slow.When setting a steady state criteria two factors must be considered.First, the criteria has to be small enough to ensure the steady statehas been achieved, and second the criteria has to be large enough thatthe simulation will end in a reasonable amount of time, since each timeit is made an order of magnitude smaller, the simulation time grows.For the meshes considered, any criteria below 10−6 will result in thesimulation ending after the first time step. The reason is that thedifference between the initial state and the first time step is alreadysmaller than 10−5, thus, the program will assume the steady state hasbeen reached. Even with a criteria of 10−6 only a few time steps are,necessary, thus the criteria must be smaller.

• The first resultsFigures 33,34 and 35 Show the results for a 20x20 mesh compared tothe benchmark results. The compared values represent the y compo-nent of the velocity along the center horizontal line (y = 0.5).

Figure 33: Comparison for Re = 100

Lid Diven Cavity

61

Page 70: 205-00718 Study for the computational resolution of

x Re = 100 Re = 4000.025 0 00.075 0.0632122 0.06650070.125 0.103576 0.1020540.175 0.125417 0.118550.225 0.133456 0.1244440.275 0.131417 0.1239370.325 0.121704 0.1185430.375 0.105593 0.1084850.425 0.0835976 0.09344490.475 0.0558541 0.0729010.525 0.0225162 0.04630550.575 -0.0158588 0.01331880.625 -0.0580108 -0.02571720.675 -0.101944 -0.06976730.725 -0.14338 -0.1183620.775 -0.175158 -0.1682250.825 -0.186728 -0.210390.875 -0.165042 -0.2248380.925 -0.100224 -0.1711870.975 0 0

Table 8: Results for the lid-driven cavity at various Re

For Re = 100 the results are fairly similar, but for Re = 400 andRe = 1000 they are fairly different. An issue that is present is that thechosen scheme for the convective term (UDS) is not as good for theNavier-Stokes equation as it was for the general convection diffusionequation. However, other conclusions can be drawn when comparingthe different benchmark results with each other and comparing thedifferent numeric results also with each other. Figures 36 and 37 showsaid comparisons.In the benchmark results, the absolute value of maximum and minimumalways increases with Re. In the results obtained with the programhowever, that is not true. That qualitative difference between the twoindicates that something is wrong with the calculated results, since evenif the convective scheme was to blame for differences in the results, thatqualitative difference should be preserved.

62

Page 71: 205-00718 Study for the computational resolution of

Figure 34: Comparison for Re = 400

Figure 35: Comparison for Re = 1000

• Finding an explanation to the problemThe issues described thus far could be attributed to the time step beingto small. Indeed it would seem that is the case, since the difference inthe results from one time step to the next is very small, and thus a lotof time steps must be calculate to reach a solution (in some cases inthe order of millions). However, that hypothesis does not hold up totesting, since it is very easy to calculate the ∆t for a mesh manually, andit turns out that ∆t is in fact calculated correctly. While the problem

63

Page 72: 205-00718 Study for the computational resolution of

Figure 36: Benckmark results for Re = 100, Re = 400 and Re = 1000

Figure 37: Numerical for Re = 100, Re = 400 and Re = 1000

in the program currently remains a misery, the following statement istrue: The issue has consequences that are similar to having a smaller∆t that the one needed.

• A provisional solutionSince the problem is not known it cannot be fixed. However since it’sconsequences are similar to having too small a ∆t, perhaps by havinga larger ∆t could help. Thus, the following instruction is added to the

64

Page 73: 205-00718 Study for the computational resolution of

code:∆t = A∆t (113)

Where A is simply a parameter that makes ∆t larger than it oughtto be. That in fact adds another error to the code, but the hope isthat it will ”counteract” the previous error. For the Re = 400 andRe = 1000 simulations a value of A = 103 was used and results wereobtained within a reasonable amount of time. With a 40x40 mesh and asteady-state criteria of 10−6 the simulation time was 23 and 69 minutesrespectably. Figures 38 and 39 show the old results, the benckmark

Figure 38: Benckmark, old results and new results for Re = 400

results and the new results.

While the results now are better, there is no guarantee that correct resultscan be achieved with the code. With that in mind it is not recommended touse this particular code for any application. If other cases are to be calculatedthis code has to either be fixed or a new code has to be written from scratch.

65

Page 74: 205-00718 Study for the computational resolution of

Figure 39: Benckmark, old results and new results for Re = 1000

5 Budget

The budget will be divided in three sections. First the cost of the hardwareused for this project will be discussed. Then, a salary will be calculatedconsidering the work hours devoted to the project. Lastly, costs related tothe electrical energy used in this project will be estimated.

5.1 Hardware

One laptop computer was used to write the code and make the report. Thatsame computer was used to run the simulations. At one point in time a desk-top computer was also used to run other simulations. Additionally, a secondscreen was connected to laptop to improve the work flow. Two keyboardsand two mouses where also used. For further technical details refer to the”Hardware” subsection of the ”Tools used for this project” section (section8). The cost of the second screen is not considered since it was a very oldscreen that had already served other purposes. The cost of the equipmentwas:

Hardware costItem Units CostLaptopcomputer

1 800

66

Page 75: 205-00718 Study for the computational resolution of

All in onecomputer8 1 630

Mouse 1 10Keyboard 1 20Total — 1460

Table 9: The cost of the different hardware elements usedfor this project

5.2 Work hours

The duration of this project has been of roughly nine months, from Januaryto September 2020. Since work began halfway through the month of Januaryand ended halfway trough the month of September, only eight months willbe considered. The salary is estimated result in a cost of 20 euros per hour(including taxes). During those months roughly 400 hours of work whereinvested in the project. That puts the total salary cost to 8000 euros.

5.3 Electricity

The laptop that was used for the vast majority of the project consumes anestimated 65W . Most of this project was done with the computer, withonly a few hours dedicated to research and taking notes without the com-puter. Thus, the computer has been on an estimated 90% of the durationof this project. Additionally, the computer was left doing calculations, oftenovernight. These include both the final calculations and test runs. The totaladditional time the computer was left on is estimated to be 300 hours, whichis a total of 660 hours.At the household where this project was done, electricity is paid at differentrates during the day and night hours. Calculations are provided assumingall work hours were during the day, all work hours were during the nightand finally the cost assuming that 60% of the work was done during the day.Table 10 shows the electrical cost of the project (does not include taxes).

Electricity cost100% day 100% night 60% day 40% night7.06 3.78 5.748

Table 10: Electrical cost of the project

8Computer + Mouse + Keyboard

67

Page 76: 205-00718 Study for the computational resolution of

6 Environmental Impact

6.1 Motivation

In recent years the world has seen an increase in the number and ferocityof natural disasters. Scientific evidence shows that that increase is directlylinked to human activity. Any action preformed by a human leaves its markson the land and the world. These marks may last mere hours or manymillennia. Of those marks, the most damaging today is the emission ofgreenhouse effect gasses (mostly CO2). The emission of greenhouse effectgasses have caused the word’s mean temperature to rise by 1.2K in the lastcentury[14]. This increase has been particularly strong since the 1980s. Thissection aims to provide a general overview of the effects of these actions, firstby taking a look at how previous changes in climate have affected life on earth.Once the situation is explained, the advantage of CFD versus numericalexperimentation will be discussed. Finally, the environmental impact of thisproject in particular will be briefly examined.

6.2 Climate Change in the past

Earth has been home to many lifeforms, over 99% of which are now extinct.Though the world’s geological history, five mass extinctions have been knownto happen. In each of those over 50% of the world’s species went extinct,and in most cases climate change was the cause of these extinctions.Most of the mass extinctions have were caused by climate change caused bysome catastrophic event (the most well-known example being the extinctionof the non-avian dinosaurs after the impact of a meteorite). Today, the annualextinction rates of animals are above any of the past mass extinctions.

6.3 Simulation versus experimentation

The benefits of simulating versus experimenting are not only economical,since the former is much better for the environment than the latter. Theonly impact simulating has on the environment is related to the generationof the energy used to run the simulation and construction of the equipmentused (or a fraction of it, if it is used for other purposes). If the power used isgenerated from a renewable source the, the impact is reduced even further.Experimenting on the other hand requires manufacturing a lot of equipmentas well as the power required to run the experiments, both of which have asignificantly larger impact on the environment.

68

Page 77: 205-00718 Study for the computational resolution of

6.4 This project

The impact of this project, has been fairly small, since only a few simplesimulations were conducted. Since the hardware used has and will serve manyother purposes than this project, the impact of it’s manufacturing won’t beconsidered as impact of this project. Thus the only impact of this project isrelated to the generation of the electricity used to power the computer.To calculate this impact, data of 2019 will be used, since data for 2020 is notavailable yet. In 2019, 261020GWh where generated in Spain. The impact tothe environment was equivalent to 4.2474 ∗ 1010kg of CO2. That means thatthe emissions were 0.1627kgCO2− eq/kWh. For the 42.9kWh consumed forthis project, the emissions are 6.97983kgCO2 − eq/kWh.

7 Future Improvements and Expansions

This project was intended as an introduction to CFD. As such there are manyavenues of expansion. Once the project is completed. Like the theoreticalbackground, those improvements and expansions are divided intro numericalmethods and physical phenomena. They are also presented as a ”next step”to the project as it is currently. Obviously since CFD is such a vast subjectmany other more advanced topics also exist.First however, it is continent to address a third improvement are that doesnot warrant it’s own subsection but that is important enough to be addressed.And that is the code itself which can be improved without adding any newfeatures to make it more efficient. It is also very untidy and efforts should bemade to improve it in that regard also. Some functions can be revised andsimplified, while other may be entirely redundant (for instance a function iscreated at one point in the development process but is latter replaced by anew, improved function without being deleted). The variable storing couldalso use some revision to see if there are more efficient ways to store andaccess variables. That the ones used now.Finally other problems can be fixed to get better solutions, such as addingadditional nodes to the stagg-x and stagg-y meshes, as discussed in the re-sults section when comparing the analytical Couette flow results with thoseobtained numerically.

7.1 Numerical Methods

• The Mesh:In the theoretical background section, non-cartesian and non-uniform

69

Page 78: 205-00718 Study for the computational resolution of

meshes were introduced. Such meshes open the doors to new possibil-ities. Non-cartesian meshes (such as the cylindrical mesh) can be usedto solve problems that can now not be solved. An simple example couldbe the Couette flow of a fluid between an axle and a rotating element.The energy equation can then be used to also calculate the hat transferin such a scenario.Non uniform meshes on the other hand can be useful since they pro-vide a finer mesh in some regions and coarser meshes in others. Forinstance, a finer mash is preferable near walls. Such a change could de-crease calculation time since only the regions that need precision wouldhave a fine mesh. The rest of the domain would use a coarser mesh asopposed to have the entire domain with a fine mesh.Another improvement that can be applied is the combination of two ormore meshes to form a more complex problem. That can be achievedby setting the boundary conditions of one mesh to be equal to theboundary conditions of another mesh.

• The solverFor this project the line-by-line solver was used in all but one cases, witha Gauss-Seidel being implemented in the other. A better solver, theconjugate-gradient method has been presented but not fully explainednor implemented in the program. Doing so could reduce computationaltime, which could be desirable if more complex problems are considered.

7.2 Physical Phenomena

• Convective schemes:Different convective schemes were presented in the general convection-diffusion equation subsection of this report. However many more exist,that seek to offer better results. Depending on what case is beingstudied it could be interesting to include more schemes in the program.The navier-stokes program used the upwind scheme, so there is alsoroom for improvement there.

• Flow around solid objects:A new Navier-Stokes code that fixes the problems discussed can be usedin conjunction with the blocking-off method to solve for flow aroundsolid objects, such as a square cylinder. The energy equation can alsobe used to calculate the temperature.

• Compressible flows:Another possible expansion is the case of compressible flows. Those

70

Page 79: 205-00718 Study for the computational resolution of

are of great importance in the aeronautical field. A case problem thatcould be used to verify the such a code is the shock-tube problem.

• Adding the energy equationWith the Boussinesq approximation, it is fairly easy to introduce theenergy equation to the Navier-Stokes code to funs the temperaturedistribution..

• Turbulence modelsSolving for non-laminar flows is cost prohibitive due to the time ittakes to solve the system, since a very fine mesh in needed at highRe. Turbulence models seek to reduce the computational time whilemaintaining the eddies that appear in such cases.

8 Tools used for this project

This section gives a list of the software and hardware used throughout thisproject. Hardware includes the computer[s] used but not peripheral devicessuch as mouse or printer. Software is divided between that used to code, tomake the report and other. A brief explanation of what each software wasused for is also given.

8.1 Hardware

The hardware used for this project was presented in the budget section. Theonly information that has to be added is some of the technical specificationsof the main computer used for this project. The operating system used isWindows 10. The manufacturer for the system and baseboard is HP, withan i7 intel core.

8.2 Software

All of the software used for the project was the latest release as of autumn2020. In some cases (such as draw.io) the software was updated to newerversion. In all cases windows versions were used. No work was done in otheroperating systems.

8.2.1 For Coding

• Main Programming IDEThe main IDE (integrated development environment) used for this

71

Page 80: 205-00718 Study for the computational resolution of

project was NetBeans, and the programming language was c++. Thefinal program and all its classes were coded in this environment.

• Other IDEsIn the early stages of the project the Eclipse IDE for java was used.Codes developed with this IDE include the one dimensional heat con-duction case using a TDMA solver. Both transient and steady-statecodes were made. An expansion to 2D was being developed when themain programming language was change to C++ to adjust to industrystandards.Dev C++ was used for the 2D steady-state heat conduction problemusing a Gauss-Seidel solver

8.2.2 For The Report

• ReportThis report was written using the LATEX language in the Texmakerenvironment.

• FiguresFor the schematics the desktop application of draw.io was used.The results of the different simulation were presented in either .csv or.txt files. The former were studied using Microsoft Excel and the latterwith the default notepad application for windows 10. The graphs andtemperature maps were made from the .txt files using GnuPlot.

8.2.3 Other

• IDEsMatlab scripts were at one point made. They were initially intendedto be used to compare the numerical results with analytical solutionsand crate figures. That role was later taken by Microsoft Excel andGnuPlot.

• Image Processing SoftwareSome work was done with GIMP both to create schematics for thereport and to create .pbm files. These files opened as black and whiteimages, but the program read them as zeroes and ones. And couldthen assign different materials according to the value. The idea wasnot implemented in the final project due to the difficulties of creatingprecise geometries.

72

Page 81: 205-00718 Study for the computational resolution of

References

[1] Suhas V. Patankar Numerical Heat Transfer and Fluid Flow Taylor Fran-cis Group, 1980

[2] Frank P. Incroopera Fundamentals of Heat and Mass Transfer John WileySons, 2007

[3] Gabriel Valiente Feruglio Conposicion de Textos Cientıficos con LaTeXEdicions UPC, 1997

[4] CTTC Numerical Resolution of the generic convection-diffusion equation2020

[5] Jonathan Richard Shewchuk An introduction to the Conjugate GradientMethod Without the Agonizing Pain Edition 11

4School of Computer Sci-

ence Carneige Mellon University August 4, 1994

[6] CTTC Fractional Step Method Staggered and Collocated Meshes 2020

[7] CTTC Numerical Methods in Compressible Flows 2020

[8] CTTC Non-Viscous Flows potential flows (v1.1c) 2020

[9] Daniel Santos Serrano Advanced Study for the numerical resolution of theNavier-Stokes equations. Applications to the industrial and aerodynamicfields. June 2019

[10] John H.Lienhard IV & John H.Lienhard V A Heat Transfer Textbookfifth edition Phlogiston Press August 2019

[11] Jacob Fish & Ted Belytschko A First Course in Finite Elements JhonWiely & sons, 2007

[12] Thomas Williams & Colin Kelley Gnuplot 5.2 an Interactive PlottingProgram December 2019

[13] David Kotz LATEX and the GnuPlot plotting program 4.6, February2012

[14] James Hansen, Makiko Sato & others Global Temperature in 2019, 15January 2020

[15] U.Ghia K.N.Ghia & C.T.Shin Hi-Re Solution for Incompressible FlowUsing the Navier-Stokes Equations and Multigrid Methods Journal of Com-putational Physics, 1982

73

Page 82: 205-00718 Study for the computational resolution of

[16] hhttps://www.ree.es/es/sala-de-prensa/actualidad/notas-de-prensa/2019/12/espana-cierra-2019-con-un-10-mas-de-potencia-instalada-de-generacion-renovable last checked on 21/9/2020

[17] Avance de Emisiones de Gases de Efecto Invernadero correspondientesal ano 2019 Ministerio para la transicion ecologica y el reto demograficoJune 2020

74