CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (https://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   Adding LES to a laminar solver (https://www.cfd-online.com/Forums/openfoam-programming-development/205128-adding-les-laminar-solver.html)

amuzeshi August 9, 2018 23:20

Adding LES to a laminar solver
 
Hi there !


My question is about adding turbulence to a laminar solver.
I'm using rheoEFoam to simulate a flow with electro-kinetic effects:cool:. Unfortunately, this solver is laminar:(; I want to simulate electric-flow interaction using LES(Large Eddy Simulation). Do you have any idea doing so?


Best wishes:)
Ali

ano August 13, 2018 05:33

Hi Ali,


The big question would be whether you want to keep your rheological models or do you have a Newtonian fluid and only want to use the electric library?


The former would be complicated, the latter much easier.

amuzeshi August 13, 2018 08:48

Hi ano:)


My case is the latter, although there is a file named constitutiveProperties in constant directory of a rheoEFoam problem in which you could


set the "type" as Newtonian and not necessarily the other models.

ano August 13, 2018 09:42

Hello Ali,

The OpenFoam turbulence model uses the inbuilt transport model, which calculates the viscosity, so that the turbulence model can add the molecular and turbulent viscosity to an effective viscosity. Therefore, it is better to stick to the inbuilt transport model instead of the constitutive model, when you want to have turbulence.

You have to do two things: A) get rid of the constitutive model and B) use instead the inbuilt OpenFoam transportmodel to describe your viscosity and the turbulencemodel to describe your turbulence.

(0.First copy the solver to a new directory and rename it (change the names in Make/files and rhoEFoam.C). Compile with 'wmake' to see whether it works.)

A. Get rid of constitutive model:

1. Delete in createFields.H:
Code:


// Create constitutive equation
constitutiveModel constEq(U, phi);

Code:

    IOdictionary cttProperties
    (
        IOobject
        (
            "constitutiveProperties",
            runTime.constant(),
            mesh,
            IOobject::MUST_READ_IF_MODIFIED,
            IOobject::NO_WRITE
        )
    );

The easiest way is to look into simpleFoam and look for everywhere where 'turbulence' or 'turbulent appears' and include these changes into rheoEFoam. You will end up for OF4 version of rheoEFoam with the following steps:

2. Delete in rheoEFoam.C (or the new name you use):
Code:

#include "constitutiveModel.H"
and
Code:

// ---- Solve constitutive equation ----                 
constEq.correct();

After this compiling is not possible since the solver still calls 'constEq' in velocity equation file, i.e. UEqn.H. This you are going to change in the next section.

B) Use instead the inbuilt OpenFoam transportModel to describe your viscosity and the turbulenceModel to describe your turbulence:

1. Add at the end of createFields.H the lines to create a transport model instance and a turbulence instance. And also a transportProperties dictionary to read the density whcih you need for the electric forcing:

Code:

singlePhaseTransportModel laminarTransport(U, phi);

autoPtr<incompressible::turbulenceModel> turbulence
(
    incompressible::turbulenceModel::New(U, phi, laminarTransport)
);
Info« "Reading transportProperties\n" « endl;
IOdictionary transportProperties
    (
  IOobject
      (
    "transportProperties",
    runTime.constant(),
    mesh,
    IOobject::MUST_READ_IF_MODIFIED,
    IOobject::NO_WRITE
      )
);
dimensionedScalar rho
    (
  transportProperties.lookup("rho")
);

2. Add the words in the bold font in rheoEFoam.C (the words in normal font are for your orientation).
First to read the declarations of the transport and turbulence model into your solver.
Code:

#include "ppUtilInterface.H"
#include "EDFModel.H"
#include "singlePhaseTransportModel.H"
#include "turbulentTransportModel.H"

Then to update and validate the turbulence fields, e.g. the turbulent viscosity nut after the construction of the object (which happens in createFields.H), add before the simple loop:
Code:

    #include "initContinuityErrs.H"

    turbulence->validate();

Before the fields are written to the time directory add a correction of both instances (e.g. update of turbulent viscosity based on the new velocity field):
Code:

        laminarTransport.correct();
        turbulence->correct();


        runTime.write();

3. Change the UEqn.H to include the Reynoldsstress and get rid of the constEq:
Code:

  (
        fvm::ddt(U)
      + fvm::div(phi, U)
      + turbulence->divDevReff(U)
      ==
        fvOptions(U)
      + elecM.Fe()/rho 

  );

4. In the end add the following bold lines to Make/options:
Code:

EXE_INC = \
  -I$(LIB_SRC)/TurbulenceModels/turbulenceModels/lnInclude \
    -I$(LIB_SRC)/TurbulenceModels/incompressible/lnInclude \
    -I$(LIB_SRC)/transportModels \
    -I$(LIB_SRC)/transportModels/incompressible/singlePhaseTransportModel \

.....

EXE_LIBS = \
  -lturbulenceModels \
    -lincompressibleTurbulenceModels \

    -lincompressibleTransportModels \

Afterwards compile. Please let me know whether it worked, I didn't try the steps myself. So most probably I am missing something.

In the end you can copy the transportProperties and turbulenceProperties e.g. from 'tutorials/incompressible/pimpleFoam/LES/channel395/constant', you have to add rho to the transportProperties file.

I wonder whether one can use the 'normal' turbulence models for flow with electro-kinetic effects?

amuzeshi August 13, 2018 12:50

I really appreciate your accurate, coherent and high velocity reply :D. I will do this and let you know what happens :). To the best of my


