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

UDF heat flux boundary conditions (heat fulx - convective losses - radiation losses)

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By JMM_UC3M

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   January 31, 2021, 05:27
Exclamation UDF heat flux boundary conditions (heat fulx - convective losses - radiation losses)
  #1
New Member
 
Jose Martin
Join Date: Jan 2021
Posts: 11
Rep Power: 5
JMM_UC3M is on a distinguished road
Hi folks,

I am creating my first UDF and I have a big problem, I do not understand how to read the face wall temperature . Can anyone help me?. The code is almost ready except how to input this temperature. Many thanks in advance.
PS: If i set up temperature at 500 K all calculus are ok, but I would need to read the real one!

UDF below!
#include "udf.h"
#define QMAX 407400 /* W/m2 */
#define EEPSILON 0.1
#define TAU 5.67e-8
#define T_AIRE 300
#define H_AIRE 40 /* convective coef.W/m2K */

/* profile for heat flux*/
DEFINE_PROFILE(heatflux_profile, t, i)

{
/* variable declaration */
real centroide[ND_ND]; /* vector position */
real x;
real y;
face_t f;
cell_t cell;
real seno; /* heat distribution */
real T_p; /* wall temperature */


begin_f_loop(f, t)
{
F_CENTROID(centroide,f,t);
x=centroide[0]; /* valor del cntroide en la componente x */
y=centroide[1]; /* valor del cntroide en la componente y */
seno=y/sqrt((x*x)+(y*y));


T_p = 500; /* I NEED TO FIND THE FUNCTION IN ORDER TO READ THE WALL TEMPERATURE */

if (0 < y)
{
F_PROFILE(f,t,i)=(QMAX*seno)+TAU*((T_p*T_p*T_p*T_p )-(EEPSILON*T_AIRE*T_AIRE*T_AIRE*T_AIRE))+H_AIRE*(T_ p-T_AIRE);

} else {
F_PROFILE(f,t,i)=0;
}
}
end_f_loop(f, t)
}
JMM_UC3M is offline   Reply With Quote

Old   January 31, 2021, 07:44
Default
  #2
New Member
 
Jose Martin
Join Date: Jan 2021
Posts: 11
Rep Power: 5
JMM_UC3M is on a distinguished road
Small correction:

#include "udf.h"
#define QMAX 407400 /* W/m2 */
#define EEPSILON 0.1
#define TAU 5.67e-8
#define T_AIRE 300
#define H_AIRE 40 /* convective coef.W/m2K */

/* profile for heat flux*/
DEFINE_PROFILE(heatflux_profile, t, i)

{
/* variable declaration */
real centroide[ND_ND]; /* vector position */
real x;
real y;
face_t f;
cell_t cell;
real seno; /* heat distribution */
real T_p; /* wall temperature */


begin_f_loop(f, t)
{
F_CENTROID(centroide,f,t);
x=centroide[0]; /* valor del cntroide en la componente x */
y=centroide[1]; /* valor del cntroide en la componente y */
seno=y/sqrt((x*x)+(y*y));


T_p = 500; /* I NEED TO FIND THE FUNCTION IN ORDER TO READ THE WALL TEMPERATURE, DO NOT WHY F_T(f,t) DOES NOT WORK */

if (0 < y)
{
F_PROFILE(f,t,i)=(QMAX*seno)-TAU*((T_p*T_p*T_p*T_p )-(EEPSILON*T_AIRE*T_AIRE*T_AIRE*T_AIRE))-H_AIRE*(T_ p-T_AIRE);

} else {
F_PROFILE(f,t,i)=0;
}
}
end_f_loop(f, t)
}
JMM_UC3M is offline   Reply With Quote

Old   January 31, 2021, 07:59
Default
  #3
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 26
pakk will become famous soon enough
You say F_T does not work, but can you be more specific? What happens if you do that?
pakk is offline   Reply With Quote

Old   January 31, 2021, 08:12
Default
  #4
New Member
 
Jose Martin
Join Date: Jan 2021
Posts: 11
Rep Power: 5
JMM_UC3M is on a distinguished road
Sure!! (btw many thanks!!! I am really stacked). And just one comment, the mesh I have is not good because I was trying to run the UDF and then I was gonna work on the mesh and so on, hope it is not the problem because when I set up T_p = 500 K it works...

Please find below the error , it seems it´s about the UDF in line 21

"Divergence detected in AMG solver: temperatureWarning: C:\\Users\\usuario\\Desktop\\udf\\heatflux_profile - copia (21).c: line 21: Warning: C:\\Users\\usuario\\Desktop\\udf\\heatflux_profile - copia (21).c: line 21: Warning: C:\\Users\\usuario\\Desktop\\udf\\heatflux_profile - copia (21).c: line 21:
Error at host: floating point exception
Warning: C:/Users/usuario/AppData/Local/Temp/heatflux_profile - copia (21).c.19192.0.c: line 21: Warning: C:/Users/usuario/AppData/Local/Temp/heatflux_profile - copia (21).c.19192.0.c: line 21: Warning: C:/Users/usuario/AppData/Local/Temp/heatflux_profile - copia (21).c.19192.0.c: line 21:
Error at Node 0: floating point exception
Error: floating point exception
Error Object: #f
Registering Udf, ("C:\Users\usuario\Desktop\udf\heatflux_profile - copia (21).c")

