2.3.25.  DEFINE_REACTING_CHANNEL_BC

2.3.25.1. Description

You can use DEFINE_REACTING_CHANNEL_BC to specify user-defined inlet conditions at any reacting channel inlet. Typically this UDF is used for manifolds where the flow in two (or more) reacting channels mix in a manifold into one (or more) reacting channels. During execution, the DEFINE_REACTING_CHANNEL_BC is called for every channel iteration. The UDF is available only if the reacting channel model is enabled.

2.3.25.2. Usage

DEFINE_REACTING_CHANNEL_BC (name, i, group)

Argument Type

Description

symbol name

UDF name.

int i

ID of the reacting channel group.

Channel_Group *group

Pointer to structure of reacting channel group.

Function returns

void

There are three arguments to DEFINE_REACTING_CHANNEL_BC: name, i, group. You supply name, the name of the UDF, while i and group are variables that are passed by the ANSYS Fluent solver to your UDF. The variable i is the integer ID of the reacting channel group. The last argument is group, which is a pointer to the reacting channel group structure. The members of the structure group are described in the header file sg_reacting_channel.h.

2.3.25.3. Example

The following UDF, named tube3_bc_from_1_and_2, specifies the inlet conditions for a reacting channel. In this UDF example, the inlet conditions (mass-flow rate, pressure, temperature, and species mass fractions) of the reacting channel, tube 3, are defined using the mass-flow weighted outlet states from the reacting channels, tubes 1 and 2.

/*******************************************************************
 * User-defined function to specify the inlet boundary conditions at a reacting channel 
 * using mass weighted average outlet variables from two other reacting channels. 
 * In this UDF, the user defined inlet conditions for temperature, mass flow rate, 
 * species mass fraction, and pressure are applied
 ********************************************************************/

 #include "udf.h"
 #include "sg_reacting_channel.h"
 #define MAX_GROUPS 3   /* maximum number of groups defined in the interface*/
 #define total_tubes 3   /* total number of wall zones in all groups used as reacting channel*/

 static void outlet_average_variables(int *group_ids, int num_groups,Channel_Group *group)
 {
     if(num_groups > N_channel_groups-1 || NULLP(group_ids))
       {
         Message("incorrect number of groups\n");
         return;
       }
     else
       {
         Material *m =group->m;   /* Material of any group, specified in the interface*/
         int i,id,j,ns,nspe=MIXTURE_NSPECIES(m);
         real mf,sum_temp,sum_mf,sum_press;
         cxboolean group_found = FALSE;
         Channel_Tube tube;
         real *sum_yi = (real *) CX_Malloc(sizeof(real)*nspe);
         spe_loop(ns,nspe)
           sum_yi[ns] =0.;
         sum_temp =0.;
         sum_press =0.;
         sum_mf=0.;

         for(j=0;j<total_tubes;j++)
            /* Total number of wall zones selected in all groups in the interface in reacting channel model*/
           {
             group_found = FALSE;
             tube = channel_tubes[j];  /* structure for any wall zone,
                                          which is specified as reacting channel wall*/
             id = tube.group_id;   /* id of the group to which this wall zone belongs*/
             for(i=0;i<num_groups;i++)   /* loop over all groups*/
               if (id == group_ids[i])
                 {
                   group_found = TRUE;   /* the current wall zone is valid reacting channel zone
                                            and belongs to a group*/
                   break;
                 }
             if(!group_found) continue ;
             i = tube.n_bands-1;   /* last grid point of the 1D grid of reacting channel wall zone*/
             mf = tube.group->mf;   /* mass flow rate of the group*/
             sum_mf += mf;
             sum_temp += mf*tube.bands[i].T;   /* temperature at the last grid point,
                                                  i.e. at the exit of the current channel*/
             sum_press += mf*tube.bands[i].pressure;   /* similar to temperature, and other variables
                                                          at exit of current channel*/
             spe_loop(ns,nspe)
               sum_yi[ns] += mf*tube.bands[i].yi[ns];
           }
         if(sum_mf > SMALL)
           {
             group->mf = sum_mf;   /* here group is the current group, where udf is applied,
                                      the mass flow rate is sum of  mf from all other groups*/
             group->temp = sum_temp/sum_mf;   /* the temperature, pressure and mass fraction at this 
                                          group are mass weighted average from exit of other groups*/
             group->pressure = sum_press/sum_mf;
             spe_loop(ns,nspe)
               group->yi[ns] = sum_yi[ns]/sum_mf;
           }         CX_Free(sum_yi);
       }
 }
/* By default, the group will use conditions provided in the interface of the 
 * group in reacting channel model set up. 
 * The UDF can modify few or all inlet conditions. 
 * Any inlet conditions provided by the udf will overwrite the default conditions 
 * provided in the interface for any given group */


DEFINE_REACTING_CHANNEL_BC(tube3_bc_from_1_and_2,i,group)
 {
    int group_ids[MAX_GROUPS];
    int num_groups =0;
    group_ids[0] = 0;   /* id of the group 0 specified in gui or tui */
    group_ids[1] = 1;
    num_groups =2;   /* total number of groups from where the averaging is to be done,
                        in this case, averaged variables from 2 groups are used 
                        to specify the inlet conditions for the third group*/
    outlet_average_variables(group_ids,num_groups,group);
 }

2.3.25.4. Hooking a Reacting Channel Solver UDF to ANSYS Fluent

After the UDF that you have defined using DEFINE_REACTING_CHANNEL_BC is compiled (Compiling UDFs), the name that you specified in the DEFINE macro argument (for example, tube3_bc_from_1_and_2) will become visible and selectable in the Reacting Channel Model dialog box in ANSYS Fluent. See Hooking DEFINE_REACTING_CHANNEL_SOLVER UDFs for details.


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