# Pulsed laser udf

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

 August 28, 2018, 04:36 Pulsed laser udf #1 Member   Saurabh Das Join Date: Jul 2018 Posts: 43 Rep Power: 7 Hello, I am writing a udf that will allow me to apply laser at a given point repetitively. In the following udf, laser will be applied for the first 1 second, followed by a lull for the next half second. Laser will fire again for a half second, and then the laser will fall silent. Code: ```#include "udf.h" #define a 0.2e-3 //radius of laser beam #define I 1.05e9 //Laser Intensity DEFINE_PROFILE(heat_Momin_flux, thread, position) { face_t f; double x[ND_ND],r,t,tempp,vol,ft; t = CURRENT_TIME; //assigning current time vallue to t begin_f_loop(f,thread) { tempp = F_T(f,thread); F_CENTROID(x,f,thread); r = sqrt(pow(x[0],2.0) + pow(x[1],2.0)); vol = (r*r)/(a*a); //exponential for laser if (t >=0 && t < 1) ft = 1; else if (t >= 1 && t < 1.5) ft = 0; else if (t >= 1.5 && t < 2) ft = 1; else ft = 0; F_PROFILE(f,thread,position) = I*ft*exp(-vol); end_f_loop(f,thread) } }``` On running this udf, the temperature of the region does not change, but stays equal to the initial temperature. I do think that the if else ladder is creating a problem. But I am not too sure. Please help me, I would be thankful to you if you could point out the error in this code.

 August 28, 2018, 05:31 #2 Senior Member   Join Date: Aug 2011 Posts: 421 Blog Entries: 1 Rep Power: 21 Please check the value of "vol". For double data type, the lower bound is at the order of , which means . As a result, the expression involving "exp(-vol)" will be zero if .

August 28, 2018, 06:08
#3
Member

Saurabh Das
Join Date: Jul 2018
Posts: 43
Rep Power: 7
Quote:
 Originally Posted by blackmask Please check the value of "vol". For double data type, the lower bound is at the order of , which means . As a result, the expression involving "exp(-vol)" will be zero if .
The equation in which the exp(-vol) is used is the laser equation and as such, the value of exp(-vol) indicates the effect of laser at a given distance. Points at a farther distance will have higher vol, thus exp(-vol) will be almost equal to zero, indicating no effect of laser at points far away from laser application, but the points which are closer to the point of laser application will have larger change in heat flux.

 August 28, 2018, 06:36 #4 Senior Member   Join Date: Aug 2011 Posts: 421 Blog Entries: 1 Rep Power: 21 You should count the cells which have non-zero values, say, "exp(-vol) > 1.0e-15". And you might need to sum up all the heat flux caused by the laser and make appropriate normalization rather than rely on the analytical expression.

 August 29, 2018, 01:39 #5 Senior Member   Alexander Join Date: Apr 2013 Posts: 2,363 Rep Power: 34 you may try to use UDMI variable to check your profile. Add following line in your code Code: `F_UDMI(F,t,0)= I*ft*exp(-vol);` best regards Sorabh likes this.

 Tags if-else, pulsed laser