26.7. Setting Up the Wet Steam Model

You can choose the wet steam model (see Wet Steam Model Theory in the Theory Guide) by opening the Multiphase Model dialog box and selecting the Wet Steam option. It is available for both the pressure-based and density-based solvers.

 Setup   Models   Multiphase Edit...

Figure 26.111: The Multiphase Model Dialog Box with the Wet Steam Model Selected (Pressure-Based)

The Multiphase Model Dialog Box with the Wet Steam Model Selected (Pressure-Based)

Figure 26.112: The Multiphase Model Dialog Box with the Wet Steam Model Selected (Density-Based)

The Multiphase Model Dialog Box with the Wet Steam Model Selected (Density-Based)

The following options are available:

  1. You can set the droplet growth formula that is to be used by the wet steam model using the TUI command:

    define/models/multiphase/wet-steam/set/droplet-growth-rate

    You have the option of using the default Young's formula or switching to Hill's formula as well as setting any modeling parameters. For details, see Phase Change Model in the Fluent Theory Guide.

  2. You can set the virial Equation of State (EOS) that is to be used by the wet steam model using the TUI command:

    define/models/multiphase/wet-steam/set/virial-equation

    You have the option of using the default EOS developed by Vukalovich or switching to the EOS proposed by Young. The selected option will also define the associated equations for the thermodynamic properties of steam. For details, see Built-in Thermodynamic Wet Steam Properties in the Fluent Theory Guide.

  3. Alternative to the virial EOS and build-in steam properties, you have an option to use Real Gas Property (RGP) tables to define the thermodynamic state and properties of steam. For details, see Real Gas Property (RGP) Table Files for the Wet Steam Model in the Fluent Theory Guide. Creating RGP files is described in Using Real Gas Property (RGP) Table Files. Once the proper RGP file is created, you can load it into Fluent by selecting:

     User-Defined User-Defined Read Table...

    or using the TUI command:

    file/table-manager/read-rgp-file

    For the Wet Steam model, there is no need to create the RGP material from the table or embed the RGP data into the case file, so both options may keep the default setting. These options can be controlled via the Settings... button in the Table File Manager dialog box.

    The loaded RGP table can now be linked to the Wet Steam model using the TUI command:

    define/models/multiphase/wet-steam/set/rgp-tables

  4. You can set the option to compute the stagnation condition values using the TUI command:

    define/models/multiphase/wet-steam/set/stagnation-conditions

    For details, see Computing Stagnation Conditions for the Wet Steam Model in the Fluent Theory Guide.

  5. You have the option to switch off the phase change model in specific cell zones using the TUI command: define/models/multiphase/wet-steam/set/zonal-phase-change

    This option can be used to prevent condensation from forming until a certain stage in a multi-stage steam turbine. In cell zones where the phase change model is switched off, the source terms of the transport equations for the wet steam model will be set to zero during the solution process. For details, see Wet Steam Flow Equations in the Fluent Theory Guide and Phase Change Model in the Fluent Theory Guide.

Solution settings and strategies for the wet steam model can be found in Wet Steam Model. Postprocessing variables are described in Model-Specific Variables.

The wet steam model is compatible with General Turbo Interfaces (GTI) that are used to simulate flows in rotating and stationary components of turbomachines, in particular steam turbines. Details of different GTI types are described in Blade Row Interaction Modeling.

26.7.1. Using User-Defined Thermodynamic Wet Steam Properties

Ansys Fluent allows you to use your own property functions and data with the wet steam model. This is achieved with user-defined wet steam property functions (UDWSPF).

These user-defined functions are written in the C programming language and there is a certain programming format that must be used so that you can build a successful library that can be loaded into the Ansys Fluent code.

The following is the procedure for using the user-defined wet steam property functions (UDWSPF):

  1. Define the wet steam equation of state and all related thermodynamic and transport property equations.

  2. Create a C source code file that conforms to the format defined in this section.

  3. Start Ansys Fluent and set up your case file in the usual way.

  4. Turn on the wet steam model.

  5. Compile your UDWSPF C functions and build a shared library file using the text user interface.

    define models multiphase wet-steam compile-user-defined-wetsteam-functions

  6. Load your newly created UDWSPF library using the text user interface.

    define models multiphase wet-steam load-unload-user-defined-wetsteam-library

  7. Run your calculation.

26.7.2. Writing the User-Defined Wet Steam Property Functions (UDWSPF)

Creating a UDWSPF C function library is reasonably straightforward:

  • The code must contain the udf.h file inclusion directive at the beginning of the source code. This allows the definitions for DEFINE macros and other Ansys Fluent functions to be accessible during the compilation process.

  • The code must include at least one in the UDF’s DEFINE functions (that is DEFINE_ON_DEMAND) to be able to use the compiled UDFs utility.

  • Any values that are passed to the solver by the UDWSPF or returned by the solver to the UDWSPF are assumed to be in SI units.

  • You must use the principle set of user-defined wet steam property functions in your UDWSPF library, as described in the list that follows. These functions are the mechanism by which your thermodynamic property data is transferred to the Ansys Fluent solver.

