Fluids

Fluids

Topics related to Fluent, CFX, Turbogrid and more

Fluent UDF DEFINE_VR_RATE unable to react

    • Jiacheng lyu
      Subscriber

      Hi, guys. Recently, I plan to define pre-exponential factors for limited rate reactions through UDF. The UDF can be compiled and mounted, but the reaction cannot proceed. Hoping to get the reason? The reactant is kerosene. The UDF code is as follows:

      include "udf.h"
      DEFINE_VR_RATE(rate_bfer,c,t,r,wk,yk,rate,rr_t)
      {
      /*If more than one reaction is defined, it is necessary to distinguish
      between these using the names of the reactions. */
          if (!strcmp(r->name, "reaction-1"))
          {
              real ci, prod, er, pef_1;
              int i;
              er = (yk[r->reactant[0]] / wk[r->reactant[0]]) / (fabsf(yk[r->reactant[1]] / wk[r->reactant[1]]) + 1e-9);
              pef_1 = r->A * er;
                  /* Calculate Arrhenius reaction rate */
              prod = 1.0;
              for(i = 0; i < r->n_reactants; i++)
              {
                  ci = C_R(c,t) * yk[r->reactant[i]] / wk[r->reactant[i]];
                  prod *= pow(ci, r->exp_reactant[i]);
              }
              *rate = pef_1 * exp(- r->E / (UNIVERSAL_GAS_CONSTANT * C_T(c,t))) * prod;
              /* without pow(C_T(c,t), r->b)*/
              /* *rr_t = *rate;*/
          /* Reaction 1 */
          }
          else if (!strcmp(r->name, "reaction-2"))
          {
              real ci, prod, er, pef_2;
              int i;
              er = (yk[r->reactant[0]] / wk[r->reactant[0]]) / (fabsf(yk[r->reactant[1]] / wk[r->reactant[1]]) + 1e-9);
              pef_2 = r->A * er;
                  /* Calculate Arrhenius reaction rate */
              prod = 1.0;
              for(i = 0; i < r->n_reactants; i++)
              {
                  ci = C_R(c,t) * yk[r->reactant[i]] / wk[r->reactant[i]];
                  prod *= pow(ci, r->exp_reactant[i]);
              }
              *rate = pef_2 * exp(- r->E / (UNIVERSAL_GAS_CONSTANT * C_T(c,t))) * prod;
              /* without pow(C_T(c,t), r->b)*/
              /* *rr_t = *rate;*/
          /* Reaction 2 */
          }
      }

    • Rob
      Forum Moderator

      If you add some message lines into the UDF are they triggered? You need to figure out if the UDF is doing something unexpected re the maths or if it's not working at all. 

    • Jiacheng lyu
      Subscriber

      I don't think the udf is working so I'm hoping to find the way to make it work. Any suggestions?

    • Rob
      Forum Moderator

      Add in some messages to see if it's triggering but not doing anything or not triggering etc. 

Viewing 3 reply threads
  • You must be logged in to reply to this topic.