CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   FLUENT (https://www.cfd-online.com/Forums/fluent/)
-   -   UDF about boiling phenomenon (https://www.cfd-online.com/Forums/fluent/138445-udf-about-boiling-phenomenon.html)

orchiders July 4, 2014 03:19

UDF about boiling phenomenon
 
Hi. everyone.

I’m studying boiling phenomenon and carrying out the vof simulation on bubble growth when boiling.

A boundary between liquid and vapor is not clear.
So I assumed that
0< volume fraction <0.5 : water
0.5< volume fraction <1 : vapor

DEFINE_INIT(my_init_function, domain)
{
Thread *t;
Thread **pt;
Thread **st;
cell_t c;
Domain *pDomain = DOMAIN_SUB_DOMAIN(domain,P_PHASE);
Domain *sDomain = DOMAIN_SUB_DOMAIN(domain,S_PHASE);

real xc[ND_ND], vof1, vof2;

mp_thread_loop_c (t,domain,pt)
if (FLUID_THREAD_P(t))
{
Thread *tp = pt[P_PHASE];

begin_c_loop (c,t)
{
C_CENTROID(xc,c,t);

vof1=C_VOF(c,tp);

if ( 0.5 < vof1 )
C_VOF(c,tp) = 1;

}
end_c_loop (c,t)
}

mp_thread_loop_c (t,domain,st)
if (FLUID_THREAD_P(t))
{
Thread *sp = st[P_PHASE];

begin_c_loop (c,t)
{
C_CENTROID(xc,c,t);

vof2=C_VOF(c,sp);

if ( 0.5 < vof2 )
C_VOF(c,sp) = 0;

}
end_c_loop (c,t)
}

}



and I wrote UDF. but It didn’t operate.

Would you please do me a favor? Please give me reply anytime you feel free. Thank you!

pakk July 4, 2014 03:38

Does it fail when you compile it? Or when you interpret it? Or when you load it? Or when you run it?


What are P_PHASE and S_PHASE? Does the program know what to do with it?

(You calculate xc, but never do anything with it. That will not cause any problem, but you could remove it, to make the code smaller.)

orchiders July 4, 2014 03:56

I arppreciate reply to my question.
I succeed UDF compile. however when operating simulation, Error: Divergence detected in AMG solver: pressure correction.

P_PHASE and S_PHASE is first phase(vapor) and second phase(liquid).
To use C_CENTROID, I defined xc[ND_ND].

pakk July 4, 2014 04:18

Quote:

Originally Posted by orchiders (Post 500018)
P_PHASE and S_PHASE is first phase(vapor) and second phase(liquid).

Yes, to me that is clear, but is it also clear to the program? Does the program know what P_PHASE is? Is it something defined by Fluent? (I never saw it before.) Or is is something you defined elsewhere?

Quote:

Originally Posted by orchiders (Post 500018)
To use C_CENTROID, I defined xc[ND_ND].

The only use that C_CENTROID has, is to give a value to xc. You never use xc, so you can remove xc and C_CENTROID without consequence.

Quote:

Originally Posted by orchiders (Post 500018)
I arppreciate reply to my question.
I succeed UDF compile. however when operating simulation, Error: Divergence detected in AMG solver: pressure correction.

Ok, so at least Fluent can process your UDF. The problem occurs later in the calculation. But I think it might be caused by your UDF.

I can more or less see what your UDF does. But I don't know what you want it to do.
What do you want your UDF to do? (Be as exact as possible, for example "VOF calculations" or "separate water from vapor" is not detailed enough.)

orchiders July 4, 2014 05:10

I want to change VOF valvue to separate water from vapor.
0<VOF<0.5 : VOF=0
0.5<VOF<1 : VOF=1

pakk July 4, 2014 05:23

And then? Continue the calculation? Make pictures? Calculate the volume occupied by water?

orchiders July 4, 2014 05:56

yes. I make picture of vapor bubble growth using calculated vapor volume fraction. and calcuate heat transfer rate and haet flux.

pakk July 4, 2014 06:40

Two questions:
- Why do you need the VOF to be either 0 or 1? If the values in the simulation are in between, you can still make pictures, and do these calculations.
- Why do you continue the simulation after making these values 0 or 1? Fluent will get really confused by this, as you noticed.

orchiders July 4, 2014 06:56

As the boundary between water and vapor is not claer, I think a boundary using volume fraction value may be simplied. However, I agree your opinion 2. I think fluent is comfused, so errors happen. Do you have any ideas?

pakk July 4, 2014 07:17

My opinion: don't change the VOF...

If you really want to have a strict distinction between vapor and liquid, add a user defined memory (UDM) and store the value there.

So instead of
Code:

C_VOF(c,tp) = 1;
write
Code:

C_UDMI(c,tp,0) = 1;
(and the same for 0)

In that way, you don't change the VOF, so Fluent will not get confused, and you can make the same plots by plotting UDM0.


All times are GMT -4. The time now is 12:32.