CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (https://www.cfd-online.com/Forums/fluent-udf/)
-   -   Help me please (https://www.cfd-online.com/Forums/fluent-udf/96306-help-me-please.html)

Daniel Zhao January 18, 2012 22:23

Help me please
 
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.

ghost82 January 19, 2012 03:16

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..

duri January 19, 2012 06:18

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.

Daniel Zhao January 19, 2012 07:24

It's not that problem.

Daniel Zhao January 19, 2012 07:28

Quote:

Originally Posted by duri (Post 340077)
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?

duri January 20, 2012 08:04

-ve means negative value.


All times are GMT -4. The time now is 09:44.