CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Running, Solving & CFD

rhoPimpleFoam

Register Blogs Community New Posts Updated Threads Search

Like Tree3Likes
  • 1 Post By ano
  • 1 Post By ano
  • 1 Post By Fridrik

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   October 10, 2017, 06:52
Question rhoPimpleFoam
  #1
Member
 
Fridrik Magnusson
Join Date: Aug 2017
Location: Denmark
Posts: 34
Rep Power: 9
Fridrik is on a distinguished road
Hallo everyone

I am studying a Transient, turbulent, compressible flow regime. I think the "rhoPimpleFoam" solver is a good start, but are interested in investigating the governing equation, so i know exactly what the OF is doing.

Can anybody help me get the source code of the solver ?

- Fridrik Magnusson
Fridrik is offline   Reply With Quote

Old   October 10, 2017, 06:56
Default
  #2
ano
Member
 
ano
Join Date: Jan 2017
Location: Delft
Posts: 58
Rep Power: 10
ano is on a distinguished road
Hi Fridrik

1. source your OpenFoam version.
2. type "sol" to go to the source code for solvers
3.
Code:
cd compressible/rhoPimpleFoam
4. Have a look at rhoPimpleFoam.C for seeing the structure. it includes the other files in the directory.
Fridrik likes this.
ano is offline   Reply With Quote

Old   October 11, 2017, 04:12
Default
  #3
Member
 
Fridrik Magnusson
Join Date: Aug 2017
Location: Denmark
Posts: 34
Rep Power: 9
Fridrik is on a distinguished road
Thanks ano

I might need a bit of help with deciphering the Source-code.

Where can i see that the solver, solves the continuity, momentum and energy equation ? (Sourcecode of rhoPimpleFoam.C below)

Code:
 /*---------------------------------------------------------------------------*\
  =========                 |
  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
   \\    /   O peration     |
    \\  /    A nd           | Copyright (C) 2011-2017 OpenFOAM Foundation
     \\/     M anipulation  |
-------------------------------------------------------------------------------
License
    This file is part of OpenFOAM.

    OpenFOAM is free software: you can redistribute it and/or modify it
    under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    for more details.

    You should have received a copy of the GNU General Public License
    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.

Application
    rhoPimpleFoam

Group
    grpCompressibleSolvers

Description
    Transient solver for turbulent flow of compressible fluids for HVAC and
    similar applications.

    Uses the flexible PIMPLE (PISO-SIMPLE) solution for time-resolved and
    pseudo-transient simulations.

\*---------------------------------------------------------------------------*/

#include "fvCFD.H"
#include "fluidThermo.H"
#include "turbulentFluidThermoModel.H"
#include "bound.H"
#include "pimpleControl.H"
#include "pressureControl.H"
#include "fvOptions.H"
#include "localEulerDdtScheme.H"
#include "fvcSmooth.H"

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

int main(int argc, char *argv[])
{
    #include "postProcess.H"

    #include "setRootCase.H"
    #include "createTime.H"
    #include "createMesh.H"
    #include "createControl.H"
    #include "createTimeControls.H"
    #include "initContinuityErrs.H"
    #include "createFields.H"
    #include "createFieldRefs.H"
    #include "createFvOptions.H"

    turbulence->validate();

    if (!LTS)
    {
        #include "compressibleCourantNo.H"
        #include "setInitialDeltaT.H"
    }

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

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

    while (runTime.run())
    {
        #include "readTimeControls.H"

        if (LTS)
        {
            #include "setRDeltaT.H"
        }
        else
        {
            #include "compressibleCourantNo.H"
            #include "setDeltaT.H"
        }

        runTime++;

        Info<< "Time = " << runTime.timeName() << nl << endl;

        if (pimple.nCorrPIMPLE() <= 1)
        {
            #include "rhoEqn.H"
        }

        // --- Pressure-velocity PIMPLE corrector loop
        while (pimple.loop())
        {
            #include "UEqn.H"
            #include "EEqn.H"

            // --- Pressure corrector loop
            while (pimple.correct())
            {
                if (pimple.consistent())
                {
                    #include "pcEqn.H"
                }
                else
                {
                    #include "pEqn.H"
                }
            }

            if (pimple.turbCorr())
            {
                turbulence->correct();
            }
        }

        rho = thermo.rho();

        runTime.write();

        Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
            << "  ClockTime = " << runTime.elapsedClockTime() << " s"
            << nl << endl;
    }

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

    return 0;
}


// ************************************************************************* //
Fridrik is offline   Reply With Quote

Old   October 12, 2017, 05:18
Default
  #4
ano
Member
 
ano
Join Date: Jan 2017
Location: Delft
Posts: 58
Rep Power: 10
ano is on a distinguished road
Hello Fridrik,

1. The code includes some "header" files, basically it just copies the included file at these positions, for the momentum predictor for example:
Code:
# include "UEqn.H"
The energy equation is EEqn.H and the pressure corrector loop is marked in the code by a comment.
The density calculation happens after the Pimple loop using thermo.rho() (in which your thermophysical model such as ideal gas is hidden)

2. It is helpful to have a look at the explanation of the simpleFoam implementation (and pimpleFoam , the first one explains more about the code).
ano is offline   Reply With Quote

