


{"id":368405,"date":"2024-05-24T01:37:25","date_gmt":"2024-05-24T01:37:25","guid":{"rendered":"\/forum\/forums\/topic\/udf-works-in-planar-option-but-not-axisymmetric\/"},"modified":"2024-05-24T01:37:25","modified_gmt":"2024-05-24T01:37:25","slug":"udf-works-in-planar-option-but-not-axisymmetric","status":"closed","type":"topic","link":"https:\/\/innovationspace.ansys.com\/forum\/forums\/topic\/udf-works-in-planar-option-but-not-axisymmetric\/","title":{"rendered":"UDF works in planar option but not axisymmetric"},"content":{"rendered":"<p>My udf works when I select the planar option, even with an axis BC, but when I select axisymmetric, the heat flux is 10x higher than expected. I only want the heat flux radial direction (y direction), which is maybe why.<\/p>\n<p>&nbsp;<\/p>\n<div>#include &#8220;udf.h&#8221;<\/div>\n<div>#include &lt;math.h&gt;<\/div>\n<div>&nbsp;<\/div>\n<div>#define rho 950 \/\/ kg\/m^3<\/div>\n<div>#define Hg 2033631 \/\/ J\/Kg<\/div>\n<div>#define Hf -310000 \/\/ J\/Kg<\/div>\n<div>#define T_ref 298 \/\/ K<\/div>\n<div>#define A1 0.01104 \/\/ m\/s<\/div>\n<div>#define A2 3.9648 \/\/ m\/s<\/div>\n<div>#define Cp 1500 \/\/ J\/(Kg*K)<\/div>\n<div>#define E1 20557.188 \/\/ J\/mol<\/div>\n<div>#define E2 55893.78 \/\/ J\/mol<\/div>\n<div>#define R_u 8.314 \/\/ J\/(mol*K)<\/div>\n<div>#define alpha 0.3<\/div>\n<div>&nbsp;<\/div>\n<div>DEFINE_PROFILE(surface_temperature_profile, t, position)<\/div>\n<div>{<\/div>\n<div>&nbsp; &nbsp; face_t f;<\/div>\n<div>&nbsp; &nbsp; real Ts, heat_flux, heat, a_face, Hv, r, Ts_old, Ts_new, error, Ts_new_prime, Area[ND_ND];<\/div>\n<div>&nbsp; &nbsp; int iter;<\/div>\n<div>&nbsp; &nbsp; begin_f_loop(f, t)<\/div>\n<div>&nbsp; &nbsp; {<\/div>\n<div>&nbsp; &nbsp; &nbsp; &nbsp; Ts = F_T(f, t);&nbsp; \/\/ Current temperature at the face<\/div>\n<div>&nbsp; &nbsp; &nbsp; &nbsp; printf(&#8220;Temp of face %d: %g K\\n&#8221;, f, Ts);<\/div>\n<div>&nbsp; &nbsp; &nbsp; &nbsp; heat = BOUNDARY_HEAT_FLUX(f, t);&nbsp; \/\/ Calculating the heat flux at face f in watts<\/div>\n<div>&nbsp; &nbsp; &nbsp; &nbsp; F_AREA(Area, f, t);<\/div>\n<div>&nbsp; &nbsp; &nbsp; &nbsp; a_face = NV_MAG(Area);<\/div>\n<div>&nbsp; &nbsp; &nbsp; &nbsp; heat_flux = heat \/ a_face; \/\/ Heat flux in W\/m^2<\/div>\n<div>&nbsp; &nbsp; &nbsp; &nbsp; printf(&#8220;Heat flux on face %d: %g W\/m^2\\n&#8221;, f, heat_flux);<\/div>\n<div>&nbsp; &nbsp; &nbsp; &nbsp; Ts_old = Ts;<\/div>\n<div>&nbsp; &nbsp; &nbsp; &nbsp; iter = 0;<\/div>\n<div>&nbsp; &nbsp; &nbsp; &nbsp; error = 1;<\/div>\n<div>&nbsp; &nbsp; &nbsp; &nbsp; while (error &gt; 1e-6 &amp;&amp; iter &lt; 100)<\/div>\n<div>&nbsp; &nbsp; &nbsp; &nbsp; {<\/div>\n<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Hv = Hg &#8211; Hf + Cp * (Ts &#8211; T_ref);&nbsp; \/\/ Calculation heat of formation<\/div>\n<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; r = (fabs(heat_flux)) \/ (Hv * rho);&nbsp; \/\/ Regression rate<\/div>\n<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (Ts_old &gt; 722)<\/div>\n<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<\/div>\n<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Ts_new = E1 \/ (R_u * (log(A1) &#8211; log(r)));&nbsp; \/\/ New surface temperature for high temperature<\/div>\n<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<\/div>\n<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else<\/div>\n<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<\/div>\n<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Ts_new = E2 \/ (R_u * (log(A2) &#8211; log(r)));&nbsp; \/\/ New surface temperature for low temperature<\/div>\n<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<\/div>\n<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; error = fabs(Ts_new &#8211; Ts_old);&nbsp; \/\/ Error calculation<\/div>\n<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Ts_old = Ts_new;&nbsp; \/\/ Update Ts_old for next iteration<\/div>\n<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; iter++;&nbsp; \/\/ Increment iteration count<\/div>\n<div>&nbsp; &nbsp; &nbsp; &nbsp; }<\/div>\n<div>&nbsp;<\/div>\n<div>&nbsp; &nbsp; &nbsp; &nbsp; Ts_new_prime = Ts + (alpha * (Ts_new &#8211; Ts));&nbsp;<\/div>\n<div>r = (fabs(heat_flux)) \/ (Hv * rho);<\/div>\n<div>&nbsp; &nbsp; &nbsp; &nbsp; printf(&#8220;New Temp %d: %g K\\n&#8221;, f, Ts_new_prime);<\/div>\n<div>&nbsp; &nbsp; &nbsp; &nbsp; printf(&#8220;r_dot %d: %g mm\/s\\n&#8221;, f, r*1000);<\/div>\n<div>&nbsp; &nbsp; &nbsp; &nbsp; F_PROFILE(f, t, position) = Ts_new_prime;&nbsp; \/\/ Update the face temperature profile<\/div>\n<div>&nbsp; &nbsp; }<\/div>\n<div>&nbsp; &nbsp; end_f_loop(f, t)<\/div>\n<div>}<\/div>\n","protected":false},"template":"","class_list":["post-368405","topic","type-topic","status-closed","hentry"],"aioseo_notices":[],"acf":[],"custom_fields":[{"0":{"_bbp_subscription":["343144","15180"],"_bbp_author_ip":["184.24.96.207"]," _bbp_last_reply_id":["0"]," _bbp_likes_count":["0"],"_btv_view_count":["218"],"_bbp_topic_status":["unanswered"],"_bbp_topic_id":["368405"],"_bbp_forum_id":["27792"],"_bbp_engagement":["15180","343144"],"_bbp_voice_count":["2"],"_bbp_reply_count":["1"],"_bbp_last_reply_id":["374025"],"_bbp_last_active_id":["374025"],"_bbp_last_active_time":["2024-07-29 14:19:21"]},"test":"zwernjaydengmail-com"}],"_links":{"self":[{"href":"https:\/\/innovationspace.ansys.com\/forum\/wp-json\/wp\/v2\/topics\/368405","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\/368405\/revisions"}],"wp:attachment":[{"href":"https:\/\/innovationspace.ansys.com\/forum\/wp-json\/wp\/v2\/media?parent=368405"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}