


{"id":30599,"date":"2018-09-26T02:38:36","date_gmt":"2018-09-26T02:38:36","guid":{"rendered":"\/forum\/forums\/topic\/udf-for-atmospheric-boundary-layer-abl\/"},"modified":"2018-09-26T02:38:36","modified_gmt":"2018-09-26T02:38:36","slug":"udf-for-atmospheric-boundary-layer-abl","status":"closed","type":"topic","link":"https:\/\/innovationspace.ansys.com\/forum\/forums\/topic\/udf-for-atmospheric-boundary-layer-abl\/","title":{"rendered":"UDF for Atmospheric Boundary Layer (ABL)"},"content":{"rendered":"<p>Hello,<\/p>\n<p><\/p>\n<p>I have been trying to simulate a homogenous ABL profile based on Richards and Hoxey&#8217;s 1993 <a href=\"https:\/\/www.sciencedirect.com\/science\/article\/pii\/0167610593901247\">approach<\/a> using FLUENT software, which requires a UDF at the inlet. I succeeded in&nbsp; creating the velocity profile using the log law<\/p>\n<p><\/p>\n<p>Uref= u (log(href\/z0)\/log(h\/z0)) [shown below in code]<\/p>\n<p><\/p>\n<p><strong>Uref<\/strong>: reference velocity at refernce height <strong>(<\/strong>href<strong>)<\/strong>, <strong>u<\/strong>: velocity at h (height), and <strong>z0<\/strong>: aerodynamic roughness height.<\/p>\n<p><\/p>\n<p>The result was successful as shown:<\/p>\n<p><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/us.v-cdn.net\/6032193\/uploads\/attachments\/2dea4495-7d5d-40eb-bc16-a94b006223d1\/5d4f6f7b-a0f2-4a21-95e5-a9670027fef8_abl.jpg?width=690&amp;upscale=false\" alt=\"\" width=\"508\" height=\"410\"><\/p>\n<p><\/p>\n<p>However, a homogenous turbulence kinetic energy (TKE) and dissipation rate (TDR) were not generated despite the inserted constant values (calculated from the mentioned apprach relative to friction velocity, u*) in the inlet display window as shown (the values were changed from 1 and 1 to differnt numbers of course).&nbsp; The results changed due to the ground roughness (may be) that might be another possible influence (UDF?).<\/p>\n<p><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/us.v-cdn.net\/6032193\/uploads\/attachments\/2dea4495-7d5d-40eb-bc16-a94b006223d1\/208a62f2-f6e3-406e-a615-a96700290058_index.jpg?width=690&amp;upscale=false\" alt=\"\"><\/p>\n<p><\/p>\n<p>So I tried making a UDF code for both TKE and TDR as well to keep them constant based on the codes below, but it didn&#8217;t work as well, the TKE gave high values at the top and minimum (zero) at the bottom:<\/p>\n<p><\/p>\n<p>#include &#8220;udf.h&#8221;<\/p>\n<p>&nbsp;#define z0 0.0000824&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \/* constants *\/<br \/>&nbsp;#define z1 0.4<br \/>&nbsp;#define uref 14.7<br \/>&nbsp;#define CMU 0.09<br \/>&nbsp;#define VKC 0.41<\/p>\n<p>&nbsp;\/* profile for x-velocity *\/<\/p>\n<p>&nbsp;DEFINE_PROFILE(log_velocity,thread,index)<br \/>&nbsp;{<br \/>&nbsp;&nbsp; real y[ND_ND]; <br \/>&nbsp;&nbsp; real z2;<br \/>&nbsp;&nbsp; face_t f;<\/p>\n<p>&nbsp;&nbsp; begin_f_loop(f,thread) <br \/>&nbsp;&nbsp; {<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; F_CENTROID(y,f,thread);<br \/>&nbsp;&nbsp;&nbsp; z2 = y[1];<br \/>&nbsp;&nbsp;&nbsp; F_PROFILE(f,thread,index) = uref*log(z2\/z0)\/log(z1\/z0);<br \/>&nbsp;&nbsp;&nbsp; }<br \/>&nbsp;end_f_loop(f,thread)<br \/>&nbsp;&nbsp; }<\/p>\n<p>&nbsp;\/* profile for kinetic energy *\/<br \/>&nbsp;<br \/>&nbsp;DEFINE_PROFILE(k_profile,thread,index)<br \/>&nbsp;{<br \/>&nbsp;&nbsp;&nbsp; real y[ND_ND], lgr, ustr;<br \/>&nbsp;&nbsp;&nbsp; real k;<br \/>&nbsp;&nbsp;&nbsp; face_t f;<\/p>\n<p>&nbsp;&nbsp;&nbsp; lgr = log((z1+z0)\/z0);<br \/>&nbsp;&nbsp;&nbsp; ustr = (uref*VKC)\/lgr;<br \/>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <\/p>\n<p>&nbsp;&nbsp;&nbsp; begin_f_loop(f,thread)<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; F_CENTROID(y,f,thread);<\/p>\n<p><\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; k = pow(ustr,2.)\/sqrt(CMU);<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; F_PROFILE(f,thread,index) = k;<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; end_f_loop(f,thread)<br \/>&nbsp;&nbsp; }<\/p>\n<p>\/* profile for dissipation rate *\/<br \/>&nbsp;<br \/>&nbsp;DEFINE_PROFILE(dissip_profile,thread,index)<br \/>&nbsp;{<br \/>&nbsp;&nbsp;&nbsp; real y[ND_ND], lgr, ustr;<br \/>&nbsp;&nbsp;&nbsp; real eps;<br \/>&nbsp;&nbsp;&nbsp; face_t f;<\/p>\n<p>&nbsp;&nbsp;&nbsp; lgr = log((z1+z0)\/z0);<br \/>&nbsp;&nbsp;&nbsp; ustr = (uref*VKC)\/lgr;<br \/>&nbsp;&nbsp;&nbsp; <\/p>\n<p>&nbsp;&nbsp;&nbsp; begin_f_loop(f,thread)<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; F_CENTROID(y,f,thread);<\/p>\n<p><\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; eps = pow(ustr,3.)\/(VKC*(z1+z0));<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; F_PROFILE(f,thread,index) = eps;<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; end_f_loop(f,thread)<br \/>&nbsp;}<\/p>\n<p><\/p>\n<p>&nbsp;<\/p>\n<p><\/p>\n<p>what should I do?<\/p>\n<p><\/p>\n<p>Kindly notice that, I&#8217;m not good coder, in fact I don&#8217;t know how to write codes, my efforts were done to try understand them, so this code is&nbsp; a beginner trial. My question is How?, Am I missing something?<\/p>\n<p><\/p>\n<p>and yes, I read the manual.<\/p>\n<p><\/p>\n<p>&nbsp;<\/p>\n<p><\/p>\n<p>Thank you for support<\/p>\n<p><\/p>\n<p>Ahmad<\/p>\n","protected":false},"template":"","class_list":["post-30599","topic","type-topic","status-closed","hentry"],"aioseo_notices":[],"acf":[],"custom_fields":[{"0":{"_bbp_old_topic_id":["2771"],"_bbp_old_topic_author_name_id":["Anonymous"],"_bbp_old_is_topic_anonymous_id":["false"],"_bbp_old_closed_status_id":["publish"],"_bbp_author_ip":[null],"_bbp_old_sticky_status_id":["normal"],"_bbp_likes_count":["0","0","0","0","0"],"_btv_view_count":["2200"],"_bbp_topic_status":["unanswered"],"_bbp_status":["publish"],"_bbp_topic_id":["30599"],"_bbp_forum_id":["27792"],"_bbp_engagement":["25","199","4948","22555","158541","162684","175441"],"_bbp_voice_count":["7"],"_bbp_reply_count":["23"],"_bbp_last_reply_id":["112668"],"_bbp_last_active_id":["112668"],"_bbp_last_active_time":["2020-04-27 11:38:41"]},"test":"ahmadzaki"}],"_links":{"self":[{"href":"https:\/\/innovationspace.ansys.com\/forum\/wp-json\/wp\/v2\/topics\/30599","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\/30599\/revisions"}],"wp:attachment":[{"href":"https:\/\/innovationspace.ansys.com\/forum\/wp-json\/wp\/v2\/media?parent=30599"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}