


{"id":159411,"date":"2021-06-11T19:02:15","date_gmt":"2021-06-11T19:02:15","guid":{"rendered":"\/forum\/forums\/topic\/how-to-export-particle-history-data-every-particle-time-step\/"},"modified":"2021-06-21T06:37:11","modified_gmt":"2021-06-21T06:37:11","slug":"how-to-export-particle-history-data-every-particle-time-step","status":"closed","type":"topic","link":"https:\/\/innovationspace.ansys.com\/forum\/forums\/topic\/how-to-export-particle-history-data-every-particle-time-step\/","title":{"rendered":"How to Export Particle History Data every Particle Time Step"},"content":{"rendered":"<div class=\"Item-Body\">\n<div class=\"Message userContent\">\n<p>Hello everyone,<\/p>\n<p>I am simulating discrete particles and I am interested in the particle-particle collisions. Therefore, I am using the DEM collision model available in Fluent. This forces me to work with instationary particles (although I am looking for a steady solution, where the particle collisions dictate the spread).<\/p>\n<p>My idea is to inject particles, until the fluid and the particles have achieved a steady state.<\/p>\n<p>Due to the use of the DEM model, and the collisions between different sized particles, I am forced to use a very small particle time step size (10^-8) in order to get &ldquo;physical&rdquo; collisions\/the right overlap.<\/p>\n<p>Since I am continuously injecting particles, the simulation would be too slow if I had 1 particle time step for each fluid time step, so I increased the number of particle iterations per time step to speed the process up. <\/p>\n<p>Desirable would be e.g. a number of Time Steps=1e6 for particle time step size 1e-8 so that I get 0,01sec simulation time with only one fluid iteration.<\/p>\n<p>So far, I have worked out a solution that fits my needs:<\/p>\n<p>Setup-&gt;General-&gt;Time: Steady<\/p>\n<p>Setup-&gt;Models-&gt;Discrete Phase (On)<\/p>\n<p>Discrete Phase Model:<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Interaction with Continuous Phase (On)<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DPM Iteration Interval: 1<\/p>\n<p> Unsteady Particle Tracking (On)<\/p>\n<p> Particle Time Step Size: 1e-8<\/p>\n<p> Number of Time Steps: 1e6<\/p>\n<p> Physical Models-&gt;DEM Collision (On)<\/p>\n<p>Injections:<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;File Injection using a unsteady file.inj as described in the Manual<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Start Time: 0<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Stop Time: 5<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Start Flow-time in File: 0<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Repeat Interval in File: 1e-6 (so that a new particle is injected every particle time step)<\/p>\n<p>Run Calculation -&gt; Number of Iterations: 1<\/p>\n<p>&nbsp;<\/p>\n<p>The simulation runs as desired and is obviously much faster than the setup (Particle Time Step Size:1e-8\/No of Steps:1\/DPM Iteration Interval:1\/Number of (Fluid) Iterations:1e6).<\/p>\n<p>&nbsp;<\/p>\n<p>However, I encounter problems when it comes to view the results:<\/p>\n<p>I want to investigate the collisions etc. in CFD-Post and therefore I want to export the particle history data.<\/p>\n<p>The way Solution-&gt;Calculation Activities-&gt;Automatic Export -&gt; Create Particle History Data Export does not work for me, since it only is executed every fluid time step.<\/p>\n<p>I do not need an export every fluid time step but every (nth) Particle Time Step, because I want to visualize the collisions and particle trajectories properly.<\/p>\n<p>I could increase the number of fluid time steps and decrease number of particle time steps but this would slow down my simulation.<\/p>\n<p>Furthermore, it seems possible with a transient simulation, but this is also not what I want.<\/p>\n<p>&nbsp;<\/p>\n<p>I made two more ideas to approach a solution but was not successful with them:<\/p>\n<p>1.)<\/p>\n<p>I had the idea to use an UDF, more accurate the &ldquo;DEFINE_DPM_SCALAR_UPDATE&rdquo; and in this UDF execute the following scheme text command:<\/p>\n<p>(ti-menu-load-string<\/p>\n<p>(format #f &quot;file\/export\/particle-history-data cfdpost tracktest injection-0 , acc-total-mag force-coll-mag force-total-mag , ,&quot;))<\/p>\n<p>But I get a compiling error when trying it. <\/p>\n<p>I read that it is eventually not possible to execute TI-commands by UDF. <\/p>\n<p>It might be an option to export the data to a .txt file, e.g. like this:<\/p>\n<p><a href=\"https:\/\/www.cfd-online.com\/Forums\/fluent-udf\/215456-udf-current-particle-position.html\" rel=\"nofollow\">https:\/\/www.cfd-online.com\/Forums\/fluent-udf\/215456-udf-current-particle-position.html<\/a><\/p>\n<div class=\"blockquote\">\n<div class=\"blockquote-content\">\n<p class=\"blockquote-line\">#include &quot;udf.h&quot;<\/p>\n<p class=\"blockquote-line\"> #include &quot;dpm.h&quot;<\/p>\n<p class=\"blockquote-line\"><\/p>\n<\/p>\n<p class=\"blockquote-line\"> DEFINE_DPM_SCALAR_UPDATE(gpif,c,t,initialize,p)<\/p>\n<p class=\"blockquote-line\"> {<\/p>\n<p class=\"blockquote-line\"> int n;<\/p>\n<p class=\"blockquote-line\"> n = N_TIME;<\/p>\n<p class=\"blockquote-line\"> char filename[50];<\/p>\n<p class=\"blockquote-line\"> real current_time = CURRENT_TIME;<\/p>\n<p class=\"blockquote-line\"> snprintf(filename,50,&quot;particleposition_%d.txt&quot;,n);<\/p>\n<p class=\"blockquote-line\"> FILE *fid1;<\/p>\n<p class=\"blockquote-line\"> fid1 = fopen(filename,&quot;a&quot;);<\/p>\n<p class=\"blockquote-line\"> if (P_TIME(p) == CURRENT_TIME)<\/p>\n<p class=\"blockquote-line\"> {<\/p>\n<p class=\"blockquote-line\"> fprintf(fid1, &quot;%f %f %f %f %f %f %f %&quot;int64_fmt&quot;<br \/>\n&quot;,P_POS(p)[0],P_POS(p)[1],P_POS(p)[2],P_VEL(p)[0],P_VEL(p)[1],P_VEL(p)[2],P_TIME(p),p-&gt;part_id);<\/p>\n<p class=\"blockquote-line\"> }<\/p>\n<p class=\"blockquote-line\"> else<\/p>\n<p class=\"blockquote-line\"> {<\/p>\n<p class=\"blockquote-line\"> printf(&quot;time is not reached&quot;);<\/p>\n<p class=\"blockquote-line\"> }<\/p>\n<p class=\"blockquote-line\"> fclose(fid1);<\/p>\n<p class=\"blockquote-line\"> }<\/p>\n","protected":false},"template":"","class_list":["post-159411","topic","type-topic","status-closed","hentry","topic-tag-cfd-post","topic-tag-collision","topic-tag-dpm-dem-fluent","topic-tag-particle-tracking","topic-tag-udf-fluent"],"aioseo_notices":[],"acf":[],"custom_fields":[{"0":{"_bbp_author_ip":[""],"_bbp_old_reply_author_name_id":["Anonymous"],"_bbp_old_is_reply_anonymous_id":["false"],"_btv_view_count":["3121"],"_bbp_likes_count":["0"],"_bbp_topic_status":["unanswered"],"_bbp_status":["publish"],"_bbp_topic_id":["159411"],"_bbp_forum_id":["27792"],"_bbp_engagement":["22555","197999"],"_bbp_voice_count":["2"],"_bbp_reply_count":["9"],"_bbp_last_reply_id":["181909"],"_bbp_last_active_id":["181909"],"_bbp_last_active_time":["2021-06-21 06:37:11"]},"test":"hansdampforgmail-com"}],"_links":{"self":[{"href":"https:\/\/innovationspace.ansys.com\/forum\/wp-json\/wp\/v2\/topics\/159411","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\/159411\/revisions"}],"wp:attachment":[{"href":"https:\/\/innovationspace.ansys.com\/forum\/wp-json\/wp\/v2\/media?parent=159411"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}