CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > ANSYS > FLUENT > Fluent UDF and Scheme Programming

"a variable = C_UDMI(c,t,0)" does not work.

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   September 26, 2018, 00:39
Exclamation "a variable = C_UDMI(c,t,0)" does not work.
  #1
New Member
 
JEONGMIN LEE
Join Date: May 2016
Posts: 1
Rep Power: 0
jm86groove is on a distinguished road
Lift force on bubble is Zero in this macro. Other variables to compute "FL" have their own numbers. Not zero.

I have no idea why "FL" goes to zero on each cell. C_UDMI problem?

Would you give me any advices to fix this issue? Thanks in advance.
--------------------------------------------------------------------------------------

DEFINE_SOURCE(Lift,c,tc,dS,eqn)

{

real source;

real sum_vv;

real sum_fa_top;

real sum_fa_bot;

real Re;

real CL;

real sum_fa;

real Gs;

real FL;

real db;

real M;

real xc[ND_ND];

real mu = 3.994e-4;

real Uz = 1.4;

real rho = 1615;

sum_vv = C_UDMI(c,tc,0);

sum_fa_top = C_UDMI(c,tc,1);

sum_fa_bot = C_UDMI(c,tc,2);

sum_fa = sum_fa_top + sum_fa_bot;

Thread **pt = THREAD_SUB_THREADS(tc);

Thread *ts = pt[1];

if(sum_vv > 0. && sum_fa > 0.)

{

if(C_VOF(c,ts) >= 0.5)

{

db = sum_vv/sum_fa;
printf("db: %e\n", db);

Re = rho*C_W(c,tc)*db/mu;
printf("Re: %e\n", Re);

Gs = fabs(C_DWDY(c,tc))*db/2/C_W(c,tc);
printf("Gs: %e\n", Gs);

M = 1/(pow(Re,2))+0.014*pow(Gs,2);
printf("M: %e\n", M);

CL = 3.877*pow(Gs,1/2)*pow(M,1/4);
printf("CL: %e\n", CL);

FL = 3/4*CL*rho*C_W(c,tc)*C_W(c,tc)/db; -----> !!! ISSUE
printf("FL: %e\n", FL);

C_CENTROID(xc,c,tc);

if(xc[1] < 0.0025)

{

source = FL;

dS[eqn] = 0;

printf("positive: %e\n", source);

}

else if(xc[1] > 0.0025)

{

source = -FL;

dS[eqn] = 0;

printf("negative: %e\n", source);

}

else

{
printf("nothing");

source = 0;

dS[eqn] = 0;

}

}

}

return source;

}

Last edited by jm86groove; September 26, 2018 at 01:59.
jm86groove is offline   Reply With Quote

Old   October 1, 2018, 04:13
Default
  #2
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 1,848
Rep Power: 29
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
did you define your UDMIs before calculation?

best regards
AlexanderZ is offline   Reply With Quote

Old   October 5, 2018, 14:33
Default
  #3
Senior Member
 
Join Date: Sep 2017
Posts: 230
Rep Power: 9
obscureed is on a distinguished road
Hi jm86groove,


If you think that FL should not be zero, but you get answers that suggest it is, then you can start debugging by printing details:
Code:
FL = 3/4*CL*rho*C_W(c,tc)*C_W(c,tc)/db;
if(fabs(FL)<1e-6) {
  Message("Bah! FL is near zero again: %g\n",FL);
  Message("   CL=%g, rho=%g, C_W=%g, db=%g\n",CL,rho,C_W,db);
  /* and eventually you become paranoid: */
  Message("   3/4 = %g\n",3/4);  /* This might well give zero!!!!! */
  Message("   3./4. = %g\n",3./4.);
  Message("   3./4.*CL = %g\n",3./4.*CL);
  Message("   3./4.*CL*rho = %g\n",3./4.*CL*rho);
  Message("   3./4.*CL*rho*C_W(c,tc) = %g\n",3./4.*CL*rho*C_W(c,tc));
  Message("   3./4.*CL*rho*C_W(c,tc)*C_W(c,tc) = %g\n",3./4.*CL*rho*C_W(c,tc)*C_W(c,tc));
  Message("   3./4.*CL*rho*C_W(c,tc)*C_W(c,tc)/db = %g\n",3./4.*CL*rho*C_W(c,tc)*C_W(c,tc)/db);
}
obscureed is offline   Reply With Quote

Old   October 5, 2018, 14:46
Default
  #4
Senior Member
 
Join Date: Sep 2017
Posts: 230
Rep Power: 9
obscureed is on a distinguished road
If the model is large and that gives an overwhelming amount of text to the screen, you can select some cells arbitrarily: replace
Code:
if(fabs(FL)<1e-6) {
with
Code:
if(c%10000==1234 && fabs(FL)<1e-6) {

A couple of points:
-- I would advise always using Message rather than printf.
-- Integer division rounds to the nearest integer, so there is always a risk that "3/4" is calculated to be "0" before it starts being floating-point. The same applies where you have typed "1/2" and "1/4" -- you should never type this! "1./2." is better, and "0.5" is better still. And "sqrt(Gs)" is probably quicker than "pow(Gs,0.5)", but speed is less important than correctness.

-- I picked 1e-6 as a small number, but it might not be small enough for your example -- in that case, try 1e-20 or whatever. But "if(FL==0.0)" is much more specific. Just like alarm bells should ring if you ever type "1/3", you should ask yourself whether a tiny value is just as bad as "(FL==0.0)". Maybe, in the circumstances, you should also ask whether infinity or NaN (not a number) are also possibilities.
obscureed is offline   Reply With Quote

Reply

Tags
c_udmi, source, udf

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
Writing a new variable as output kuria OpenFOAM Running, Solving & CFD 7 May 12, 2021 14:01
A CFX-POST error (ver 14.5.7) wangyflp88 CFX 2 July 22, 2017 01:17
equationReader in combination with variable expansion philippose OpenFOAM Bugs 5 January 23, 2012 14:58
Transient post-processing, Time averaged pressure work Turbomachine CFX 1 January 3, 2011 18:01
variable viscosity -NOT! George Bergantz Main CFD Forum 15 September 19, 2000 15:28


All times are GMT -4. The time now is 03:37.