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

Termination problem after loading the UDF file

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   March 4, 2022, 02:38
Default Termination problem after loading the UDF file
  #1
New Member
 
bilal
Join Date: Oct 2021
Location: pakistan
Posts: 27
Rep Power: 5
hbilal1076 is on a distinguished road
Dear Concern,

In Ansys Fluent, when I compile and load the UDF file, and also in the Cell zone conditions>Fluid I added/enabled the source term and uploaded the UDF file and even initialize but when I click on calculate, after 5 second it become terminated and get closed and back to the main page (main page I means where all tab of geometry, mesh, setup, solution are listed).

I even tried the other UDF sample model from fluent manual and it also get terminated.

Kindly explain the possible mistake that I am doing.

Thank you very much for your time and assistance.

Sincerely,

Bilal
hbilal1076 is offline   Reply With Quote

Old   March 7, 2022, 00:24
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
show UDF code
show console output after you've loaded UDF.
__________________
best regards


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

Old   March 7, 2022, 01:59
Default after compiling UDF and initializing, while calculating the fluent get crashed
  #3
New Member
 
bilal
Join Date: Oct 2021
Location: pakistan
Posts: 27
Rep Power: 5
hbilal1076 is on a distinguished road
Dear Prof. AlexanderZ,
Thank you very much for your reply.
Here is my UDF file.

#include "udf.h"
DEFINE_SOURCE(energy,c,t,ds,eqn)
{
/*FILE *fp;*/
real source,tep,sigma,Pamb,tamb;
real MW[14];
real XH2O,Xco,XCO2,pH2O,pco,pCO2;
real MWmix,sum=0;
real kapa,absH2O,absco,absCO2;
real a0,a1,a2,a3,a4,a5;
real b0,b1,b2,b3,b4,b5;
real c0,c1,C2,c3,c4;
real d0,d1,d2,d3,d4;
int i;
/*fp=fopen("properties.txt","a+");*/
tep=C_T(c,t);
MW[0]=2;
MW[1]=1;
MW[2]=40;
MW[3]=44;
MW[4]=4;
MW[5]=16;
MW[6]=17;
MW[7]=29;
MW[8]=33;
MW[9]=18;
MW[10]=28;
MW[11]=32;
MW[12]=34;
MW[13]=28;
sigma=0.000000056697;
Pamb=1.0;
tamb=298.0;
a0=18.741;
a1=-121.310;
a2=273.500;
a3=-194.05;
a4=56.31;
a5=-5.8169;
b0=-0.23093;
b1=1.12393;
b2=9.4153;
b3=-2.99880;
b4=0.51382;
b5=-.000018684;
c0=6.6334;
c1=-0.0035686;
C2=0.000000016682;
c3=0.00000000025611;
c4=-0.000000000000026558;
if(tep<=750)
{
d0=4.7869;
d1=-0.06953;
d2=0.000295775;
d3=-0.000000425732;
d4=0.000000000202894;
}
else
if(tep>750)
{
d0=10.09;
d1=-0.01183;
d2=0.0000047753;
d3=-0.000000000587209;
d4=-0.000000000000025334;
}
for(i=0;i<14;i++)
{
sum=sum+C_YI(c,t,i)/MW[i];
}
MWmix=1/sum;
XH2O=C_YI(c,t,9)*MWmix/18;
Xco=C_YI(c,t,10)*MWmix/28;
XCO2=C_YI(c,t,3)*MWmix/44;
pH2O=XH2O*Pamb;
pco=Xco*Pamb;
pCO2=XCO2*Pamb;
absCO2=a0+(a1*(1000/tep))+(a2*pow(1000/tep,2))+(a3*pow(1000/tep,3))+(a4*pow(1000/tep,4))+(a5*pow(1000/tep,5));
absco=d0+(d1*tep)+(d2*pow(tep,2))+(d3*pow(tep,3))+ (d4*pow(tep,4));
absH2O=b0+(b1*(1000/tep))+(b2*pow(1000/tep,2))+(b3*pow(1000/tep,3))+(b4*pow(1000/tep,4))+(b5*pow(1000/tep,5));
kapa=(absco*pco)+(absCO2*pCO2)+(absH2O*pH2O);
source=-(4*sigma*kapa*(pow(tep,4)-pow(tamb,4)));
ds[eqn]=0;
/*fprintf(fp,"abc");
fclose(fp);*/
return source;
}
hbilal1076 is offline   Reply With Quote

