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

UDF for defining Heat Flux Profile at a wall

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

Like Tree5Likes
  • 1 Post By ghost82
  • 2 Post By flotus1
  • 2 Post By flotus1

Reply
 
LinkBack Thread Tools Display Modes
Old   October 17, 2014, 11:15
Default UDF for defining Heat Flux Profile at a wall
  #1
New Member
 
Join Date: Oct 2014
Posts: 7
Rep Power: 2
Alex90 is on a distinguished road
Hi Guys, I am relativeley new to Ansys Fluent UDF Scripting and so far I did not get very far with my code ...

So what is my problem. I want to define an axial profile of the wall heat flux. I have a 4000mm long cylinder within Ansys the axis is orientated into z direction. The crux is that I have a constant wall heat flux within specific distances. For example from z>=0 to z<=300mm the heat flux q=0 and from z>300 to z<=600 the heat flux q=4738.666 .... and so on ....

Here is what I scripted so far :

#include "udf.h"
Define_Profile(heat_flux,thread,i)
{
face_t f;
begin_f_loop(f,thread)
{
if(x[2] <= 300)
F_PROFILE(f,thread,i) = 0;
else if(x[2] <= 600 && x[2] > 300)
F_PROFILE(f,thread,i) = 3500.955;
else if(x[2] <= 1050 && x[2] > 600)
F_PROFILE(f,thread,i) = 4738.666;
else if(x[2] <= 2100 && x[2] > 1050)
F_PROFILE(f,thread,i) = 4971.053;
else if(x[2] <= 2850 && x[2] > 2100)
F_PROFILE(f,thread,i) = 5092.298;
else if(x[2] <= 3300 && x[2] > 2850)
F_PROFILE(f,thread,i) = 4738.666;
else if(x[2] <= 3600 && x[2] > 3300)
F_PROFILE(f,thread,i) = 3500.955;
else if(x[2] <= 3900 && x[2] > 3600)
F_PROFILE(f,thread,i) = 2121.791;
else
F_PROFILE(f,thread,i) = 0;
}
end_f_loop(f,thread);
}


Unfortanetley this does not work. I wrote this with the code blocks editor and saved it as heat_flux.c , afterwards I compiled this within Fluent.
I got the following failure :
line 1 parse error ....

Can someone please help me with finding the failure. Thank you ...
Alex90 is offline   Reply With Quote

Old   October 17, 2014, 12:17
Default
  #2
Senior Member
 
ghost82's Avatar
 
Daniele
Join Date: Oct 2010
Location: Italy
Posts: 919
Rep Power: 15
ghost82 will become famous soon enough
Hi
you didn't hold the position vector.
Add
Code:
real x[ND_ND];
before face_t f

Define_Profile(heat_flux,thread,i) should be uppercase DEFINE_PROFILE(....)

Daniele
famon likes this.
__________________
Google is your friend and the same for the search button!
ghost82 is offline   Reply With Quote

Old   October 20, 2014, 04:32
Default
  #3
Senior Member
 
flotus1's Avatar
 
Alex
Join Date: Jun 2012
Location: Germany
Posts: 1,107
Rep Power: 19
flotus1 will become famous soon enoughflotus1 will become famous soon enough
After you added this, I think you still need to write the current face position to the variable x by adding
Code:
F_CENTROID (x,f,thread);
at the beginning of the face loop.
ghost82 and famon like this.
flotus1 is offline   Reply With Quote

Old   October 20, 2014, 08:43
Default
  #4
New Member
 
Join Date: Oct 2014
Posts: 7
Rep Power: 2
Alex90 is on a distinguished road
Hi guys, i added what ghost82 wrote and tried it again. This time Fluent compiled it without failure. I did a steady calculation which finished after 1 iteration ... Post-Processing the results their is no single Heat Flux all over my geometry. I have the feeling that i did not specify geometry as flotus1 suggested ... so here is my second code :