Old   October 18, 2017, 01:58
Post Energy equation
  #5
Member
 
Fridrik Magnusson
Join Date: Aug 2017
Location: Denmark
Posts: 34
Rep Power: 9
Fridrik is on a distinguished road
Thanks Ano,
That really helped, i have one question on the implementation of the energy equation.

Why is the governing equation defined as:


\rho \frac{DQ}{Dt}\equiv\frac{\partial \rho Q}{\partial t}+\nabla\cdot (\rho UQ)
Why not:
\rho \frac{DQ}{Dt}\equiv\rho \left(\frac{\partial  Q}{\partial t}+\nabla\cdot ( UQ)\right)

Why can the density jump in and out of the material differential ? (unless the density is constant)

Last edited by Fridrik; October 18, 2017 at 02:07. Reason: missing equations:
Fridrik is offline   Reply With Quote

Old   October 18, 2017, 09:03
Default
  #6
ano
Member
 
ano
Join Date: Jan 2017
Location: Delft
Posts: 58
Rep Power: 10
ano is on a distinguished road
Hi Fridrik,

this is a very good question.

\frac{D ( \rho Q)}{D t}=\rho \frac{D Q}{D t}+Q \frac{D \rho}{D t}

In the last term the continuity equation is hidden, which is zero: \frac{D \rho}{D t}=0

Consequently
\frac{D (\rho Q)}{D t}=\rho \frac{D Q}{D t}

I attach a detailed derivation of the energy equation like it is used in many OF solvers (I noted this down some time ago. If you find mistakes, please tell me. Only the energy dissipation term due to viscous stresses in the second last equation is typically neglected as well.)
Attached Files
File Type: pdf derivationHeatEq_EV.pdf (41.3 KB, 196 views)
ErenC likes this.
ano is offline   Reply With Quote

Old   October 18, 2017, 09:55
Default
  #7
Member
 
Fridrik Magnusson
Join Date: Aug 2017
Location: Denmark
Posts: 34
Rep Power: 9
Fridrik is on a distinguished road
Hi ano
Quote:
Originally Posted by ano View Post
In the last term the continuity equation is hidden, which is zero: \frac{D \rho}{D t}=0
It seems to add up, but i cannot agree on the continuity equation yet, can because i derive it to be:

\frac{D\rho}{Dt}+\rho(\nabla u) = 0

Am i missing something fundamental ?

a quick derivation of the cont eq.
conteq.PNG
Fridrik is offline   Reply With Quote

Old   October 20, 2017, 04:58
Default
  #8
ano
Member
 
ano
Join Date: Jan 2017
Location: Delft
Posts: 58
Rep Power: 10
ano is on a distinguished road
You are right. I should correct that in my notes.

But also including the compressible terms in the Navier-Stokes equations you get rid of the density in the material derivative in the end.
ano is offline   Reply With Quote

Old   October 20, 2017, 05:30
Default
  #9
Member
 
Fridrik Magnusson
Join Date: Aug 2017
Location: Denmark
Posts: 34
Rep Power: 9
Fridrik is on a distinguished road
Then:

\frac{D\rho Q}{DT}\neq\rho\frac{DQ}{DT}

Which suggest that the energy equation is wrongly implemented for compressible cases ?

where it should be:
\rho\frac{DQ}{DT}\equiv\rho\left(\frac{DQ}{DT}+\nabla\cdot (UQ)\right)

-Fridrik Magnusson
Fridrik is offline   Reply With Quote

Old   October 20, 2017, 10:14
Default
  #10
ano
Member
 
ano
Join Date: Jan 2017
Location: Delft
Posts: 58
Rep Power: 10
ano is on a distinguished road
Quote:
But also including the compressible terms in the Navier-Stokes equations you get rid of the density in the material derivative in the end.
Go through the derivation including the compressible terms (the ones containing the divergence of the velocity) for all equations. And you will again be able to write your density outside the derivative without additional terms.

(If not, please post which additional term you can not get rid of or where you got stuck.)
ano is offline   Reply With Quote

Old   October 23, 2017, 05:49
Default
  #11
Member
 
Fridrik Magnusson
Join Date: Aug 2017
Location: Denmark
Posts: 34
Rep Power: 9
Fridrik is on a distinguished road
Ano you where right, After deriving the energy equation. The cont. eq. arrived.

I have showned the proof below

Capture.PNG

-Fridrik Magnusson
ano likes this.
Fridrik is offline   Reply With Quote

Reply

Tags
governing equation, rhopimplefoam


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
rhoPimpleFoam Boundary Condition Problem dancfd OpenFOAM Pre-Processing 18 September 16, 2021 07:43
rhoPimpleFoam solver adrieno OpenFOAM Running, Solving & CFD 11 April 6, 2016 11:01
Pressure stair-step behaviour using rhopimplefoam joegi.geo OpenFOAM Running, Solving & CFD 3 December 12, 2014 12:10
rhoPimpleFoam floating point error dancfd OpenFOAM Running, Solving & CFD 6 January 5, 2014 20:57
Questions about buoyantPimpleFoam and rhoPimpleFoam Mojtaba.a OpenFOAM Running, Solving & CFD 6 August 1, 2012 04:50


All times are GMT -4. The time now is 20:44.