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/)
-   -   UDF neither compiling nor interpreting. (https://www.cfd-online.com/Forums/fluent-udf/176255-udf-neither-compiling-nor-interpreting.html)

shan12 August 14, 2016 05:05

UDF neither compiling nor interpreting.
 
Hi

i am trying to simulate steam distribution & condensation for a transient case. For this i am using the following udf:


#include "udf.h"
#define PI 3.141592654
#define PR_NUMBER(cp,mu,k) ((cp)*(mu)/(k))
#define IP_HEAT_COEFF(k,nu,d) ((k)*(Nu)/(d))
DEFINE_MASS_TRANSFER(liq_gas_source,cell,thread,fr om_index,from_species_index, to_index, to_species_index)
{ double alfa_g,alfa_f,Hig,Hif, q_val,m_lg,t_sub,t_sup,Tsat,Hsat,Hsat_f,NV_VEC(v), v_fg,v_f,afg;
Thread *gas = THREAD_SUB_THREAD(thread, from_index);Thread *liq = THREAD_SUB_THREAD(thread, to_index);
double kf = C_K_L(cell,liq),p_op,press,d ; //= C_PHASE_DIAMETER(cell,gas)
double ro_f=C_R(cell,liq),cp_f=C_CP(cell,liq),hfg,mu_f=C_ MU_L(cell,liq);
double F1,F2,F3,F4,F5,F6,F7,Re,Pr,Nu;
double sat_hf (double Tsat1);double sat_hg (double Tsat1);double sat_t (double press);double bub_dia (double teta);
//------------------------------------------------
alfa_f=C_VOF(cell,liq); //liquid volume fraction.
alfa_g=1.0-C_VOF(cell,liq); //vapor volume fraction.
// -------------------------------------------------
NV_DD(v,=,C_U(cell,gas),C_V(cell,gas),C_W(cell,gas ),-,C_U(cell,liq),C_V(cell,liq),C_W(cell,liq)); //relative velocity vector
v_fg = NV_MAG(v); //relative velocity magnitude.
if(alfa_g<0.00001)
v_fg=v_fg*alfa_g*100000.0;
v_f=sqrt(C_U(cell,liq)*C_U(cell,liq)+C_V(cell,liq) *C_V(cell,liq)+C_W(cell,liq)*C_W(cell,liq)); //liquid velocity magnitude.
//--------------------------------------------------
p_op = RP_Get_Real ("operating-pressure"); // operating pressure.
press = C_P(cell,thread) + p_op; // absolute pressure = gauge pressure + operating pressure.
// -------------------------------------------
Tsat=sat_t(press); //Saturation Temperature at sysytem Pressure.
//--------------------------------------------------------//
Hsat=sat_hg(Tsat); //Saturation vapor enthalpy at saturation Temperature.
// _________________________________________________
Hsat_f=sat_hf(Tsat); //Saturation liquid enthalpy at saturation Temperature.
// -------------------------------------------------
t_sub=Tsat-C_T(cell, liq); //Liquid Subcooling.
t_sup=Tsat-C_T(cell, gas); //vapor Superheat.
hfg=Hsat-Hsat_f;
d=bub_dia(t_sub); //mean bubble diameter.
afg=6.0*alfa_g/d; //interfacial area per unit volume.
//-----------------------------------------------
Hig=0.0; Hif=0.0;
Re = RE_NUMBER(ro_f,v_fg,d,mu_f);
Pr = PR_NUMBER (cp_f,mu_f,kf);
if (Re <776.06)
Nu = 2. + 0.6*sqrt(Re)*pow(Pr,1./3.);
if (Re >=776.06)
Nu = 2. + 0.27*pow(Re,0.62)*pow(Pr,1./3.);
Hif = IP_HEAT_COEFF(kf,Nu,d);
C_UDMI(cell,thread,0)=Hif;
Hif=Hif*afg;
Hig=10000.0*alfa_f;
C_UDMI(cell,thread,1)=Hig;
Hig=10000.0*alfa_f*afg;
Hif=(Hif>0.0)? Hif:0.0;
Hig=(Hig>0.0)? Hig:0.0;
//-----------------------------------------------
F1=(alfa_g-1.0e-10)/(0.1-1.0e-10);
F2=(F1<1.0)? F1:1.0;
F3=(F2>0.0)? F2:0.0;
F4=472.4*alfa_g*alfa_f;
F5=(F4>4.724)? F4:4.7240;
F6=F3*17539.0*F5;
Hif=(F6<Hif)? F6:Hif;
if (afg>0.0)
C_UDMI(cell,thread,2)=Hif/afg;
// -----------------------------------------------
q_val=Hig*t_sup+Hif*t_sub;
// -------------- Condensation ------------------
F3=0.0;
if (q_val>0.0)
{
F3=q_val/hfg;
F3= (F3>20000.0)? 20000.0:F3;
}
// ---------------Evaporation ------------------
F4=0.0;
if(q_val<0.0)
F4=q_val/hfg;
// ---------------------------------------------
m_lg=0.0;
m_lg=F3;
C_UDMI(cell,thread,3)=afg;
return (m_lg);
}
//---------------------------------------------------------------------------------------------------------------------------------
double sat_hf (double Tsat1)
{ double c1,c2,c3,c4,c5,Hsat_f;
if (Tsat1 < 273.16)
{ c1=3.678415406; c2=94.566331838;c3=-633700.4102444666;
Hsat_f=c1*pow(Tsat1,2.0)+c2*Tsat1+c3; }
else if ((Tsat1>=273.16) & (Tsat1<=458.15))
{ c1=0.00000097;c2=0.002933502;c3=-3.38991465;c4=5320.465596609;c5=-1265549.5606907;
Hsat_f=c1*pow(Tsat1,4.0)+c2*pow(Tsat1,3.0)+c3*pow( Tsat1,2.0)+c4*Tsat1+c5; }
else if ((Tsat1>458.15) & (Tsat1<588.150))
{ c1=0.028052788; c2=-38.680020889;c3= 22284.565666958;c4=-4003454.94420909;
Hsat_f=c1*pow(Tsat1,3.0)+c2*pow(Tsat1,2.)+c3*Tsat1 +c4; }
else if ((Tsat1>=588.150) & (Tsat1<633.150))
{ c1=0.610403253; c2=-1079.52580492;c3=642594.322849692; c4=-127269493.290113;
Hsat_f=c1*pow(Tsat1,3.0)+c2*pow(Tsat1,2.0)+c3*Tsat 1+c4; }
else
{ c1=2649.754012668; c2=- 3368892.04636868; c3= 1072543945.66977;
Hsat_f=c1*pow(Tsat1,2.0)+c2*Tsat1+c3; }
return Hsat_f;
}
//---------------------------------------------------
double sat_hg (double Tsat1)
{ double c1,c2,c3,c4,c5,Hsat;
if (Tsat1<=269.15)
{ c1=-0.012899897;c2=1861.128740978;c3=1994029.58484808;
Hsat=c1*pow(Tsat1,2.)+c2*Tsat1+c3; }
else if ((Tsat1>269.150) & (Tsat1<=358.15))
{ c1=-0.00798344; c2=6.377237731; c3=146.657325997; c4=2148141.56510444;
Hsat=c1*pow(Tsat1,3.)+c2*pow(Tsat1,2.)+c3*Tsat1+c4 ; }
else if ((Tsat1>358.15) & (Tsat1<458.15))
{ c1=-0.014401837;c2=13.590523939;c3=-2555.16588222;c4=2485409.51767315;
Hsat=c1*pow(Tsat1,3.)+c2*pow(Tsat1,2.)+c3*Tsat1+c4 ; }
else if ((Tsat1>=458.15) & (Tsat1<=558.15))
{ c1=-0.000124769;c2=0.22202041;c3=-155.344116048;c4=51361.267113676; c5=-3995548.42675866;
Hsat=c1*pow(Tsat1,4.)+c2*pow(Tsat1,3.)+c3*pow(Tsat 1,2.)+c4*Tsat1+c5; }
else if ((Tsat1>558.15) & (Tsat1<588.15))
{ c1=-0.177777778;c2=283.203809529;c3=-151359.20946363;c4=29939791.2629894;
Hsat=c1*pow(Tsat1,3.0)+c2*pow(Tsat1,2.0)+c3*Tsat1+ c4; }
else if ((Tsat1>=588.15) & (Tsat1<=623.150))
{ c1=-0.012; c2=28.391200001;c3=-25225.882420901;c4=9972990.42478661;c5=-1477098302.26595;
Hsat=c1*pow(Tsat1,4.)+c2*pow(Tsat1,3.)+c3*pow(Tsat 1,2.)+c4*Tsat1+c5; }
else
{ c1=-107.446320491; c2=203758.913457164;c3=-128801861.923354;c4=27142374107.2608;
Hsat=c1*pow(Tsat1,3.0)+c2*pow(Tsat1,2.0)+c3*Tsat1+ c4; }
return Hsat;
}
//---------------------------------------------------
double sat_t (double press)
{ double c1,c2,c3,n1,Tsat;
if (press<=85.35)
{ c1=210.739597573;n1=0.039362021;
Tsat=c1*pow(press,n1); }
else if ((press>85.35) & (press<=437.6))
{ c1=207.962053686;n1=0.042353185;
Tsat=c1*pow(press,n1); }
else if ((press>437.6) & (press<=1227.6))
{ c1=-0.000008432;c2=0.031700943; c3=-16.214491439+273.15;
Tsat=c1*pow(press,2.)+c2*press+c3; }
else if ((press>1227.6) & (press<7383.7))
{ c1=16.71336998; c2=-109.349132911+273.15;
Tsat=c1*log(press)+c2; }
else if ((press>=7383.7) & (press<25033.0))
{ c1=20.470120624;c2=-142.617297081+273.15;
Tsat=c1*log(press)+c2; }
else if ((press>=25033.0) & (press<=57834.0))
{ c1=24.25874557; c2=-180.96039468+273.15;
Tsat=c1*log(press)+c2; }
else if ((press>57834.0) & (press<=143280.0))
{ c1=27.960189855;c2=-221.972248234+273.15;
Tsat=c1*log(press)+c2; }
else if ((press>143280.0) & (press<=313000.0))
{ c1=4.989420793; n1=0.260632601; c2=273.15;
Tsat=c1*pow(press,n1)+c2; }
else if ((press>313000.0) & (press<=617800.0))
{ c1=5.779367813; n1=0.249057459; c2=273.15;
Tsat=c1*pow(press,n1)+c2; }
else if ((press>617800.0) & (press<1723000.0))
{ c1=6.41872514; n1=0.241236812; c2=273.15;
Tsat=c1*pow(press,n1)+c2; }
else if ((press>=1723000.0) & (press<5941800.0))
{ c1=6.784406757; n1=0.237370672; c2=273.15;
Tsat=c1*pow(press,n1)+c2; }
else if ((press>=5941800.0) & (press<=12845000.0))
{ c1=6.870220827; n1=0.236551273; c2=273.15;
Tsat=c1*pow(press,n1)+c2; }
else if ((press>12845000.0) & (press<=18651000.0))
{ c1=7.241741603; n1=0.233334685; c2=273.15;
Tsat=c1*pow(press,n1)+c2; }
else
{ c1=7.742231269; n1=0.229326725; c2=273.15;
Tsat=c1*pow(press,n1)+c2; }
return Tsat;
}
//----------------------------------------------
double bub_dia (double teta)
{ double d0=1.5e-4;
double teta0=13.5;
double d1=1.5e-3;
double teta1=0.0;
double d;
if (teta>13.5)
d=d0;
else if (teta<0.0)
d=d1;
else
d=(d1*(teta-teta0)+d0*(teta1-teta))/(teta1-teta0);
return d;
}

when i compile then it is compiled, libudf file appears. But when i try to use it in mass transfer option, it shows an error " no user defined function", when i interpret it gives segmentation error.

kindly help.
Thanx in advance.


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