The following lists the user-defined wet steam property function names and arguments, as well as a short description of their functions. Function inputs from the Ansys Fluent solver consist of one or more of the following variables: T = temperature (), P = pressure (), and = vapor-phase density ().

  • void wetst_init(Domain *domain)

    This will be called when you load the UDWSPF. You use it to initialize wet steam model constants or your own model constants. It returns nothing.

  • real wetst_satP(real T)

    This is the saturated pressure function, which takes on temperature in K and returns saturation pressure in Pa.

  • real wetst_satT(real P, real T)

    This is the saturated temperature function, which takes on pressure in Pa and a starting guess temperature in K and returns saturation temperature in K.

  • real wetst_eosP(real rho, real T)

    This is the equation of state, which takes on vapor density in kg/m3 and Temperature in K and returns pressure in Pa.

  • real wetst_eosRHO(real P, real T)

    This is the equation of state, which takes on pressure in Pa and temperature in K and returns vapor density in kg/m3.

  • real wetst_cpv(real T, real rho)

    This is the vapor specific heat at constant pressure, which takes on temperature in K and vapor density in kg/m3 and returns specific heat at constant pressure in J/kg/K.

  • real wetst_cvv(real T, real rho)

    This is the vapor specific heat at constant volume, which takes on temperature in K and vapor density in kg/m3 and returns specific heat at constant volume in J/kg/K.

  • real wetst_hv(real T,real rho)

    This is the vapor specific enthalpy, which takes on temperature in K and vapor density in kg/m3 and returns specific enthalpy in J/Kg.

  • real wetst_sv(real T, real rho)

    This is the vapor specific entropy, which takes on temperature in K and vapor density in kg/m3 and returns specific entropy in J/Kg/K.

  • real wetst_muv(real T, real rho)

    This is the vapor dynamic viscosity, which takes on temperature in K and vapor density in kg/m3 and returns viscosity in kg/m/s.

  • real wetst_ktv(real T, real rho)

    This is the vapor thermal conductivity, which takes on temperature in K and vapor density in kg/m3 and returns thermal conductivity in W/m/K.

  • real wetst_rhol(real T)

    This is the saturated liquid density, which takes on temperature in K and returns liquid density in kg/m3.

  • real wetst_cpl(real T)

    This is the saturated liquid specific heat at constant pressure, which takes on temperature in K and returns liquid specific heat in J/kg/K.

  • real wetst_mul(real T)

    This is the liquid dynamic viscosity, which takes on Temperature in K and returns dynamic viscosity in kg/m/s.

  • real wetst_ktl(real T)

    This is the liquid thermal conductivity, which takes on temperature in K and returns thermal conductivity in W/m/K.

  • real wetst_surft(real T)

    This is the liquid surface tension, which takes on Temperature in K and returns surface tension N/m.

At the end of the code you must define a structure of type WS_Functions whose members are pointers to the principle functions listed previously. The structure is of type WS_Functions and its name is WetSteamFunctionList.

 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*/
  };  

26.7.3. Compiling Your UDWSPF and Building a Shared Library File

This section presents the steps you will need to follow to compile your UDWSPF C code and build a shared library file. This process requires the use of a C compiler. For more details on compiler requirements, see Compilers in the Fluent Customization Manual.


Important:  To use the UDWSPF you will need to first build the UDWSPF library by compiling your UDWSPF C code and then loading the library into the Ansys Fluent code.


The UDWSPF shared library is built in the same way that the Ansys Fluent executable itself is built. Internally, a script called Makefile is used to invoke the system C compiler to build an object code library that contains the native machine language translation of your higher-level C source code. This shared library is then loaded into Ansys Fluent (either at run time or automatically when a case file is read) by a process called dynamic loading. The object libraries are specific to the computer architecture being used, as well as to the particular version of the Ansys Fluent executable being run. The libraries must, therefore, be rebuilt any time Ansys Fluent is upgraded, when the computer’s operating system level changes, or when the job is run on a different type of computer.

The general procedure for compiling UDWSPF C code is as follows:

  1. Place the UDWSPF C code in your working directory (that is, where your case file resides).

  2. Launch Ansys Fluent.

  3. Read your case file into Ansys Fluent.

  4. You can now compile your UDWSPF C code and build a shared library file using the commands provided in the text command interface (TUI):

    1. Select the define/models/multiphase/wet-steam menu item.

      define models multiphase wet-steam

      If the Wet Steam model has not been enabled yet, use the following TUI commands to enable it:

      define/models/multiphase/wet-steam> enable?

      Enable wet steam model? [no] yes

    2. Select the compile-user-defined-wetsteam-functions option.

    3. Enter the compiled UDWSPF library name.

      The name given here is the name of the directory where the shared library (for example, libudf) will reside. For example, if you press Enter then a directory should exist with the name libudf, and this directory will contain library file called libudf. If, however, you type a new library name such as mywetsteam, then a directory called mywetsteam will be created and it will contain the library libudf.

    4. Continue on with the procedure when prompted.

    5. Enter the C source file names.


      Important:  Ideally you should place all of your functions into a single file. However, you can split them into separate files if desired.


    6. Enter the header file names, if applicable. If you do not have an extra header file, then press Enter when prompted.

      Ansys Fluent will then start compiling the UDWSPF C code and put it in the appropriate architecture directory.

26.7.4. Loading the UDWSPF Shared Library File

To load the UDWSPF library, perform the following steps:

  • Go to the define/models/multiphase/wet-steam menu item in the text user interface.

    define models multiphase wet-steam

  • Select the load-unload-user-defined-wetsteam-library option and follow the procedure when prompted.

    If the loading of the UDWSPF library is successful, you will see a message similar to the following:

       Opening user-defined wet steam library "libudf"...
       Library "libudf/lnamd64/2d/libudf.so" opened
    
       Setting material properties to Wet-Steam...
    
       Initializing user defined material properties...
     

26.7.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*/
  };
 /**********************************************************************/