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

Laser Melting UDF Heat Source Issue [Fluent Crashing]

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   August 12, 2024, 11:39
Default Laser Melting UDF Heat Source Issue [Fluent Crashing]
  #1
New Member
 
Rakibul Islam Kanak
Join Date: Feb 2024
Posts: 5
Rep Power: 2
kanak_BUET_ME19 is on a distinguished road
Hello everyone,

I am trying to simulate Selective Laser Melting in Ansys Fluent. Its a two phase problem. So I am using VOF model.

my domain dimension is :

L = 0.8 mm (X axis)
W = 0.2 mm (Y axis)
H = 0.28 mm (Z axis)

In this domain , I patched the domain ( x = 0.8 mm, y = 0.2 mm , z= 0.2 mm) as solid and the rest is gas.

I am trying to model the heat source as surface heat source and place it at x = 0 mm , y = 0.1 mm and z is undefined as I will use if statement to find the interface ( where 0<VOF<1)

My UDF code is given below. After Compiling and initialising , when I try to view the user defined volumetric heat source under the contour tab , FLUENT Crashes instantly. I am not sure what went wrong. Yes I also created 5 user defined memory locations. Can anyone help?

#include "udf.h"
#include "sg_mphase.h"
#include "mem.h"
#include "sg_mem.h"
#include "math.h"
#include "flow.h"
#include "unsteady.h"
#include "metric.h"

// Constants
#define A 0.4 // Absorption coefficient
#define P 200 // Laser power (W)
#define R 40e-6 // Spot radius (m)
#define v 0.5 // Scan speed of laser (m/s)
#define Pi 3.1415926535 // Pi constant
#define x0 0.0 // Initial x position of the laser (m)
#define y0 0.1e-3 // Initial y position of the laser (m)

// UDF for adjusting the gradient heat
DEFINE_ADJUST(adjust_gradient_heat, domain)
{
Thread *t;
Thread **pt;
cell_t c;
int phase_domain_index = 3.0; // thjats my metal domain
Domain *pDomain = DOMAIN_SUB_DOMAIN(domain, phase_domain_index);

Alloc_Storage_Vars(pDomain, SV_VOF_RG, SV_VOF_G, SV_NULL);
Scalar_Reconstruction(pDomain, SV_VOF, -1, SV_VOF_RG, NULL);
Scalar_Derivatives(pDomain, SV_VOF, -1, SV_VOF_G, SV_VOF_RG, Vof_Deriv_Accumulate);

mp_thread_loop_c(t, domain, pt)
if (FLUID_THREAD_P(t))
{
Thread *ppt = pt[phase_domain_index];

begin_c_loop(c, t)
{
C_UDMI(c, t, 0) = C_VOF_G(c, ppt)[0];
C_UDMI(c, t, 1) = C_VOF_G(c, ppt)[1];
C_UDMI(c, t, 2) = C_VOF_G(c, ppt)[2];
C_UDMI(c, t, 3) = sqrt(C_UDMI(c, t, 0) * C_UDMI(c, t, 0) +
C_UDMI(c, t, 1) * C_UDMI(c, t, 1) +
C_UDMI(c, t, 2) * C_UDMI(c, t, 2)); // Magnitude of gradient of volume fraction

}
end_c_loop(c, t)
}

Free_Storage_Vars(pDomain, SV_VOF_RG, SV_VOF_G, SV_NULL);
}

// UDF for defining the heat source
DEFINE_SOURCE(heat_source, c, t, dS, eqn)
{
Thread *pri_th; // Gas phase
Thread *sec_th; // solid phase
real source;
real x[ND_ND], time;
time = CURRENT_TIME; // Acquire time from Fluent solver
C_CENTROID(x, c, t); // Acquire the cell centroid location
real T = C_T(c, t);

pri_th = THREAD_SUB_THREAD(t, 0);
sec_th = THREAD_SUB_THREAD(t, 1);





real rho = C_R(c,t);
real Cp = C_CP(c,t);

real rhom = C_R(c,sec_th);
real Cpm = C_CP(c,sec_th);

real rhog = C_R(c,pri_th);
real Cpg = C_CP(c,pri_th);
real factor = (2 * rho * Cp) / (rhom * Cpm + rhog * Cpg);

real r = sqrt(pow(x[0] - x0 - v * time, 2.0) + pow(x[1] - y0, 2.0));

if (C_VOF(c, t) > 0.05 && C_VOF(c, t) < 1)
{
source = ((2 * A * P) / (Pi * R * R)) * exp((-2 * (r * r)) / (R * R))*factor * C_UDMI(c,t,3);
dS[eqn] = 0.0;
}
else
{
source = 0.0;
dS[eqn] = 0.0;
}

return source;
}
kanak_BUET_ME19 is offline   Reply With Quote

Reply


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
what is swap4foam ?? AB08 OpenFOAM 28 February 2, 2016 02:22
Trouble compiling utilities using source-built OpenFOAM Artur OpenFOAM Programming & Development 14 October 29, 2013 11:59
centOS 5.6 : paraFoam not working yossi OpenFOAM Installation 2 October 9, 2013 02:41
OpenFOAM on MinGW crosscompiler hosted on Linux allenzhao OpenFOAM Installation 127 January 30, 2009 20:08
DecomposePar links against liblamso0 with OpenMPI jens_klostermann OpenFOAM Bugs 11 June 28, 2007 18:51


All times are GMT -4. The time now is 11:45.