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

Implementing a local Cmu in k-epsilon model

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   June 15, 2020, 16:40
Default Implementing a local Cmu in k-epsilon model
  #1
Senior Member
 
René Thibault
Join Date: Dec 2019
Location: Canada
Posts: 114
Rep Power: 6
Tibo99 is on a distinguished road
Hi foamers!

I try to implement a Cmu constant which varies in term of 'z' in the domain for the k-epsilon turbulence model. So, in other words, I try to implement a local Cmu in the domain.

I looked for some code example on the web and here on CFD-Online, but had no luck.

Is there someone that could point me out toward something in order to be able to achieve that?

Thank for your help!

Best Regards,

Last edited by Tibo99; June 15, 2020 at 17:50.
Tibo99 is offline   Reply With Quote

Old   June 22, 2020, 04:21
Default
  #2
Senior Member
 
Join Date: Dec 2019
Location: Cologne, Germany
Posts: 355
Rep Power: 8
geth03 is on a distinguished road
i think that one is possible.

you would need to create a new turbulence model which inherits from the
k-epsilon turbulence model.

then you can overwrite/re-implement the correct()-function, bc here k and epsilon equations are solved. you can create a new Cmu, which is calculated based on the 'z' in your domain. adjust the k-epsilon equation afterwards.

keep in mind that this modification demands advanced programming skills.

i don't know any tutorial or whatsoever that shows how to do that.
geth03 is offline   Reply With Quote

Old   June 22, 2020, 14:51
Default
  #3
Senior Member
 
René Thibault
Join Date: Dec 2019
Location: Canada
Posts: 114
Rep Power: 6
Tibo99 is on a distinguished road
Thank you very much for replying!

I think your're right about how complex this could be.

But, I end up with the following attempt.

I obviously copy the whole structure for the k-e model and name it kEpsilonABL.

And then, I saw in the literature that Cmu(z) = u*^4/k(z)^2 (see picture in attachment).

So, What I've done is, I switched the variable 'Cmu_' in the code for 'uStar_' and then assign the unit with 'dimensionSet' in order to be consistent with the unit, like so:

Code:
 uStar_
    (
        dimensioned<scalar>::lookupOrAddToDict
        (
            "uStar",
            this->coeffDict_,
            dimensionSet(0, 1, -1, 0, 0, 0, 0),
            0.511
        )
    ),
And then, I added to following line

Code:
const volScalarField Cmu_ = pow(uStar_,4)/pow(k_,2);
here,

Code:
void kEpsilonABL<BasicTurbulenceModel>::correctNut()
{
    const volScalarField Cmu_ = pow(uStar_,4)/pow(k_,2);
    this->nut_ = Cmu_*(sqr(k_)/epsilon_);
    this->nut_.correctBoundaryConditions();
    fv::options::New(this->mesh_).correct(this->nut_);

    BasicTurbulenceModel::correctNut();
}
Finnaly, I compile everything.

Everything compute and converge. The shape of the profile for the tubulent kinetic energy 'k' is good, but don't have the right results. The values are about 3x greater of what the analytic results give. Obviously, since the value for 'k' are not good, the values on the velocity profile 'Ux' and 'epsilon' are not there, but the shape of the profiles are good though.

Any suggestions? Do you think this could or should work?

Best Regards!
Attached Images
File Type: png Cmu.png (1.1 KB, 81 views)
Attached Files
File Type: c kEpsilonABL.C (7.7 KB, 11 views)
File Type: h kEpsilonABL.H (6.2 KB, 7 views)
Tibo99 is offline   Reply With Quote

Old   June 23, 2020, 05:42
Default
  #4
Senior Member
 
Join Date: Dec 2019
Location: Cologne, Germany
Posts: 355
Rep Power: 8
geth03 is on a distinguished road
i think your approach is ok.

i assume, from your 1-D dependancy of Cmu_, that your flow problem is also 1-D. is that correct?
geth03 is offline   Reply With Quote

Old   June 23, 2020, 11:21
Default
  #5