#include "udf.h"
DEFINE_PROFILE(heat_flux,thread,i)
{
real x[ND_ND];
face_t f;
begin_f_loop(f,thread)
{
F_CENTROID (x,f,thread);
if(x[2] <= 300)
F_PROFILE(f,thread,i) = 0;
else if(x[2] <= 600 && x[2] > 300)
F_PROFILE(f,thread,i) = 3500.955;
else if(x[2] <= 1050 && x[2] > 600)
F_PROFILE(f,thread,i) = 4738.666;
else if(x[2] <= 2100 && x[2] > 1050)
F_PROFILE(f,thread,i) = 4971.053;
else if(x[2] <= 2850 && x[2] > 2100)
F_PROFILE(f,thread,i) = 5092.298;
else if(x[2] <= 3300 && x[2] > 2850)
F_PROFILE(f,thread,i) = 4738.666;
else if(x[2] <= 3600 && x[2] > 3300)
F_PROFILE(f,thread,i) = 3500.955;
else if(x[2] <= 3900 && x[2] > 3600)
F_PROFILE(f,thread,i) = 2121.791;
else
F_PROFILE(f,thread,i) = 0;
}
end_f_loop(f,thread);
}


Thank you for your fast answers and your support
Alex90 is offline   Reply With Quote

Old   October 20, 2014, 08:45
Default
  #5
Senior Member
 
ghost82's Avatar
 
Daniele
Join Date: Oct 2010
Location: Italy
Posts: 919
Rep Power: 15
ghost82 will become famous soon enough
1 iteration??
Adjust number of iterations in the run tab and adjust residual values in the monitor tab to let the solution converge.
ghost82 is offline   Reply With Quote

Old   October 20, 2014, 08:50
Default
  #6
New Member
 
Join Date: Oct 2014
Posts: 7
Rep Power: 2
Alex90 is on a distinguished road
I addjusted the iterations number before the calculation to 100 ... I will try the residuals now ...
Alex90 is offline   Reply With Quote

Old   October 20, 2014, 09:18
Default
  #7
Senior Member
 
flotus1's Avatar
 
Alex
Join Date: Jun 2012
Location: Germany
Posts: 1,107
Rep Power: 19
flotus1 will become famous soon enoughflotus1 will become famous soon enough
Did you add what I suggested? Otherwise the heat flux will be zero everywhere and it comes as no surprise that the solution of the energy equation converges after 1 iteration.
flotus1 is offline   Reply With Quote

Old   October 20, 2014, 09:29
Default
  #8
New Member
 
Join Date: Oct 2014
Posts: 7
Rep Power: 2
Alex90 is on a distinguished road
Hi Flotus you mean F_CENTROID ? ....


#include "udf.h"
DEFINE_PROFILE(heat_flux,thread,i)
{
real x[ND_ND];
face_t f;
begin_f_loop(f,thread)
{
F_CENTROID (x,f,thread);
if(x[2] <= 300)
F_PROFILE(f,thread,i) = 0;
Alex90 is offline   Reply With Quote

Old   October 20, 2014, 10:44
Default
  #9
Senior Member
 
flotus1's Avatar
 
Alex
Join Date: Jun 2012
Location: Germany
Posts: 1,107
Rep Power: 19
flotus1 will become famous soon enoughflotus1 will become famous soon enough
Yes.
Additionally, keep in mind that Fluent expects values to be in SI-units. So "if(x[2] <= 300)" checks if the z-value is smaller than 300m.
Just to be sure I would rather enter these values with a decimal point, so 300.0 instead of 300 and F_PROFILE(f,thread,i) = 0.0; instead of F_PROFILE(f,thread,i) = 0;
ghost82 and famon like this.
flotus1 is offline   Reply With Quote

Reply

Thread Tools
Display Modes

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 On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Define_profile UDF for Transient Heat flux boundary condition Amoljoshi Fluent UDF and Scheme Programming 1 May 9, 2014 11:17
Conjugate Heat Transfer: Wall Heat Flux at Coupled Walls? MaxHeat FLUENT 3 April 21, 2013 18:22
Heat Flux Profile at Fluid-Porous Interface Hitch8 CFX 4 December 15, 2012 10:57
UDF to calculate average heat flux dynamics Fluent UDF and Scheme Programming 0 July 21, 2012 18:54
heat flow UDF on coupled surface (wall-shadow wall) Friedmann Fluent UDF and Scheme Programming 0 August 5, 2010 10:25


All times are GMT -4. The time now is 11:46.