|
[Sponsors] |
January 18, 2012, 23:23 |
Help me please
|
#1 |
New Member
Zhao Yao
Join Date: Jan 2012
Location: China
Posts: 3
Rep Power: 14 |
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. |
|
January 19, 2012, 04:16 |
|
#2 |
Senior Member
Rick
Join Date: Oct 2010
Posts: 1,016
Rep Power: 27 |
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; |
|
January 19, 2012, 07:18 |
|
#3 |
Senior Member
duri
Join Date: May 2010
Posts: 245
Rep Power: 17 |
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.
|
|
January 19, 2012, 08:24 |
|
#4 |
New Member
Zhao Yao
Join Date: Jan 2012
Location: China
Posts: 3
Rep Power: 14 |
It's not that problem.
|
|
January 19, 2012, 08:28 |
|
#5 |
New Member
Zhao Yao
Join Date: Jan 2012
Location: China
Posts: 3
Rep Power: 14 |
||
January 20, 2012, 09:04 |
|
#6 |
Senior Member
duri
Join Date: May 2010
Posts: 245
Rep Power: 17 |
-ve means negative value.
|
|
|
|