24.6.5. UDWSPF Example

This section describe a simple UDWSPF. You can use this example as the basis for your own UDWSPF code. For approximate calculations at low pressure, the simple ideal-gas equation of state and constant isobaric specific heat is assumed and used. The properties at the saturated liquid line and the saturated vapor line used in this example are similar to the one used by ANSYS Fluent.

/**********************************************************************/
 /* User Defined Wet Steam Properties:
   EOS    : Ideal Gas Eq.
   Vapor Sat. Line : W.C.Reynolds tables (1979)
   Liquid Sat. Line: E. Eckert & R. Drake book (1972)
 
   Use ideal-gas EOS with Steam properties
   to model wet steam condensation in low pressure nozzle
   Author: L. Zori
   Date : Jan. 29 2004
 */
 /**********************************************************************/
 #include "udf.h"
 #include "stdio.h"
 #include "ctype.h"
 #include "stdarg.h"
 
 /*Global Constants for this model*/
 real ws_TPP = 338.150 ;
 real ws_aaa = 0.01 ;
 real cpg = 1882.0;/* Cp-vapor at low-pressure region*/
 
 DEFINE_ON_DEMAND(I_do_nothing)
 {
    /* This is a dummy function to allow us to use */
    /* the Compiled UDFs utility      */
 } 
 void wetst_init(Domain *domain)
 {
    /*
      You must initialize these material property constants.
      they will be used in the wet steam model in fluent
    */
    ws_Tc = 647.286  ;/*Critical Temp. */
    ws_Pc = 22089000.00 ;/*Critical Pressure */
    mw_f  = 18.016 ;/*fluid droplet molecular weight (water) */
    Rgas_v  = 461.50 ;/*vapor Gas Const*/
 }
 
 real wetst_satP(real T)
 {
    real psat;
    real SUM=0.0;
    real pratio;
    real F;
    real a1 = -7.41924200 ;
    real a2 = 2.97210000E-01;
    real a3 = -1.15528600E-01;
    real a4 = 8.68563500E-03;
    real a5 = 1.09409899E-03;
    real a6 = -4.39993000E-03;
    real a7 = 2.52065800E-03;
    real a8 = -5.21868400E-04;
    if (T > ws_Tc) T = ws_Tc ;
    F  = ws_aaa*(T - ws_TPP)  ;
    SUM = a1 + F*(a2+ F*(a3+ F*(a4+ F*(a5+ F*(a6+ F*(a7+ F*a8)))))) ;
    pratio = (ws_Tc/T - 1.0)*SUM;
    psat  = ws_Pc *exp(pratio) ;  
   return psat; /*Pa */
 } 
 real
 wetst_satT(real P, real T)
 {
    real tsat;
    real dT, dTA,dTM,dP,p1,p2,dPdT;
   real dt = 1.e-4;
    int i ;
      for (i=0; i<25; ++i)
       {
         if (T > ws_Tc) T = ws_Tc-0.5;
 
         p1= wetst_satP(T)  ;
         p2= wetst_satP(T+dt) ;
         dPdT = (p2-p1)/dt;
 
         dP = P - p1 ;
 
         dT = dP/dPdT  ;
 
         dTA = fabs(dT);
         T = T + dT;
         if (fabs(dT)<TEMP_eps*T) break;
         }
      tsat = T;
    return tsat; /*K */
 }
 
 real
 wetst_eosP(real rho, real T)
 {
    real P;

    P = rho* Rgas_v * T ;  

   return P; /*Pa */
 } 
 real
 wetst_eosRHO(real P, real T)
 {
     real rho;

     rho = P/(Rgas_v * T) ;

     return rho; /*kg/m3 */
 }
 
 
 real
 wetst_cpv(real T, real rho)
 {
     real cp;

     cp = cpg ;

     return cp; /* (J/Kg/K) */
 }
 
 real
 wetst_cvv(real T, real rho)
 {
    real cv;

    cv = wetst_cpv(T,rho) - Rgas_v ;

    return cv; /* (J/Kg/K) */
 }
 
 real
 wetst_hv(real T,real rho)
 {
    real h;

    h = T* wetst_cpv(T,rho) ;

   return h; /* (J/Kg) */
 }
 
 real
 wetst_sv(real T, real rho)
 {
    real s ;

    real TDatum=288.15;
    real PDatum=1.01325e5;
    s=wetst_cpv(T,rho)*log(T/TDatum)+
    Rgas_v*log(PDatum/(Rgas_v*T*rho));

  return s; /* (J/Kg/K) */
 }
 
 
 real
 wetst_muv(real T, real rho)
 {
    real muv;

    muv=1.7894e-05 ;

    return muv; /* (Kg/m/s) */
 }
 
 real
 wetst_ktv(real T, real rho)
 {
    real ktv;

    ktv=0.0242 ;

    return ktv; /* W/m/K */
 } 
 real
 wetst_rhol(real T)
 {
    real rhol;

    real SUM = 0.0;
    int ii;
    int i;
    real rhoc = 317.0;
    real D[8];

    D[0] =  3.6711257 ;
    D[1] = -2.8512396E+01 ;
    D[2] =  2.2265240E+02 ;
    D[3] = -8.8243852E+02 ;
    D[4] =  2.0002765E+03 ;
    D[5] = -2.6122557E+03 ;
    D[6] =  1.8297674E+03 ;
    D[7] = -5.3350520E+02 ;
    if (T > ws_Tc) T = ws_Tc ;
    for(ii=0;ii 8;++ii)
      {
         i = ii+1 ;
         SUM += D[ii] * pow((1.0 - T/ws_Tc), i/3.0);
      }
    rhol = rhoc*(1.0+SUM);

    return rhol; /* (Kg/m3) */
 }
 
 
 real
 wetst_cpl(real T)
 {
    real cpl;

   real a1= -36571.6 ;
    real a2= 555.217 ;
    real a3= -2.96724 ;
    real a4= 0.00778551;
    real a5= -1.00561e-05;
    real a6= 5.14336E-09;

    if (T > ws_Tc) T = ws_Tc ;
    cpl = a1 + T*(a2+ T*(a3+ T*(a4+ T*(a5+ T*a6)))) ;

    return cpl; /* (J/Kg/K) */
 }
 
 
 real
 wetst_mul(real T)
 {
    real mul;

    real a1= 0.530784;
    real a2= -0.00729561;
    real a3= 4.16604E-05 ;
    real a4= -1.26258E-07;
    real a5= 2.13969E-10;
    real a6= -1.92145E-13;
    real a7= 7.14092E-17;

    if (T > ws_Tc) T = ws_Tc ;
    mul = a1 + T*(a2+ T*(a3+ T*(a4+ T*(a5+ T*(a6+ T*a7))))) ;

    return mul; /* (Kg/m/s) */
 }
 
 real
 wetst_ktl(real T)
 {
  real ktl;

    real a1= -1.17633;
    real a2= 0.00791645;  real a3= 1.48603E-05;
    real a4= -1.31689E-07;
    real a5= 2.47590E-10;
    real a6= -1.55638E-13;

    if (T > ws_Tc) T = ws_Tc ;
    ktl = a1 + T*(a2+ T*(a3+ T*(a4+ T*(a5+ T*a6)))) ;

  return ktl; /* W/m/K */
 }
 
 real
 wetst_surft(real T)
 {
    real sigma;

    real Tr;
    real a1= 82.27  ;
    real a2= 75.612;
    real a3= -256.889 ;
    real a4= 95.928;

    if (T > ws_Tc) T = ws_Tc ;
    Tr  = T/ws_Tc ;
    sigma = 0.001*(a1 + Tr*(a2+ Tr*(a3+ Tr*a4))) ;

    return sigma ;/* N/m */
 }
 
 /* do not change the order of the function list */
 UDF_EXPORT WS_Functions WetSteamFunctionList =
   {
   wetst_init,     /*initialization  function*/
   wetst_satP,     /*Saturation  pressure*/
   wetst_satT,     /*Saturation  temperature*/
   wetst_eosP,     /*equation  of  state*/
   wetst_eosRHO,   /*equation  of  state*/
   wetst_hv,       /*vapor  enthalpy*/
   wetst_sv,       /*vapor  entropy*/   
   wetst_cpv,      /*vapor  isobaric  specific  heat*/
   wetst_cvv,      /*vapor  isochoric  specific  heat*/
   wetst_muv,      /*vapor  dynamic  viscosity*/
   wetst_ktv,      /*vapor  thermal  conductivity*/
   wetst_rhol,     /*sat.  liquid  density*/
   wetst_cpl,      /*sat.  liquid  specific  heat*/
   wetst_mul,      /*sat.  liquid  viscosity*/
   wetst_ktl,      /*sat.  liquid  thermal  conductivity*/
   wetst_surft     /*liquid  surface  tension*/
  };
 /**********************************************************************/
 

Release 18.2 - © ANSYS, Inc. All rights reserved.