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/)
-   -   nutRoughWallFunction and Surface Roughness Documented (https://www.cfd-online.com/Forums/openfoam-programming-development/71412-nutroughwallfunction-surface-roughness-documented.html)

AlanR December 31, 2009 01:48

nutRoughWallFunction and Surface Roughness Documented
 
In the interest of documentation, I offer the following:
I'm modeling atmospheric boundary layer flow and need to use rough walls with carefully defined surface roughness. A forum search turned up a nice piece of code to implement the FLUENT surface roughness http://www.cfd-online.com/Forums/ope...roughness.html. I decided to try it - only to find that it's obsoleted by a new function in 1.6 - which I didn't see in the release notes.

Using a standard RAS k-epsilon turbulence model, in the /0/nut file replace 'nutWallFunction' with 'nutRoughWallFunction.' To make this work, you need to specify Ks (sand grain roughness height in meters) and Cs, the roughness constant (the link above takes you to the wiki and a good explanation of the model. After some trial and error, I found the correct syntax (for roughness height = 1 mm and Cs = 0.5 is the FLUENT default value - appropriate for pipe flow).

{
type nutRoughWallFunction::Ks;
value uniform 0.001;
type nutRoughWallFunction::Cs;
value uniform 0.5;
}

After finding this, I searched nutRoughWallFunction in the forums. There is a thread in bug fixes: apparently the code in 1.6 resets itself and gives very low values of roughness. This was fixed in version 1.6.x (reported in October). The current git version of 1.6.x should work correctly.

For anyone interested in atmospheric roughness, there's a simple conversion. This was part of my master's thesis (my research done in Fluent, I'm now switching to OpenFOAM). Ks = atmospheric roughness height * 30. Cs = 0.327. I found this in a peer reviewed journal, tested it in FLUENT simulations, and subsequently found very similar conversions in other journal articles.

Please correct my documentation if anyone finds mistakes - I'm still pretty new at this. Also, please feel free to add. I spent several hours today figuring this out - I learned quite a bit and got surface roughness working in my simulation. I have learned a lot from this forum over the last few months - today, I'm taking the opportunity to give something in return. :cool:

ancsa February 12, 2010 09:56

Hi Alan, I followed your instructions and so far everythings goes fine, thanks, I think you saved me a few hours of forum search at least, I used the git version straigh.

And I'm also trying to use it for atmospheric flows:)

AlanR February 12, 2010 14:20

Ancsa, I'm glad the message was useful to someone - you are the first to reply.

How are you generating meshes? I'm having my share of problems with snappyHexMesh - I can only get down 10 meter resolution before I run into problems - cells in the x direction get refined and in the y direction do not. Do you have a good method?
Thanks, Alan

ancsa February 15, 2010 03:43

I'm sorry but I have no good method, I have just started with OpenFOAM and I'm using an ex-fluent mesh to compare the results.

Sylvain February 16, 2010 08:43

Hi Alan,

Thanks for the contribution. I’m also working on the surface roughness problem for atmospheric flow. I followed your advices, it’s working but it seems that the values you specify in the nut file are not taken into account. For example, if you specify negative values or extremely high values for Ks an Cs, the results are always the same. I have recompiled the git version and specified Ks and Cs as you did, but it is always the same. Did you try to specify obvious rubbish (Chris Greeshields all rights reserved)?

I have asked my colleagues regarding the atmospheric roughness, you can indeed specify Ks=30*atmospheric roughness, but you have also to modify Cs to compensate. The problem is that the Ks you obtain is much more important than the wall cell size. Ks cannot be greater than half the wall cell size. Following a paper from Blocken 2007 you can specify Ks as half the wall cell size (almost) and you specify Cs according a formula Cs=E/Ks*z0 with E=9.73 and z0 the real roughness value. In Fluent, it seems that you cannot specify a Cs greater than 1, expect via an UDF. That’s why it would be nice if you could do it in OpenFOAM.

Regarding the snappyHexMesh thing I’m not yet so confident, but the cells should be split by 2^level in the three directions. More, if you use the add_layers you should be able to specify a small cell size at the wall. Meshing complex topology will be my next step, once I have understood how the roughness is working on a simple plate.

Thanks again for you help.

Sylvain

ancsa February 16, 2010 09:36

Isn't it from the nutRoughWallFunctionFvPatchScalarField.C filter out the small Ks values?:
scalar Edash = E_;

if (KsPlus > 2.25)
{
Edash /= fnRough(KsPlus, Cs_[faceI]);
}

if Ks is too small the original E is taken into consideration as I understand.

I will also check the difference running with nut and nutRough wall function.

Heesei March 22, 2010 10:20

roughnessHeight and roughnessConstant
 
Hi Sylvain

I have just seen your message and I have the same problem as you: reconstructing the results of Blocken et al. (2007) does not work. Specifying different values for Ks and Cs always leads to the same result. I suppose this is the reason for the strange plots I get.

Have you already managed to solve the problem? It would be nice if you could give me a hint how to get a (more or less) horizontally homogeneous wind profile.

Thanks in advance.

Irina

AlanR March 22, 2010 10:29

Irina,
I ran a simulation over a flat domain yesterday (by mistake actually) and ended up with a nicely converged solution and a consistent profile. I set Ks = 1.2 and Cs = 0.327. The model was simpleFoam, K-epsilon. I set the inlet profile using timeVeryingMappedFixedValue and it hardly changed across the domain - roughly 1 km wide.
You also need to be careful with k and epsilon, both of which can affect the profile across the domain.
Alan

maruthamuthu_venkatraman April 16, 2010 08:38

Sensitivity of Ks value for nutRoughwallfunction
 
Hello,
I tried to set various values for Ks in the input to account for roughness by using nutroughwallFunction. But its seems the results are same for ks = 0 and ks=0.01.
cs = 0.5 for both cases.

yplus is set for 30,
k is set to kqRwallfunction and
omega as omegaWallfunction.

Any hints will be useful

Thanks

Sylvain April 16, 2010 10:56

Hello,

I didn’t succeed to solve this problem and unfortunately I have no many time to work on this subject. Anyway I ran simulations in a very simple case (2D, log profile at the inlet) with different values of roughness, even negative, always leading to the same result regarding the pressure and velocity field.
I thought that the model didn’t read the values prescribed in the nut file. But if you turn on the debug mode associated with the nutRoughwallfunction you can see that the model do take into account the values ( you have Kplus negative also). So I guess the problem is not in the nutRoughwallfunction model, but rather in the way it is communicating with the turbulence model.

I really don’t know, but this roughness issue is annoying me!!!

Regards

maruthamuthu_venkatraman April 16, 2010 12:15

Thanks for your reply. Iam attending OF Workshop in Chalmers, may be we will discuss about this issue and shall see the possibilities to fix it. In the meanwhile we shall wait for some other foam users or the developers comments about it.

Have a good weekend!

Adrian April 29, 2010 04:13

Hello everyone

I encountered the same problem as most of you, the Ks and Cs values are not taken into account. I was working with a 2D domain and a pressure difference implemented between two sides. The logarithmic profile develops nicely but it only changes with the pressure, not with the Ks/Cs values.

So did anyone find out something new about this problem?

Cheers Adrian

Heesei May 5, 2010 04:53

Bug in nutRoughWallFunction
 
I started a new thread

http://www.cfd-online.com/Forums/ope...ues-ks-cs.html

and finally got the answer to this problem from gocarts:

"nutRoughWallFunction in OpenFOAM 1.6 doesn't work correctly due to a bug. Try the latest 1.6.x from the git repository for the corrected version."


Kind regards,

Irina

Sylvain May 5, 2010 05:38

Thanks Irina for your help.

I didn't succeed in compiling the whole git version and couldn't test it. Did it solve your problem, is it working now? I can recompile "by hand" the nutRoughWallFunction of the git, but is the problem just located in this function or in another one (turbulence model for example).

Thanks again for your help.

Sylvain

ancsa May 5, 2010 06:11

In the first post of this thread Alan also mentioned the bug.

So all your problem is because you didn't use the git version? I think it's better using that one, since all new bug fixes are there, while the compiled version is not getting newer as I see. For example there was also a bug in omegaNutWallFunction. There is a good script at in the forum somewhere to do that.

If with the git version you manage, please post here.

Sylvain May 5, 2010 08:17

Alan indeed mentions that bug. As I wasn't able to compile the whole git version (the compilation is crashing on OpenSuse and I didn't found why) I only recompiled the nutRoughWallFunction, but it didn't change anything. I took a look inside the function and I didn't see much difference, maybe I have to take a closer look. So my point is that maybe the problem is occurring elsewhere (but where?). I will try to find a computer where the git version is compiling so that I can try and see if the bug is solved with the latest version.

maddalena May 28, 2010 10:11

Specify different roughness
 
Dear all,
I would like to specify different roughness on a same surface.
I am thinking on something like:
if x < 1 than Cs = n1 Ks = m1
elseif 1<x<2 than Cs = n2 Ks = m2
elseif x > 2 than cd = n3 Ks = m3
end
Alternatively, I can divide the surface in different patches, and specify the roughness for each one.
Does anybody know if one of these two solution is already implemented in OF?
Any other suggestion is welcome!
Thank you, maddalena

maddalena May 28, 2010 16:19

Quote:

Originally Posted by AlanR (Post 241183)
Using a standard RAS k-epsilon turbulence model, in the /0/nut file replace 'nutWallFunction' with 'nutRoughWallFunction.' To make this work, you need to specify Ks (sand grain roughness height in meters) and Cs, the roughness constant (the link above takes you to the wiki and a good explanation of the model. After some trial and error, I found the correct syntax (for roughness height = 1 mm and Cs = 0.5 is the FLUENT default value - appropriate for pipe flow).

{
type nutRoughWallFunction::Ks;
value uniform 0.001;
type nutRoughWallFunction::Cs;
value uniform 0.5;
}

After finding this, I searched nutRoughWallFunction in the forums. There is a thread in bug fixes: apparently the code in 1.6 resets itself and gives very low values of roughness. This was fixed in version 1.6.x (reported in October). The current git version of 1.6.x should work correctly.

Well.. Since nutRoughWallFunction is defined in 0/nut file for every patch, I simply need to define a different Ks and Cs for the patch I want a different roughness... :o Yeah, that's sound obvious now!

mad

Daniele111 June 3, 2010 13:04

Hi
I'm trying to simulate an atmospheric boundary layer, for K and epsilon what kind of boundary conditions impose you on top and bottom?

Thanks

Daniele111 June 4, 2010 11:48

1 Attachment(s)
In my atmospheric boundary layer simulation, i have this problem, I impose a logarithmic velocity profile at inlet, but when I plot it in paraview in a semilog plot, I don't have a straight line, but two always at 1m from the bottom...I don't understand...the plot of a log in a semilog plot would a straight line. Help me please!

Thanks


All times are GMT -4. The time now is 05:00.