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

fluent crash after hooking this udf?!?

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   June 9, 2024, 15:23
Unhappy fluent crash after hooking this udf?!?
  #1
New Member
 
Mohammad
Join Date: May 2024
Posts: 7
Rep Power: 2
DrMaMad is on a distinguished road
I have written this Udf for an unsteady problem to compute mass rate into two walls; (without any error was compiled)
But when I was starting to calculate, I couldn't understand why Fluent crashed and closed.


thank you in advanced
i need any help


#include "udf.h"
DEFINE_EXECUTE_AT_END(Each_Timestep_Massrate) //after each step run
{
FILE *data;//folder to save data
Domain *d;
Thread *tg;//face thread glass wall
Thread *tw;//race thread water boundary
Thread *threadg;//cell thread near glass
Thread *threadw;//cell thread near water
face_t fw;
face_t fg;
cell_t cellg;
cell_t cellw;
real timestep, rateg, ratew, Fluxg, Fluxw;
real F_YIg, C_YIg, glass_T, glass_P, diffg, densg, dsg, Ag_by_es;
real F_YIw, C_YIw, water_T, water_P, diffw, densw, dsw, Aw_by_es;
real xcfg[ND_ND], xccg[ND_ND], dsgv[ND_ND], Ag[ND_ND],
esg[ND_ND];
real xcfw[ND_ND], xccw[ND_ND], dswv[ND_ND], Aw[ND_ND],
esw[ND_ND];
real delphig[ND_ND]={0.,0.};
real delphiw[ND_ND]={0.,0.};
timestep = RP_Get_Real("flow-time")/10;
d = Get_Domain(1);
rateg = 0.;
ratew = 0.;
Fluxg = 0.;
Fluxw = 0.;
tg = Lookup_Thread(d,5);
tw = Lookup_Thread(d,8);
begin_f_loop(fg,tg)
{
cellg=F_C0(fg,tg);
threadg = THREAD_T0(tg);
F_CENTROID(xcfg,fg,tg);
C_CENTROID(xccg,cellg,threadg);
NV_VV(dsgv, =, xcfg, -, xccg);
dsg=NV_MAG(dsgv);
F_AREA(Ag,fg,tg);
if (dsg != 0.)
{
esg[0]= dsgv[0]/dsg;
esg[1]= dsgv[1]/dsg;
Ag_by_es=NV_DOT(Ag,Ag)/NV_DOT(Ag,esg);
}
else
{
NV_VV(esg, =, dsgv, -, dsgv);
Ag_by_es=0.;
}
F_YIg= F_YI(fg,tg,0);
C_YIg= C_YI(cellg,threadg,0);

delphig[0]=C_YI_G(cellg,threadg,0)[0];
delphig[1]=C_YI_G(cellg,threadg,0)[1];
glass_T=F_T(fg,tg);
glass_P=F_P(fg,tg) + 101325;
if (glass_P < 101325)
glass_P = 101325;
if (glass_P > 1013250)
glass_P = 1013250;
if (glass_T < 300)
glass_T = 300;
if (glass_T > 400)
glass_T = 400;
diffg = 2.6e-5 * (101325/glass_P) * pow((glass_T/298), 1.5);
if (NNULLP(THREAD_STORAGE(tg,SV_DENSITY)))
densg = F_R(fg,tg);
else
densg = C_R(cellg,threadg);
Fluxg=densg * ((diffg*(F_YIg-C_YIg)/dsg*Ag_by_es)+(diffg*
((NV_DOT(delphig,Ag))+(Ag_by_es*NV_DOT(delphig,esg )))));
rateg += Fluxg;
}
end_f_loop(fg,tg)
begin_f_loop(fw,tw)
{
cellw=F_C0(fw,tw);
threadw = THREAD_T0(tw);
F_CENTROID(xcfw,fw,tw);
C_CENTROID(xccw,cellw,threadw);
NV_VV(dswv, =, xcfw, -, xccw);
dsw=NV_MAG(dswv);
F_AREA(Aw,fw,tw);
if (dsw != 0.)
{
esw[0]= dswv[0]/dsw;
esw[1]= dswv[1]/dsw;
Aw_by_es=NV_DOT(Aw,Aw)/NV_DOT(Aw,esw);
}
else
{
NV_VV(esw, =, dswv, -, dswv);
Aw_by_es=0.;
}
F_YIw= F_YI(fw,tw,0);
C_YIw= C_YI(cellw,threadw,0);
//delphiw=C_UDMI(cellw,threadw,0);
delphiw[0]=C_YI_G(cellw,threadw,0)[0];
delphiw[1]=C_YI_G(cellw,threadw,0)[1];
water_T=F_T(fw,tw);
water_P=F_P(fw,tw) + 101325;
if (water_P < 101325)
water_P = 101325;
if (water_P > 1013250)
water_P = 1013250;
if (water_T < 300)
water_T = 300;
if (water_T > 400)
water_T = 400;
diffw = 2.6e-5 * (101325/water_P) * pow((water_T/298), 1.5);
if (NNULLP(THREAD_STORAGE(tw,SV_DENSITY)))
densw = F_R(fw,tw);
else
densw = C_R(cellw,threadw);
Fluxw=densw * ((diffw*(F_YIw-C_YIw)/dsw*Aw_by_es)+(diffw*
((NV_DOT(delphiw,Aw))+(Aw_by_es*NV_DOT(delphiw,esw )))));
ratew += Fluxw;
}
end_f_loop(fw,tw)
data=fopen("D:\\desktop\\simulation\\Ansys\\Gaurav 6\\GauravFluent6_files\\dp0\\FFF-10\\Fluent\\MASSRATE.txt","a");
fprintf(data,"time-step evaporation-rate condensation-rate\n");
fprintf(data,"%f\t%e\t%e\n",timestep,ratew,rateg);
fclose(data);
}
DrMaMad is offline   Reply With Quote

Old   June 9, 2024, 16:15
Default domain
  #2
New Member
 
Mohammad
Join Date: May 2024
Posts: 7
Rep Power: 2
DrMaMad is on a distinguished road
this problem is about a trapizoidal 2d planar domain which has 4 walls: UDF computes diffusive mass flux in two of these walls called glass and water
DrMaMad is offline   Reply With Quote

Reply

Tags
fluent crash, udf


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
Running Fluent from Python: UDF Compilation problems Ames Fluent UDF and Scheme Programming 5 November 16, 2020 07:12
Sutile and Tricky : Drive Fluent UDF parameters directly from workbench amscosta Fluent UDF and Scheme Programming 4 July 21, 2020 17:50
Compiling UDF in FLuent ekha FLUENT 6 July 3, 2019 04:02
Fluent UDF for thermal NOx larsschwarzer Fluent UDF and Scheme Programming 1 July 18, 2014 09:39
fluent UDF external library lapack problem Rick FLUENT 0 May 7, 2008 11:16


All times are GMT -4. The time now is 12:22.