


{"id":163072,"date":"2021-10-14T07:01:09","date_gmt":"2021-10-14T07:01:09","guid":{"rendered":"\/forum\/forums\/topic\/udf-for-plug-flow-reactor-change-in-concentration-with-change-in-position\/"},"modified":"2021-10-14T23:29:54","modified_gmt":"2021-10-14T23:29:54","slug":"udf-for-plug-flow-reactor-change-in-concentration-with-change-in-position","status":"closed","type":"topic","link":"https:\/\/innovationspace.ansys.com\/forum\/forums\/topic\/udf-for-plug-flow-reactor-change-in-concentration-with-change-in-position\/","title":{"rendered":"UDF for plug flow reactor, change in concentration with change in position"},"content":{"rendered":"<div class=\"Item-Body\">\n<div class=\"Message userContent\">\n<p>Hey all,<\/p>\n<p>I&#039;m new to CFD and I&#039;m trying to write a UDF that calculates the concentration at any position as a function of its x-coordinate (for example, Ca = .5C &#8211; .1x, or dCa\/dx = -kCa). This is my first time trying to write a UDF.<\/p>\n<p>I think I have the right idea, but I have a feeling there&#039;s a more efficient way to do it. Do you mind looking at it and giving me some insight\/critiques? This is for the examples dCa\/dx = -kCa. I tried defining the rate in terms of the derivative of the concentration of species A as a function of time and velocity. You can ignore the real x[ND_ND].<\/p>\n<p>Two Questions: 1) Are we able to use the DEFINE_VR_RATE macro to define the fraction of a species, or can we only apply it to define reaction rates? 2) Would I use the begin_f_loop in this case? The reactor is supposed to be 2D. <\/p>\n<p>DEFINE_VR_RATE(pfr_react_rate,c,t,r,w,yi,rate,rr_t)<\/p>\n<p>{<\/p>\n<p> real x[ND_ND];&nbsp;&nbsp;\t&nbsp;&nbsp;\/* x[ND_ND] is a vector that holds values of face in 1, 2, or 3 dimensions *\/<\/p>\n<p> float k = 1;&nbsp;\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\/* reaction rate constant *\/<\/p>\n<p> float Cao = .5;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\/* initial concentration of A *\/<\/p>\n<p> real Ca = ;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\/* real value of Ca concentration *\/<\/p>\n<p> real Y_A;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\/* mass fraction of calculated component *\/<\/p>\n<p> weight_A = w[0];&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\/* assigns the molar mass of A to the molar mass of the first species *\/<\/p>\n<p> real time = CURRENT_TIME;&nbsp;\/* variable assigned to the present simulation time *\/<\/p>\n<p><\/p>\n<\/p>\n<p> \/* is this the right type of loop to use? *\/<\/p>\n<p> begin_f_loop(f,t)&nbsp;<\/p>\n<p> {<\/p>\n<p> Y_A = yi[0];&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\/* Assigns the mass fraction of species to the first member of mass fraction array *\/<\/p>\n<p> Ca = Cai*exp(-k * NODE_X(node));&nbsp;&nbsp;\/* Change in concentration as a function of x position *\/<\/p>\n<p> Y_A = weight_A*Ca \/C_R(c,t);&nbsp;&nbsp;&nbsp;\/* This is probably unnecessary *\/<\/p>\n<p> rate = -k*C_U(c,t)*Ca*exp(-k * C_U(c,t) * time));&nbsp;&nbsp;\/* This is supposed to calculate the rate as a function of velocity and time *\/<\/p>\n<p> }<\/p>\n<p> end_loop(f,t,);<\/p>\n<p>}<\/p>\n<p><\/p>\n<\/p>\n<p>Thanks!<\/p>\n","protected":false},"template":"","class_list":["post-163072","topic","type-topic","status-closed","hentry","topic-tag-2d","topic-tag-ansys-student","topic-tag-cfd","topic-tag-fluent","topic-tag-udf-fluent"],"aioseo_notices":[],"aioseo_head":"\n\t\t<!-- All in One SEO 4.9.10 - aioseo.com -->\n\t<meta name=\"description\" content=\"Hey all,I&#039;m new to CFD and I&#039;m trying to write a UDF that calculates the concentration at any position as a function of its x-coordinate (for example, Ca = .5C - .1x, or dCa\/dx = -kCa). This is my first time trying to write a UDF.I think I have the right idea, but I have\" \/>\n\t<meta name=\"robots\" content=\"max-image-preview:large\" \/>\n\t<link rel=\"canonical\" href=\"https:\/\/innovationspace.ansys.com\/forum\/forums\/topic\/udf-for-plug-flow-reactor-change-in-concentration-with-change-in-position\/\" \/>\n\t<meta name=\"generator\" content=\"All in One SEO (AIOSEO) 4.9.10\" \/>\n\t\t<meta property=\"og:locale\" content=\"en_US\" \/>\n\t\t<meta property=\"og:site_name\" content=\"Ansys Learning Forum | Ansys Innovation Space\" \/>\n\t\t<meta property=\"og:type\" content=\"article\" \/>\n\t\t<meta property=\"og:title\" content=\"UDF for plug flow reactor, change in concentration with change in position | Ansys Learning Forum\" \/>\n\t\t<meta property=\"og:description\" content=\"Hey all,I&#039;m new to CFD and I&#039;m trying to write a UDF that calculates the concentration at any position as a function of its x-coordinate (for example, Ca = .5C - .1x, or dCa\/dx = -kCa). This is my first time trying to write a UDF.I think I have the right idea, but I have\" \/>\n\t\t<meta property=\"og:url\" content=\"https:\/\/innovationspace.ansys.com\/forum\/forums\/topic\/udf-for-plug-flow-reactor-change-in-concentration-with-change-in-position\/\" \/>\n\t\t<meta property=\"article:published_time\" content=\"2021-10-14T07:01:09+00:00\" \/>\n\t\t<meta property=\"article:modified_time\" content=\"2021-10-14T23:29:54+00:00\" \/>\n\t\t<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n\t\t<meta name=\"twitter:title\" content=\"UDF for plug flow reactor, change in concentration with change in position | Ansys Learning Forum\" \/>\n\t\t<meta name=\"twitter:description\" content=\"Hey all,I&#039;m new to CFD and I&#039;m trying to write a UDF that calculates the concentration at any position as a function of its x-coordinate (for example, Ca = .5C - .1x, or dCa\/dx = -kCa). This is my first time trying to write a UDF.I think I have the right idea, but I have\" \/>\n\t\t<script type=\"application\/ld+json\" class=\"aioseo-schema\">\n\t\t\t{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/innovationspace.ansys.com\\\/forum\\\/forums\\\/topic\\\/udf-for-plug-flow-reactor-change-in-concentration-with-change-in-position\\\/#breadcrumblist\",\"itemListElement\":[{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/innovationspace.ansys.com\\\/forum#listItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/innovationspace.ansys.com\\\/forum\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/innovationspace.ansys.com\\\/forum\\\/topics\\\/#listItem\",\"name\":\"Topics\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/innovationspace.ansys.com\\\/forum\\\/topics\\\/#listItem\",\"position\":2,\"name\":\"Topics\",\"item\":\"https:\\\/\\\/innovationspace.ansys.com\\\/forum\\\/topics\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/innovationspace.ansys.com\\\/forum\\\/forums\\\/topic-tag\\\/fluent\\\/#listItem\",\"name\":\"fluent\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/innovationspace.ansys.com\\\/forum#listItem\",\"name\":\"Home\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/innovationspace.ansys.com\\\/forum\\\/forums\\\/topic-tag\\\/fluent\\\/#listItem\",\"position\":3,\"name\":\"fluent\",\"item\":\"https:\\\/\\\/innovationspace.ansys.com\\\/forum\\\/forums\\\/topic-tag\\\/fluent\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/innovationspace.ansys.com\\\/forum\\\/forums\\\/topic\\\/udf-for-plug-flow-reactor-change-in-concentration-with-change-in-position\\\/#listItem\",\"name\":\"UDF for plug flow reactor, change in concentration with change in position\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/innovationspace.ansys.com\\\/forum\\\/topics\\\/#listItem\",\"name\":\"Topics\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/innovationspace.ansys.com\\\/forum\\\/forums\\\/topic\\\/udf-for-plug-flow-reactor-change-in-concentration-with-change-in-position\\\/#listItem\",\"position\":4,\"name\":\"UDF for plug flow reactor, change in concentration with change in position\",\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/innovationspace.ansys.com\\\/forum\\\/forums\\\/topic-tag\\\/fluent\\\/#listItem\",\"name\":\"fluent\"}}]},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/innovationspace.ansys.com\\\/forum\\\/#organization\",\"name\":\"Ansys Learning Forum\",\"description\":\"Ansys Innovation Space\",\"url\":\"https:\\\/\\\/innovationspace.ansys.com\\\/forum\\\/\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/innovationspace.ansys.com\\\/forum\\\/forums\\\/topic\\\/udf-for-plug-flow-reactor-change-in-concentration-with-change-in-position\\\/#webpage\",\"url\":\"https:\\\/\\\/innovationspace.ansys.com\\\/forum\\\/forums\\\/topic\\\/udf-for-plug-flow-reactor-change-in-concentration-with-change-in-position\\\/\",\"name\":\"UDF for plug flow reactor, change in concentration with change in position | Ansys Learning Forum\",\"description\":\"Hey all,I'm new to CFD and I'm trying to write a UDF that calculates the concentration at any position as a function of its x-coordinate (for example, Ca = .5C - .1x, or dCa\\\/dx = -kCa). This is my first time trying to write a UDF.I think I have the right idea, but I have\",\"inLanguage\":\"en-US\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/innovationspace.ansys.com\\\/forum\\\/#website\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/innovationspace.ansys.com\\\/forum\\\/forums\\\/topic\\\/udf-for-plug-flow-reactor-change-in-concentration-with-change-in-position\\\/#breadcrumblist\"},\"datePublished\":\"2021-10-14T07:01:09+00:00\",\"dateModified\":\"2021-10-14T23:29:54+00:00\"},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/innovationspace.ansys.com\\\/forum\\\/#website\",\"url\":\"https:\\\/\\\/innovationspace.ansys.com\\\/forum\\\/\",\"name\":\"Ansys Learning Forum\",\"description\":\"Ansys Innovation Space\",\"inLanguage\":\"en-US\",\"publisher\":{\"@id\":\"https:\\\/\\\/innovationspace.ansys.com\\\/forum\\\/#organization\"}}]}\n\t\t<\/script>\n\t\t<!-- All in One SEO -->\n\n","aioseo_head_json":{"title":"UDF for plug flow reactor, change in concentration with change in position | Ansys Learning Forum","description":"Hey all,I'm new to CFD and I'm trying to write a UDF that calculates the concentration at any position as a function of its x-coordinate (for example, Ca = .5C - .1x, or dCa\/dx = -kCa). This is my first time trying to write a UDF.I think I have the right idea, but I have","canonical_url":"https:\/\/innovationspace.ansys.com\/forum\/forums\/topic\/udf-for-plug-flow-reactor-change-in-concentration-with-change-in-position\/","robots":"max-image-preview:large","keywords":"","webmasterTools":{"miscellaneous":""},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"BreadcrumbList","@id":"https:\/\/innovationspace.ansys.com\/forum\/forums\/topic\/udf-for-plug-flow-reactor-change-in-concentration-with-change-in-position\/#breadcrumblist","itemListElement":[{"@type":"ListItem","@id":"https:\/\/innovationspace.ansys.com\/forum#listItem","position":1,"name":"Home","item":"https:\/\/innovationspace.ansys.com\/forum","nextItem":{"@type":"ListItem","@id":"https:\/\/innovationspace.ansys.com\/forum\/topics\/#listItem","name":"Topics"}},{"@type":"ListItem","@id":"https:\/\/innovationspace.ansys.com\/forum\/topics\/#listItem","position":2,"name":"Topics","item":"https:\/\/innovationspace.ansys.com\/forum\/topics\/","nextItem":{"@type":"ListItem","@id":"https:\/\/innovationspace.ansys.com\/forum\/forums\/topic-tag\/fluent\/#listItem","name":"fluent"},"previousItem":{"@type":"ListItem","@id":"https:\/\/innovationspace.ansys.com\/forum#listItem","name":"Home"}},{"@type":"ListItem","@id":"https:\/\/innovationspace.ansys.com\/forum\/forums\/topic-tag\/fluent\/#listItem","position":3,"name":"fluent","item":"https:\/\/innovationspace.ansys.com\/forum\/forums\/topic-tag\/fluent\/","nextItem":{"@type":"ListItem","@id":"https:\/\/innovationspace.ansys.com\/forum\/forums\/topic\/udf-for-plug-flow-reactor-change-in-concentration-with-change-in-position\/#listItem","name":"UDF for plug flow reactor, change in concentration with change in position"},"previousItem":{"@type":"ListItem","@id":"https:\/\/innovationspace.ansys.com\/forum\/topics\/#listItem","name":"Topics"}},{"@type":"ListItem","@id":"https:\/\/innovationspace.ansys.com\/forum\/forums\/topic\/udf-for-plug-flow-reactor-change-in-concentration-with-change-in-position\/#listItem","position":4,"name":"UDF for plug flow reactor, change in concentration with change in position","previousItem":{"@type":"ListItem","@id":"https:\/\/innovationspace.ansys.com\/forum\/forums\/topic-tag\/fluent\/#listItem","name":"fluent"}}]},{"@type":"Organization","@id":"https:\/\/innovationspace.ansys.com\/forum\/#organization","name":"Ansys Learning Forum","description":"Ansys Innovation Space","url":"https:\/\/innovationspace.ansys.com\/forum\/"},{"@type":"WebPage","@id":"https:\/\/innovationspace.ansys.com\/forum\/forums\/topic\/udf-for-plug-flow-reactor-change-in-concentration-with-change-in-position\/#webpage","url":"https:\/\/innovationspace.ansys.com\/forum\/forums\/topic\/udf-for-plug-flow-reactor-change-in-concentration-with-change-in-position\/","name":"UDF for plug flow reactor, change in concentration with change in position | Ansys Learning Forum","description":"Hey all,I'm new to CFD and I'm trying to write a UDF that calculates the concentration at any position as a function of its x-coordinate (for example, Ca = .5C - .1x, or dCa\/dx = -kCa). This is my first time trying to write a UDF.I think I have the right idea, but I have","inLanguage":"en-US","isPartOf":{"@id":"https:\/\/innovationspace.ansys.com\/forum\/#website"},"breadcrumb":{"@id":"https:\/\/innovationspace.ansys.com\/forum\/forums\/topic\/udf-for-plug-flow-reactor-change-in-concentration-with-change-in-position\/#breadcrumblist"},"datePublished":"2021-10-14T07:01:09+00:00","dateModified":"2021-10-14T23:29:54+00:00"},{"@type":"WebSite","@id":"https:\/\/innovationspace.ansys.com\/forum\/#website","url":"https:\/\/innovationspace.ansys.com\/forum\/","name":"Ansys Learning Forum","description":"Ansys Innovation Space","inLanguage":"en-US","publisher":{"@id":"https:\/\/innovationspace.ansys.com\/forum\/#organization"}}]},"og:locale":"en_US","og:site_name":"Ansys Learning Forum | Ansys Innovation Space","og:type":"article","og:title":"UDF for plug flow reactor, change in concentration with change in position | Ansys Learning Forum","og:description":"Hey all,I'm new to CFD and I'm trying to write a UDF that calculates the concentration at any position as a function of its x-coordinate (for example, Ca = .5C - .1x, or dCa\/dx = -kCa). This is my first time trying to write a UDF.I think I have the right idea, but I have","og:url":"https:\/\/innovationspace.ansys.com\/forum\/forums\/topic\/udf-for-plug-flow-reactor-change-in-concentration-with-change-in-position\/","article:published_time":"2021-10-14T07:01:09+00:00","article:modified_time":"2021-10-14T23:29:54+00:00","twitter:card":"summary_large_image","twitter:title":"UDF for plug flow reactor, change in concentration with change in position | Ansys Learning Forum","twitter:description":"Hey all,I'm new to CFD and I'm trying to write a UDF that calculates the concentration at any position as a function of its x-coordinate (for example, Ca = .5C - .1x, or dCa\/dx = -kCa). This is my first time trying to write a UDF.I think I have the right idea, but I have"},"aioseo_meta_data":{"post_id":"163072","title":null,"description":null,"keywords":null,"keyphrases":null,"primary_term":null,"canonical_url":null,"og_title":null,"og_description":null,"og_object_type":"default","og_image_type":"content","og_image_url":null,"og_image_width":null,"og_image_height":null,"og_image_custom_url":null,"og_image_custom_fields":null,"og_video":null,"og_custom_url":null,"og_article_section":null,"og_article_tags":null,"twitter_use_og":true,"twitter_card":"default","twitter_image_type":"default","twitter_image_url":null,"twitter_image_custom_url":null,"twitter_image_custom_fields":null,"twitter_title":null,"twitter_description":null,"schema":{"blockGraphs":[],"customGraphs":[],"default":{"data":{"Article":[],"Course":[],"Dataset":[],"FAQPage":[],"Movie":[],"Person":[],"Product":[],"ProductReview":[],"Car":[],"Recipe":[],"Service":[],"SoftwareApplication":[],"WebPage":[]},"graphName":"","isEnabled":true},"graphs":[]},"schema_type":"default","schema_type_options":null,"pillar_content":false,"robots_default":true,"robots_noindex":false,"robots_noarchive":false,"robots_nosnippet":false,"robots_nofollow":false,"robots_noimageindex":false,"robots_noodp":false,"robots_notranslate":false,"robots_max_snippet":null,"robots_max_videopreview":null,"robots_max_imagepreview":"large","priority":null,"frequency":null,"local_seo":null,"limit_modified_date":false,"created":"2024-10-28 20:25:29","updated":"2024-10-28 20:25:29","ai":null,"breadcrumb_settings":null,"seo_analyzer_scan_date":null},"aioseo_breadcrumb":"<div class=\"aioseo-breadcrumbs\"><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/innovationspace.ansys.com\/forum\" title=\"Home\">Home<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">&raquo;<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/innovationspace.ansys.com\/forum\/topics\/\" title=\"Topics\">Topics<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">&raquo;<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/innovationspace.ansys.com\/forum\/forums\/topic-tag\/fluent\/\" title=\"fluent\">fluent<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">&raquo;<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\tUDF for plug flow reactor, change in concentration with change in position\n\t\t<\/span><\/div>","aioseo_breadcrumb_json":[{"label":"Home","link":"https:\/\/innovationspace.ansys.com\/forum"},{"label":"Topics","link":"https:\/\/innovationspace.ansys.com\/forum\/topics\/"},{"label":"fluent","link":"https:\/\/innovationspace.ansys.com\/forum\/forums\/topic-tag\/fluent\/"},{"label":"UDF for plug flow reactor, change in concentration with change in position","link":"https:\/\/innovationspace.ansys.com\/forum\/forums\/topic\/udf-for-plug-flow-reactor-change-in-concentration-with-change-in-position\/"}],"acf":[],"custom_fields":[{"0":{"_bbp_author_ip":[""],"_bbp_old_reply_author_name_id":["Anonymous"],"_bbp_old_is_reply_anonymous_id":["false"],"_btv_view_count":["576"],"_bbp_likes_count":["0"],"_bbp_subscription":["232559"],"_bbp_topic_status":["unanswered"],"_bbp_status":["publish"],"_bbp_topic_id":["163072"],"_bbp_forum_id":["27792"],"_bbp_engagement":["5120","232559"],"_bbp_voice_count":["2"],"_bbp_reply_count":["2"],"_bbp_last_reply_id":["194749"],"_bbp_last_active_id":["194749"],"_bbp_last_active_time":["2021-10-14 23:29:54"]},"test":"ajdussaultcpp-edu"}],"_links":{"self":[{"href":"https:\/\/innovationspace.ansys.com\/forum\/wp-json\/wp\/v2\/topics\/163072","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\/163072\/revisions"}],"wp:attachment":[{"href":"https:\/\/innovationspace.ansys.com\/forum\/wp-json\/wp\/v2\/media?parent=163072"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}