Senior Member
 
René Thibault
Join Date: Dec 2019
Location: Canada
Posts: 114
Rep Power: 6
Tibo99 is on a distinguished road
Hi!

Yes, you're right.

I started with this approach to make the BC work with the model and matching the analytics solution.

By confirming this, I'll step in with a 2D simulation and I guess it should work.

But, like I said, the result are no good in 1D. It doesn't match with the analytics results by using the code's line I just showed in my last post.

I can't find where is the issue by doing this that way.....

Thank for replying though!

Regards,
Tibo99 is offline   Reply With Quote

Old   June 23, 2020, 15:56
Default
  #6
Senior Member
 
Michael Alletto
Join Date: Jun 2018
Location: Bremen
Posts: 615
Rep Power: 15
mAlletto will become famous soon enough
Did you check that the cmu used in the boundary condition for nut is the same as the one computed in your modification
mAlletto is offline   Reply With Quote

Old   June 23, 2020, 16:09
Default
  #7
Senior Member
 
René Thibault
Join Date: Dec 2019
Location: Canada
Posts: 114
Rep Power: 6
Tibo99 is on a distinguished road
Good question!

Since I didn't get any error when I launched the simulation, I was assuming that the 'Cmu' use for 'nut' in the boundary conditions was the same (global variable).

I modify it in the espilon boundary condition, but not in nut. Don't know why!!!!!!! No rational answer!!! lol

Since 'k' is use in 'nut', I'll add a constant 'ustar' and then compute 'Cmu' as I did in the turbulence model but in the loop.

Let see if this will work........

Thank again!!!

Last edited by Tibo99; June 23, 2020 at 21:08.
Tibo99 is offline   Reply With Quote

Old   June 23, 2020, 21:34
Default
  #8
Senior Member
 
René Thibault
Join Date: Dec 2019
Location: Canada
Posts: 114
Rep Power: 6
Tibo99 is on a distinguished road
Here is the results of the simulation. Obviously, it didn't work. It look like something happen at the bottom of the 'k' profile but, other than that, the shape of every profile seems to follow the right law.

