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

Help me please

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   January 18, 2012, 22:23
Smile Help me please
  #1
New Member
 
Zhao Yao
Join Date: Jan 2012
Location: China
Posts: 3
Rep Power: 14
Daniel Zhao is on a distinguished road
I'm doing some research on GSHP now and I programmed a UDF to realise some unique function.The udf can be interpreted,however Fluent can't work and the error is
Error: Floating point error: invalid number
Error Object: ()
My udf is below

#include "udf.h"
#define PI 3.14159
#define gt 0.02
#define ID_outlet 16
#define cp 4200
#define density 1000
DEFINE_PROFILE(inlet_temp,thread,index)
{
real NV_VEC(A);
real sum_T_A=0.0;
real sum_A=0.0;
Thread*thread_out;
face_t f;
Domain*domain;
real outlet_temp;
real outlet_temp1;
real t;
real load;
real load_high;
real load_low;
real m1;
real m2;
real EER;
real COP;
real EER0=78/14.5;
real COP0=65/19.1;
real a;
real b;
real a1;
real a2;
real b1;
real b2;
domain=Get_Domain(1);
thread_out=Lookup_Thread(domain,ID_outlet);
begin_f_loop(f,thread_out)
{
F_AREA(A,f,thread_out);
sum_A+=NV_MAG(A);
sum_T_A+=NV_MAG(A)*F_T(f,thread_out);
}
end_f_loop(f,thread_out)
outlet_temp=sum_T_A/sum_A;
outlet_temp1=outlet_temp-273.15;
a1=0.68843*pow(outlet_temp1,3)-0.05305*pow(outlet_temp1,2)+0.000583738*outlet_tem p1+106.641;
a2=0.71527*pow(outlet_temp1,2)+0.0275*outlet_temp1 +64.91261;
b1=3.0098*pow(outlet_temp1,2)+0.04375*outlet_temp1 +100.24608;
b2=0.27943*pow(outlet_temp1,3)-0.01956*pow(outlet_temp1,2)+0.00069132*outlet_temp 1+99.88978;
a=a1/a2;
b=b1/b2;
EER=EER0*a;
COP=COP0*b;
m1=density*16/(3600*18);
m2=density*13/(3600*18);
t=RP_Get_Real("flow-time");
load=(14.21+57.42*sin(2*PI*t/(8760*3600)-2674*PI/4380))/18;
load_high=(71.63/18)*0.5;
load_low=(-43.21/18)*0.6;
begin_f_loop(f,thread)
{
if(load>=load_high)
F_PROFILE(f,thread,index)=outlet_temp-load*1000*(1-EER)/(EER*cp*m1);
else if(load<=load_low)
F_PROFILE(f,thread,index)=outlet_temp+load*1000*(1 +COP)/(COP*cp*m2);
else
F_PROFILE(f,thread,index)=outlet_temp;
}
end_f_loop(f,thread)
}
Your effort will be appreciated.
Daniel Zhao is offline   Reply With Quote

Old   January 19, 2012, 03:16
Default
  #2
Senior Member
 
ghost82's Avatar
 
Rick
Join Date: Oct 2010
Posts: 1,016
Rep Power: 26
ghost82 will become famous soon enough
I'm not a udf exper but maybe your problem is here?

Code:
a1=0.68843*pow(outlet_temp1,3)-0.05305*pow(outlet_temp1,2)+0.000583738*outlet_tem  p1+106.641;
a2=0.71527*pow(outlet_temp1,2)+0.0275*outlet_temp1  +64.91261;
b1=3.0098*pow(outlet_temp1,2)+0.04375*outlet_temp1  +100.24608;
b2=0.27943*pow(outlet_temp1,3)-0.01956*pow(outlet_temp1,2)+0.00069132*outlet_temp  1+99.88978;
If so, just remove the spaces..
ghost82 is offline   Reply With Quote

Old   January 19, 2012, 06:18
Default
  #3
Senior Member
 
duri
Join Date: May 2010
Posts: 245
Rep Power: 16
duri is on a distinguished road
Print and check a,b,a2,b2 any of these is going zero. Or outlet_temp1 is -ve. If these are fine try compiling in dp.
duri is offline   Reply With Quote

Old   January 19, 2012, 07:24
Default
  #4
New Member
 
Zhao Yao
Join Date: Jan 2012
Location: China
Posts: 3
Rep Power: 14
Daniel Zhao is on a distinguished road
It's not that problem.
Daniel Zhao is offline   Reply With Quote

Old   January 19, 2012, 07:28
Default
  #5
New Member
 
Zhao Yao
Join Date: Jan 2012
Location: China
Posts: 3
Rep Power: 14
Daniel Zhao is on a distinguished road
Quote:
Originally Posted by duri View Post
Print and check a,b,a2,b2 any of these is going zero. Or outlet_temp1 is -ve. If these are fine try compiling in dp.
What does -ve mean?
Daniel Zhao is offline   Reply With Quote

Old   January 20, 2012, 08:04
Default
  #6
Senior Member
 
duri
Join Date: May 2010
Posts: 245
Rep Power: 16
duri is on a distinguished road
-ve means negative value.
duri 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



All times are GMT -4. The time now is 10:26.