Fluids

Fluids

Multiphase flow – DEFINE PROFILE – UDF

    • dhaya400
      Subscriber

      Hi

      While searching for multiphase -Define profile macro, I came across the below line from the udf manual:

      "In multiphase cases a DEFINE_PROFILE UDF may be called more than once (particularly if the profile is used in a mixture domain thread). If this needs to be avoided, then add the prefix MP_ to the UDF name. The function will then be called only once even if it is used for more than one profile."

      How to implement the above statement in DEFINE_PROFILE macro? Can anyone explain with example?

    • Karthik R
      Administrator
      Hello Are you planning to use an analytical expression? If so, I'd simply use the Fluent expressions and avoid using a UDF completely.
      Karthik
    • dhaya400
      Subscriber
      Hi
      Thank you for your reply.
      Its not a simple expression. I have already wrote the macro and it is running. Due to multiphase physics, the define profile udf is running 3 times/timestep.
      In order to correct this, I have searched for info in the udf manual and found the below statement "In multiphase cases a DEFINE_PROFILE UDF may be called more than once (particularly if the profile is used in a mixture domain thread). If this needs to be avoided, then add the prefix MP_ to the UDF name. The function will then be called only once even if it is used for more than one profile."
      If I add MP_ in the udf name nothing this changing. So please suggest me, where I supposed to add MP_ in the udf.

      Thanks
      DK
    • Rob
      Ansys Employee
      Looking at the manual https://ansyshelp.ansys.com/account/Secured?returnurl=/Views/Secured/corp/v211/en/flu_udf/flu_udf_sec_define_profile.html%23x1-1810003.3.17 the UDF name is the bit:
      DEFINE_PROFILE (name, t, i) so try DEFINE_PROFILE (MP_name, t, i) and let us know how you get on.

    • dhaya400
      Subscriber

      Hi Rob Thank you for your reply.
      I tried your suggestion already, but it is executing as usual (3 times / time step). There is no change in execution.
      Some background info: I am working on a multiphase problem using mixture model. The macro I am using is given below:
      DEFINE_PROFILE(pressure_out_bca,mt,i)
      {
      #if !RP_HOST
      real Z = 5.1918E+07;
      real C = 8.697E-10;
      real R = 10.6080E+08;
      real ts;
      ts = CURRENT_TIMESTEP;
      face_t f;
      begin_f_loop(f,mt)
      {
      if (CURRENT_TIME == 0)
      {
      F_UDMI(f,mt,0) = 13332.2;
      F_UDMI(f,mt,1) = F_UDMI(f,mt,0);
      F_UDMI(f,mt,3) = 1.22E-05;
      }
      else
      {
      F_UDMI(f,mt,3) = fabs (Q12);
      F_UDMI(f,mt,1) = ((F_UDMI(f,mt,0)*R*C)+(F_UDMI(f,mt,3)*R*ts)+(F_UDMI(f,mt,3)*Z*ts)+(Z*R*C*F_UDMI(f,mt,3))-(Z*R*C*F_UDMI(f,mt,2))) / (ts +(R*C));
      }
      }
      end_f_loop(f,mt)
      begin_f_loop(f,mt)
      {
      F_UDMI(f,mt,0) = F_UDMI(f,mt,1);
      F_UDMI(f,mt,2) = F_UDMI(f,mt,3);
      }
      end_f_loop(f,mt)
      begin_f_loop(f,mt)
      {
      F_PROFILE(f,mt,i) = F_UDMI(f,mt,1); /* Calculate pressure and apply to outlet*/
      }
      end_f_loop(f,mt)
      #endif /* !RP_HOST */
      }
      Thanks DK
    • Rob
      Ansys Employee
      What's Q12?
    • dhaya400
      Subscriber
      Hi Rob,
      Q12 is the flow rate, which i am calculating using DEFINE_EXECUTE_AT_END macro.
      The macro given below:
      real Q12; /* current time step flow rate */
      #define BCA_ID 63 /* domain id*/
      DEFINE_EXECUTE_AT_END(flow_rate_bca)
      {
      #if !RP_HOST
      Domain *d;
      real m;
      cell_t c;
      Thread *t;
      face_t f;
      d = Get_Domain(1);
      t= Lookup_Thread(d, BCA_ID);
      /* loop to calculate mass flow rate at outlet */
      begin_f_loop(f,t)
      {
      if (PRINCIPAL_FACE_P(f,t))
      {
      m += F_FLUX(f,t);
      }
      }
      end_f_loop(f,t)
      Q12 = m / 1060.0; /* convert mass flow rate to volume flow rate */
      #if RP_NODE
      /* Perform node synchronized actions here. Does nothing in Serial */
      Q12 = PRF_GRSUM1(Q12);
      #endif /* RP_NODE */
      m = 0.0;
      #endif /* !RP_HOST */
      }
    • Rob
      Ansys Employee
      OK, and to confirm DEFINE_PROFILE(MP_pressure_out_bca,mt,i) doesn't change behaviour? Can you check you recompiled and reloaded the libudf?
    • dhaya400
      Subscriber
      I have recompiled and reloaded the udf. Adding DEFINE_PROFILE(MP_pressure_out_bca,mt,i) doesn't change the behavior.
Viewing 8 reply threads
  • You must be logged in to reply to this topic.