2.3.26.  DEFINE_REACTING_CHANNEL_SOLVER

2.3.26.1. Description

You can use DEFINE_REACTING_CHANNEL_SOLVER to specify a user-defined heat transfer coefficient or heat flux at the reacting channel walls. During execution, the DEFINE_REACTING_CHANNEL_SOLVER is called for every channel iteration. The UDF is available only if the reacting channel model is enabled.

2.3.26.2. Usage

DEFINE_REACTING_CHANNEL_SOLVER (name, params, inlet_state, dist, dt, wall_temp, wall_hf, compute_htc)

Argument Type

Description

symbol name

UDF name.

int *params

Pointer to array of current channel parameters.

real *inlet_state

Pointer to array of inlet species composition, temperature and pressure.

real *dist

Pointer to array of axial distance of discrete points from channel inlet.

real *dt

Pointer to array of time step of integration at discrete points.

real *wall_temp

Pointer to array of channel wall temperature at discrete points.

real *wall_hf

Pointer to array of channel wall heat flux at discrete points

cxboolean *compute_htc

Pointer to a flag. Set TRUE only if heat transfer coefficient is computed with the UDF.

Function returns

void

There are eight arguments to DEFINE_REACTING_CHANNEL_SOLVER: name, params, inlet_state, dist, dt, wall_temp, wall_hf, compute_htc. You supply name, the name of the UDF, while params, inlet_state, dist, dt, wall_temp, wall_hf, and compute_htc are variables that are passed by the ANSYS Fluent solver to your UDF. The variable params contains four integer values specifying the number of species, the number of discrete points along the channel axis, the index of the current channel, and the index of the current channel group. The array inlet_state has N +2 elements, where N is the number of species in the channel material. The first N element of the array contains the mass fraction of the species at the channel inlet. The next two elements are temperature and pressure at the channel inlet. The variables dist, dt, wall_temp, and wall_hf have M elements, where M is the number of discrete points specified along the axis of the channel from the channel inlet to the exit. Your UDF will need to set the Boolean variable compute_htc to TRUE if you want to set the heat transfer coefficient to the reacting channel wall using this UDF or set it to FALSE if you want to set the reacting channel wall heat flux. Your UDF will need to set the value of wall_hf with the heat transfer coefficient if the flag is true or the heat flux from the reacting channel if the flag is false.

2.3.26.3. Example

The following UDF, set_channel_htc, specifies the heat transfer coefficient at the reacting channel wall. The function must be executed as a compiled UDF in ANSYS Fluent.

#include "udf.h"
#include "sg_reacting_channel.h"

/*
  
   There are following two main structures "defined in sg_reacting_channel.h"

   Channel_Group *channel_groups; //channel groups, containing information about inlet conditions, 
   material, model setting etc.
   Channel_Tubes *channel_tubes ' // wall zones, selected as reacting channels, information regarding 
   grid, heat flux, temperature and all other variables stored on this

  
   params is a pointer to integer array containing channel parameters. The array has following 
   four values stored 

   no of species = params[0];
   no of grid points in channel = params[1]
   id of channel = params[2];
   id of the group to which this channel belong = params[3];

   By just having id of channel, we can get all the information regarding a channel as following:

  
   id_channel = params[2];
   Channel_Tube tube =  channel_tubes[id_chanel];
   Channel_Group *group = tube.group;  //tube belongs to the group


   1. Getting the group variables like pressure, temperature, mass flow rate etc from the group 
      obtained above. All these are inlet conditions.

   real pressure = group->pressure.
   real temp = group->temp;
   real mf = group->mf;
   real yi[ns] = group->yi[ns];

   2. The variables like velocity, diameter, rho etc are either available at each grid point 
      of the tube or calculated at each grid point as follows

->Each tube has many grid points along the axial direction. Each grid point is called as bands. 
  All solution variables are stored in bands. 
    
        int nbands = params[1];
        
        For nth grid point, starting from inlet of the tube.

        Material *m = group->m ; //mixture material of the reacting channel group 
        real temp = tube.bands[n].T
        yk[ns] = tube.bands[n].yi[ns];
        pressure = tube.bands[n].pressure;


        
        //band is any grid point of the channel
        
        rho = tube.bands[n].rho;
        band_ktc = Thermal_Conductivity(0, NULL, m, temp, 0., yk,xk,0.);
                   //xk is the mole fraction, yk is the mass fraction
        band_dia = 2.*sqrt(MAX(0., channel_tubes[i].bands[j].area/M_PI));
                  //area of the bands is available and stored, diamete is calculated.
        band_mu =  Viscosity(0,NULL,m,temp,rho,yk,xk,0.);
        band_vel = tube.bands[n].vel;


   */

