0% found this document useful (0 votes)
150 views5 pages

Moving Heat Source Term Using Define-Source - CFD Online Discussion Forums

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
150 views5 pages

Moving Heat Source Term Using Define-Source - CFD Online Discussion Forums

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

12/11/2019 Moving heat source term using Define-Source -- CFD Online Discussion Forums

[Sponsors]

Home
News
Forums
Wiki
Links
Jobs
Books
Events
Tools
Feeds
About
Search

Home > Forums > Software User Forums > ANSYS > FLUENT > Fluent UDF and Scheme Programming

Moving heat source term using User Name User Name Remember Me

Define-Source Password Log in

REGISTER BLOGS COMMUNITY NEW POSTS UPDATED THREADS SEARCH

1 Likes

LINKBACK THREAD TOOLS SEARCH THIS THREAD DISPLAY MODES

May 5, 2017, 06:04 Moving heat source term using Define-Source #1

snsd03090412 Hi! Gus. I am working on the simulation of selective laser melting for time
New Member dependent heat source term in DEFINE_SOURCE Macros. I want to simulate one
track situation to know the distribution of temperature. My volumetric heat source
魏志軒 formula is as follows . The size of substrate is 0.5m*0.5m*0.3 m. The initial laser
Join Date: Apr 2017 xyz position ( 0.01 m, 0.03 m, 0.028 m) move to the final position ( 0.04 m, 0.03
Posts: 1
m, 0.028 m) as time goes by. But, after I interpret my udf, the result shows
Rep Power: 0
floating point exception. I don't know why it doesn't work, can any of you guys give
me some suggestions?
#include "udf.h"
DEFINE_SOURCE(gaussian_heat_flux,c,t,dS,eqn)
{
float A = 0;
real x[3];
real se;
real s=0.000006;
real source; // heat flux
real d=0.000006;
real p = 450; // laser power
real n = 0.45; // process efficiency;
real a = 0.0015; // deposition half width
real b = 0.0009; // melt pool depth
real cc = 0.0015; // longitudinal ellipsoid axis c.
real FF = 1; // scaling factor
real vel = 0.01; // laser beam velocity
real time; // time
real x_coor; // x_coordinates
real y_coor; // y_coordinates
real z_coor; // z_coordinates
real x_ini = 0.01; // x_ini
real y_ini = 0.03; // y_ini
real z_ini = 0.028; // z_ini
real absorp = 0.4; // absorptivity of ss316
real circle = 3.14; // PI
real emis; // emissivity
real sigma = 0.0000000567; // stefan-boltzmann
real Tinf = 300.0; // environment temp
https://www.cfd-online.com/Forums/fluent-udf/187379-moving-heat-source-term-using-define-source.html 1/5
12/11/2019 Moving heat source term using Define-Source -- CFD Online Discussion Forums
real coeff_h; // heat transfer coefficient
real dummy; // dummy variable
time = RP_Get_Real("flow-time");

C_CENTROID(x,c,t);
x_coor = x[0];
y_coor = x[1];
z_coor = x[2];
if (vel*time<=0.04)
{
dummy = 3 * pow((x_coor - x_ini - vel*time), 2) / pow(a, 2) + 3 * pow((y_coor -
y_ini), 2) / pow(b, 2) + 3 * (z_coor - z_ini ) / pow(cc, 2);
se = (6 * pow(3, 0.5)*p*n*FF) / (a*b*cc*circle*pow(circle, 0.5));
source = se*exp(-dummy);
dS[eqn] = 0.0;
return source;

}
else
{
source = 0;
dS[eqn] = 0;
}}
DEFINE_PROPERTY(ss316_density, c, t)
{
real rho_lam;
real temp = C_T(c, t);
if (temp <= 1658)
{
rho_lam = -0.5212*temp + 8126.4;
}
else if (temp>1658 && temp <= 1723)
{
rho_lam = -5.9702*temp + 17161;
}
else if (temp > 1723)
{
rho_lam = -0.7653*temp + 8192.8;
}
return rho_lam;
}
DEFINE_PROPERTY(ss316_conductivity, c, t)
{
real rho_lam;
real temp = C_T(c, t);
if (temp <= 1658)
{
rho_lam = 0.0141*temp + 10.665;
}
else if (temp>1658 && temp <= 1723)
{
rho_lam = -0.0855*temp + 175.88;
}
else if (temp > 1723)
{
rho_lam = 0.0143*temp + 3.8433;
}
return rho_lam;
}
DEFINE_INIT(initial, d)
{
cell_t c;
Thread *t;
/* loop over all cell threads in the domain */
thread_loop_c(t, d)
{
/* loop over all cells */
begin_c_loop_all(c, t)
{
C_T(c, t) = 300.0;
}
end_c_loop_all(c, t)
}
}
Att h d I
https://www.cfd-online.com/Forums/fluent-udf/187379-moving-heat-source-term-using-define-source.html 2/5
12/11/2019 Moving heat source term using Define-Source -- CFD Online Discussion Forums
Attached Images
formula.gif (14.0 KB, 15 views)
result.jpg (121.0 KB, 29 views)

