Project 3- Adding a temperature dictionary to the incompressible icoFoam case to solve the energy equation
The LaTeX code of the file is mentioned below with the link of the PDF. The PDF of the report also contains the link to the GitHub repository.
https://drive.google.com/file/d/17sC718EAc1XHs526hOgBbb3LOFoW5U5e/view?usp=sharing
\documentclass[a5paper]{report}
\usepackage{graphicx} % Required for inserting images
\usepackage{hyperref} % Required for inserting Url's
\title{\textbf{Customizing the icoFoam solver to solve the Temperature field in OpenFOAM.}}
\author{Altamash Siddiqui}
\date{September 2023}
\begin{document}
\maketitle
\section{\underline{Aim}:}
To customize the \textit{incompressible/icoFoam} solver of OpenFOAM to solve the \textbf{Temperature} field and run the solver on a tutorial.
\section{\underline{Objective}:}
\begin{itemize}
\item To create a \underline{icoTempFoam} solver by copying and customizing the working of icoFOAM solver of incompressible solvers.
\item Adding the \textbf{Temperature equation} in the main source code of icoFOAM.
\item Running it on the \textit{incompressible/cavity} tutorial by creating and customizing the tutorial according to the need of the solver.
\item Adding and committing the changes done on the concern files to \textbf{Git repository}.
\end{itemize}
By doing so we gain the proper understanding to how to write and customize the existing code according to our need and what requirements and changes are necessary to create a solver and test it on a tutorial.\newpage
\section{\underline{Theory and Working}:}\subsection{\textbf{icoFOAM:}}
The \textit{icoFOAM} solver is a part of \underline{Incompressible solvers} group. It is a \textbf{Transient solver for incompressible, laminar flow of Newtonian fluids}.\\ The icoFOAM solver solves the \textbf{Continuity Equation} \begin{equation}
\nabla\cdot u = 0
\end{equation} and \textbf{Momentum Equation} \begin{equation}
\frac{\partial\mathbf{u}}{\partial\mathbf{t}} + \mathbf{\nabla}\cdot \mathbf{(u\otimes u)} - \mathbf{\nabla\cdot (\nu\nabla u)} = \mathbf{-\nabla p}
\end{equation} for simulating the flow and not the Energy equation.\\ Where \textbf{u} = Velocity \(m/s\)\\ \textbf{p} = Kinematic Pressure, In OpenFOAM the pressure used is \textbf{Kinematic Pressure}, which is given by $\frac{\mathbf{p_s}}{\mathbf{\rho}}$ where $p_s$ is static pressure. It's units are {$m^2/s^2$}.\\ The icoFOAM uses the \textbf{PISO} algorithm to solve the continuity and momentum equation.\par
The icoFOAM solver, solves only the Continuity and Momentum Equation to simulate fluid flow. If we want the solver to solve for Temperature than we have to add the following equation in the source code:\begin{equation}\label{Teqn}
\frac{\partial\mathbf{T}}{\partial\mathbf{t}} + \mathbf{(U\cdot\nabla)T} = \mathbf{\kappa\nabla^2 T}
\end{equation} where $\kappa$ is the \textbf{Heat Diffusion Coefficient} it's unit is $m^2/s$.
\section{Procedure:} \subsection{\underline{Creating the solver}:}Initially the icoFoam solver do not solve energy equation so we have to add equation (3) as mentioned, into the \textit{solver source code}. To do so follow the steps below:
\begin{enumerate}
\item Copy the complete \textit{icoFoam} solver,that contains the \textbf{Make}, \textbf{createField.H} and the \textbf{icoFoam.C} file from the \underline{OpenFOAM directory to your own \textit{solvers} directory}. Copy the \textit{icoFoam} as \textbf{\textit{tempicoFoam}} as shown in image below. \\ \includegraphics[width=10cm , height=3cm]{image/copy to run.png}
\item Navigate to you \textit{solvers} directory and go to your tempicoFoam solver root file. As we are going to make a lot of changes it is best to Version Control the modified files,so initialize a \textbf{git} in the solver folder.\\ \includegraphics[width=10cm , height=3cm]{git init.png}. So from now on the changes made in the files are supposed to be \textbf{add} and \textbf{commit} using the git commands to keep track of the changes.
\item First thing to do is to change the name of the source code file from \textit{icoFoam.C} to \textit{tempicoFoam.C} that matches with the description of the solver.\\ This can be done using this command: \textbf{\underline{mv icoFoam.C tempicoFoam.C}}\\ \includegraphics[width=10cm , height=3cm]{changes .C file name.png}
\item As we have changed the source code file name, this same thing has to be done in the \textit{Make/files} folder. The \textit{files} contains the Compiled location path which has to be change to USER APPBIN as well as the executable name and the source file that has to be compiled.\\ \includegraphics[width=10cm , height=3cm]{Makefiles changes.png} This will make sure that whatever chnages are made,compiles in \textbf{\textit{user bin}} with customized executable name.
\item All the changes that are done make sure to add them to staging area and then commit them, so that these files are version controll and also can be pushed to \textbf{GitHub}. \\ \includegraphics[width=10cm , height=3cm]{Makefiles git add and commit.png}
\item As we want the solver to solve the Temperature equation, we have to created the \textbf{Temperature} Field and also we have to include the constant $\mathbf{\kappa}$ into the \textit{transportProperties} dictionary.
\begin{itemize}
\item Navigate to the \textbf{createField.H} file and add the scalar field that is Temperature and set it to AUTO READ and AUTO WRITE. So the temperature field is read from \textbf{0} written for every time-step. \\ \includegraphics[width=10cm , height=3cm]{adding T in cF.H.png}
\item The constant $\mathbf{\kappa}$ also a input and has to be read for calculation, this has to be read from the transportProperties. So beneath the $\nu$ constant we will initialize $\kappa$. Also mention proper dimensionSet for the constant using the \textit{dimensionSet} function of OpenFOAM.\\ \includegraphics[width=10cm , height=3cm]{adding kappa in cF.h.png}. After add and commit these changes to local git.
\item Here is the full \textbf{createField.H} file:\\ \begin{verbatim}
Info<< "Reading transportProperties\n" << endl xss=removed xss=removed includegraphics[width=10cm height=3cm]{add includegraphics[width=10cm height=3cm]{compilation includegraphics[width=10cm height=3cm]{checking includegraphics[width=10cm height=3cm]{copy includegraphics[width=10cm height=3cm]{cavity includegraphics[width=10cm height=3cm]{T.png} includegraphics[width=10cm height=3cm]{controlDict.png} includegraphics[width=10cm height=3cm]{fvSchemes.png} includegraphics[width=10cm height=3cm]{fvSolution.png} xss=removed OPENFOAM=2212 patch=230110 version=2212 LSB;label=32;scalar xss=removed xss=removed xss=removed xss=removed xss=removed xss=removed xss=removed xss=removed xss=removed xss=removed xss=removed xss=removed xss=removed xss=removed xss=removed xss=removed xss=removed xss=removed xss=removed xss=removed includegraphics[width=7cm height=3cm]{image/pinital.png} includegraphics[width=7cm height=3cm]{image/Ufinal.png} includegraphics[width=7cm height=3cm]{image/Tinital.png} includegraphics[width=7cm height=3cm]{image/Tfinal.png}>