Fluids

Fluids

DPM injection on surface with predefined conditions using UDF

    • VeraBFM
      Subscriber

      Hello everyone,

      I am a PhD student and I am trying to perform particle injections using the discrete phase model in Ansys Fluent. My final goal is to inject one particle per parcel with defined settings like diameter and massflow on my velocity-inlet at the face centers but not at every face of the surface.

      I first used a surface injection, but that is not want I want. What I want to do is to define a radius, starting from the center of my inlet and to inject one particle per parcel at the face centers lying within this radius. To inject particles I use the macro DEFINE_DPM_INJECTION_INIT(name,I). Therefore I need to loop over all particles with loop(p, I ->init). I am not sure, if I need this command, because to check if the face centers are within my predefined radius I loop over all faces of my inlet using begin_f_loop(f,thread). So I have two loops now but so far I did not manage to find out a way to store the coordinates of the face centers without F_CENTROID(x,f,thread). And therefore I used begin_f_loop(f,thread) to loop over the inlet faces. Another problem is, that with DEFINE_DPM_INJECTION_INIT(name,I) I loop over particles, not parcels and depending on whether I set single or surface injection in the DPM settings in Fluent, loop(p, I->p_init) is repeated as many times as the number of faces of the inlet (surface injection) or only once (single injection) and then the right number of particles that should be injected starting from the center of the faces that fullfill the condition to be within the radius is divided on to one parcel (single injection) or as many parcels as the complete surface has faces (surface injection). I wanted to solve this problem by choosing the option one particle per parcel but this option seems not to be possible in Fluent. Is there a possibility to write a UDF to define the positions and properties of parcels and to get one particle per parcel doing a loop over all faces?

      My code is:

       #include "udf.h"

       #include "surf.h" /* RP_CELL and RP_THREAD are defined in surf.h */

       #include "dpm.h"


       DEFINE_DPM_INJECTION_INIT(init_bubbles_wuerfel,I)

       {

        Particle *p;

        cell_t cell;

        face_t f;

        real r;


        int zone_ID = 12;

        Domain *domain;         /* domain is declared as a variable  */

        domain = Get_Domain(1);

        Thread *thread = Lookup_Thread(domain,zone_ID);

        Thread *cthread;


         /*the centroid of the boundary face (x0,y0,z0) */

        real x0 = 0.0702225;

        real y0 = -0.0911812;

        real z0 = 1.3;


        /*x holds the position vector of the face center

        it is 3 long because of 3D case  */

        real x[3];


        /*the maximum radius of the offset where particles should be emitted*/

        real dpm_radius = 0.005; /*radius of the pipe in m*/


        loop(p, I->p_init)

        {

          begin_f_loop(f,thread)

          {

         /* this function stores the center coordinates of every face in the predefined 2D or 3D vector x*/

           F_CENTROID(x,f,thread);


         /* three-dimensional pythagoras to calculate distance */

           r = pow(pow((x[0]-x0),2)+pow((x[1]-y0),2)+pow((x[2]-z0),2),0.5);


           if (r < dpm_radius)

           {Message("r ist kleiner als der definierte Radius: %s ",I->name);

            /* Standard Ansys Fluent Looping Macro to get particle

               streams in an Injection*/

           cell = PP_CELL(p); /*Get the cell and thread that

                                  * the particle is currently in */

           cthread = PP_CELL_THREAD(p);

           PP_POS(p)[0] = x[0];

             /*P_INIT_POS(p)[1] = x[1];

             P_INIT_POS(p)[2] = x[2]*/

           PP_DIAM(p) = 3e-7;

           PP_RHO(p) = 1000.0;

           PP_MASS(p) = 1.413716694115407e-17;

           PP_FLOW_RATE(p) = 1.979203371761569e-15;

           Message("loop: %s ",I->name); 

           }

          }

          end_f_loop(f,thread)

        }

       }

      I would be really glad, if anyone could help me. Thank you very much,

      Vera

    • Rob
      Ansys Employee
      You can change the parcel settings but it's usually not recommended as you may or may not get a parcel depending on whether the mass flow is high enough. Why can't you use the parcels and a cone injection or the like?
    • VeraBFM
      Subscriber
      I have also tried a cone injection, but for my use case (breathing with particle generation in the trachea as an inlet) an equal distribution of particles on the inlet as a surface would be better. A surface injection works, but my inlet has significantly more faces than particles to be injected per time step and also per second. This means that I have less than one particle per parcel using the standard parcel release method and the display in post processing suggests a lot of particles that are actually not present. Therefore, it would be easier if it were possible to specify one particle per parcel and not on each face of the inlet surface. Also I would like to vary the origin of the particles, i.e. the faces on which a particle is injected in each time step, to get a statistical distribution. I have also tried to specify the particles as an injection file. Is there a possibility to automatically load a new injection file at each time step or after a defined number of time steps, e.g. via a UDF or otherwise?
Viewing 2 reply threads
  • You must be logged in to reply to this topic.