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

UDF for gradual increase in heat generation with time in FSW tool

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By AlexanderZ

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   August 2, 2020, 12:28
Default UDF for gradual increase in heat generation with time in FSW tool
  #1
New Member
 
Rohan
Join Date: Mar 2020
Posts: 24
Rep Power: 6
rohan@123 is on a distinguished road
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
rohan@123 is offline   Reply With Quote

Old   August 2, 2020, 20:26
Default
  #2
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
Ansys Flluent Customization manual
look for define_source macro
__________________
best regards


******************************
press LIKE if this message was helpful
AlexanderZ is offline   Reply With Quote

Old   August 3, 2020, 11:34
Default
  #3
New Member
 
Rohan
Join Date: Mar 2020
Posts: 24
Rep Power: 6
rohan@123 is on a distinguished road
I have seen the manual early sir but cannot getting how to formulate the whole udf for my case.
rohan@123 is offline   Reply With Quote

Old   August 4, 2020, 03:02
Default
  #4
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
show your code and we will try to fix it, if needed
__________________
best regards


******************************
press LIKE if this message was helpful
AlexanderZ is offline   Reply With Quote

Old   August 6, 2020, 00:35
Default
  #5
New Member
 
Rohan
Join Date: Mar 2020
Posts: 24
Rep Power: 6
rohan@123 is on a distinguished road
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.
Attached Images
File Type: png 11111111.PNG (144.6 KB, 18 views)
rohan@123 is offline   Reply With Quote

Old   August 6, 2020, 01:54
Default
  #6
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
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.
__________________
best regards


******************************
press LIKE if this message was helpful
AlexanderZ is offline   Reply With Quote

Old   August 6, 2020, 04:51
Default
  #7
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
compile code
Code:
#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;
}
please, dont send me private messages next time. Lets discuss your case here
__________________
best regards


******************************
press LIKE if this message was helpful
AlexanderZ is offline   Reply With Quote

Old   August 7, 2020, 00:52
Default
  #8
New Member
 
Rohan
Join Date: Mar 2020
Posts: 24
Rep Power: 6
rohan@123 is on a distinguished road
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
Attached Images
File Type: jpg model.JPG (45.0 KB, 4 views)
rohan@123 is offline   Reply With Quote

Old   August 7, 2020, 04:57
Default
  #9
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
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
__________________
best regards


******************************
press LIKE if this message was helpful
AlexanderZ is offline   Reply With Quote

Old   August 7, 2020, 23:21
Default
  #10
New Member
 
Rohan
Join Date: Mar 2020
Posts: 24
Rep Power: 6
rohan@123 is on a distinguished road
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.
rohan@123 is offline   Reply With Quote

Old   August 10, 2020, 01:48
Default
  #11
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
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
__________________
best regards


******************************
press LIKE if this message was helpful
AlexanderZ is offline   Reply With Quote

Old   August 10, 2020, 11:26
Default
  #12
New Member
 
Rohan
Join Date: Mar 2020
Posts: 24
Rep Power: 6
rohan@123 is on a distinguished road
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
rohan@123 is offline   Reply With Quote

Old   August 11, 2020, 01:56
Default
  #13
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
show your code and I'll try to fix it, if needed
__________________
best regards


******************************
press LIKE if this message was helpful
AlexanderZ is offline   Reply With Quote

Old   July 28, 2022, 22:18
Default
  #14
New Member
 
Join Date: Apr 2022
Posts: 2
Rep Power: 0
axt5488 is on a distinguished road
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)));
}
.
.
.
axt5488 is offline   Reply With Quote

Old   August 1, 2022, 00:42
Default
  #15
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
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
axt5488 likes this.
__________________
best regards


******************************
press LIKE if this message was helpful
AlexanderZ is offline   Reply With Quote

Reply

Tags
#fluent #udf #data


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
UDF for Time Dependent Heat Flux imam_mustafa Fluent UDF and Scheme Programming 1 September 23, 2019 04:09
pimpleDyMFoam computation randomly stops babapeti OpenFOAM Running, Solving & CFD 5 January 24, 2018 06:28
Question about heat transfer coefficient setting for CFX Anna Tian CFX 1 June 16, 2013 07:28
same geometry,structured and unstructured mesh,different behaviour. sharonyue OpenFOAM Running, Solving & CFD 13 January 2, 2013 23:40
plot over time fferroni OpenFOAM Post-Processing 7 June 8, 2012 08:56


All times are GMT -4. The time now is 08:51.