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

UDF for Heat Flux Profile

Register Blogs Community New Posts Updated Threads Search

Like Tree2Likes
  • 1 Post By pakk
  • 1 Post By pakk

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   January 22, 2018, 13:23
Default UDF for Heat Flux Profile
  #1
New Member
 
Jacob
Join Date: Jan 2018
Posts: 3
Rep Power: 8
Jacob_Bing is on a distinguished road
Hello,

I am working on creating a simulation to model a laser beam incident on the surface of a material. Because the beam of the laser has an intensity distribution similar to a normal distribution curve in 2D, I have been trying to write a UDF to apply that profile to the flux in my model.

The problem I am having is, when I run the simulation, the flux distribution appears to only be calculated at four points. It starts and ends at the correct values of approximately zero flux. However, it creates a horizontal line for the majority of the surface's width at the value that the flux should obtain at the center of the curve. The end points connect to this line with a straight line at each end.

My mesh in this area contains 14 cells along a 7um wide surface the flux is applied to and my UDF is shown below. If anyone could help me fix the UDF or tell me what is going wrong that would be great. Thank you.


#include "udf.h"
#define sig 0.0000035/3.

DEFINE_PROFILE(gauss_flux_small, thread, position)
{
real y[ND_ND];
real x;
face_t f;

begin_f_loop(f, thread)
{
F_CENTROID(y,f,thread);
x = y[2];
F_PROFILE(f, thread, position)=728000000.0*exp(-x*x/(2.0*sig*sig))/(sig*sqrt(2.0*3.14159265));
}
end_f_loop(f, thread)
}
Jacob_Bing is offline   Reply With Quote

Old   January 22, 2018, 14:34
Default
  #2
Senior Member
 
Join Date: Sep 2017
Posts: 246
Rep Power: 12
obscureed is on a distinguished road
Hi Jabob_Bing,

At first sight, your UDF looks OK.

(Well, one warning: "#define sig 0.0000035/3." is very dangerous. If you later have "xyz = abc * sig;", then this is expanded to "xyz = abs * 0.0000035/3.", which is what you wanted. If you have "xyz = abc / sig;", then this is expanded to "xyz = abs / 0.0000035/3.", which is NOT what you wanted! -- wrong by a factor of 9. The preprocessor does a copy-and-paste, with no thought about numerical meaning. Therefore, you should definitely put brackets in "#define sig (0.0000035/3.)". As it happens, you have escaped this danger.)

The equation you have typed for the intensity is a function only of the z-coordinate, y[2], which you have called "x" (which is possibly a strange name). So if the face with this profile is perpendicular to the x-axis, for example, then the source will be a line, centred on the y-axis. These names are already confusing me, so I'd advise you to check this is what you intended. If you wanted a circular spot, you presumably should have put something like "exp(-(y[1]*y[1]+y[2]*y[2])/...".

With so few faces, it won't hurt to print out every value, as in something like this:
Code:
#include "udf.h"
#define sig (0.0000035/3.)
/* Change the following to NO_DEBUG when not required: */
#define DEBUG 1

DEFINE_PROFILE(gauss_flux_small, thread, position)
{
  real fcent[ND_ND];
  real z, flux;
  face_t f;
#ifdef DEBUG
  real farea[ND_ND], totalrate=0.;
#endif

  begin_f_loop(f, thread)
  {
    F_CENTROID(fcent,f,thread);
    z = fcent[2];
    flux=728000000.0*exp(-z*z/(2.0*sig*sig))/(sig*sqrt(2.0*M_PI));
    F_PROFILE(f, thread, position)=flux;
#ifdef DEBUG
    Message("face %d, coordinate %16.7g, flux %16.7g\n",f,z,flux);
    F_AREA(farea, f, thread);
    totalrate += flux * NV_MAG(farea);
#endif
  }
  end_f_loop(f, thread)
#ifdef DEBUG
  Message("Total rate = %16.6g\n",totalrate);
#endif
}
It also wouldn't hurt to multiply flux by area (from F_AREA, which gives you an array, then NV_MAG) and report a total applied power. With so few faces, the total might be some way off the theoretical value.

