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

Creating a heat Flux UDF with a temperature Dependent argument

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   March 19, 2018, 12:36
Default Creating a heat Flux UDF with a temperature Dependent argument
  #1
New Member
 
Constantinos
Join Date: Mar 2018
Posts: 3
Rep Power: 8
nagas is on a distinguished road
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)
nagas is offline   Reply With Quote

Old   March 19, 2018, 21:38
Default
  #2
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
what initial temperature do you use to start your case?

Best regards
AlexanderZ is offline   Reply With Quote

Old   March 20, 2018, 08:00
Default
  #3
New Member
 
Constantinos
Join Date: Mar 2018
Posts: 3
Rep Power: 8
nagas is on a distinguished road
Quote:
Originally Posted by AlexanderZ View Post
what initial temperature do you use to start your case?

Best regards
The default 300K.
nagas is offline   Reply With Quote

Old   March 20, 2018, 08:14
Default
  #4
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27
pakk will become famous soon enough
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.
pakk is offline   Reply With Quote

Reply

Tags
heat flux, segmentation error, temperature dependent, udf


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
Temperature & Heat Flux Boundary jamesmaca FLUENT 5 December 11, 2019 06:16
UDF for time dependent heat flux rontgen5 Fluent UDF and Scheme Programming 5 August 8, 2019 04:04
Wall Heat Flux & Temperature Greg Perkins FLUENT 10 November 20, 2015 10:32
Question about heat transfer coefficient setting for CFX Anna Tian CFX 1 June 16, 2013 07:28
Basic question: UDF for wall heat flux Carl FLUENT 1 August 5, 2006 20:01


All times are GMT -4. The time now is 14:31.