Calculation complete."

That´s the UDF I have used with the right function to read the wall temperature

#include "udf.h"
#define R 0.01
#define QMAX 40740 /* W/m2 */
#define EEPSILON 0.1
#define TAU 5.67e-8
#define T_AIRE 300
#define H_AIRE 40

/* profile for heat flux*/
DEFINE_PROFILE(BC, t, i)

{
/* declaración de variables */
real centroide[ND_ND]; /* vector de posición */
real x;
real y;
face_t f;
cell_t cell;
real seno; /* para meter la distribucion de calor */
real T_p; /* temperatura de la pared */


begin_f_loop(f, t)
{
F_CENTROID(centroide,f,t);
x=centroide[0]; /* valor del cntroide en la componente x */
y=centroide[1]; /* valor del cntroide en la componente y */
seno=y/sqrt((x*x)+(y*y));


T_p = F_T(f,t);


if (0 < y)
{
F_PROFILE(f,t,i)=(QMAX*seno)-TAU*((T_p*T_p*T_p*T_p)-(EEPSILON*T_AIRE*T_AIRE*T_AIRE*T_AIRE))-H_AIRE*(T_p-T_AIRE);

} else {
F_PROFILE(f,t,i)=0;
}
}
end_f_loop(f, t)
}
JMM_UC3M is offline   Reply With Quote

Old   January 31, 2021, 11:21
Default
  #5
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 26
pakk will become famous soon enough
Is that in the first iteration?

And try this: initialize your simulation, don't run, and plot the heat Flux on your relevant boundary. Is that what you expected?
pakk is offline   Reply With Quote

Old   January 31, 2021, 12:19
Default
  #6
New Member
 
Jose Martin
Join Date: Jan 2021
Posts: 11
Rep Power: 5
JMM_UC3M is on a distinguished road
Hi Pakk, I think it was the mesh.... I cannot beleive it... I am running the simulation, but first checks seems good.... I will replay in a few hours heheheh.... I created a good mesh, but now I dont have the floating point (it was in the second iteration BTW)
pakk likes this.
JMM_UC3M is offline   Reply With Quote

Old   January 31, 2021, 14:56
Default
  #7
New Member
 
Jose Martin
Join Date: Jan 2021
Posts: 11
Rep Power: 5
JMM_UC3M is on a distinguished road
Just to close out this issue, I guess there were two different problems:
1) The mesh
2) just in case I created alll "z" coordinates in the positive side, just in case
Additionally, a pair of formulas were not ok, but it was not the problem... Below the UDF for a tube of a solar receiver, were you can see the heat flux, and the two losses (convective and radiation)

#include "udf.h"
#define QMAX 407400 /* W/m2 */
#define EEPSILON 0.9
#define TAU 5.67e-8
#define T_AIRE 300
#define H_AIRE 40

/* profile for heat flux*/
DEFINE_PROFILE(receiver, t, i)

{
/* declaración de variables */
real centroide[ND_ND]; /* vector de posición */
real x;
real y;
face_t f;
cell_t cell;
real seno; /* para meter la distribucion de calor */
real T_p; /* temperatura de la pared */


begin_f_loop(f, t)
{
F_CENTROID(centroide,f,t);
x=centroide[0]; /* valor del cntroide en la componente x */
y=centroide[1]; /* valor del cntroide en la componente y */
seno=y/sqrt((x*x)+(y*y));


T_p=F_T(f,t); /*500*/


if (0 < y)
{
F_PROFILE(f,t,i)=(QMAX*seno)-TAU*((T_p*T_p*T_p*T_p)-(EEPSILON*T_p*T_p*T_p*T_p))-H_AIRE*(T_p-T_AIRE);

} else {
F_PROFILE(f,t,i)=0;
}
}
end_f_loop(f, t)
}



PS: Thanks pakk
JMM_UC3M 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
CFD analaysis of Pelton turbine amodpanthee CFX 31 April 19, 2018 18:02
Problem in setting Boundary Condition Madhatter92 CFX 12 January 12, 2016 04:39
Waterwheel shaped turbine inside a pipe simulation problem mshahed91 CFX 3 January 10, 2015 11:19
Error finding variable "THERMX" sunilpatil CFX 8 April 26, 2013 07:00
mixed boundary conditions including heat flux, convective heat transfer and radiation lotus_blue FLUENT 0 April 3, 2013 18:55


All times are GMT -4. The time now is 09:50.