I hope this helps.
Ed
obscureed is offline   Reply With Quote

Old   January 23, 2018, 10:39
Default
  #3
New Member
 
Jacob
Join Date: Jan 2018
Posts: 3
Rep Power: 8
Jacob_Bing is on a distinguished road
Hello,

I think I figured out what the problem was. I have a face that runs in the x direction and I am trying to get the flux to vary along that face. When I changed the code to;

f_centroid(y,f,thread);
x=y[0];

It seems to work correctly. Because I was used to Matlab, I thought that the array positions started at 1 instead of 0. Is there a different way that I could write the code to make it less confusing? Thank you for the help.
Jacob_Bing is offline   Reply With Quote

Old   February 17, 2018, 07:24
Default flux profile
  #4
Member
 
Join Date: Oct 2017
Posts: 52
Rep Power: 9
gouravjee is on a distinguished road
can anyone tell me how to view flux udf profile in fluent ?
gouravjee is offline   Reply With Quote

Old   February 19, 2018, 06:26
Default
  #5
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27
pakk will become famous soon enough
Maybe if you explain what you mean with "flux udf profile"... Do you mean the heat flux as defined by a UDF? In that case, it is the same way as you would show any flux, it does not matter that it was generated by a UDF...
gouravjee likes this.
pakk is offline   Reply With Quote

Old   February 20, 2018, 01:08
Default Energy equation
  #6
Member
 
Join Date: Oct 2017
Posts: 52
Rep Power: 9
gouravjee is on a distinguished road
Quote:
Originally Posted by pakk View Post
Maybe if you explain what you mean with "flux udf profile"... Do you mean the heat flux as defined by a UDF? In that case, it is the same way as you would show any flux, it does not matter that it was generated by a UDF...
Thanks pakk for your reply,
I have got the solution for my problem.
But i am stuck in an another problem. I have to write a UDS for an energy equation.
Can you suggest some source or thread or post from where i can read
about it ??
gouravjee is offline   Reply With Quote

Old   November 11, 2019, 04:02
Default udf code
  #7
New Member
 
Nourhan Bahgat
Join Date: Aug 2019
Posts: 13
Rep Power: 7
Nourhan Bahgat is on a distinguished road
please , how write code udf for this graph to insert as a bc in fluent
Attached Images
File Type: jpg Screenshot (37).jpg (127.9 KB, 19 views)
Nourhan Bahgat is offline   Reply With Quote

Old   November 11, 2019, 04:13
Default
  #8
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27
pakk will become famous soon enough
Take the code above and change the equation.
Nourhan Bahgat likes this.
pakk is offline   Reply With Quote

Old   November 11, 2019, 04:48
Default
  #9
New Member
 
Nourhan Bahgat
Join Date: Aug 2019
Posts: 13
Rep Power: 7
Nourhan Bahgat is on a distinguished road
Quote:
Originally Posted by pakk View Post
Take the code above and change the equation.
Thanks for your response, I will try .
Nourhan Bahgat 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
Radiation in semi-transparent media with surface-to-surface model? mpeppels CFX 11 August 22, 2019 08:30
UDF for defining Heat Flux Profile at a wall Alex90 Fluent UDF and Scheme Programming 13 August 4, 2018 06:34
Udf for moving heat flux in 2D cylindrical geometry devia21 Fluent UDF and Scheme Programming 0 April 20, 2015 01:27
UDF for time dependent stepwise heat flux profile bugrasss Fluent UDF and Scheme Programming 0 April 15, 2015 07:32
Transient udf for limiting flux (solid fuel combustion) Bharadwaj B S FLUENT 0 February 23, 2015 09:46


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