


{"id":361704,"date":"2024-04-11T12:05:23","date_gmt":"2024-04-11T12:05:23","guid":{"rendered":"\/forum\/forums\/topic\/fluent-udf-define_vr_rate-unable-to-react\/"},"modified":"2024-04-11T12:05:23","modified_gmt":"2024-04-11T12:05:23","slug":"fluent-udf-define_vr_rate-unable-to-react","status":"closed","type":"topic","link":"https:\/\/innovationspace.ansys.com\/forum\/forums\/topic\/fluent-udf-define_vr_rate-unable-to-react\/","title":{"rendered":"Fluent UDF DEFINE_VR_RATE unable to react"},"content":{"rendered":"<p>Hi, guys. Recently, I plan to define pre-exponential factors for limited rate reactions through UDF. The UDF can be compiled and mounted, but the reaction cannot proceed. Hoping to get the reason? The reactant is kerosene. The UDF code is as follows:<\/p>\n<h1>include &#8220;udf.h&#8221;<br \/>DEFINE_VR_RATE(rate_bfer,c,t,r,wk,yk,rate,rr_t)<br \/>{<br \/>\/*If more than one reaction is defined, it is necessary to distinguish<br \/>between these using the names of the reactions. *\/<br \/>&nbsp; &nbsp; if (!strcmp(r-&gt;name, &#8220;reaction-1&#8221;))<br \/>&nbsp; &nbsp; {<br \/>&nbsp; &nbsp; &nbsp; &nbsp; real ci, prod, er, pef_1;<br \/>&nbsp; &nbsp; &nbsp; &nbsp; int i;<br \/>&nbsp; &nbsp; &nbsp; &nbsp; er = (yk[r-&gt;reactant[0]] \/ wk[r-&gt;reactant[0]]) \/ (fabsf(yk[r-&gt;reactant[1]] \/ wk[r-&gt;reactant[1]]) + 1e-9);<br \/>&nbsp; &nbsp; &nbsp; &nbsp; pef_1 = r-&gt;A * er;<br \/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \/* Calculate Arrhenius reaction rate *\/<br \/>&nbsp; &nbsp; &nbsp; &nbsp; prod = 1.0;<br \/>&nbsp; &nbsp; &nbsp; &nbsp; for(i = 0; i &lt; r-&gt;n_reactants; i++)<br \/>&nbsp; &nbsp; &nbsp; &nbsp; {<br \/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ci = C_R(c,t) * yk[r-&gt;reactant[i]] \/ wk[r-&gt;reactant[i]];<br \/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; prod *= pow(ci, r-&gt;exp_reactant[i]);<br \/>&nbsp; &nbsp; &nbsp; &nbsp; }<br \/>&nbsp; &nbsp; &nbsp; &nbsp; *rate = pef_1 * exp(- r-&gt;E \/ (UNIVERSAL_GAS_CONSTANT * C_T(c,t))) * prod;<br \/>&nbsp; &nbsp; &nbsp; &nbsp; \/* without pow(C_T(c,t), r-&gt;b)*\/<br \/>&nbsp; &nbsp; &nbsp; &nbsp; \/* *rr_t = *rate;*\/<br \/>&nbsp; &nbsp; \/* Reaction 1 *\/<br \/>&nbsp; &nbsp; }<br \/>&nbsp; &nbsp; else if (!strcmp(r-&gt;name, &#8220;reaction-2&#8221;))<br \/>&nbsp; &nbsp; {<br \/>&nbsp; &nbsp; &nbsp; &nbsp; real ci, prod, er, pef_2;<br \/>&nbsp; &nbsp; &nbsp; &nbsp; int i;<br \/>&nbsp; &nbsp; &nbsp; &nbsp; er = (yk[r-&gt;reactant[0]] \/ wk[r-&gt;reactant[0]]) \/ (fabsf(yk[r-&gt;reactant[1]] \/ wk[r-&gt;reactant[1]]) + 1e-9);<br \/>&nbsp; &nbsp; &nbsp; &nbsp; pef_2 = r-&gt;A * er;<br \/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \/* Calculate Arrhenius reaction rate *\/<br \/>&nbsp; &nbsp; &nbsp; &nbsp; prod = 1.0;<br \/>&nbsp; &nbsp; &nbsp; &nbsp; for(i = 0; i &lt; r-&gt;n_reactants; i++)<br \/>&nbsp; &nbsp; &nbsp; &nbsp; {<br \/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ci = C_R(c,t) * yk[r-&gt;reactant[i]] \/ wk[r-&gt;reactant[i]];<br \/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; prod *= pow(ci, r-&gt;exp_reactant[i]);<br \/>&nbsp; &nbsp; &nbsp; &nbsp; }<br \/>&nbsp; &nbsp; &nbsp; &nbsp; *rate = pef_2 * exp(- r-&gt;E \/ (UNIVERSAL_GAS_CONSTANT * C_T(c,t))) * prod;<br \/>&nbsp; &nbsp; &nbsp; &nbsp; \/* without pow(C_T(c,t), r-&gt;b)*\/<br \/>&nbsp; &nbsp; &nbsp; &nbsp; \/* *rr_t = *rate;*\/<br \/>&nbsp; &nbsp; \/* Reaction 2 *\/<br \/>&nbsp; &nbsp; }<br \/>}<\/h1>\n<p><img decoding=\"async\" src=\"\/forum\/wp-content\/uploads\/sites\/2\/2024\/04\/11-04-2024-1712837069-mceclip0.png\"><img decoding=\"async\" src=\"\/forum\/wp-content\/uploads\/sites\/2\/2024\/04\/11-04-2024-1712837120-mceclip1.png\"><\/p>\n","protected":false},"template":"","class_list":["post-361704","topic","type-topic","status-closed","hentry","topic-tag-cfd-udf-fleunt","topic-tag-chemical-reaction"],"aioseo_notices":[],"acf":[],"custom_fields":[{"0":{"_bbp_subscription":["80503","199"],"_bbp_author_ip":["168.143.243.14"]," _bbp_last_reply_id":["0"]," _bbp_likes_count":["0"],"_btv_view_count":["805"],"_bbp_topic_status":["unanswered"],"_bbp_topic_id":["361704"],"_bbp_forum_id":["27792"],"_bbp_engagement":["199","80503"],"_bbp_voice_count":["2"],"_bbp_reply_count":["3"],"_bbp_last_reply_id":["361750"],"_bbp_last_active_id":["361750"],"_bbp_last_active_time":["2024-04-11 14:27:39"]},"test":"315914335qq-com"}],"_links":{"self":[{"href":"https:\/\/innovationspace.ansys.com\/forum\/wp-json\/wp\/v2\/topics\/361704","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\/361704\/revisions"}],"wp:attachment":[{"href":"https:\/\/innovationspace.ansys.com\/forum\/wp-json\/wp\/v2\/media?parent=361704"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}