See file in attachment for the BC applied. A source term has been apply on epsilon and k (see Parente: https://www.researchgate.net/publica...n_of_ABL_flows).

I added the following code line in the nut file:

Code:
const scalar Cmu25 = pow025(pow(ustar_,4)/pow(k[celli],2));
in the loop here:

Code:
forAll(nutw, facei)
    {
        label celli = patch().faceCells()[facei];
		
	const scalar Cmu25 = pow025(pow(ustar_,4)/pow(k[celli],2));
		
        scalar uStar = Cmu25*sqrt(k[celli]);
        scalar yPlus = uStar*y[facei]/nuw[facei];

        scalar Edash = (y[facei] + z0_[facei])/z0_[facei];

        nutw[facei] =
            nuw[facei]*(yPlus*kappa_/log(max(Edash, 1+1e-4)) - 1);

        if (debug)
        {
            Info<< "yPlus = " << yPlus
                << ", Edash = " << Edash
                << ", nutw = " << nutw[facei]
                << endl;
        }
    }
Any suggestions? Any thought?

Thank you very much for your tips!

Regards,
Attached Images
File Type: png 1D_Results.png (30.3 KB, 21 views)
File Type: png BC.png (3.5 KB, 13 views)
Attached Files
File Type: c nutParenteWallFunctionFvPatchScalarField.C (5.6 KB, 4 views)
File Type: h nutParenteWallFunctionFvPatchScalarField.H (5.9 KB, 3 views)
Tibo99 is offline   Reply With Quote

Old   June 24, 2020, 04:28
Default
  #9
Senior Member
 
Michael Alletto
Join Date: Jun 2018
Location: Bremen
Posts: 615
Rep Power: 15
mAlletto will become famous soon enough
From a first look you use two ustar. One you priscibe and one computed from k. This is in contradiction. Than k ist too high. Did ou check the model constants in the epsilon equation
mAlletto is offline   Reply With Quote

Old   June 24, 2020, 12:53
Default
  #10
Senior Member
 
René Thibault
Join Date: Dec 2019
Location: Canada
Posts: 114
Rep Power: 6
Tibo99 is on a distinguished road
Make sense about the 'ustar' so, since I didn't had any error message before, I came back to the original state for the 'nut' file with 'Cmu'.

Really weird that I end up with the same results though.

Talking about the constant in epsilon equation, I'll try to explain quickly why I use these constant. First, my goal is to replicate the results of what Yang(2009) got in his paper (https://www.sciencedirect.com/scienc...67610508001815) by using his constant with the method developed by Parente (Cmu varies) (https://www.researchgate.net/publica...n_of_ABL_flows)

The constant are (Yang,2009):
z0 = 0.000225m
u*= 0.511 m/s
C1e=1.5
C2e=2.51
Cmu=0.028 (will varies in our case)
sigmaK=1.67
sigmaEpsilon=2.51
C1=-0.17 (k profile constant)
C2=1.62 (k profile constant)

Since Parente use a different version of 'k' profile as Yang use, the 'k' profile constant become : C1=-0.414, C2=3.945. Parente doesn't show in his paper the constant of the transport equation. That why I used Yang data.

Parente use a source term on epsilon with the constant C1 and C2(see attachment). The notation is the same as used in the 'k' profile, which is confusing because, when I developed the source term on epsilon myself, these constant are Ce1 and Ce2 instead (see picture). I make Cmu varies in this source term as well.

However, when I use the epsilon constant in the source term, it unstable. It doesn't converge. But if I use the 'k' profile constant in the source term, it give the result I showed in my post #8.

About the BC for epsilon, I canceled these line:
Code:
//const scalar Cmu25 = pow025(Cmu_);
//const scalar Cmu75 = pow(Cmu_, 0.75);
And added these line in the loop (see file in attachment):
Code:
const scalar Cmu25 = pow025(pow(ustar_,4)/pow(k[celli],2));
const scalar Cmu75 = pow((pow(ustar_,4)/pow(k[celli],2)), 0.75);
Again, thank you very much for taking the time to read my post and interact with me.

Best regards and stay safe,
Attached Images
File Type: png k_Parente.png (1.6 KB, 8 views)
File Type: png Se_Parente.png (3.3 KB, 7 views)
File Type: png SourceTerm_Se.png (98.6 KB, 17 views)
Attached Files
File Type: c z0epsilonWallFunctionFvPatchScalarField.C (15.2 KB, 5 views)

Last edited by Tibo99; June 25, 2020 at 11:52.
Tibo99 is offline   Reply With Quote

Old   January 5, 2024, 18:37
Default
  #11
New Member
 
Huy Quang Dong
Join Date: Nov 2017
Posts: 19
Rep Power: 8
cunconbkhp is on a distinguished road
Hi Tibo99!

I'm trying to do exacly the same thing with Openfoam version 2212. I'm following the work of Salazar. Hi did some modification from Parent's work. I'm looking for a way to add the source term Se(z) like in your picture. Howerver i haven't found the good way to define z in the code and include it in tmp<fvScalarMatrix> epsEqn. That's great if you could give me some hints. Thanks in advance.
cunconbkhp is offline   Reply With Quote

Reply


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
[solidMechanics] Support thread for "Solid Mechanics Solvers added to OpenFOAM Extend" bigphil OpenFOAM CC Toolkits for Fluid-Structure Interaction 686 December 22, 2022 09:10
Wrong flow in ratating domain problem Sanyo CFX 17 August 15, 2015 06:20
epsilon and K blowing up. sivakumar OpenFOAM Running, Solving & CFD 1 October 25, 2012 04:50
Upgraded from Karmic Koala 9.10 to Lucid Lynx10.04.3 bookie56 OpenFOAM Installation 8 August 13, 2011 04:03
IcoFoam parallel woes msrinath80 OpenFOAM Running, Solving & CFD 9 July 22, 2007 02:58


All times are GMT -4. The time now is 15:58.