|
[Sponsors] |
January 31, 2017, 13:48 |
UDF Not working
|
#1 |
New Member
Ashwath Vaidhyanathan
Join Date: Oct 2016
Posts: 9
Rep Power: 10 |
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 ? |
|
February 2, 2017, 03:50 |
|
#2 |
Member
KirMaks
Join Date: Aug 2016
Posts: 34
Rep Power: 10 |
Hallo,
try to replace the comparison at Code:
else if Code:
(t>5700 && t<=14400) |
|
February 3, 2017, 02:00 |
|
#3 |
New Member
Ashwath Vaidhyanathan
Join Date: Oct 2016
Posts: 9
Rep Power: 10 |
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 ! |
|
February 3, 2017, 04:28 |
|
#4 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
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! |
|
February 3, 2017, 04:47 |
|
#5 |
New Member
Ashwath Vaidhyanathan
Join Date: Oct 2016
Posts: 9
Rep Power: 10 |
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 |
|
February 3, 2017, 10:13 |
|
#6 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
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)? |
|
February 3, 2017, 14:01 |
|
#7 |
New Member
Ashwath Vaidhyanathan
Join Date: Oct 2016
Posts: 9
Rep Power: 10 |
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 ! |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
UDF Compilation Error - Loading Library - COMMON Problem! Help! | robtheslob | Fluent UDF and Scheme Programming | 8 | July 24, 2015 01:53 |
UDF for Oscillating Membrane/Diaphragm of a Synthetic Jet | cuan1029 | Fluent UDF and Scheme Programming | 0 | December 8, 2014 09:20 |
Serial UDF is working for parallel computation also | Tanjina | Fluent UDF and Scheme Programming | 0 | December 26, 2013 19:24 |
UDF is working in Laptop, but not working in Serial Cluster | Tanjina | Fluent UDF and Scheme Programming | 0 | December 20, 2013 22:42 |
UDF...UDF...UDF...UDF | Luc SEMINEL | FLUENT | 0 | November 25, 2002 05:03 |