


{"id":160146,"date":"2021-07-06T10:06:32","date_gmt":"2021-07-06T10:06:32","guid":{"rendered":"\/forum\/forums\/topic\/adding-something-like-udf-in-ansys-mechanical-adding-a-source-term\/"},"modified":"2021-07-27T07:11:12","modified_gmt":"2021-07-27T07:11:12","slug":"adding-something-like-udf-in-ansys-mechanical-adding-a-source-term","status":"closed","type":"topic","link":"https:\/\/innovationspace.ansys.com\/forum\/forums\/topic\/adding-something-like-udf-in-ansys-mechanical-adding-a-source-term\/","title":{"rendered":"Adding something like UDF in Ansys Mechanical \/ Adding a source term"},"content":{"rendered":"<div class=\"Item-Body\">\n<div class=\"Message userContent\">\n<p>Hello everybody, <\/p>\n<p>for my simulation it is necessary to implement chemical reactions and their influence, e.g. the reduction extent of a specific geometry. I want to include this as a source term. How can this be done with Ansys Mechanical? <\/p>\n<p>I tried a few APDL commands. The following code is just a &quot;pseudo code&quot;. It has a lot of errors in it. I want to know if the structure and design of the code is okay or if there is any better solution. <\/p>\n<pre class=\"code codeBlock\" spellcheck=\"false\">! ############################################\n! Getting values and material data\n! ############################################\n\n*GET, NumberOfMeshElements, VOLU, 0, COUNT, , Body 1, ! Number of Elements in Body 1\n*GET, TimeStepSize, ACTIVE, 0, SOLU, DTIME\n\n*SET, CeriaAmount, 1000 ! in mol \n*SET, ReductionEnthalpy, 500 ! in kJ\/mol O (\n\n*SET, OxygenPartialPressure, 100 ! Setting oxygen partial pressure\n*SET, Temperature, TEMP ! Setting Temperature as a variable\n\n*SET, ReductionExtent, 0 ! previous reduction extent \n\n! ############################################\n! Calculation of Source Term\n! ############################################\n\n! Begin of Loop for each time step\n*DO, t, 0, 10, TimeStepSize ! solve together with transient thermal analysis (convection, radiation, conduction) \nReductionExtent = 0.35 * EXP(Temperature) ! goal: storing of previous (t-1) value for later calculation of Rate of Change\n\n! Begin of Loop for each element\n*DO, i, 1, NumberOfMeshElements, 1 ! needed for each mesh element because each mesh element has a different temperature\n*GET, MeshElementVolume, VOLU, i, VOLU, , Body 1,\nReductionExtentRateOfChange = ReductionExtent(t-1)- ReductionExtent(i) \/ TimeStepSize\nS_reaction = - CeriaAmount \/ MeshElementVolume * ReductionEnthalpy * ReductionExtentRateOfChange ! usally a source term\n<\/pre>\n<p><\/p>\n<p>I am very very thankful for any help. Maybe you have an example of how to add a source term. <\/p>\n<p>Ani<\/p>\n","protected":false},"template":"","class_list":["post-160146","topic","type-topic","status-closed","hentry","topic-tag-ansys-mechanical","topic-tag-apdl-coding","topic-tag-energy-balance-1","topic-tag-source-term"],"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":["1364"],"_bbp_likes_count":["0"],"_bbp_subscription":["248098"],"_bbp_topic_status":["unanswered"],"_bbp_status":["publish"],"_bbp_topic_id":["160146"],"_bbp_forum_id":["27791"],"_bbp_engagement":["240","185297","206495"],"_bbp_voice_count":["3"],"_bbp_reply_count":["11"],"_bbp_last_reply_id":["184645"],"_bbp_last_active_id":["184645"],"_bbp_last_active_time":["2021-07-27 07:11:12"]},"test":"anikohlhas-info"}],"_links":{"self":[{"href":"https:\/\/innovationspace.ansys.com\/forum\/wp-json\/wp\/v2\/topics\/160146","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\/160146\/revisions"}],"wp:attachment":[{"href":"https:\/\/innovationspace.ansys.com\/forum\/wp-json\/wp\/v2\/media?parent=160146"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}