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

UDF Not working

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   January 31, 2017, 13:48
Default UDF Not working
  #1
New Member
 
Ashwath Vaidhyanathan
Join Date: Oct 2016
Posts: 9
Rep Power: 10
av147@snu.edu.in is on a distinguished road
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 ?
av147@snu.edu.in is offline   Reply With Quote

Old   February 2, 2017, 03:50
Default
  #2
Member
 
KirMaks
Join Date: Aug 2016
Posts: 34
Rep Power: 10
kirmaks is on a distinguished road
Hallo,

try to replace the comparison at
Code:
else if
with:

Code:
(t>5700 && t<=14400)
Regards, Maksim
kirmaks is offline   Reply With Quote

Old   February 3, 2017, 02:00
Default
  #3
New Member
 
Ashwath Vaidhyanathan
Join Date: Oct 2016
Posts: 9
Rep Power: 10
av147@snu.edu.in is on a distinguished road
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 !
av147@snu.edu.in is offline   Reply With Quote

Old   February 3, 2017, 04:28
Default
  #4
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27
pakk will become famous soon enough
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!
pakk is offline   Reply With Quote

Old   February 3, 2017, 04:47
Default
  #5
New Member
 
Ashwath Vaidhyanathan
Join Date: Oct 2016
Posts: 9
Rep Power: 10
av147@snu.edu.in is on a distinguished road
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
av147@snu.edu.in is offline   Reply With Quote

Old   February 3, 2017, 10:13
Default
  #6
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27
pakk will become famous soon enough
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)?
pakk is offline   Reply With Quote

Old   February 3, 2017, 14:01
Default
  #7
New Member
 
Ashwath Vaidhyanathan
Join Date: Oct 2016
Posts: 9
Rep Power: 10
av147@snu.edu.in is on a distinguished road
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 !
av147@snu.edu.in 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


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


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