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

UDF to Define Temperature Dependent Negative Heat Source

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   September 9, 2019, 14:06
Default UDF to Define Temperature Dependent Negative Heat Source
  #1
New Member
 
Amitav tikadar
Join Date: Jul 2017
Location: Atlanta
Posts: 14
Rep Power: 9
ATIKADAR is on a distinguished road
Hi,

I am trying to calculate the average temperature of interface at each iteration (since I am solving steady state problem) and based on the interface temperature I want to update my negative heat source value (Q_Source=(-constant*(T_Interface-T_Constant))/volume). First, I tried UDM to store interface temperature but didn't work. Then I tried to GLOBAL variable to avoid UDM, but again no luck. I am using ANSYS FLUENT 2019 R2. For both cases, I Interpreted the UDF and during the interpretetion, FLUENT didn't show any error. I have attached my written UDF below. Can someone please help me to fix the problem?

Thanks in advance.

/*********UDF with UDM**********/

#include "udf.h"

/*********INTERFACE TEMPERATURE**************/

DEFINE_EXECUTE_AT_END(average_interface_temp_of_wi ndings_air)
{
Domain *d;
face_t f;
real temper = 0.0;
real A[ND_ND];
real tsavg=0.0;
real area = 0.0;
real area_tot = 0.0;
int ID = 10; /*this is the ID of the interface that I want to get the temperature from*/
Thread *t;
d = Get_Domain(1);
t = Lookup_Thread(d,ID);

/*We are trying to calculate area weighted average temperature of a surface- as per the definition of area weighted average*/

begin_f_loop(f,t)
{
F_AREA(A,f,t); /*get face area which is a vector*/
area = NV_MAG(A);/*get magnitude of the face area*/
area_tot += area; /*calculate total area*/
temper = F_T(f,t); /*calculate face temperature*/
tsavg += temper*area;
}
end_f_loop(f,t)
tsavg /= area_tot;
printf("Average Interface Temperature = %g\n",tsavg);

begin_f_loop(f,t)
{
F_UDMI(f,t,0) = tsavg; /* User Define Memory */
}
end_f_loop(f,t)

}

/**********NEGATIVE HEAT SOURCE***************/

DEFINE_SOURCE(negative_heat_source,c,t,dS,eqn)
{
real source;
face_t f;
source = -5000.*(F_UDMI(f,t,0)-290.); /* For the time being, I have assumed an arbitrary constant for hA and T_Sat */
dS[eqn] = 0.; /* Need to double check. It can be -5000. as a resultant of the derivative of source term */
return source;
}

/******UDF with Global Variable***********/

#include "udf.h"

/*********INTERFACE TEMPERATURE**************/

real tsavg=0; /* Defining Global Variable */
DEFINE_EXECUTE_AT_END(average_interface_temp)
{
Domain *d;
face_t f;
/*real tsavg=0;*/
real temper = 0.0;
real A[ND_ND];
real area = 0.0;
real area_tot = 0.0;
int ID = 10; /*this is the ID of the interface that I want to get the temperature from*/
Thread *t;
d = Get_Domain(1);
t = Lookup_Thread(d,ID);

/*We are trying to calculate area weighted average temperature of a surface- as per the definition of area weighted average*/

begin_f_loop(f,t)
{
F_AREA(A,f,t); /*get face area which is a vector*/
area = NV_MAG(A);/*get magnitude of the face area*/
area_tot += area; /*calculate total area*/
temper = F_T(f,t); /*calculate face temperature*/
tsavg += temper*area;
}
end_f_loop(f,t)
tsavg /= area_tot;
printf("Average Interface Temperature = %g\n",tsavg);
}

/**********NEGATIVE HEAT SOURCE***************/

DEFINE_SOURCE(heat_source,c,t,dS,eqn)
{
real source;
source = -5000.*(tsavg-300.); /* For the time being, I have assumed an arbitrary constant for hA and T_Sat */
dS[eqn] = 0.; /* Need to double check. It can be -5000. as a resultant of the derivative of source term */
return source;
}
ATIKADAR is offline   Reply With Quote

Old   September 23, 2019, 04:52
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
if you are using 2019R2 -> it means you run your code in parallel, but it was not considered

you have to modify your code:
Ansys Fluent Customization manual
-> Global Reduction Macros

other problem
Code:
DEFINE_SOURCE(negative_heat_source,c,t,dS,eqn)
{
real source;
face_t f;
source = -5000.*(F_UDMI(f,t,0)-290.); /* For the time being, I have assumed an arbitrary constant for hA and T_Sat */
in F_UDMI(f,t,0) f is not defined cause you dont have any loops through faces. Define_source has a build in loop over cells


fix these issues first

best regards
AlexanderZ is offline   Reply With Quote

Reply

Tags
fluent - udf, udf source, udf source energy


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
Adding temperature dependent heat source using fvOptions in chtMultiRegionSimpleFoam shaileshbg OpenFOAM Running, Solving & CFD 14 January 26, 2024 19:48
[Other] Tabulated thermophysicalProperties library chriss85 OpenFOAM Community Contributions 62 October 2, 2022 04:50
[foam-extend.org] Problems installing foam-extend-4.0 on openSUSE 42.2 and Ubuntu 16.04 ordinary OpenFOAM Installation 19 September 3, 2019 19:13
SparceImage v1.7.x Issue on MAC OS X rcarmi OpenFOAM Installation 4 August 14, 2014 07:42
friction forces icoFoam ofslcm OpenFOAM 3 April 7, 2012 11:57


All times are GMT -4. The time now is 12:35.