CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Running, Solving & CFD (https://www.cfd-online.com/Forums/openfoam-solving/)
-   -   BC -> k e simpleFoam (https://www.cfd-online.com/Forums/openfoam-solving/98996-bc-k-e-simplefoam.html)

klio March 23, 2012 07:47

BC -> k e simpleFoam
 
Hello!

I tried to simulate a simple airflow with the kEpsilon model, solver simpleFoam. a totalPressureInlet with 0.44 pa is given. Velocity has to be calculated. The residuals and the continuity looks good but the velocity much to small about 1e-06. the Solution should be about 0.35 m/s.

BC:

U:
internalField uniform (0 0 0);

outlet: type zeroGradient;

inlet: type pressureInletVelocity;
value uniform (0 0 0);

wall: type fixedValue;
value uniform (0 0 0);
------------------------------------------------------------
p:
internalField uniform (0 0 0);

outlet: type zeroGradient;

inlet: type totalPressure;
p0 uniform 0.44;
value uniform 0.44;
gamma 1;

wall: type zeroGradient
------------------------------------------------------------
epsilon:

internalField 0.02247;
outlet: type zeroGradient;

inlet: type turbulentIntensityKineticEnergyInlet;
intensity 0.001;
value uniform 0.02247;

wall: type epsilonWallFunction;
value uniform 0.02247;
---------------------------------------------------------------------------------------
k
internalField uniform (0 0 0);

outlet: type zeroGradient;

inlet: type turbulentMixingLengthDissipationRateInlet;
mixingLength 0.01;
value uniform 1.356e-03;

wall: type kqRWallFunction;
value uniform 1.356e-03;

Has anyone a hint for me ?

kmooney March 23, 2012 09:32

I'm guessing it is an issue with your p and U boundary conditions. Neither of them actually drive a flow. You'd need something like a fixed value U or a fixed pressure gradient to get some momentum into the domain.

klio March 27, 2012 04:53

Hi!
Thanks for your quick reply!
With fixedGradent instead of fixedValue in my pressure inlet BC i got a flow in my flow simulation :rolleyes:.

klio March 28, 2012 03:37

Ok but now i got the problem that the pressure decreases at the inlet. i thought fixed Gradient is NOT variable.
Do you have an idea what goes wrong there?

soonic March 28, 2012 13:50

Perhaps nothing is wrong. You fixed the gradient, not the value.

klio March 29, 2012 07:56

hmmm... Thanks!

But I have the Problem that I just know the fix pressure value at the inlet and if I only fix the Value there, there is nothing which drives my Flow.
so should I fix the value and the gradient at the inlet and how does it works ?

soonic March 29, 2012 09:47

what is the dimension of the p variable you have prediscribed ?
check if it is not p/rho. And you have maybe correct solution for the wrong task.

klio March 29, 2012 09:57

yes it is p/rho!
My pressure is about 0.5 pa, rho is 1.225 so my PressureValue is about 0.44
an the solution is about 2000 times smaller!
I also tried to set initial conditions with potentialFoam but either my velocities are much to small or much to high! :o

klio March 29, 2012 10:16

I think I can't really imagine how the BC at inlet and outlet of U and P should be set correctly.
When I take a look at the examples I can only find BC where the velocity is known. Not so in my case!

soonic March 29, 2012 10:43

1 Attachment(s)
try attached case with simpleFoam. It seems fine with your values on D=1cm pipe.

(it is based on case_pipe_viscous_heating for mySimpleFoam solver found on that forum)

edit: it is only laminar case.

klio March 29, 2012 10:49

Ok I'll try it thank you very much. Hope that even works in k e model

soonic March 29, 2012 12:33

yes, it do. Tried with 10Pa on inlet to have Re in turbulent zone.

klio March 30, 2012 03:24

Thank you very much for this nice example. I took same BC for k-e-Model and it didn't worked!

klio March 30, 2012 08:41

Hi at all!

now the Laminar model works!

But if I take the same BC as in the laminar model for the kE-Modell it doesn't work!

My BC are:

k & epsilon

interiorField: 1
pressure_inlet: 1
pressure_outlet: 1
wall: WllFunktion 1

p

interiorField: 0
pressure_inlet: 0.44
pressure_outlet: 0
wall: zeroGradient

U

interiorField: (0 0 0)
pressure_inlet: zeroGradient
pressure_outlet: zeroGradient
wall: (0 0 0)

Can anyone help me?

soonic April 2, 2012 08:24

what is not working? descrbie more.
Is your Re in turbulent zone ? Try initialize the case with higher eps values and add approximate/correct values for k and eps at your BCs.

the test case with values of one "does not work" too. Correct values will make it.

klio April 3, 2012 02:52

Thinks for your help!

In my case i have to compare fluent with openFoam! So i got a simulation from my college with given BC. And to compare it correctly I have do set the same initial condition as he did. Which is k & epsilon is 1 the pressure is 0.5 (in my case 0.44 because of dimensions) and velocity is not known. so its not possible to change the values.

If I set the BC like shown before the simulation crashes with errors! I think because of the bounding variables (up to inf) -> velocities higher than 1e+20. I also tried to set BC of k eps at the walls to zeroGradient it also didn't work. Its also diverging

soonic April 3, 2012 04:22

1 Attachment(s)
I tryed to set correct values for pressure to have turbulent flow and set calculated values for k and eps and there is the case again.
I still do not know, how big is your pipe. I just bet, that correct values for k and epsilon are thousand times smaller than one.

lobstar April 3, 2012 05:47

Hi kilo, I'm having the exact same problem as you. I'm also trying to do a comparison between fluent and openfoam using a turbulent flow. I've also tried using simplefoam and the k-e model. I haven't been able to get the simulation to work using a set pressure drop and having velocity calculated, but used my results from the fluent to set the boundary conditions and I'm also getting velocities of 1e20. I haven't been able to get soonic's suggestions to work for me. Have you had any luck?

klio April 3, 2012 10:56

hi!

@soonic:
hmm ... my Model is a cube with a 0.006 m thick pipe (0.06 m long ) at the inlet and same at the outlet.
I also have calculated the k and epsilon for the model but it must work somehow with the same input parameter a fluent gets. ive tried now :

k & epsilon

interiorField: 0
pressure_inlet: 1
pressure_outlet: 1
wall: zeroGradient

p

interiorField: 0
pressure_inlet: 0.44
pressure_outlet: 0
wall: zeroGradient

U

interiorField: (0 0 0)
pressure_inlet: zeroGradient
pressure_outlet: zeroGradient
wall: (0 0 0)

-----> IT WAS MUCH BETTER! but now the velocity is to small!! 0.002 instead of 0.35 :rolleyes:

@lobstar:

no i had no luck!!!

but i found out that k & epsilon & nut File should have same type of wall BC! and don't let OpenFoam generate your nut file or others automatically!
if you found out anything please tell me - i'll do the same!
you should also set the internal Field of k an epsilon 0, because i fond out that fluent also does so! and if you don't know what fluent does you can tell fluent to write out bc and then you get an acci file (terrible to read but lots information in it!)

kmooney April 3, 2012 11:15

You might want to take a second swing at your k & E boundary/internal conditions. I'm not too familiar with setting up these kinds of models but those values look like they might be pretty off after looking at this setup: [tutorials/incompressible/simpleFoam/pitzDaily]. Perhaps try reading up on the models' best practices or looking at some of the other tutorials with k&E turbulence modeling already set up.

lobstar April 3, 2012 11:21

Thanks for the advice on on the k/e/nut bcs getting the fluent bc data, that's really helpful! I'll continue to look around and of course will let you know what i find. so far my searches have been unfruitful as some of the recommendations i've seen don't make a lot of sense (either because my understanding is flawed or because it genuinely doesn't make sense). A recommendation i saw suggested using a fixed pressure gradient instead of two fixed values as apparently openfoam doesn't recognise the pressure drop as causing a flow (initiating momentum to quote the advisor). I haven't managed to get this to work but i'll keep trying and let you know the results.

klio April 3, 2012 11:23

hmmm yes but if i set a gradient the pressure is not fixed as soonic adverted me to and then my pressure de- or increases and the velocity as well! and the tutorials are all not very helpful because they all have velocity driven flows. and in my case this is not possible!

klio April 10, 2012 03:31

Quote:

Originally Posted by lobstar (Post 352926)
Thanks for the advice on on the k/e/nut bcs getting the fluent bc data, that's really helpful! I'll continue to look around and of course will let you know what i find. so far my searches have been unfruitful as some of the recommendations i've seen don't make a lot of sense (either because my understanding is flawed or because it genuinely doesn't make sense). A recommendation i saw suggested using a fixed pressure gradient instead of two fixed values as apparently openfoam doesn't recognise the pressure drop as causing a flow (initiating momentum to quote the advisor). I haven't managed to get this to work but i'll keep trying and let you know the results.

Hi did you find out anything?

lobstar April 10, 2012 04:34

Hey Kilo,

No such luck I'm afraid. Whenever I tried using the pressureInletVelocity or any variation of it with a fixedGradient pressure (at either inlet or outlet) it didn't converge or gave a result with infinite pressure. I'll keep trying variations as I continue to look for a solution but I'm not expecting much. I may also be flawed in my understanding of fixed gradient, I assumed it was the pressure gradient from inlet to outlet, so dp/dx (x being distance between inlet and outlet). How about you, any luck? When you say you the pressure won't be fixed if you use gradient, do you use it on bot inlet and outlet? Again this is probably because I've misunderstood what is defined by fixedGradient but I thought if you had fixed value at one and fixed gradient at the other then you should essentially have to fixed values just defined differently.

kid April 10, 2012 04:57

@kilo
What is the error message you get? Please paste the error messgae,as this would help.

klio April 10, 2012 05:06

@lobstar:

so you mean if i have an inletpressure of 0.5 pa and at the outlet my pressure is 0 i just have to know the distance between them?

ok so if i know the inlet value do i set this to fixedValue and then a gradient at the outlet or should i set the outlet to zero and the gradient at the inlet?

what about 3D simulation what would be the right distance ?
Because my inlet is orthogonal to z direction and my outlet is orthogonal to x direction!

@kid: i don't get error messages i just get wrong solutions!

lobstar April 10, 2012 11:37

I believe so yes, but again my understanding could be flawed. Not quite sure what to do for your model, I have been modelling flow through a pipe because I thought it would be simple! I think if you just use total distance (as in the distance the flow will travel through) it should make physical sense as your looking for how pressure changes relative to distance. I modelled both, as in fixedvalue inlet fixedgradient outlet and vice versa, though the former makes most sense to me if you want to use the pressureinletvelocity bc but I couldn;t get either to work.
Just reading through the thread again, you said you got a laminar version to work. Does this mean it was a pressure driven flow through the same geometry using icofoam? If so maybe the issue is having a pressure driven flow with simplefoam.

klio April 10, 2012 12:04

Yes I got a laminar solution and it was nearly correct! velocities about 0.48 instead of 0.9. and the flow was driven with the BC that you can find in the example pipe_pressure_turm of soonic. it worked because there was no e and k. I think the problem is that Open Foam is not able to correct given BC (that only can be wrong like a k and e value 1 in a 0.006 m thick pipe where air flows) so it crashes or it gets wrong solutions! Fluent is able to do that.

So i think there is no way to get same solutions with the same bc you have to calculate the epsilon and the k on your own and set right values (that you will also find in fluent if you get your steady solution).

:(

lobstar April 10, 2012 12:23

Ok, I'll give the laminar version a go and see what I can manage. From there I'll try using the results I have from fluent as the values for the turbulent values and see how it goes. What your saying does make sense but what I've read from other people would suggest that it OpenFOAM should be able to correct it and that the values you put in are only initial values that are improved via iterations. Otherwise you'd only really need one iteration as if all your inputs were exactly correct then the first set of results should be correct too.

klio April 12, 2012 05:01

hmmm... it could also be possible that the sovers OF uses are different to Fluent and thats the reason why simulations diverge. So because of that you have to set initial conditions nearer to the final solution so that the sim converges.

I did that and now i got nearly the same solution with kE - Model as with the laminar calculation. (But for me it would also be more satisfying if the right solution could be calculated with the same initial BC)

klio April 12, 2012 05:20

But look at this file. It's about a OF and Fluent comparison and also initial k & epsilon for the OF sim are much smaller (1e-15 instead of 1e-5)
http://www.google.com/url?sa=t&rct=j...MwLbLOwI_cwvWQ

lobstar April 12, 2012 07:09

Hi kilo, I haven't been able to get the laminar version to work either. But I think I've made a mistake. When I look at soonic's bcs he has put the inlet pressure as 0.44 but then calculates for a hundred bar. Do you know where the 0.44 has come from? I'm just downloading the file to have a look, will let you know my thoughts.

soonic April 12, 2012 07:28

Hi, I set the case like that:
- I knew diameter of pipe and wish to have Re in laminar/turbulent zone. (choose Re or compute limit velocity)
- I computed velocity for Re
- I computed dyn.pressure corresponding to velocity
- I set bc with value p/rho

kid April 12, 2012 07:33

@soonic

Can you have a look at this link plz
http://www.cfd-online.com/Forums/ope...tml#post354340

Regards
CFDkid

klio April 12, 2012 09:07

@lobstar: if you look at the dimentions you will see [0 2 -2 0 0 0 0] thats m²/s² -> p [pa] / rho [kg/m³]

did you use simpleFoam for the laminar calculation like soonics example?

lobstar April 12, 2012 09:16

@kilo
Yeah i did! I also divided my pressures by the density of the fluid. However going from what soonic said I think i understand what's wrong, the pressures set don't produce a laminar flow. i'll try and change the pressures for a laminar flow and see how it goes. How did you change from laminar to turbulent? did you keep p and U bcs the same? What did you use for k/e/nut? Sorry for all the questions! Also I think you're right, Openfoam seems to need starting values very close to the correct values in order to converge. Requires a lot more work to run a simulation than in Fluent!

@ soonic
can i ask what equation you used to calculate dyn pressure? Thanks for the advice thouhg, has cleared a lot up!

lobstar April 12, 2012 09:27

also kilo that link was a great find, really helpful guidance tool!

klio April 12, 2012 10:30

first I just added the requred files and changed laminar Flag from RASModell to kEpsilon.

Yes! I thougt i'd be a good idea not to change whats already working ;) (but may i have to if i don't get correct solutions)

k epsilon and nut are now fixed at inlet ZeroGradient at outlet and on walls depending on whats converging either wallFunction or (zeroGradient and nut: calculated)

soonic April 12, 2012 11:03

i do not know if it is correct to use it like that, but i calculated dynamic pressure like: pd = rho/2 * U^2

klio April 13, 2012 04:37

You calculated [kg]/[m]³ * [m]²/[s]² = [kg]/[m]*[s]² which is [pa]

But may it explains this

->because of dimensions pressure inlet is u²
-> u is not known but the pressure (in my case 0.5 pa) -> 2*p/rho = 0.816326531 = u² -> the pressure inlet value
-> u = ~0.9


All times are GMT -4. The time now is 19:45.