Fluids

Fluids

Calculate a bubble average speed

    • Hugo66000
      Subscriber

      Hello everyone !


      I am trying to calculate the average speed of a gas bubble in a liquid but I don't really know how to proceed... I think I should use a UDF (you will find it attached), I don't have any compilation error (so the grammar must be correct) but Fluent is crashing after an error message. 


      I am not used to creating a UDF, but I think I did everything as in the Ansys documentation.

    • Hugo66000
      Subscriber

      I will put attached my error message.

      By the way, I am pretty sure the error is happening at the very beginning of the code because my "test1" does not appear in the command window...


       


      Thank you very much for your help !


      Best regards,


      Hugo

    • DrAmine
      Ansys Employee

      Ansys staff do not download attachments. Which models are you using?

    • Hugo66000
      Subscriber

      Thank you for your answer, I understand, so here is the code :


       


      #include "udf.h"


      DEFINE_ON_DEMAND(on_demand_calc)


      {


         real u;


         real uavg=0.;


         int i;


         int ph_index_gas = 3; /* This is the phase ID that has my gas in Fluent (foud in "phase") */


         cell_t c;


         Thread *mix_th, *subth; /* I believe mix_th is the mixture level thread pointer */


         subth = THREAD_SUB_THREAD(mix_th, ph_index_gas);


         printf("n test1");


         i=0;


         /* Loop over all cells  */


         begin_c_loop(c,mix_th)


             {


        printf("n test2");


        u = C_U(c,mix_th);          /* get cell velocity */


        uavg = uavg+u; 


        i = i+1;


             }


         end_c_loop(c,mix_th)


         uavg = uavg/i;


         printf("n uavg = %g   u = %g   i = %gn",uavg,u,i);


      }


      The error is a "received signal SIGSEGV"  type.


      I am using a multiphase VOF model and the energy equation. The study is in 2D and the solver planar (so the bubble is more of an infinite cylinder).


      Best regards,


      Hugo


       

    • DrAmine
      Ansys Employee

      UDF wrong as you are not getting first the right mixture thread just as hint. More information in the UDF manual: thread_sub_thread accepts the phase domain index as second argument which zero for primary phase.


       


      By the way what you want to do in the UDF can be easily done via Report Definition and Volume Averaging or Sum Functions.

    • Hugo66000
      Subscriber

      Oh ! So first I would like to ask you about the Report Definition because I looked there first. With that, I can have the Volume average speed, yes, but it is for the whole domain and not only for the air bubble (so taking into account all the liquid at rest)... Is there a way to isolate the average bubble speed ?


      Thank you for your time,


      Best regards, Hugo

    • DrAmine
      Ansys Employee
      Create an expression based report definition
    • Hugo66000
      Subscriber

      Amine, I am so sorry I can't figure out what you want to make me understand !
      By using this report section, I found the way to delete the velocity field in the liquid and to keep the one in the bubble (by multiplying the velocity field of the whole domain by the air volume fraction). But, then, if I use a volume or vertex average for the speed, this will be on the whole domain (meaning this is taking into account the liquid which as a velocity=0) and I don't know how to correct that...


      Thanks,


      Best regards, Hugo

    • DrAmine
      Ansys Employee
      You can create a function like vof×velocity and average that in the domain so that it does only consider cells filled with vof.
    • Hugo66000
      Subscriber

      Yes I see what you mean, but let's say my bubble as a uniform speed of 1m/s and occupies 1/4 of my domain. When I average this, I obtain a mean velocity of 1/4 m/s because the average function took into account the liquid. So it tells me that I have an average velocity of 0.25 m/s while we know the average velocity of the bubble is 1 m/s.


      Best regards, Hugo

    • DrAmine
      Ansys Employee

      For that reason you make a sum and not a volume average.You divide by the sum of cells containing that phase.

    • Hugo66000
      Subscriber

      Obvioulsy ! Thank you very much for your patience Amine ! (for those interested, you can find the bubble surface in volume report -> Volume and select the gas phase, then you should know the size of your mesh and be able to deduce the number of cells in your bubble).


      Best regards, Hugo

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