CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (https://www.cfd-online.com/Forums/fluent-udf/)
-   -   UDF for recycling particles by changing its positions (https://www.cfd-online.com/Forums/fluent-udf/216487-udf-recycling-particles-changing-its-positions.html)

keishlaortiz April 9, 2019 13:30

UDF for recycling particles by changing its positions
 
1 Attachment(s)
Hello!

I'm trying to recycle particles escaped from outlet to inlet. I followed and modified the UDF posted in this thread: https://www.cfd-online.com/Forums/fl...dpm-udf-2.html. In my case, if the particle x-position is greater than 0.20 m and y-position is greater than or equal to -0.42 m, then the particle is close to the outlet and I want to change the position such that is re-injected into the inlet. However, it seems like this approach is not working since the particles get stuck at the outlet. Here is my UDF:

Code:

#include "udf.h"

DEFINE_DPM_BC(continue_tracking,p,t,f,f_normal,dim)
{
        //here we want to keep track of the particle that reaches the outlet so we can "recycle" it
        return PATH_ACTIVE;
}

DEFINE_DPM_SCALAR_UPDATE(recycle_particles,c,t,initialize,p)
{
        FILE *fp;

        if (P_POS(p)[1] > 0)
        {
                P_USER_REAL(p,1) = 0.;
        }

        if (P_POS(p)[1] >= -0.42 && P_POS(p)[1] < 0 && P_POS(p)[0] > 0.20 && P_USER_REAL(p,1) == 0.)
        {
                // save particle id and time to a file
        Message("The outlet boundary UDF is being called...\n");
                fp=fopen("recycleparticles.txt", "a"); // x, y, z particle positions [m], particle ID [#] and time [s]
                //fprintf(fp,"%e %e %e %d %e\n",P_POS(p)[0],P_POS(p)[1],P_POS(p)[2],p->part_id,P_TIME(p));
                fprintf(fp,"%d %e\n",p->part_id,P_TIME(p));
                fclose(fp);

                // save the number of times this particle has been recycled


                P_USER_REAL(p,0) = P_USER_REAL(p,0) + 1.;
                P_USER_REAL(p,1) = 1.;

                // send particle to the inlet boundary
                // just need to change y-position
                P_POS(p)[1] = 2.6534e-017;

        }
}

I also attached a zip file containing the workbench file, geometry file and udf code. If anyone can help me with this it would be appreciated.

bikooo3878 August 17, 2020 17:55

I'm working on something very similar. It seems to me that your code should be working well. Have you figured what was the issue?


All times are GMT -4. The time now is 10:49.