


{"id":308742,"date":"2023-09-26T14:34:47","date_gmt":"2023-09-26T14:34:47","guid":{"rendered":"\/forum\/forums\/topic\/fluent-drag-modification-udf\/"},"modified":"2023-09-26T14:34:47","modified_gmt":"2023-09-26T14:34:47","slug":"fluent-drag-modification-udf","status":"closed","type":"topic","link":"https:\/\/innovationspace.ansys.com\/forum\/forums\/topic\/fluent-drag-modification-udf\/","title":{"rendered":"FLUENT- Drag modification UDF"},"content":{"rendered":"<p>Hello everyone,<br \/>I am trying to simulate a gas-liquid stirred tank. I am using a Grace drag model, for the modification, I dont want to use Brucato model, but I want to define a UDF based on another model. I know that I need to use the DEFINE_EXCHANGE_PROPERTY macro. The formula I would like to use can be defined as :<\/p>\n<p><span style=\"font-size: 12pt\">C_D_modified= modification_coefficient* C_D<\/span><br \/>* C_D being the drag coefficient that is already being calculated by the Grace model.<\/p>\n<p>My issue is that I don&#8217;t know how to call the drag coefficient that FLUENT is already calculating through the Grace model. I searched the UDF manual and was not able to find any macro for this. I found a code online which redefines the drag coefficient within the modification. So, I ended up writing the UDF below:<\/p>\n<p><span style=\"font-size: 12pt\"># include &#8220;udf.h&#8221;<\/span><\/p>\n<p><span style=\"font-size: 12pt\">#define sigma= 0.072;<\/span><br \/><span style=\"font-size: 12pt\">#define mu_ref=0.0009;<\/span><br \/><span style=\"font-size: 12pt\">#define C_exp=0;<\/span><\/p>\n<p><span style=\"font-size: 12pt\">DEFINE_EXCHANGE_PROPERTY(lane_drag_mod, cell, mixture_thread, scnd_clmn, frst_clmn)<\/span><\/p>\n<p><span style=\"font-size: 12pt\">{<\/span><br \/><span style=\"font-size: 12pt\">Thread *thread_f, *thread_g;<\/span><br \/><span style=\"font-size: 12pt\">real x-vel-f, x-vel-g, y-vel-f, y-vel-g, z-vel-f, z-vel-g;&nbsp;<\/span><br \/><span style=\"font-size: 12pt\">real rho_f, rho_g, mu_f,g;<\/span><br \/><span style=\"font-size: 12pt\">real eps_f, k_f;<\/span><br \/><span style=\"font-size: 12pt\">real tau_b, int_t;<\/span><br \/><span style=\"font-size: 12pt\">real stk, m_coeff;<\/span><br \/><span style=\"font-size: 12pt\">real Eo, Mo, Re, Hfac, Jfac, C_Dsph, C_Dcap, C_Delip:<\/span><br \/><span style=\"font-size: 12pt\">real C_D, C_Dmod;<\/span><\/p>\n<p><span style=\"font-size: 12pt\">thread_f = THREAD_SUB_THREAD(mix_thread, scnd_clmn); &nbsp; &nbsp; \/* liquid phase *\/<\/span><br \/><span style=\"font-size: 12pt\">thread_g = THREAD_SUB_THREAD(mix_thread, f_col); &nbsp; &nbsp;\/* gas phase*\/<\/span><\/p>\n<p><span style=\"font-size: 12pt\">\/* ===================find phase velocities in all spatial directions================*\/<\/span><br \/><span style=\"font-size: 12pt\">x_vel_f = C_U(cell, thread_f);<\/span><br \/><span style=\"font-size: 12pt\">y_vel_f = C_V(cell, thread_f);<\/span><br \/><span style=\"font-size: 12pt\">z_vel_f = C_W(cell, thread_f);<\/span><br \/><span style=\"font-size: 12pt\">x_vel_g = C_U(cell, thread_g);<\/span><br \/><span style=\"font-size: 12pt\">y_vel_g = C_V(cell, thread_g);<\/span><br \/><span style=\"font-size: 12pt\">z_vel_g = C_W(cell, thread_g);<\/span><\/p>\n<p><span style=\"font-size: 12pt\">\/* ====================compute velocitiy differences=================================*\/<\/span><br \/><span style=\"font-size: 12pt\">slip_x = x_vel_g &#8211; x_vel_f;<\/span><br \/><span style=\"font-size: 12pt\">slip_y = y_vel_g &#8211; y_vel_f;<\/span><br \/><span style=\"font-size: 12pt\">slip_z = z_vel_g &#8211; z_vel_f;<\/span><br \/><span style=\"font-size: 12pt\">abs_v = sqrt(slip_x*slip_x + slip_y*slip_y + slip_z*slip_z);<\/span><\/p>\n<p><span style=\"font-size: 12pt\">\/*=====================finding the properties of gas and liquid======================*\/<\/span><\/p>\n<p><span style=\"font-size: 12pt\">rho_f = C_R(cell, thread_f);<\/span><br \/><span style=\"font-size: 12pt\">rho_g = C_R(cell, thread_g);<\/span><br \/><span style=\"font-size: 12pt\">mu_f = C_MU_L(cell, thread_f);<\/span><br \/><span style=\"font-size: 12pt\">k_f= C_K(cell, thread_f);<\/span><br \/><span style=\"font-size: 12pt\">eps_f= C_D(cell, threaf_f);<\/span><br \/><span style=\"font-size: 12pt\">g= NV_MAG(M-gravity);<\/span><br \/><span style=\"font-size: 12pt\">diam = C_PHASE_DIAMETER(cell, thread_g);<\/span><br \/><span style=\"font-size: 12pt\">void_g = C_VOF(cell, thread_g);<\/span><\/p>\n<p><span style=\"font-size: 12pt\">\/*================calculating bubble relaxation time and the integral time===========*\/<\/span><br \/><span style=\"font-size: 12pt\">tau_b=rho_g*diam*diam\/18.\/mu_g;<\/span><br \/><span style=\"font-size: 12pt\">int_t=0.135*k_f\/eps_f;<\/span><\/p>\n<p><span style=\"font-size: 12pt\">\/*===================calculating modification coefficient============================*\/<\/span><br \/><span style=\"font-size: 12pt\">stk=tau_b\/int_t;<\/span><br \/><span style=\"font-size: 12pt\">m_coeff= powf((1 &#8211; 1.4 * powf(stk,0.7) * exp(-0.6 * stk)),-2.0)<\/span><\/p>\n<p><span style=\"font-size: 12pt\">\/*=======================Grace drag model defining==================================*\/<\/span><br \/><span style=\"font-size: 12pt\">Eo= (g * (rho_f &#8211; rho_g) * diam * diam)\/ sigma;<\/span><br \/><span style=\"font-size: 12pt\">Mo= (powf(mu_f,4) * g * (rho_f &#8211; rho_g))\/(powf(rho_f,2) * powf(sigma,3);<\/span><br \/><span style=\"font-size: 12pt\">Re= (rho_f * abs_v * diam)\/ mu_f;<\/span><br \/><span style=\"font-size: 12pt\">Hfac= 4\/3 * Eo * powf (Mo,-0.149) * powf (mu_f\/mu_ref, -0.14);<\/span><\/p>\n<p><span style=\"font-size: 12pt\">if (2&lt;Hfac&lt;=59.3)<\/span><br \/><span style=\"font-size: 12pt\">{<\/span><br \/><span style=\"font-size: 12pt\">Jfac= 0.94 * powf(Hfac,0.757);<\/span><br \/><span style=\"font-size: 12pt\">}<\/span><br \/><span style=\"font-size: 12pt\">else if (Hfac&gt;59.3)<\/span><br \/><span style=\"font-size: 12pt\">{<\/span><br \/><span style=\"font-size: 12pt\">Jfac= 3.42 * powf(Hfac,0.441);<\/span><br \/><span style=\"font-size: 12pt\">}<\/span><\/p>\n<p><span style=\"font-size: 12pt\">U_ter=(mu_f\/(rho_f * diam)) * powf(Mo,-0.149) * (Jfac-0.857);<\/span><\/p>\n<p><span style=\"font-size: 12pt\">if (Re&lt;0.01)<\/span><br \/><span style=\"font-size: 12pt\">{<\/span><br \/><span style=\"font-size: 12pt\">C_Dsph=24\/Re;<\/span><br \/><span style=\"font-size: 12pt\">}<\/span><br \/><span style=\"font-size: 12pt\">else if (Re=&gt;0.01)<\/span><br \/><span style=\"font-size: 12pt\">{<\/span><br \/><span style=\"font-size: 12pt\">C_Dsph=24*(1+0.15*powf(Re,0.687))\/Re;<\/span><br \/><span style=\"font-size: 12pt\">}<\/span><\/p>\n<p><span style=\"font-size: 12pt\">C_Dcap=8\/3.;<\/span><\/p>\n<p><span style=\"font-size: 12pt\">C_Delip=(4*g*diam*(rho_f-rho_g))\/(3*powf(U_ter,2)*rho_f);<\/span><\/p>\n<p><span style=\"font-size: 12pt\">C_D=powf(void_g,C_exp)*max(min(C_Delip,C_Dcap),C_Dsph);<\/span><br \/><span style=\"font-size: 12pt\">\/*==========================Calculating modified drag===============================*\/<\/span><br \/><span style=\"font-size: 12pt\">C_Dmod=m_coeff*C_D;<\/span><\/p>\n<p><span style=\"font-size: 12pt\">return C_Dmod<\/span><br \/><span style=\"font-size: 12pt\">}<\/span><\/p>\n<p>Now, can anyone tell me if this is corect?<br \/>Also, looking at the Theory guide, I can see that the interphase Exchange coefficient (K_pq) is dependent on the drag coefficient. Should I also embed that within the code?&nbsp;<br \/>I appreciate any help you can give me. I am really stuck with this and no one can help me.<\/p>\n<p>Many thanks,Roya<\/p>\n","protected":false},"template":"","class_list":["post-308742","topic","type-topic","status-closed","hentry","topic-tag-drag-coefficient","topic-tag-multiphase-eulerian","topic-tag-udf"],"aioseo_notices":[],"acf":[],"custom_fields":[{"0":{"_bbp_subscription":["249676","199"],"_bbp_author_ip":["23.206.193.41"]," _bbp_last_reply_id":["0"]," _bbp_likes_count":["0"],"_btv_view_count":["1485"],"_bbp_topic_status":["unanswered"],"_bbp_status":["publish"],"_bbp_topic_id":["308742"],"_bbp_forum_id":["27796"],"_bbp_engagement":["199","249676"],"_bbp_voice_count":["2"],"_bbp_reply_count":["3"],"_bbp_last_reply_id":["309025"],"_bbp_last_active_id":["309025"],"_bbp_last_active_time":["2023-09-27 11:10:01"]},"test":"roya-jamshidianregeneron-com"}],"_links":{"self":[{"href":"https:\/\/innovationspace.ansys.com\/forum\/wp-json\/wp\/v2\/topics\/308742","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\/308742\/revisions"}],"wp:attachment":[{"href":"https:\/\/innovationspace.ansys.com\/forum\/wp-json\/wp\/v2\/media?parent=308742"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}