# Defining a source term

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

 November 21, 2018, 07:27 Source term for axisymmetric problems #1 Member   Saurabh Das Join Date: Jul 2018 Posts: 43 Rep Power: 6 Hello, I am solving a 2D-axisymmetrical laser heating problem. The laser radius is 0.4mm and it has a profile I = I0*exp(-del*x), where x is the x co-ordinate of the cell and del is the absorptivity coefficient in m^-1 . I wrote the following macro for heat source: Code: ```DEFINE_SOURCE(top_hat,c,t,dS,eqn) { real x[ND_ND],time; real x0,y0,source; real I0 = 1e5; real del = 1; time=RP_Get_Real("flow-time"); C_CENTROID(x,c,t); x0 = x[0]; y0 = x[1]; if (y0 > 0 && y0 < 0.4e-3) { source = I0*exp(-del*x); dS[eqn] = 0; } else { source = 0; dS[eqn] = 0; } return source; }``` However results are not what is expected. I expected a parabolic profile of temperature, but I get the following. Is the source term macro correctly defined? Thanks Last edited by Sorabh; November 21, 2018 at 22:50.

November 22, 2018, 20:01
#2
Senior Member

Join Date: Feb 2010
Posts: 164
Rep Power: 16
Quote:
 Originally Posted by Sorabh Hello, I am solving a 2D-axisymmetrical laser heating problem. The laser radius is 0.4mm and it has a profile I = I0*exp(-del*x), where x is the x co-ordinate of the cell and del is the absorptivity coefficient in m^-1 . I wrote the following macro for heat source: Code: ```DEFINE_SOURCE(top_hat,c,t,dS,eqn) { real x[ND_ND],time; real x0,y0,source; real I0 = 1e5; real del = 1; time=RP_Get_Real("flow-time"); C_CENTROID(x,c,t); x0 = x[0]; y0 = x[1]; if (y0 > 0 && y0 < 0.4e-3) { source = I0*exp(-del*x); dS[eqn] = 0; } else { source = 0; dS[eqn] = 0; } return source; }``` However results are not what is expected. I expected a parabolic profile of temperature, but I get the following. Is the source term macro correctly defined? Thanks
DEFINE_SOURCE will apply to all cells in the domain. So your condition y0 > 0 && y0 < 0.4e-3 will apply to all the cells whose y coordinate <0.4e-3.
You should add additional condition to specify only the first column cells near the left wall. Or another method, do not use DEFINE_SOURCE, just use DEFINE_PROFILE to specify the heat flux on left wall.

November 23, 2018, 22:56
#3
Member

Saurabh Das
Join Date: Jul 2018
Posts: 43
Rep Power: 6
Quote:
 Originally Posted by gearboy DEFINE_SOURCE will apply to all cells in the domain. So your condition y0 > 0 && y0 < 0.4e-3 will apply to all the cells whose y coordinate <0.4e-3. You should add additional condition to specify only the first column cells near the left wall. Or another method, do not use DEFINE_SOURCE, just use DEFINE_PROFILE to specify the heat flux on left wall.
Thanks... but I have defined a condition 'I = I0*exp(-alpha*x)' where alpha = 1.
Will that not be enough to constraint along x axis?
I also considered using the DEFINE_PROFILE to specify heat flux on the wall.. but it is supposed to be a volumetric heat source, hence both x and y (not just y) co-ordinates should be involved.

 November 24, 2018, 06:03 #4 Senior Member   Join Date: Sep 2017 Posts: 235 Rep Power: 10 Hi Sorabh, Here are a few thoughts: ++ It is a mistake to write "exp(-del*x)", since x is an array. A helpful compiler would have issued a warning about this. Instead, try "exp(-del*x0)". ++ If you make this correction, the source looks correctly defined. The test for "if(y>0)" is pointless (since y<0, and on this occasion even y==0 are impossible). ++ I do not remember the details of source terms in 2D-axisymmetric simulations, but I do remember that you need to check the details. Is the source really "per m3", or is it in fact "per angle of rotation" (hence missing a factor of 2*M_PI)? You need to check this -- and I would not trust my understanding of the manuals (and I would not assume that UDFs and GUI-defined values use the same rules), so you need to check this in a test model. I cannot stress this too much. If you do not do this check, you should regard your results as doubtful to within a factor of 2*M_PI. ++ If your model's extent in the x-direction is small compared to the lengthscale "(1./del)", then the rate of source will be approximately constant in the x-direction. In that sense, I do not see your results as obviously wrong. Good luck! Ed

 November 28, 2018, 09:58 #5 Member   Saurabh Das Join Date: Jul 2018 Posts: 43 Rep Power: 6 Yeah, I did what you said.. the 'x' in the equation was actually x[0], and the heat generation is defined in W/m^3, so that is sorted out. I noticed that whenever the point of heat generation is at one of the boundaries, the solution is borked.. but it works when the heat is generated 'within' the doman...

 Tags laser-heating, source term