|
[Sponsors] |
January 22, 2018, 13:23 |
UDF for Heat Flux Profile
|
#1 |
New Member
Jacob
Join Date: Jan 2018
Posts: 3
Rep Power: 8 |
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) } |
|
January 22, 2018, 14:34 |
|
#2 |
Senior Member
Join Date: Sep 2017
Posts: 246
Rep Power: 12 |
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 } I hope this helps. Ed |
|
January 23, 2018, 10:39 |
|
#3 |
New Member
Jacob
Join Date: Jan 2018
Posts: 3
Rep Power: 8 |
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. |
|
February 17, 2018, 07:24 |
flux profile
|
#4 |
Member
Join Date: Oct 2017
Posts: 52
Rep Power: 9 |
can anyone tell me how to view flux udf profile in fluent ?
|
|
February 19, 2018, 06:26 |
|
#5 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
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...
|
|
February 20, 2018, 01:08 |
Energy equation
|
#6 | |
Member
Join Date: Oct 2017
Posts: 52
Rep Power: 9 |
Quote:
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 ?? |
||
November 11, 2019, 04:02 |
udf code
|
#7 |
New Member
Nourhan Bahgat
Join Date: Aug 2019
Posts: 13
Rep Power: 7 |
please , how write code udf for this graph to insert as a bc in fluent
|
|
November 11, 2019, 04:13 |
|
#8 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
Take the code above and change the equation.
|
|
November 11, 2019, 04:48 |
|
#9 |
New Member
Nourhan Bahgat
Join Date: Aug 2019
Posts: 13
Rep Power: 7 |
||
|
|
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 |