rishitosh likes this.

Last edited by snsd03090412; May 5, 2017 at 07:10.

January 24, 2018, 11:50 #2

rishitosh hey snsd03090412!!


New Member did u solve the problem??
I am trying solve similar kind of problem..
using your idea...
#include "udf.h"
#include "metric.h"
#include "math.h"

#define P 7000 /*peak power of laser*/


Rishitosh Ranjan
Join Date: Dec 2012 DEFINE_SOURCE(gaussian_heat_flux,c,t,dS,eqn)
Location: Trichirapalli, {
Tamilnadu, India real x[2];
Posts: 22 real Q, a1, b, time, vel,dt;
Rep Power: 8
real x1, x2, y[2];
a=b= 0.003;
time = RP_Get_Real("flow-time");
vel = 1e-3;
C_CENTROID(y,c,t);
x1 = y[0]; /*xmax=0.0005 ans xmin=-0.0005*/
x2 = y[1]; /*ymax=0 and ymin=-.0003*/
if (vel*time<=0.005)
{
Q=(3 * P / (M_PI*a1*b))*exp(- (3 * pow(x1-vel*time, 2) / pow(a1, 2)) - (3 *
pow(x2, 2) / pow(b, 2)));
dS[eqn] = 0.0;
return Q;
}
else
{
return 0;
dS[eqn] = 0;
}
}

but its is not wrking well...


can you help in this regard..
thank you.

January
25, 2018, #3
04:39

pakk Quote:
Senior
Member
Originally Posted by rishitosh
a=b= 0.003;
Join
Date:
Nov This is not allowed. (Or it might technically be valid code, but will do something completely different
2013 then what you expect.)
Posts:
1,437
Rep I think you mean:
Power: Code:
20

https://www.cfd-online.com/Forums/fluent-udf/187379-moving-heat-source-term-using-define-source.html 3/5
12/11/2019 Moving heat source term using Define-Source -- CFD Online Discussion Forums

a=0.003;
b=0.003;

January 26, 2018, 14:11 #4

obscureed I do not agree with you on this, Pakk -- that looks like perfectly valid C to me, and
Senior Member it should do the same as the two-line alternative that you propose. See
https://en.wikipedia.org/wiki/Operat...ment_operators
Join Date: Sep 2017 There is a problem that variable "a" is not declared in either case -- I don't know
Posts: 222 why, but the variables are "a1" and "b". It surprises me that this file gets through
Rep Power: 7
the compiler without errors.

A serious error is that size-3 arrays need to be declared as "real y[3];", for
example, so that y[0], y[1] and y[2] are available. (It seems not to matter for x[2],
since x is not used.)

A (possibly benign, possibly dangerous) error is that no value is returned in the


"else" branch.

I would advise you to check the equation for Q -- there is nothing clearly wrong,
but... there seem to be some significantly different lengthscales in operation (0.3m
to 0.0003m), which is possible; the factors of 3 are surprising (for a standard
definition of widths "a1" and "b"); and the laser appears to be centred on 0.0 for
the y-coordinate "x2". (It looks possible that exp(XXX) could evaluated for some
large negative values of XXX -- I would hope that these would safely underflow to
zero.)

Ed

January 28, 2018, 13:44 #5

pakk I stand corrected...


Senior Member

Join Date: Nov 2013


Posts: 1,437
Rep Power: 20

January
29, 2018, #6
05:22

pakk By the way: the "Fluent-way" of defining a variable for position is


Senior Code:
Member
real y[ND_ND];
Join
Date:
Nov
2013
Posts:
ND_ND here means the number of dimensions. In this way, if you go to a two-dimensional case and
1,437 are able to use the same code, it uses a tiny little bit less memory. In most cases not enough to be
Rep noticeable, but it might be a good habit to use it always.
Power:
20
And although the "y[2]" part is definitely wrong in this code, I don't see how it could lead to a floating
point exception... Are you compiling or interpreting?

https://www.cfd-online.com/Forums/fluent-udf/187379-moving-heat-source-term-using-define-source.html 4/5
12/11/2019 Moving heat source term using Define-Source -- CFD Online Discussion Forums

« Previous Thread | Next Thread »

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

Forum Rules

Similar Threads
Thread Thread Starter Forum Replies Last Post

[swak4Foam] swak4Foam-groovyBC build


zxj160 OpenFOAM Community Contributions 18 July 30, 2013 14:14
problem

Free surface boudary conditions with September 9, 2006


Fan Main CFD Forum 10
SOLA-VOF 13:24

October 20, 2000


UDF Scalar Code: HT 1 Greg Perkins FLUENT 8
13:40

October 14, 2000


UDFs for Scalar Eqn - Fluid/Solid HT Greg Perkins FLUENT 0
00:03

October 11, 2000


UDFs for Scalar Eqn - Fluid/Solid HT Greg Perkins FLUENT 0
04:43

All times are GMT -4. The time now is 17:15.

Contact Us - CFD Online - Privacy Statement - Top

© CFD Online

https://www.cfd-online.com/Forums/fluent-udf/187379-moving-heat-source-term-using-define-source.html 5/5

You might also like