


{"id":159628,"date":"2021-06-18T20:36:12","date_gmt":"2021-06-18T20:36:12","guid":{"rendered":"\/forum\/forums\/topic\/using-a-udf-for-heat-generation\/"},"modified":"2021-12-15T01:47:52","modified_gmt":"2021-12-15T01:47:52","slug":"using-a-udf-for-heat-generation","status":"closed","type":"topic","link":"https:\/\/innovationspace.ansys.com\/forum\/forums\/topic\/using-a-udf-for-heat-generation\/","title":{"rendered":"Using a UDF for Heat Generation"},"content":{"rendered":"<div class=\"Item-Body\">\n<div class=\"Message userContent\">\n<p>I&#039;m currently attempting to use the following UDF I found off the CFD-Online forum.<\/p>\n<pre class=\"code codeBlock\" spellcheck=\"false\">#include &quot;udf.h&quot;\n#include &quot;math.h&quot;\n\nDEFINE_ADJUST(cellheatgenerate,d)\n{\n\treal SOC,ds,tm,Ri,tempu,volume,source,temp;\n\tThread *t;\n\tcell_t c;\n\ttm = CURRENT_TIME;\n\tthread_loop_c(t,d)\n\t{\t\n\t\tbegin_c_loop(c,t)\n\t\t{\t\t\n\t\t\tSOC = 1.-((90.*tm)\/5400.);\n\n\t\t\tif ((SOC &gt;= 0.) &amp;&amp; (SOC &lt;= 0.77))\n\t\t\t\tds = (99.88*SOC)-76.67;\n\t\t\telse if ((SOC &gt; 0.77) &amp;&amp; (SOC &lt;= 0.87))\n\t\t\t\tds = -30.;\n\t\t\telse if ((SOC &gt;0.87) &amp;&amp; (SOC &lt;=1.))\n\t\t\t\tds = -20.;\n\n\t\t\tvolume = C_VOLUME(c,t);\n\t\t\ttempu = C_T(c,t);\n\t\t\tif (tm == 0.)\n\t\t\t\ttemp = 291.15;\n\t\t\telse if (tm &gt; 0.)\n\t\t\t\ttemp = tempu;\n\t\t\t\n\t\t\tif (temp &lt;= 298.15)\n\t\t\t\tRi = 0.000002258*pow(SOC,-0.3952);\n\t\t\telse if ((temp &gt; 298.15) &amp;&amp; (temp &lt;= 308.15))\n\t\t\t\tRi = 0.000001857*pow(SOC,-0.2787);\n\t\t\telse if (temp &gt; 308.15)\n\t\t\t\tRi = 0.000001659*pow(SOC,-0.1692);\n\n\t\t\ttemp = C_T(c,t);\n\t\t\tsource = ((Ri*8100.)-(90.*temp*ds\/96.485))\/volume;\n\t\t\tC_UDMI(c,t,0) = source;\t\t\t\n\t\t}\t\t\n\t\tend_c_loop(c,t)\t\t\n\t}\t\n}\n\nDEFINE_SOURCE(my_heat_source,c,t,dS,eqn)\n{\n\treal source;\n\tsource =  C_UDMI(c,t,0);\t\n\tdS[eqn] = 0.0;\n\treturn source;\n}\n<\/pre>\n<p>I&#039;m currently having problems applying this UDF to my Fluent simulation. I open up Compiled Functions, add the .C file, build it, then load it without any errors showing up, but I&#039;m unable to see where the myheatsource and cellheatgenerate is being applied.<\/p>\n","protected":false},"template":"","class_list":["post-159628","topic","type-topic","status-closed","hentry"],"aioseo_notices":[],"acf":[],"custom_fields":[{"0":{"_bbp_author_ip":[""],"_bbp_old_reply_author_name_id":["Anonymous"],"_bbp_old_is_reply_anonymous_id":["false"],"_btv_view_count":["2246"],"_bbp_likes_count":["0"],"_bbp_subscription":["239345"],"_bbp_topic_status":["unanswered"],"_bbp_status":["publish"],"_bbp_topic_id":["159628"],"_bbp_forum_id":["27792"],"_bbp_engagement":["25","199","155988","184487","200223"],"_bbp_voice_count":["5"],"_bbp_reply_count":["14"],"_bbp_last_reply_id":["182676"],"_bbp_last_active_id":["182676"],"_bbp_last_active_time":["2021-12-15 01:47:52"]},"test":"kuuku-botchwayudc-edu"}],"_links":{"self":[{"href":"https:\/\/innovationspace.ansys.com\/forum\/wp-json\/wp\/v2\/topics\/159628","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\/159628\/revisions"}],"wp:attachment":[{"href":"https:\/\/innovationspace.ansys.com\/forum\/wp-json\/wp\/v2\/media?parent=159628"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}