We have an exciting announcement about badges coming in May 2025. Until then, we will temporarily stop issuing new badges for course completions and certifications. However, all completions will be recorded and fulfilled after May 2025.
Fluids

Fluids

Topics related to Fluent, CFX, Turbogrid and more.

UDF for multiphase flow

    • nicolo varallo
      Subscriber

      Good morning to everyone.

      I am simulating the flow field in a cylindrical 3D bubble column using the Eulerian-Eulerian approach.

      I need to define a drag coefficient that depends on the distance from the wall.  My idea was to use the C_CENTROID macro to calculate the distance from the column centre and consequently define the drag coefficient, but it did not work.

      Can anyone help me?

      In the following, how I calculate the spatial coordinate to define the dependency of the drag coefficient on the radial coordinate.

      begin_c_loop_all(c,t)
          {
              C_CENTROID(xc,c,t);
              r=pow(xc[0]*xc[0]+xc[2]*xc[2],0.5);  //distance from the column centre. The coordinate y is the column axis
              CD= a*r  // just an example
             }
      end_c_loop_all(c,t)

       

       

    • Rob
      Forum Moderator

      It's not compiling, giving an error or giving the wrong answer? "Not working" isn't that precise! :) 

    • nicolo varallo
      Subscriber

      Sorry for that. It gives the wrong answer; the compilation is ok.

      I obtain a constant coefficient without any spatial dependency.

       

    • Rob
      Forum Moderator

      Looking at https://ansyshelp.ansys.com/account/Secured?returnurl=/Views/Secured/corp/v241/en/flu_udf/flu_udf_MultiphaseDEFINE.html%23flu_udf_sec_define_exchange_property  I don't know if you need the cell loop. 

    • nicolo varallo
      Subscriber

      Thanks for you reply.

      I tried without cell loop, but it is the same. I think the problem is related to the calculation of the distance from the wall. I implemented this simple udf to see if the C_CENTROID works as expected. The udf defines a drag coefficient equal to 3 if the axial coordinate is smaller than 2m, 5 otherwise:

      #include "udf.h"
      #include "math.h"
      DEFINE_EXCHANGE_PROPERTY(WLL,c,t,i,j)
      {
      Thread *t_a = THREAD_SUB_THREAD(t,j);
      Thread *t_w = THREAD_SUB_THREAD(t,i);
      real CD;
      real xc[ND_ND];
      real a=2;
      C_CENTROID(xc,c,t);
      real y=xc[1];
              if (y < a)
                  {
                  CD=3;
                  }
                  else if (y>a) 
                  {
                  CD=5;
                  }
       
      begin_c_loop_int(c,t)
      {
      C_UDMI(c,t,0)=CD;
      }
      end_c_loop_int(c,t)
      return CD;
      }
       
      The result obtained is wrong as the figure shows:

      The withe line corresponds to a distance from the column bottom of 2m.

       

    • Rob
      Forum Moderator

      The white line may be 2m from the column bottom but the UDF is looking at the y-coordinate. What range of y does Fluent show (Scale is a good way to check). 

    • nicolo varallo
      Subscriber

       

       

      y is the axial coordinate, with y comprised between 0 and 2m, x between -0.12 and 0.12m and z between -0.12 and 0.12m.

      The contour represents only the region of interest, not the whole geometry.

      The problem is that the udf does not correctly compute the distance from the column’s bottom.

       

       

    • Rob
      Forum Moderator

      You're not computing a distance, xc[1] is the y-coordinate. So if your domain is 0-2m in the y direction. 

      • nicolo varallo
        Subscriber

        Why not? If the reference frame is (0,0,0) and coincides with the column bottom, the y-coordinate of each cell centre coincides with the distance of the cell centre from the column bottom. 

    • Rob
      Forum Moderator

      Reference frame isn't necessarily inside the domain. What is the minimum y coordinate in your mesh? 

    • nicolo varallo
      Subscriber

      0m:

    • Rob
      Forum Moderator

      Thanks - that's what I wanted to check. You're not working with "wall distance" as that's a different macro, and not useful here. Can you replot the contour and overlay the mesh? 

    • nicolo varallo
      Subscriber

      Here it is: 

    • Rob
      Forum Moderator

      Get rid of the cell loop around the UDM. 

    • nicolo varallo
      Subscriber

      Now it works. Thank you very much!

    • Rob
      Forum Moderator

      I had to ask too! 

Viewing 14 reply threads
  • The topic ‘UDF for multiphase flow’ is closed to new replies.