# Creating a heat Flux UDF with a temperature Dependent argument

 Register Blogs Members List Search Today's Posts Mark Forums Read

 March 19, 2018, 11:36 Creating a heat Flux UDF with a temperature Dependent argument #1 New Member   Constantinos Join Date: Mar 2018 Posts: 3 Rep Power: 8 Hi y'all! I want to create a UDF for the heat flux on the side of a cylinder. The function of the heat flux is as follows: Capture.PNG and the parameter Y-bar has the following values Capture1.PNG While the parameters Please note: In the same .c file I have included 3 udf's in total and the other 2 work properly, so there is no point in including them in this post. (That's why you may see some definitions not used in the udf. I have interpreted it and the error I get is "Error: received a fatal signal (Segmentation fault)" . FLUENT interprets the file with no errors. I am not familiar with C language, but I suppose that the problem has to do with the whole logic of the udf: the definition of the parameter for some temperature values and then obtaining the desired value for the respective temperatura through linear interpolation, saving it in a new variable (Y_bar1) which is finally used in the definition of the heat flux profile. Since I cannot find where exactly the problem seems to be lying, can anyone suggest some other logic I can create the UDF and especially how to create a temperature dependent parameter or at least tell me what the segmentation error is in my code?? The UDF is as follows Code: ```#include "udf.h" #define pi 3.1415926526535897 #define mi 0.4 #define F_n 12000 #define w 78.54 #define r_p 0.00325 #define t_melt 864 #define r_s 0.0115 DEFINE_PROFILE(qpin_side,t,i) { real x[ND_ND]; real y; real u; real r; real A_p; face_t f; real temp = F_T(f,t); real sqm = mi/sqrt(3*(1+mi*mi)); int kelvin[8],Y_bar[8]; kelvin[0]=293; kelvin[1]=373; kelvin[2]=473; kelvin[3]=573; kelvin[4]=673; kelvin[5]=773; kelvin[6]=873; kelvin[7]=973; Y_bar[0]=440e+06; Y_bar[1]=437e+06; Y_bar[2]=364e+06; Y_bar[3]=181e+06; Y_bar[4]=61e+05; Y_bar[5]=50e+05; Y_bar[6]=40e+05; Y_bar[7]=0; begin_f_loop(f, t) { real Y_bar1; for ( i=0; i<7; i++) { if(temp > kelvin[i] && temp < kelvin[i+1]){ Y_bar1 = Y_bar[i]+(temp-kelvin[i])*(Y_bar[i+1]-Y_bar[i])/(kelvin[i+1]-kelvin[i]); } } F_CENTROID (x,f,t); y = x[1]; u = x[0]; r = sqrt(u*u+y*y); A_p = pi*r_p*r_p; F_PROFILE(f,t,i) = sqm*r_p*w*Y_bar1; } end_f_loop(f,t)```

 March 19, 2018, 20:38 #2 Senior Member   Alexander Join Date: Apr 2013 Posts: 2,363 Rep Power: 34 what initial temperature do you use to start your case? Best regards

March 20, 2018, 07:00
#3
New Member

Constantinos
Join Date: Mar 2018
Posts: 3
Rep Power: 8
Quote:
 Originally Posted by AlexanderZ what initial temperature do you use to start your case? Best regards
The default 300K.

 March 20, 2018, 07:14 #4 Senior Member   Join Date: Nov 2013 Posts: 1,965 Rep Power: 26 Three things: 1. You define Y_bar as integers, but the values that you give don't fit as integers. I would redefine them as float. This is not causing your current problem, but if you don't fix this you might see very strange results later on. 2. You define "temp" as "F_T(f,t)", the temperature on face "f", before you have specified which face "f" you are talking about. This causes your error. You should move this down, into the loop. 3. Your code does not specify what happens if the temperature is below 293 K or above 973 K. So if you reach these temperature, you run into undefined behavior.

 Tags heat flux, segmentation error, temperature dependent, udf