CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (https://www.cfd-online.com/Forums/fluent-udf/)
-   -   Invalid Cp and Floating point exception in FLUENT UDF (https://www.cfd-online.com/Forums/fluent-udf/245599-invalid-cp-floating-point-exception-fluent-udf.html)

Cooper24 October 14, 2022 10:22

Invalid Cp and Floating point exception in FLUENT UDF
 
I am trying to move a Laser over a cylindrical pellet. The Laser is applied using a UDF and using DEFINE_PROFILE. When I remove the UDF and just apply a constant surface heat flux on the surface, the simulation runs. But when I am using the UDF, the simulation does not start and throws a floating point exception error along with Invalid Cp warning. I have attached the image of the domain. My UDF is as follows:

#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"
#include "sg.h"

#define eta 0.35 // Absorption coefficient
#define P 500 // Laser power
#define R 40e-6 // spot radius
#define v 0.04 // scan speed of laser
#define ha 25 // Heat transfer coefficient
#define Ta 298 // Ambient air temperature
#define s 5.67e-8 // Stefan Boltzmann constant
#define e 0.5 // Emmisivity
#define Pi 3.1415926535
#define x0 -200e-6 // Initial x position of the laser
#define y0 0.0 // Intiial y position of the laser
#define Ts 1357 // Solidus temperature
#define Tl 1357 // Liquidus temperature

DEFINE_PROFILE(Laser, t, i) // The name of the UDF is Laser
{
real x[ND_ND], time; // Define face centroid vector, time
time = RP_Get_Real("flow-time"); // Acquire time from Fluent solver
face_t f; // face thread


begin_f_loop(f,t)
{
F_CENTROID(x,f,t);
real r = sqrt(pow(x[0]-x0-v*time,2.0) + pow(x[1]-y0,2.0));
real T = F_T(f,t);

if(r<=R)
{
F_PROFILE(f,t,i) = (((2*eta*P)/(Pi*R*R))*exp((-2*(r*r))/(R*R))) - ha*(T-Ta) - (s*e*(pow(T,4) - pow(Ta,4)));
}
else
{
F_PROFILE(f,t,i) = - ha*(T-Ta) - (s*e*(pow(T,4) - pow(Ta,4)));
}
}
end_f_loop(f,t)
}

Someone please help!! Thanks in advance.


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