DEFINE_REACTING_CHANNEL_SOLVER(set_channel_htc,params,inlet_state,dist,dt,wall_temp,wall_hf,compute_htc)
{
    int g_pts, id_c = params[2],j, ns,nspecies= params[0];
    real Nu,Re,vel,channel_dia,visc,Prt,rho,ktc;
    real xk[MAX_SPE_EQNS],yk[MAX_SPE_EQNS];
    Channel_Tube tube =  channel_tubes[id_c];
    Channel_Group *group = tube.group;
    Material *m = group->m ;
    real p,temp,pgauge,mfrate;
    real op_pres_save;
    
    *compute_htc = TRUE ;
    g_pts = params[1];
    Prt=0.85;

    for (j=0;j++)
      {
        if (j == 0 || N_ITER < 1) /*first band or first iteration*/
          {
            spe_loop(ns,nspecies) /*initial conditions from the inlet bc of the group*/
              yk[ns] = group->yi[ns];
            temp = group->temp ;
          }
        else
          {
            spe_loop(ns,nspecies)
              yk[ns] = tube.bands[j-1].yi[ns];
            temp = tube.bands[j-1].T ;
          }

        mfrate = group->mf;
        p = group->pressure;
        Mole_Fraction(m,yk,xk);

        pgauge =0.;
        op_pres_save = op_pres;
        op_pres = group->pressure; /*channel inlet pressure can be different than the operating pressure*/

        rho =  Density(0,NULL,m,temp,pgauge,yk,0,0,0,0,0,0,0,0);
        channel_dia = 2.*sqrt(MAX(0., tube.bands[j].area/M_PI));
        vel = mfrate/(SMALL_S+rho*tube.bands[j].area);
        visc= Viscosity(0,NULL,m,temp,rho,yk,xk,0.);
        ktc = Thermal_Conductivity(0, NULL, m, temp, 0., yk,xk,0.);
        Re = rho*channel_dia*vel/visc;
        op_pres = op_pres_save;

        Nu=3.66;/*You can specify own correlation for Nusselt Number: E.g., one formulation is given below*/
#if 1
        if(Re < 3000)
          Nu=3.66;
        else
          {/*use Gnielinksi correlation for turbulent flows*/
            real fac = 0.125/ (SMALL + pow((0.79*log(Re)-1.64), 2)); /*f/8*/
            Nu = 1.2*fac*(Re - 1000)*M_keprt/(SMALL + (1. + 12.7 *sqrt(SMALL+fac) * (pow(M_keprt,0.66) -1)));
            Nu *= pow((temp/tube.bands[j].wall_temp),0.36); /*temperature correction*/
          }
#endif
        wall_hf[j] = Nu*ktc/channel_dia;
      }

}

2.3.26.4. Hooking a Reacting Channel Solver UDF to ANSYS Fluent

After the UDF that you have defined using DEFINE_REACTING_CHANNEL_SOLVER is compiled (Compiling UDFs), the name that you specified in the DEFINE macro argument (for example, set_channel_htc) will become visible and selectable in the User-Defined Function Hooks dialog box in ANSYS Fluent. See Hooking DEFINE_REACTING_CHANNEL_SOLVER UDFs for details.


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