# RhoSimpleFoam

rhoSimpleFoam

rhoSimpleFoam is a steady-state solver for compressible, turbulent flow, using the SIMPLE (Semi-Implicit Method for Pressure Linked Equations) algorithm. In the newer releases it also includes an option to use the SIMPLEC (Semi-Implicit Method for Pressure Linked Equations Consistent) algorithm. It is a pressure based compressible solver. That means that a pressure equation is solved and the density is related to the pressure via an equation of state.

## 1 Solution Strategy

The solver follows a segregated solution strategy. This means that the equations for each variable characterizing the system (the velocity $\bold u$, the pressure $p$, the energy (either internal energy or enthalpy depending on the choice of the user) and the variables characterizing turbulence) is solved sequentially and the solution of the preceding equations is inserted in the subsequent equation. The non-linearity appearing in the momentum equation (the face flux $\phi_f$ which is a function of the velocity and density $\rho_f$ ) is resolved by computing it from the velocity and pressure values of the preceding iteration. Note that the density is related to the pressure via an equation of state which can be selected by the user. The dependence from the pressure is introduced to avoid a decoupling between the momentum and pressure equations and hence the appearance of high frequency oscillation in the solution (check board effect). The first equation to be solve is the momentum equation. It delivers a velocity field $\bold u^*$ which is in general not divergence free, i.e. it does not satisfy the continuity equation. After that the energy equation is solved. Then that the momentum and the continuity equations are used to construct an equation for the pressure. The aim is to obtain a pressure field $p^{n}$, which, if inserted in the momentum equation, delivers a divergence free velocity field $\bold u$. After correcting the velocity field, the equations for turbulence are solved. The above iterative solution procedure is repeated until convergence.

A good book which describes the derivation of the pressure equation for compressible cases is the one of [1].

The source code can be found in rhoSimpleFoam.C



int main(int argc, char *argv[])
{
argList::addNote
(
"Steady-state solver for compressible turbulent flow."
);

#include "postProcess.H"

#include "addCheckCaseOptions.H"
#include "setRootCaseLists.H"
#include "createTime.H"
#include "createMesh.H"
#include "createControl.H"
#include "createFields.H"
#include "createFieldRefs.H"
#include "initContinuityErrs.H"

turbulence->validate();

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

Info<< "\nStarting time loop\n" << endl;

while (simple.loop())
{
Info<< "Time = " << runTime.timeName() << nl << endl;

// Pressure-velocity SIMPLE corrector
#include "UEqn.H"
#include "EEqn.H"

if (simple.consistent())
{
#include "pcEqn.H"
}
else
{
#include "pEqn.H"
}

turbulence->correct();

runTime.write();

runTime.printExecutionTime(Info);
}

Info<< "End\n" << endl;

return 0;
}


## 2 Equations

In the next section the equation to be solved are described. In contrast to incompressible fluids, where the density is constant, in compressible flows the density varies in space and time, i.e., it the density became a thermodynamic property. For a pure mixture the thermodynamic state is fully described by to variables, i.e., $\rho = \rho(p,T)$ the density is a function of the pressure and the temperature. For this reason in compressible flows we need to solve besides the equations for the momentum and the pressure (which is derived from the continuity equations) also an equation which gives us the evolution of the temperature. We will see later that the temperature is obtained via a thermodynamic relation after we solved the energy equation. After that, the density $\rho$ can be obtained from the other two variables via an equation of state.

### 2.1 Momentum Equation

The equation of motion in rhosimpleFoam are written for a moving frame of reference. They are however formulated for the absolute velocity (the derivation of the equations of motion can be found in https://openfoamwiki.net/index.php/See_the_MRF_development and also in https://diglib.tugraz.at/download.php?id=581303c7c91f9&location=browse. Some additional information can be found in https://pingpong.chalmers.se/public/pp/public_courses/course07056/published/1497955220499/resourceId/3711490/content/UploadedResources/HakanNilssonRotatingMachineryTrainingOFW11-1.pdf):

 - $\nabla \cdot ( \rho \bold{u_R} \otimes \bold{u_I}) + \rho \bold{\Omega} \times \bold{u_I} = \nabla p + \nabla \cdot (\bold{R_{vis}} + \bold{R_{tur}} )$ (1)

$\bold{u_R}$ represents the velocity in the relative reference frame, $\bold{u_I}$ is the velocity described in the inertial reference frame, $\bold{\Omega}$ is the angular velocity of the moving reference frame, $\bold{R_{vis}} + \bold{R_{tur}}$ is the sum of the viscous and turbulent stress tensor.

The source code can be found in the file UEqn.H:


// Solve the Momentum equation

MRF.correctBoundaryVelocity(U);

tmp<fvVectorMatrix> tUEqn
(
fvm::div(phi, U)
+ MRF.DDt(rho, U)
+ turbulence->divDevRhoReff(U)
==
fvOptions(rho, U)
);
fvVectorMatrix& UEqn = tUEqn.ref();

UEqn.relax();

fvOptions.constrain(UEqn);

solve(UEqn == -fvc::grad(p));

fvOptions.correct(U);

# 3 References

1. Moukalled, F., L. Mangani, and M. Darwish. "The finite volume method in computational fluid dynamics." An Advanced Introduction with OpenFOAM and Matlab (2016):