Ansys Products

Ansys Products

Discuss installation & licensing of our Ansys Teaching and Research products.

FLUENT- Drag modification UDF

    • Roya
      Subscriber

      Hello everyone,
      I am trying to simulate a gas-liquid stirred tank. I am using a Grace drag model, for the modification, I dont want to use Brucato model, but I want to define a UDF based on another model. I know that I need to use the DEFINE_EXCHANGE_PROPERTY macro. The formula I would like to use can be defined as :

      C_D_modified= modification_coefficient* C_D
      * C_D being the drag coefficient that is already being calculated by the Grace model.

      My issue is that I don't know how to call the drag coefficient that FLUENT is already calculating through the Grace model. I searched the UDF manual and was not able to find any macro for this. I found a code online which redefines the drag coefficient within the modification. So, I ended up writing the UDF below:

      # include "udf.h"

      #define sigma= 0.072;
      #define mu_ref=0.0009;
      #define C_exp=0;

      DEFINE_EXCHANGE_PROPERTY(lane_drag_mod, cell, mixture_thread, scnd_clmn, frst_clmn)

      {
      Thread *thread_f, *thread_g;
      real x-vel-f, x-vel-g, y-vel-f, y-vel-g, z-vel-f, z-vel-g; 
      real rho_f, rho_g, mu_f,g;
      real eps_f, k_f;
      real tau_b, int_t;
      real stk, m_coeff;
      real Eo, Mo, Re, Hfac, Jfac, C_Dsph, C_Dcap, C_Delip:
      real C_D, C_Dmod;

      thread_f = THREAD_SUB_THREAD(mix_thread, scnd_clmn);     /* liquid phase */
      thread_g = THREAD_SUB_THREAD(mix_thread, f_col);    /* gas phase*/

      /* ===================find phase velocities in all spatial directions================*/
      x_vel_f = C_U(cell, thread_f);
      y_vel_f = C_V(cell, thread_f);
      z_vel_f = C_W(cell, thread_f);
      x_vel_g = C_U(cell, thread_g);
      y_vel_g = C_V(cell, thread_g);
      z_vel_g = C_W(cell, thread_g);

      /* ====================compute velocitiy differences=================================*/
      slip_x = x_vel_g - x_vel_f;
      slip_y = y_vel_g - y_vel_f;
      slip_z = z_vel_g - z_vel_f;
      abs_v = sqrt(slip_x*slip_x + slip_y*slip_y + slip_z*slip_z);

      /*=====================finding the properties of gas and liquid======================*/

      rho_f = C_R(cell, thread_f);
      rho_g = C_R(cell, thread_g);
      mu_f = C_MU_L(cell, thread_f);
      k_f= C_K(cell, thread_f);
      eps_f= C_D(cell, threaf_f);
      g= NV_MAG(M-gravity);
      diam = C_PHASE_DIAMETER(cell, thread_g);
      void_g = C_VOF(cell, thread_g);

      /*================calculating bubble relaxation time and the integral time===========*/
      tau_b=rho_g*diam*diam/18./mu_g;
      int_t=0.135*k_f/eps_f;

      /*===================calculating modification coefficient============================*/
      stk=tau_b/int_t;
      m_coeff= powf((1 - 1.4 * powf(stk,0.7) * exp(-0.6 * stk)),-2.0)

      /*=======================Grace drag model defining==================================*/
      Eo= (g * (rho_f - rho_g) * diam * diam)/ sigma;
      Mo= (powf(mu_f,4) * g * (rho_f - rho_g))/(powf(rho_f,2) * powf(sigma,3);
      Re= (rho_f * abs_v * diam)/ mu_f;
      Hfac= 4/3 * Eo * powf (Mo,-0.149) * powf (mu_f/mu_ref, -0.14);

      if (2
      {
      Jfac= 0.94 * powf(Hfac,0.757);
      }
      else if (Hfac>59.3)
      {
      Jfac= 3.42 * powf(Hfac,0.441);
      }

      U_ter=(mu_f/(rho_f * diam)) * powf(Mo,-0.149) * (Jfac-0.857);

      if (Re<0.01)
      {
      C_Dsph=24/Re;
      }
      else if (Re=>0.01)
      {
      C_Dsph=24*(1+0.15*powf(Re,0.687))/Re;
      }

      C_Dcap=8/3.;

      C_Delip=(4*g*diam*(rho_f-rho_g))/(3*powf(U_ter,2)*rho_f);

      C_D=powf(void_g,C_exp)*max(min(C_Delip,C_Dcap),C_Dsph);
      /*==========================Calculating modified drag===============================*/
      C_Dmod=m_coeff*C_D;

      return C_Dmod
      }

      Now, can anyone tell me if this is corect?
      Also, looking at the Theory guide, I can see that the interphase Exchange coefficient (K_pq) is dependent on the drag coefficient. Should I also embed that within the code? 
      I appreciate any help you can give me. I am really stuck with this and no one can help me.

      Many thanks,Roya

    • Rob
      Forum Moderator

      Looking at the example I don't think it's available. I'm also very limited in what I can say as UDFs aren't fully supported and we're straying into specific knowledge. 

      Others in the Community aren't necessarily bound by the same rules as staff. 

      • Roya
        Subscriber

        Hello Rob. Thanks for your answer.

        May I ask what do you mean by your comment? I do not find it clear. Which example? What do you mean by "Others in the Community aren't necessarily bound by the same rules as staff"?

        I need a drag modification except Brucato as Brucato over predicts for gas-liquid flow. The only way there is to define a UDF, and doing that, I am not sure how I can call the drag coefficient being calculated by FLUENT (I use Grace model), to the code so I can multiply it to the modification coefficient I am defining in UDF. The only I found was to maybe embed the drag model in the code as well and then use the whole UDF as a Drag model instead of a modification model.

        Another issue is that the interphase exchange coefficient which is given as K_pq in FLUENT theory guide, is also dependent on the drag coefficient and if I change drag coefficient, then I should also change K_pq.

        In tutorial, there is no modification example in DEFINE-EXCHANGE-PROPERTY. I really appreciate any useful insight you can give me.

    • Rob
      Forum Moderator

      https://ansyshelp.ansys.com/account/Secured?returnurl=/Views/Secured/corp/v232/en/flu_udf/flu_udf_MultiphaseDEFINE.html%23flu_udf_sec_define_exchange_property  Example 1? 

      Staff knowledge of the Ansys software can be considered as an export under US Export Law. As such we're restricted to general/public knowledge and the documentation. 

Viewing 2 reply threads
  • The topic ‘FLUENT- Drag modification UDF’ is closed to new replies.