CFD Online Logo CFD Online URL
Home > Forums > Software User Forums > ANSYS > FLUENT > Fluent UDF and Scheme Programming

UDF for recycling particles by changing its positions

Register Blogs Members List Search Today's Posts Mark Forums Read

Like Tree1Likes
  • 1 Post By keishlaortiz

LinkBack Thread Tools Search this Thread Display Modes
Old   April 9, 2019, 13:30
Exclamation UDF for recycling particles by changing its positions
New Member
Join Date: Jul 2018
Posts: 1
Rep Power: 0
keishlaortiz is on a distinguished road

I'm trying to recycle particles escaped from outlet to inlet. I followed and modified the UDF posted in this thread: Periodic BC in ANSYS DDPM, UDF. 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:

#include "udf.h"

        //here we want to keep track of the particle that reaches the outlet so we can "recycle" it
	return PATH_ACTIVE;

	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));

		// 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.
Attached Files
File Type: zip (134.6 KB, 4 views)
bikooo3878 likes this.
keishlaortiz is offline   Reply With Quote

Old   August 17, 2020, 17:55
Join Date: Sep 2016
Posts: 30
Rep Power: 9
bikooo3878 is on a distinguished road
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?
bikooo3878 is offline   Reply With Quote


dpm, particles, udf

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
DPM: UDF - loop over all particles chris Fluent UDF and Scheme Programming 31 June 17, 2020 05:52
Calculation of "escaped" particles in dpm via UDF abolfazl FLUENT 0 November 18, 2018 13:28
UDF for tracking particles in DPM abolfazl FLUENT 1 October 27, 2018 12:32
[PyFoam] Problems with the new PyFoam release zfaraday OpenFOAM Community Contributions 13 December 9, 2014 18:58
udf init random particles positions olivia FLUENT 2 August 3, 2004 03:35

All times are GMT -4. The time now is 01:14.