Fluids

Fluids

Topics relate to Fluent, CFX, Turbogrid and more

thermal NOx udf help

    • mabrys
      Subscriber

      I am working on project where I want to update the thermal rate constants through a UDF function, and for a start, I'm trying to replicate the standard model in fluent for the thermal NO formation. This is to ensure that my UDF works as intended.

      However, I run into problems with my current version of the UDF, as it does not give the same results or, in some cases, can't run at all (floating point and divergence).

      My current udf is based on previous version found online for a older version of the fluent software provided by Ansys: https://www.cfd-online.com/Forums/fluent/44944-nox-udf.html

      Therefore, I'm looking for a UDF that replicates NOx model exactly for a newer version of fluent or help with my existing code as attached to message.

    • RK
      Ansys Employee
      Hello,
      The older version of UDF might not work. Ansys employees will not be able to download any attachments. Please let us know if you have any specific questions and we will be happy to assist you.
    • mabrys
      Subscriber

      Is it possible to get the source code for the thermal NOx rate in fluent? 
      My UDF code should reproduce the default thermal NOx rate in fluent (theory guide page 341). Fluent can run the code, but the solution differs from the default rate.

      Here is my code:

      "

      #include "udf.h"
      /* const real R_Gas_C = 1.9872; Universal gas constant in cal/mole/K */ const real P_Atm = 101325.; /* unit atm in Pa */

      DEFINE_NOX_RATE(user_nox, c, t, Pollut, Pollut_Par, NOx) {
        switch (Pollut_Par->pollut_io_pdf) {
        case IN_PDF:

      POLLUT_FRATE(Pollut) = 0.0;
      POLLUT_RRATE(Pollut) = 0.0;

      switch (Pollut_Par->pollut_io_pdf) {

      case IN_PDF:

      if (POLLUT_EQN(Pollut_Par) == EQ_NO) {

      /* Thermal NOx */

      if (NOx->thermal_nox && NOx->thermal_udf_replace) {

      real kf1, kr1, kf2, kr2, kf3;

      real o_eq=0.0, oh_eq=0.0;

      real s1, s2, s3, rf, rr;

      Rate_Const K_Z_F[3] = {{1.80e8, 0.0, 38370.0},

      {1.80e4, 1.0, 4680.0},

      {7.10e7, 0.0, 450.0}};

      Rate_Const K_Z_R[3] = {{3.80e7, 0.0, 425.0},

      {3.81e3, 1.0, 20820.0},

      {1.70e8, 0.0, 24560.0}};

      Rate_Const K_O[2] = {{36.64, 0.5, 27123.0},

      {3.97e5, -0.5, 31090.0}};

      Rate_Const K_OH = {2.129e2, -0.57, 4595.0};

      kf1 = ARRH(Pollut, K_Z_F[0]);

      kr1 = ARRH(Pollut, K_Z_R[0]);

      kf2 = ARRH(Pollut, K_Z_F[1]);

      kr2 = ARRH(Pollut, K_Z_R[1]);

      kf3 = ARRH(Pollut, K_Z_F[2]);

      /* determine O concentration */

      if (NOx->o_mode == PARTIAL_EQUILIBRIUM) {

      /* use partial equilibrium O model (Warnatz data) */

      o_eq = ARRH(Pollut, K_O[0]);

      }

      else if (NOx->o_mode == FULL_EQUILIBRIUM) {

      /* use full equilibrium O model (Westenburg) */

      o_eq = ARRH(Pollut, K_O[1]);

      }

      else if (NOx->o_mode == LOCAL_MASS_FRACTION) {

      /* use local [O] mass fraction */

      o_eq = MOLECON(Pollut, O);

      }

      if ((NOx->o_mode == PARTIAL_EQUILIBRIUM || NOx->o_mode == FULL_EQUILIBRIUM))

      o_eq *= sqrt(MOLECON(Pollut, O2));

      /* determine OH concentration */

      /* if local OH concentration is zero then calculate it from [O] and [H2O] */

      if (NOx->oh_mode == PARTIAL_EQUILIBRIUM) {

      /* (Westbrook&Baulch -- Andre Peters) */

      oh_eq = ARRH(Pollut, K_OH);

      oh_eq *= sqrt(o_eq*MOLECON(Pollut, H2O));

      }

      else if (NOx->oh_mode == LOCAL_MASS_FRACTION) {

      /* use local OH mass fraction */

      oh_eq = MOLECON(Pollut, OH);

      }

      else if (NOx->oh_mode == 0) {

      /* do not include OH in NO calculation */

      oh_eq = 0.0;

      }

      rf = rr = 0.0;

      s2 = s3 = 0.0;

      s1 = kf2*MOLECON(Pollut, O2);

      if (s1 < 1e-6) {

      rf = 2.*o_eq*kf1*MOLECON(Pollut, N2);

      rr = 0.0;

      POLLUT_FRATE(Pollut) = rf;
      POLLUT_RRATE(Pollut) = rr;


      }

      else {

      s2 = 1.+ kf3*oh_eq/s1;

      s3 = s1 + kr1*MOLECON(Pollut, IDX(NO))/s2;

      rf = 2.*o_eq*kf1*MOLECON(Pollut, N2)*s1/s3;

      rr = 2.*o_eq*kr1*MOLECON(Pollut, IDX(NO))*kr2*MOLECON(Pollut, IDX(NO))/s3;


      POLLUT_FRATE(Pollut) = rf;
      POLLUT_RRATE(Pollut) = rr;


      }
          }
          break;

          case OUT_PDF:
          /* Char Contributions, must be included here */
          break;

        default:
        /* Not used */
        break;
        }
       } 
      break;

      default:

      ;

      }

      }

      "

Viewing 2 reply threads
  • The topic ‘thermal NOx udf help’ is closed to new replies.