


{"id":383099,"date":"2024-09-19T07:46:31","date_gmt":"2024-09-19T07:46:31","guid":{"rendered":"https:\/\/innovationspace.ansys.com\/forum\/forums\/topic\/udf-for-reinjecting-particles\/"},"modified":"2024-09-19T07:46:31","modified_gmt":"2024-09-19T07:46:31","slug":"udf-for-reinjecting-particles","status":"publish","type":"topic","link":"https:\/\/innovationspace.ansys.com\/forum\/forums\/topic\/udf-for-reinjecting-particles\/","title":{"rendered":"UDF for reinjecting particles"},"content":{"rendered":"<p>&lt;p&gt;&lt;span style=&#8221;font-size: 12pt;&#8221;&gt;Hi all,&lt;\/span&gt;&lt;br&gt;&lt;br&gt;&lt;span style=&#8221;font-size: 12pt;&#8221;&gt;I am working on creating a UDF to track particles hitting the outlet boundary. The setup involved in an air purifier in a small chamber, and I aim to set the purifier&#8217;s efficiency at 95%. (95% of the particles that reach the outlet will escape, while 5% will be reinjected from a reinjection point)&lt;\/span&gt;&lt;br&gt;&lt;br&gt;&lt;span style=&#8221;font-size: 12pt;&#8221;&gt;From my understanding:&lt;\/span&gt;&lt;br&gt;&lt;span style=&#8221;font-size: 12pt;&#8221;&gt;<strong>return PATH_END<\/strong>&nbsp;is used for considering particles escaped from the domain and&lt;\/span&gt;&lt;br&gt;&lt;span style=&#8221;font-size: 12pt;&#8221;&gt;<strong>return PATH_ACTIVE<\/strong>&nbsp;is for continuously tracking particles&lt;\/span&gt;&lt;br&gt;&lt;br&gt;&lt;span style=&#8221;font-size: 12pt;&#8221;&gt;I would like to set up the system so that 5% of particles are reinjected from the reinjection point and continue being tracked. While&nbsp;<strong>PATH_END<\/strong>&nbsp;seems to work as expected,&nbsp;<strong>PATH_ACTIVE<\/strong>&nbsp;does not. In the console, particles are being aborted.&lt;\/span&gt;&lt;br&gt;&lt;br&gt;&lt;span style=&#8221;font-size: 12pt;&#8221;&gt;I have revised my code several times and attempted different solutions, but I am currently out of ideas.&lt;\/span&gt;&lt;br&gt;&lt;br&gt;&lt;span style=&#8221;font-size: 12pt;&#8221;&gt;Would anyone be able to help me solve this issue or suggest any possible approaches? I would greatly appreciate your insights.&lt;\/span&gt;&lt;br&gt;&lt;br&gt;&lt;span style=&#8221;font-size: 12pt;&#8221;&gt;Thank you in advance!&lt;\/span&gt;&lt;br&gt;&lt;br&gt;&lt;span style=&#8221;font-size: 12pt;&#8221;&gt;Best regards,&lt;\/span&gt;&lt;br&gt;&lt;span style=&#8221;font-size: 12pt;&#8221;&gt;Dahae&lt;\/span&gt;&lt;br&gt;&lt;br&gt;&lt;span style=&#8221;font-size: 12pt;&#8221;&gt;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;&lt;\/span&gt;&lt;br&gt;&lt;span style=&#8221;font-size: 12pt;&#8221;&gt;Here is my code FYI:&lt;\/span&gt;&lt;br&gt;&lt;br&gt;&lt;span style=&#8221;font-size: small;&#8221;&gt;#include &#8220;udf.h&#8221;&lt;br&gt;#include &#8220;dpm.h&#8221;&lt;br&gt;&lt;br&gt;#define REINJECT_POSITION_X 2.0 \/\/ Set the x-coordinate of the reinjection point&lt;br&gt;#define REINJECT_POSITION_Y 0.425 \/\/ Set the y-coordinate of the reinjection point&lt;br&gt;#define REINJECT_POSITION_Z 0.18 \/\/ Set the z-coordinate of the reinjection point&lt;br&gt;&lt;br&gt;\/* Global variables *\/&lt;br&gt;int particle_count = 0;&lt;br&gt;int escaped_count = 0;&lt;br&gt;int reinjected_count = 0;&lt;br&gt;&lt;br&gt;DEFINE_DPM_BC(udf_outlet, tp, t, f, f_normal, dim)&lt;br&gt;{&lt;br&gt;particle_count++;&lt;br&gt;&lt;br&gt;if (particle_count &lt;= 95)&lt;br&gt;{&lt;br&gt;\/* Mark as escaped *\/&lt;br&gt;escaped_count++;&lt;br&gt;&lt;br&gt;return PATH_END;&lt;br&gt;&lt;br&gt;}&lt;br&gt;&lt;br&gt;if (particle_count &gt; 95)&lt;br&gt;{&lt;br&gt;\/* Mark as reinjected *\/&lt;br&gt;reinjected_count++;&lt;br&gt;&lt;br&gt;\/* Move particle to specific point *\/&lt;br&gt;P_POS(tp)[0] = REINJECT_POSITION_X; \/\/ Specific X position&lt;br&gt;P_POS(tp)[1] = REINJECT_POSITION_Y; \/\/ Specific Y position&lt;br&gt;P_POS(tp)[2] = REINJECT_POSITION_Z; \/\/ Specific Z position&lt;br&gt;&lt;br&gt;return PATH_ACTIVE;&lt;br&gt;}&lt;br&gt;&lt;br&gt;\/* Reset the counter after 100 particles *\/&lt;br&gt;if (particle_count &gt; 100)&lt;br&gt;{&lt;br&gt;particle_count = 0;&lt;br&gt;escaped_count = 0;&lt;br&gt;reinjected_count = 0;&lt;br&gt;}&lt;br&gt;&lt;br&gt;return PATH_ACTIVE;&lt;br&gt;}&lt;\/span&gt;&lt;\/p&gt;<\/p>\n","protected":false},"template":"","class_list":["post-383099","topic","type-topic","status-publish","hentry","topic-tag-dpm","topic-tag-dpm-tracking","topic-tag-dpm-udfs"],"aioseo_notices":[],"acf":[],"custom_fields":[{"0":{"_bbp_subscription":["458012","199"],"_bbp_author_ip":["114.70.121.22"],"_btv_view_count":["332"],"_bbp_topic_status":["unanswered"],"_bbp_topic_id":["383099"],"_bbp_forum_id":["27792"],"_bbp_engagement":["199","458012"],"_bbp_voice_count":["2"],"_bbp_reply_count":["9"],"_bbp_last_reply_id":["386896"],"_bbp_last_active_id":["386896"],"_bbp_last_active_time":["2024-09-25 08:48:31"]},"test":"dseongkangwon-ac-kr"}],"_links":{"self":[{"href":"https:\/\/innovationspace.ansys.com\/forum\/wp-json\/wp\/v2\/topics\/383099","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/innovationspace.ansys.com\/forum\/wp-json\/wp\/v2\/topics"}],"about":[{"href":"https:\/\/innovationspace.ansys.com\/forum\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":0,"href":"https:\/\/innovationspace.ansys.com\/forum\/wp-json\/wp\/v2\/topics\/383099\/revisions"}],"wp:attachment":[{"href":"https:\/\/innovationspace.ansys.com\/forum\/wp-json\/wp\/v2\/media?parent=383099"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}