


{"id":236917,"date":"2022-10-03T15:56:47","date_gmt":"2022-10-03T15:56:47","guid":{"rendered":"\/forum\/forums\/topic\/udf-for-mass-transfer-vof\/"},"modified":"2022-10-03T15:56:47","modified_gmt":"2022-10-03T15:56:47","slug":"udf-for-mass-transfer-vof","status":"closed","type":"topic","link":"https:\/\/innovationspace.ansys.com\/forum\/forums\/topic\/udf-for-mass-transfer-vof\/","title":{"rendered":"UDF for mass transfer VOF"},"content":{"rendered":"<p>Hello, I am working on a UDF for a problem with mass transfer at the interface between a liquid and a vapor layer. I use the DEFINE_MASS_TRANSFER macro to sweep, finding the interface by checking the volume of fluid using:&nbsp;&nbsp;(C_VOF(cell, liq) &gt; 0.05) &amp;&amp; (C_VOF(cell, liq) &lt;= 0.95)) and then applying the mass transfer to just those cells that are at the interface.&nbsp;<\/p>\n<p>However, when I run this, I am not getting into the if-statement to check the VOF. My understanding is that the DEFINE macros will sweep and I do not need a loop to go through the faces (ie. begin_f_loop(f, thread), etc) but I&#8217;ve tried it with that as well with the same result.&nbsp;<\/p>\n<p>Also, I know that there is an interface because this is essentially a two-zone problem and I patch the zones at the beginning to have a liquid zone and a vapor zone. Plotting the VOF shows an area where the if statement is satisfied. Any ideas what I am missing here?<\/p>\n<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<\/p>\n<p>\/\/ UDF to define a simple mass transfer based on VOF.The &#8220;TO&#8221; phase is the gas and the &#8220;FROM&#8221; phase is the liquid phase<\/p>\n<p>#include &#8220;udf.h&#8221;<br \/>#include &#8220;sg_mphase.h&#8221;<\/p>\n<p>DEFINE_MASS_TRANSFER(liq_gas_source, cell, thread, from_index, from_species_index, to_index, to_species_index)<br \/>{<br \/>&nbsp; &nbsp; real m_lg;<br \/>&nbsp; &nbsp; real T_SAT = 373.15;<br \/>&nbsp; &nbsp; Thread* liq = THREAD_SUB_THREAD(thread, from_index);<br \/>&nbsp; &nbsp; Thread* gas = THREAD_SUB_THREAD(thread, to_index);<br \/>&nbsp; &nbsp; Message(&#8220;\\n \\n UDF IS DOING SOMETHING&#8221;);<br \/>&nbsp; &nbsp; m_lg = 0.;<br \/>&nbsp; &nbsp; face_t f;<\/p>\n<p>&nbsp; &nbsp; &nbsp; &nbsp; if ((C_VOF(cell, liq) &gt; 0.05) &amp;&amp; (C_VOF(cell, liq) &lt;= 0.95))<br \/>&nbsp; &nbsp; &nbsp; &nbsp; {<br \/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Message(&#8220;\\n \\n I found the interface!&#8221;);<br \/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<br \/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (C_T(cell, liq) &gt; T_SAT)<br \/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \/* Evaporating *\/<br \/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; m_lg = -0.1 * C_VOF(cell, liq) * C_R(cell, liq) *<br \/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; (C_T(cell, liq) &#8211; T_SAT) \/ T_SAT;<br \/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br \/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (C_T(cell, gas) &lt; T_SAT)<br \/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \/* Condensing *\/<br \/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; m_lg = 0.1 * C_VOF(cell, gas) * C_R(cell, gas) *<br \/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; (T_SAT &#8211; C_T(cell, gas)) \/ T_SAT;<br \/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<\/p>\n<p>&nbsp; &nbsp; &nbsp; &nbsp; }<br \/>&nbsp; &nbsp; return (m_lg);<br \/>}<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"template":"","class_list":["post-236917","topic","type-topic","status-closed","hentry","topic-tag-interface","topic-tag-mass-flow-rate-1","topic-tag-udf","topic-tag-vof"],"aioseo_notices":[],"acf":[],"custom_fields":[{"0":{"_bbp_subscription":["492","199"],"_bbp_author_ip":["23.192.164.14"]," _bbp_last_reply_id":["0"]," _bbp_likes_count":["0"],"_btv_view_count":["2883"],"_bbp_topic_status":["unanswered"],"_bbp_status":["publish"],"_bbp_topic_id":["236917"],"_bbp_forum_id":["27792"],"_bbp_engagement":["199","492"],"_bbp_voice_count":["2"],"_bbp_reply_count":["9"],"_bbp_last_reply_id":["237017"],"_bbp_last_active_id":["237017"],"_bbp_last_active_time":["2022-10-05 08:56:14"]},"test":"cneedhamumd-edu"}],"_links":{"self":[{"href":"https:\/\/innovationspace.ansys.com\/forum\/wp-json\/wp\/v2\/topics\/236917","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\/236917\/revisions"}],"wp:attachment":[{"href":"https:\/\/innovationspace.ansys.com\/forum\/wp-json\/wp\/v2\/media?parent=236917"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}