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/)
-   -   UDF Not working (https://www.cfd-online.com/Forums/fluent-udf/183291-udf-not-working.html)

av147@snu.edu.in January 31, 2017 12:48

UDF Not working
 
Hi everyone !

I was writing a code for a transient temperature analysis, for 0 to 5700 secs i have a equation and for 5701 to 14400 i have another equation for temperature change with time.
I wrote the following code

#include "udf.h"
DEFINE_PROFILE(unsteady_temperature, thread, position)
{
face_t f;
int time;
real t= CURRENT_TIME;
begin_f_loop(f, thread);
{
if(t<=5700)
F_PROFILE(f, thread, position) = (6*10^(-8))*t^(5)-(7*10^(-14))*(t^(4))+(2*10^(-10))*(t^(3))-(0.0072*t)+326.75;
else if(5701<=t<=14400)
F_PROFILE(f, thread, position) = -(5*10^(-21))*(t^(5))+(2*10^(-16))*(t^(4))-(5*10^(-12))*(t^(3))+(4*10^(-8))*(t^(2))-0.0002^(t)+306.58;

}
end_f_loop(f, thread);
}


Also my doubt is do i have to include some kind of a loop statement for updating time after each iteration ?

kirmaks February 2, 2017 02:50

Hallo,

try to replace the comparison at
Code:

else if
with:

Code:

(t>5700 && t<=14400)
Regards, Maksim

av147@snu.edu.in February 3, 2017 01:00

Hello !

Thank you for your reply, i did modify the code, changed the if-else condition as you mentioned and also the power operator, the udf was interpreted successfully, but once i ran the calculation Divergence was detected in MAG solver for temperature

The code i used was:

#include "udf.h"
DEFINE_PROFILE(unsteady_temperature, thread, position)
{
face_t f;
int time;
real t= CURRENT_TIME;
begin_f_loop(f, thread);
{
if(t<=5700){
F_PROFILE(f, thread, position) = (6*(pow(10,-8)))*pow(t,5)-(7*pow(10,-14))*(pow(t,4))+(2*(pow(10,-10)))*(pow(t,3))+(5*(pow(10,-7)))*(pow(t,2))-0.0072*(t)+326.75;
}
else if(t>5700 && t<=14400){
F_PROFILE(f, thread, position) = -(5*(pow(10,-21)))*(pow(t,5))+2*(pow(10,-16))*(pow(t,4))-(5*(pow(10,-12)))*(pow(t,3))+(4*(pow(10,-8)))*(pow(t,2))-(0.0002*t)+306.58;
}
}
end_f_loop(f, thread);
}

Waiting for a solution !

pakk February 3, 2017 03:28

Yeah, that is probably because your equation for temperature is crazy, for t<5700 you are putting extremely high temperatures on your system.

I guess that the problem is in the first coefficient 6*(pow(10,-8)), that is surprisingly high.

If you put in the wrong numbers, you will get the wrong results!

av147@snu.edu.in February 3, 2017 03:47

Hi

I think i din't get you, you said 6*(pow(10,-8)) was a very high value, but isn't it 6*10^(-8) which is actually a very low value

Thanks
AshwaTH

pakk February 3, 2017 09:13

Just fill in t=5000 and you will know what I mean.

I don't know where you found these coefficients, but check them carefully. Does it really say 6*10^(-8)? Is is not, for example, 6*10^(-18)?

av147@snu.edu.in February 3, 2017 13:01

Hey

The UDF successfully ran, i actually got data from a temperature surface monitor, used that data and curve fitted it to obtain the equation which i used, all i did was to again properly curve-fit the data.
Thanks !


All times are GMT -4. The time now is 20:36.