knowledge, RANS models don't fit for low Re problems with which I'm dealing.

amuzeshi August 19, 2018 03:31

Quote:

Originally Posted by ano (Post 702461)
Hello Ali,

The OpenFoam turbulence model uses the inbuilt transport model, which calculates the viscosity, so that the turbulence model can add the molecular and turbulent viscosity to an effective viscosity. Therefore, it is better to stick to the inbuilt transport model instead of the constitutive model, when you want to have turbulence.

You have to do two things: A) get rid of the constitutive model and B) use instead the inbuilt OpenFoam transportmodel to describe your viscosity and the turbulencemodel to describe your turbulence.

(0.First copy the solver to a new directory and rename it (change the names in Make/files and rhoEFoam.C). Compile with 'wmake' to see whether it works.)

A. Get rid of constitutive model:

1. Delete in createFields.H:
Code:


// Create constitutive equation
constitutiveModel constEq(U, phi);

Code:

    IOdictionary cttProperties
    (
        IOobject
        (
            "constitutiveProperties",
            runTime.constant(),
            mesh,
            IOobject::MUST_READ_IF_MODIFIED,
            IOobject::NO_WRITE
        )
    );

The easiest way is to look into simpleFoam and look for everywhere where 'turbulence' or 'turbulent appears' and include these changes into rheoEFoam. You will end up for OF4 version of rheoEFoam with the following steps:

2. Delete in rheoEFoam.C (or the new name you use):
Code:

#include "constitutiveModel.H"
and
Code:

// ---- Solve constitutive equation ----                 
constEq.correct();

After this compiling is not possible since the solver still calls 'constEq' in velocity equation file, i.e. UEqn.H. This you are going to change in the next section.

B) Use instead the inbuilt OpenFoam transportModel to describe your viscosity and the turbulenceModel to describe your turbulence:

1. Add at the end of createFields.H the lines to create a transport model instance and a turbulence instance. And also a transportProperties dictionary to read the density whcih you need for the electric forcing:

Code:

singlePhaseTransportModel laminarTransport(U, phi);

autoPtr<incompressible::turbulenceModel> turbulence
(
    incompressible::turbulenceModel::New(U, phi, laminarTransport)
);
Info« "Reading transportProperties\n" « endl;
IOdictionary transportProperties
    (
  IOobject
      (
    "transportProperties",
    runTime.constant(),
    mesh,
    IOobject::MUST_READ_IF_MODIFIED,
    IOobject::NO_WRITE
      )
);
dimensionedScalar rho
    (
  transportProperties.lookup("rho")
);

2. Add the words in the bold font in rheoEFoam.C (the words in normal font are for your orientation).
First to read the declarations of the transport and turbulence model into your solver.
Code:

#include "ppUtilInterface.H"
#include "EDFModel.H"
#include "singlePhaseTransportModel.H"
#include "turbulentTransportModel.H"

Then to update and validate the turbulence fields, e.g. the turbulent viscosity nut after the construction of the object (which happens in createFields.H), add before the simple loop:
Code:

    #include "initContinuityErrs.H"

    turbulence->validate();

Before the fields are written to the time directory add a correction of both instances (e.g. update of turbulent viscosity based on the new velocity field):
Code:

        laminarTransport.correct();
        turbulence->correct();


        runTime.write();

3. Change the UEqn.H to include the Reynoldsstress and get rid of the constEq:
Code:

  (
        fvm::ddt(U)
      + fvm::div(phi, U)
      + turbulence->divDevReff(U)
      ==
        fvOptions(U)
      + elecM.Fe()/rho 

  );

4. In the end add the following bold lines to Make/options:
Code:

EXE_INC = \
  -I$(LIB_SRC)/TurbulenceModels/turbulenceModels/lnInclude \
    -I$(LIB_SRC)/TurbulenceModels/incompressible/lnInclude \
    -I$(LIB_SRC)/transportModels \
    -I$(LIB_SRC)/transportModels/incompressible/singlePhaseTransportModel \

.....

EXE_LIBS = \
  -lturbulenceModels \
    -lincompressibleTurbulenceModels \

    -lincompressibleTransportModels \

Afterwards compile. Please let me know whether it worked, I didn't try the steps myself. So most probably I am missing something.

In the end you can copy the transportProperties and turbulenceProperties e.g. from 'tutorials/incompressible/pimpleFoam/LES/channel395/constant', you have to add rho to the transportProperties file.

I wonder whether one can use the 'normal' turbulence models for flow with electro-kinetic effects?

After the step B-5 above:

6-in solver.C delete :
Code:

    bool  sPS =  cttProperties.subDict("passiveScalarProperties").lookupOrDefault<Switch>("solvePassiveScalar",  false);
Code:

if (sPS) C.writeOpt() = IOobject::AUTO_WRITE;
Code:

if (sPS)
            {
              #include "CEqn.H"
            }

7-in UEqn.H ADD the words in the bold font:

Code:

    dimensionedScalar  rho_ = transportProperties.lookup("rho");
    tmp<fvVectorMatrix> tUEqn
    (
        fvm::ddt(U)
      + fvm::div(phi, U)
+ turbulence->divDevReff(U)
      ==
        fvOptions(U) 

      + elecM.Fe()/rho_
    );

9- wmake
And that's it! It is successfully compiled! :D
ano ! I really appreciate your co-operation.:)


All times are GMT -4. The time now is 07:10.