Old   March 7, 2022, 02:19
Default
  #4
New Member
 
bilal
Join Date: Oct 2021
Location: pakistan
Posts: 27
Rep Power: 5
hbilal1076 is on a distinguished road
When I click on calculate it start processing and after 2 second this error appeared in console and the fluent get crashed and disappeared and closed to the main window (main window I means where mesh, setup, result etc. are listed.
Attached Images
File Type: jpg lllllll11111.jpg (92.4 KB, 4 views)
hbilal1076 is offline   Reply With Quote

Old   March 7, 2022, 02:39
Default
  #5
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
remove this line
Code:
if(tep>750)
problem could be with mass fraction :

Code:
sum=sum+C_YI(c,t,i)/MW[i];
and
XH2O=C_YI(c,t,9)*MWmix/18;
Xco=C_YI(c,t,10)*MWmix/28;
XCO2=C_YI(c,t,3)*MWmix/44;
check carefully IDs of fractions 9, 10 and 3
if I were you I would print in console variable to check if they are defined properly

Code:
for(i=0;i<14;i++)
{
Message0("current sum -> %f, current mass -> %f, of fraction ->%d",sum,C_YI(c,t,i),i);
sum=sum+C_YI(c,t,i)/MW[i];
};
__________________
best regards


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

Old   March 8, 2022, 01:20
Default
  #6
New Member
 
bilal
Join Date: Oct 2021
Location: pakistan
Posts: 27
Rep Power: 5
hbilal1076 is on a distinguished road
Dear Prof. AlexanderZ,

I removed

if(tep>750)

but still the same error, also you mentioned the problem in mass fraction but I don't know what will be the problem to edit?

Thank you
Bilal
hbilal1076 is offline   Reply With Quote

Old   March 8, 2022, 01:22
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
print in console variable to check if they are defined properly

edit this part of code as following:
Code:
for(i=0;i<14;i++)
{
Message0("current sum -> %f, current mass -> %f, of fraction ->%d",sum,C_YI(c,t,i),i);
sum=sum+C_YI(c,t,i)/MW[i];
};
show the console output
__________________
best regards


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

Old   March 8, 2022, 01:59
Default
  #8
New Member
 
bilal
Join Date: Oct 2021
Location: pakistan
Posts: 27
Rep Power: 5
hbilal1076 is on a distinguished road
Dear Prof. AlexanderZ,
I edited and used the below, but again the same Error.
For your convenience, I attached the error screen shot.


#include "udf.h"
DEFINE_SOURCE(energy,c,t,ds,eqn)
{
/*FILE *fp;*/
real source,tep,sigma,Pamb,tamb;
real MW[14];
real XH2O,Xco,XCO2,pH2O,pco,pCO2;
real MWmix,sum=0;
real kapa,absH2O,absco,absCO2;
real a0,a1,a2,a3,a4,a5;
real b0,b1,b2,b3,b4,b5;
real c0,c1,C2,c3,c4;
real d0,d1,d2,d3,d4;
int i;
/*fp=fopen("properties.txt","a+");*/
tep=C_T(c,t);
MW[0]=2;
MW[1]=1;
MW[2]=40;
MW[3]=44;
MW[4]=4;
MW[5]=16;
MW[6]=17;
MW[7]=29;
MW[8]=33;
MW[9]=18;
MW[10]=28;
MW[11]=32;
MW[12]=34;
MW[13]=28;
sigma=0.000000056697;
Pamb=1.0;
tamb=298.0;
a0=18.741;
a1=-121.310;
a2=273.500;
a3=-194.05;
a4=56.31;
a5=-5.8169;
b0=-0.23093;
b1=1.12393;
b2=9.4153;
b3=-2.99880;
b4=0.51382;
b5=-.000018684;
c0=6.6334;
c1=-0.0035686;
C2=0.000000016682;
c3=0.00000000025611;
c4=-0.000000000000026558;
if(tep<=750)
{
d0=4.7869;
d1=-0.06953;
d2=0.000295775;
d3=-0.000000425732;
d4=0.000000000202894;
}
else
{
d0=10.09;
d1=-0.01183;
d2=0.0000047753;
d3=-0.000000000587209;
d4=-0.000000000000025334;
}
for(i=0;i<14;i++)
{
Message0("current sum -> %f, current mass -> %f, of fraction ->%d",sum,C_YI(c,t,i),i);
sum=sum+C_YI(c,t,i)/MW[i];
};
MWmix=1/sum;
XH2O=C_YI(c,t,9)*MWmix/18;
Xco=C_YI(c,t,10)*MWmix/28;
XCO2=C_YI(c,t,3)*MWmix/44;
pH2O=XH2O*Pamb;
pco=Xco*Pamb;
pCO2=XCO2*Pamb;
absCO2=a0+(a1*(1000/tep))+(a2*pow(1000/tep,2))+(a3*pow(1000/tep,3))+(a4*pow(1000/tep,4))+(a5*pow(1000/tep,5));
absco=d0+(d1*tep)+(d2*pow(tep,2))+(d3*pow(tep,3))+ (d4*pow(tep,4));
absH2O=b0+(b1*(1000/tep))+(b2*pow(1000/tep,2))+(b3*pow(1000/tep,3))+(b4*pow(1000/tep,4))+(b5*pow(1000/tep,5));
kapa=(absco*pco)+(absCO2*pCO2)+(absH2O*pH2O);
source=-(4*sigma*kapa*(pow(tep,4)-pow(tamb,4)));
ds[eqn]=0;
/*fprintf(fp,"abc");
fclose(fp);*/
return source;
}
Attached Images
File Type: jpg error1.jpg (90.5 KB, 6 views)
File Type: jpg error1a.jpg (92.8 KB, 7 views)
hbilal1076 is offline   Reply With Quote

Old   March 8, 2022, 05:55
Post
  #9
New Member
 
bilal
Join Date: Oct 2021
Location: pakistan
Posts: 27
Rep Power: 5
hbilal1076 is on a distinguished road
In Ansys fluent, as I am burning acetylene in oxygen rich region that give a product of H2O and CO2.
Therefore, I think my species order is C2H2,O2,H2O,CO2 shown in screenshot but the UDF I am using contain the species order of CO,CO2,H2O, already pasted/shared above, so is this the mistake I am doing?
If this is the mistake then I have to add variable for C2H2 and O2 also?

Actually I am trying to find the temperature and mole fraction of CO2 and H2O for each Grid, therefore my question is
(1) should I just need to remove the species CO from the above shared UDF code and no need to add C2H2 and O2?
(2) or remove the specie CO and add C2H2 and O2 to the above code?
Your comment/assistance will be highly appreciated
TIA
Attached Images
File Type: png specie order.PNG (20.2 KB, 2 views)
hbilal1076 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
[OpenFOAM.com] swak4foam compiling issues on a cluster saj216 OpenFOAM Installation 5 January 17, 2023 17:05
[swak4Foam] Installation Problem with OF 6 version Aurel OpenFOAM Community Contributions 14 November 18, 2020 17:18
[Other] Adding solvers from DensityBasedTurbo to foam-extend 3.0 Seroga OpenFOAM Community Contributions 9 June 12, 2015 18:18
Trouble compiling utilities using source-built OpenFOAM Artur OpenFOAM Programming & Development 14 October 29, 2013 11:59
friction forces icoFoam ofslcm OpenFOAM 3 April 7, 2012 11:57


All times are GMT -4. The time now is 20:35.