|
[Sponsors] |
Termination problem after loading the UDF file |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
March 4, 2022, 02:38 |
Termination problem after loading the UDF file
|
#1 |
New Member
bilal
Join Date: Oct 2021
Location: pakistan
Posts: 27
Rep Power: 5 |
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 |
|
March 7, 2022, 00:24 |
|
#2 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
show UDF code
show console output after you've loaded UDF.
__________________
best regards ****************************** press LIKE if this message was helpful |
|
March 7, 2022, 01:59 |
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 |
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; } |
|
March 7, 2022, 02:19 |
|
#4 |
New Member
bilal
Join Date: Oct 2021
Location: pakistan
Posts: 27
Rep Power: 5 |
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.
|
|
March 7, 2022, 02:39 |
|
#5 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
remove this line
Code:
if(tep>750) 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; 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 |
|
March 8, 2022, 01:20 |
|
#6 |
New Member
bilal
Join Date: Oct 2021
Location: pakistan
Posts: 27
Rep Power: 5 |
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 |
|
March 8, 2022, 01:22 |
|
#7 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
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]; };
__________________
best regards ****************************** press LIKE if this message was helpful |
|
March 8, 2022, 01:59 |
|
#8 |
New Member
bilal
Join Date: Oct 2021
Location: pakistan
Posts: 27
Rep Power: 5 |
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; } |
|
March 8, 2022, 05:55 |
|
#9 |
New Member
bilal
Join Date: Oct 2021
Location: pakistan
Posts: 27
Rep Power: 5 |
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 |
|
|
|
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 |