


{"id":166718,"date":"2022-02-24T16:41:27","date_gmt":"2022-02-24T16:41:27","guid":{"rendered":"\/forum\/forums\/topic\/udf-for-partial-pressure-in-heat-pipe-simulation-divergence-after-one-time-step\/"},"modified":"2022-03-01T19:57:01","modified_gmt":"2022-03-01T19:57:01","slug":"udf-for-partial-pressure-in-heat-pipe-simulation-divergence-after-one-time-step","status":"closed","type":"topic","link":"https:\/\/innovationspace.ansys.com\/forum\/forums\/topic\/udf-for-partial-pressure-in-heat-pipe-simulation-divergence-after-one-time-step\/","title":{"rendered":"UDF for partial pressure in heat pipe simulation &#8211; divergence after one time step"},"content":{"rendered":"<div class=\"Item-Body\">\n<div class=\"Message userContent\">\n<p>Hi,<\/p>\n<p>I am working on the simulation of a heat pipe with non-condensable gases. For that I am using the VOF model with the Lee model for evaporation\/condensation, as well as the species transport model to account for gas diffusion of vapor into the NCG-vapor mixture.<\/p>\n<p>I am using a UDF to calculate the partial pressure of vapor in the gas mixture and then find the saturation temperature at each cell, everything goes well, it compiles, hooks, etc. My problem is the simulation runs for one time step, then in the next one when the residuals shoot up, it diverges. The fluids are water (phase-changing) and air (NCG). My gas mixture has water-vapor as the first component.<\/p>\n<p>I am not sure if this is needed, but this is the UDF I am using (adapted from this post: <a href=\"\/forum\/discussion\/29866\/saturation-temperature-udf\" rel=\"nofollow\">\/forum\/discussion\/29866\/saturation-temperature-udf<\/a>)<\/p>\n<p><\/p>\n<\/p>\n<p>#include &quot;udf.h&quot;<\/p>\n<p>#define MOLAR_MASS_WATER 18.01534 \/\/g\/mol<\/p>\n<p>#define MOLAR_MASS_AIR 28.97 \/\/ g\/mol<\/p>\n<p>DEFINE_PROPERTY(saturation_temp, c, t)<\/p>\n<p>{<\/p>\n<p>\/\/ t: mixture thread<\/p>\n<p>\/\/ c: cell variable<\/p>\n<p>\/\/ Cell volume<\/p>\n<p>real vol = C_VOLUME(c, t);<\/p>\n<p>Thread *pt = THREAD_SUB_THREAD(t, 0); \/\/ Primary phase thread<\/p>\n<p>Thread *st = THREAD_SUB_THREAD(t, 1); \/\/ Secondary phase thread<\/p>\n<p>\/\/ Get the volume fraction of both phases<\/p>\n<p>real vf_s = C_VOF(c, st);<\/p>\n<p>real vf_p = 1 &#8211; vf_s;<\/p>\n<p>\/\/ Get the pressure of the mixture&nbsp;<\/p>\n<p>real p_mix = C_P(c, t);<\/p>\n<p>\/\/ Get the operating pressure<\/p>\n<p>real p_op = RP_Get_Real(&quot;operating-pressure&quot;);<\/p>\n<p>\/\/ Primary phase density<\/p>\n<p>real rho_p = C_R(c, pt);<\/p>\n<p>\/\/ Get mass fractions in primary phase<\/p>\n<p>real mf[2]; \/\/ to store mass fractions<\/p>\n<p>Material *m = THREAD_MATERIAL(pt);<\/p>\n<p>Material *sp = NULL;<\/p>\n<p>int i; \/\/ Species index &#8211; 0 for water vapor and 1 for air<\/p>\n<p>mixture_species_loop(m, sp, i)<\/p>\n<p>{<\/p>\n<p>mf[i] = C_YI(c, pt, i);<\/p>\n<p>}<\/p>\n<p>real p_w; \/\/ h20 pressure for cell<\/p>\n<p>\/\/ If secondary phase only<\/p>\n<p>if (vf_s == 1)<\/p>\n<p>{<\/p>\n<p>p_w = p_mix + p_op;<\/p>\n<p>}<\/p>\n<p>\/\/ If primary phase or mixture of phases<\/p>\n<p>else&nbsp;<\/p>\n<p>{<\/p>\n<p>\/\/ Find the partial pressure of water vapour<\/p>\n<p>\/\/ partial pressure = cell pressure * water mole fraction<\/p>\n<p>\/\/ mass of primary phase in cell<\/p>\n<p>real m_prim = rho_p * vol * vf_p;<\/p>\n<p>\/\/ mass of water vapour and air in cell<\/p>\n<p>real m_wv = mf[0] * m_prim;<\/p>\n<p>real m_air = m_prim &#8211; m_wv;<\/p>\n<p>\/\/ No of moles in water vapour and air<\/p>\n<p>real N_wv = m_wv \/ MOLAR_MASS_WATER;<\/p>\n<p>real N_air = m_air \/ MOLAR_MASS_AIR;<\/p>\n<p>real N_total = N_wv + N_air;<\/p>\n<p>\/\/ water vapour partial pressure<\/p>\n<p>p_w = (C_P(c, t)+ p_op)* (N_wv \/ N_total);<\/p>\n<p>}<\/p>\n<p>\/\/ Calculate saturation temperature<\/p>\n<p>real t_sat;<\/p>\n<p>t_sat = (1730.63 \/ (10.196 &#8211; log10(p_w))) + 39.724;<\/p>\n<p>return t_sat;<\/p>\n<p>}<\/p>\n","protected":false},"template":"","class_list":["post-166718","topic","type-topic","status-closed","hentry","topic-tag-multiphase","topic-tag-phase-change","topic-tag-species-diffusion"],"aioseo_notices":[],"acf":[],"custom_fields":[{"0":{"_btv_view_count":["912"],"_bbp_likes_count":["1"],"_bbp_subscription":["249574"],"_bbp_topic_status":["unanswered"],"_bbp_status":["publish"],"_bbp_topic_id":["166718"],"_bbp_forum_id":["27792"],"_bbp_engagement":["25","249574"],"_bbp_voice_count":["2"],"_bbp_reply_count":["2"],"_bbp_last_reply_id":["206589"],"_bbp_last_active_id":["206589"],"_bbp_last_active_time":["2022-03-01 19:57:01"]},"test":"fjulioumich-edu"}],"_links":{"self":[{"href":"https:\/\/innovationspace.ansys.com\/forum\/wp-json\/wp\/v2\/topics\/166718","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\/166718\/revisions"}],"wp:attachment":[{"href":"https:\/\/innovationspace.ansys.com\/forum\/wp-json\/wp\/v2\/media?parent=166718"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}