UDF for gradual increase in heat generation with time in FSW tool
Hi everyone,
I am trying to simulate the behaviour of material flow considering the gradual rise in temperature in the fsw tool with time during welding in fluent and need to define this increase with the help of an UDF. Regards, Rohan |
Ansys Flluent Customization manual
look for define_source macro |
I have seen the manual early sir but cannot getting how to formulate the whole udf for my case.
|
show your code and we will try to fix it, if needed
|
1 Attachment(s)
Hi sir, I am basically new to UDF formulation. My main idea that I would like to convey is that, "When the impression of the tool will rotate and traverse along the weld line then heat would gradually increase with time in it", as you can see in the attached file. I have also seen the UDF manual but no fruitful thing happened. So I would like that if you would help then it qipl not only motivate me but also help others in the forum.
|
I will not do you job instead of you.
what I recommend, start with constant heat source, make UDF code for that and apply it You can find example in Ansys Fluent Customization manual, look for define_source macro Later add time/coordinate dependence in the code. |
compile code
Code:
#include "udf.h" |
1 Attachment(s)
Hi, @AlexanderZ,
I just saw your interpreted code. If I am not wrong you are trying to say the final code as follows: #include "udf.h" #include "math.h" DEFINE_SOURCE(energy_1, c, t, dS, eqn) { real source; real time; time = CURRENT_TIME; if (time >= 275.0) source = 0.0; else if (time >= 12.100000e+002) source = (47.69 * pow(time, 2)) / 3.82; else source = (1400000) / 3.82; dS[eqn] = 0.0; return source; } But in regard to your above mentioned troubleshooted code of mine a query is their: (1) How to add co-ordinate dependence in the code i.e. how to specify that I want to define this UDF_source code to that particular geometry (impression of tool) only? P.S. Kindly see the attcahment for further details. N.B. (1) The dimension of the plate is 200*150*4 mm (2) The dimension of the impression of the tool is, shoulder radius=12.5 mm pin base radius=3.5 mm pin tip radius=2.5 mm Length of the pin=3 mm Depression of tool inside the plate=0.05 mm Offset of tool along Aluminum side=1.5 mm |
you need to apply this source to zone, where your laser is
get coordinate of each finite cell, check if it within the laser circle or not. and move laser circle in time, of course |
Hi, @AlexanderZ, from your reply I understood that this UDF should be interpreted in boundary conditions. Ok got it.
But, I cant understood what you said by "check if it within the laser circle or not and move laser circle in time". Kindly elaborate with keeping in mind my model context. For information, In my model their is not any laser source or any thing. Just the tool will get heated up gradually with time. |
ok, so you are simulating friction welding, no idea why I thought about laser welding
so it means, you need to switch between DEFINE_SOURCE to DEFINE_PROFILE macro, cause heat is not volumetric (as in laser welding), but it is surface heat DEFINE_PROFILE is applied as boundary condition to the face concept of code is this: get coordinate of each finite face check if it within the circle of your tool if yes, put source value on the next time step move circle of tool (now coordinates are different, cause it moves in time along welding seam) repeat steps |
Hi, can you kindly show me how to do it if you are aware of the code. The dimensions of the model are given in my trailing responses. It will help me a lot.
Regards, rohan |
show your code and I'll try to fix it, if needed
|
Hello Alexander
I am working on a similar case but for laser welding and DEFINE_SOURCE macro. For heat source movement I manually define conditions with using if / else-if condition for each time step. I calculate the position of the laser spot according to defined welding velocity for each time step to see if it works or not. But the code only calculates the first if condition and creates the spot for the first step and does not keep continues. I think I am missing something with looping macros according to the UDF Manual it is mentioned that for DEFINE_SOURCE macro UDF will not need to loop over cells in the thread since ANSYS Fluent is already doing it. thread_loop_c looks like an option but can not find any application in DEFINE_SOURCE. I think there is a easier way for time increment (maybe for macros) in my case but I didnot find it. (Please consider the increment value is not integer - 0.00005sec) Any comment helps, thanks in advance #include "udf.h" #include "math.h" #include "metric.h" #include "sg.h" #include "sg_mphase.h" #include "mem.h" #include "sg_mem.h" #include "flow.h" #include "unsteady.h" #define A 0.24 /*Absorption coefficient*/ #define P 400 /*Laser Power*/ #define re 0.0002 /*radius on top*/ #define ri 0.0001 /*radius on bottom*/ #define r0 0.00006 /*Laser Spot radius*/ #define zi 0.00005 /*cone length parameter lower z axis*/ #define ze 0.0001 /*cone length parameter upper z axis*/ #define v1 1.200 /*laser velocity*/ #define v2 0 /*laser velocity*/ DEFINE_SOURCE(heat_source, c, t, dS, eqn) { real x[ND_ND]; double source = 0.0; //static real laser_center[ND_ND] = { 0, 0, 0 }; C_CENTROID(x, c, t); real time = RP_Get_Real("flow-time"); real H = ze - zi; real radius_vol; real q_cons; radius_vol = M_PI * H * pow(re, 2) + (re * ri) + pow(ri, 2); q_cons = 6 * A * P / radius_vol; if (time == 0.00005 && 0.00055 < x[0] && x[0] < 0.00067 && 0.00055 < x[1] && x[1] < 0.00067) { source = q_cons * exp(-1 * (pow(0.00006, 2.0) / pow(r0, 2))); } else if (time == 0.00010 && 0.00061 < x[0] && x[0] < 0.00073 && 0.00055 < x[1] && x[1] < 0.00067) { source = q_cons * exp(-1 * (pow(0.00012, 2.0) / pow(r0, 2))); } else if (time == 0.00015 && 0.00067 < x[0] && x[0] < 0.00079 && 0.00055 < x[1] && x[1] < 0.00067) { source = q_cons * exp(-1 * (pow(0.00018, 2.0) / pow(r0, 2))); } else if (time == 0.00020 && 0.00073 < x[0] && x[0] < 0.00085 && 0.00055 < x[1] && x[1] < 0.00067) { source = q_cons * exp(-1 * (pow(0.00024, 2.0) / pow(r0, 2))); } else if (time == 0.00025 && 0.00079 < x[0] && x[0] < 0.00091 && 0.00055 < x[1] && x[1] < 0.00067) { source = q_cons * exp(-1 * (pow(0.00030, 2.0) / pow(r0, 2))); } . . . |
problem is in your condition time == 0.00005 -> condition
most likely you want it to be time <= 0.00005 -> condition actually, most likely you will never get exact this time moment time == 0.00005 |
All times are GMT -4. The time now is 20:06. |