


{"id":390945,"date":"2024-10-23T00:37:01","date_gmt":"2024-10-23T00:37:01","guid":{"rendered":"https:\/\/innovationspace.ansys.com\/forum\/forums\/topic\/problem-with-the-udf-and-the-default-turbulent-viscosity-of-realizable-k-e\/"},"modified":"2024-10-23T00:37:01","modified_gmt":"2024-10-23T00:37:01","slug":"problem-with-the-udf-and-the-default-turbulent-viscosity-of-realizable-k-e","status":"publish","type":"topic","link":"https:\/\/innovationspace.ansys.com\/forum\/forums\/topic\/problem-with-the-udf-and-the-default-turbulent-viscosity-of-realizable-k-e\/","title":{"rendered":"Problem with the UDF and the default turbulent viscosity of Realizable k-e"},"content":{"rendered":"<p>&lt;p&gt;Hi Fluent experts,&lt;\/p&gt;&lt;p&gt;I am trying to make the UDF for the Realizable k-epsilon turbulent viscosity based on the paper of Shih et al. and that expressed in the Fluent theory guide.&lt;\/p&gt;&lt;p&gt;The UDF code is for 2D simulation as follows:&lt;\/p&gt;&lt;p&gt;#include &#8220;udf.h&#8221;&lt;br&gt;#include &#8220;math.h&#8221;&lt;\/p&gt;&lt;p&gt;DEFINE_TURBULENT_VISCOSITY(tur_vis,c,t)&lt;br&gt;{&lt;br&gt;&nbsp; real mu_tur;&lt;br&gt;&nbsp; real S11, S12, S22, W12, W12r, S;&lt;br&gt;&nbsp; real SMU, WAS, PHI, USTAR;&lt;br&gt;&nbsp; real AS;&lt;br&gt;&nbsp; real CMU, a1, a2, a3, a4, a5, a6;&lt;br&gt;&nbsp; real PHI2, F2;&lt;\/p&gt;&lt;p&gt;\/***\/&lt;br&gt;&nbsp; real betas=0.09;&lt;br&gt;&nbsp; real A0=4.04;&lt;br&gt;&nbsp; real rho=C_R(c,t);&lt;br&gt;&nbsp; real k=C_K(c,t);&lt;br&gt;&nbsp; real w=C_D(c,t);&lt;br&gt;&nbsp; real CMUL=C_MU_L(c,t);&lt;br&gt;&nbsp; real y=C_WALL_DIST(c,t);&lt;\/p&gt;&lt;p&gt;\/***\/&lt;br&gt;&nbsp; real wr=-1.485446130; &nbsp; &nbsp; &nbsp; \/***rotation speed unit: 1\/s***\/&lt;\/p&gt;&lt;p&gt;\/***\/&lt;br&gt;&nbsp; S11=0.5*(C_DUDX(c,t)+C_DUDX(c,t));&lt;br&gt;&nbsp; S12=0.5*(C_DUDY(c,t)+C_DVDX(c,t));&lt;br&gt;&nbsp; S22=0.5*(C_DVDY(c,t)+C_DVDY(c,t));&lt;br&gt;&nbsp;&lt;br&gt;&nbsp; W12=0.5*(C_DVDX(c,t)-C_DUDY(c,t));&lt;\/p&gt;&lt;p&gt;\/*** Cal vorticity with angular velocity wr ***\/&lt;br&gt;&nbsp;&lt;br&gt;&nbsp; W12r=W12-wr;&lt;\/p&gt;&lt;p&gt;\/*** Cal U* &nbsp;***\/&lt;\/p&gt;&lt;p&gt;&nbsp; USTAR=sqrt(S11*S11+2.0*S12*S12+S22*S22+2.0*W12r*W12r);&lt;\/p&gt;&lt;p&gt;\/*** Cal Phi ***\/&lt;\/p&gt;&lt;p&gt;&nbsp; SMU=sqrt(S11*S11+2.0*S12*S12+S22*S22);&lt;br&gt;&nbsp; WAS=(pow(S11,3)+pow(S22,3)+3.0*pow(S12,2)*(S11+S22))\/pow(SMU,3);&lt;br&gt;&nbsp; PHI=1.0\/3.0*acos(max(-1.0,min(sqrt(6.0)*WAS,1.0)));&lt;\/p&gt;&lt;p&gt;\/*** Cal As ***\/&lt;br&gt;&nbsp;&lt;br&gt;&nbsp; AS = sqrt(6.0)*cos(PHI);&lt;\/p&gt;&lt;p&gt;\/*** Cal CMU ***\/&lt;br&gt;&nbsp;&lt;br&gt;&nbsp; CMU=1.0\/(A0+AS*USTAR*k\/w);&lt;\/p&gt;&lt;p&gt;\/*** Cal Viscosity ***\/&lt;\/p&gt;&lt;p&gt;&nbsp; mu_tur=CMU*rho*k*k\/w;&lt;br&gt;&nbsp;&nbsp;&lt;br&gt;&nbsp; return mu_tur;&lt;br&gt;}&lt;\/p&gt;&lt;p&gt;The simulations were performed for both the UDF and the default viscous model. However, there is a large deviation between these simulations&#8217; averaged results. I do not know why and why this difference is because the UDF code was based on the expression in the Fluent theory guide. I also compared the simulation between the UDF code and the default turbulent viscosity of the SST k-omega model and got a good agreement between the results.&lt;\/p&gt;&lt;p&gt;Could anyone please help?&lt;\/p&gt;&lt;p&gt;Thank you very much.&lt;\/p&gt;<\/p>\n","protected":false},"template":"","class_list":["post-390945","topic","type-topic","status-publish","hentry"],"aioseo_notices":[],"aioseo_head":"\n\t\t<!-- All in One SEO 4.9.10 - aioseo.com -->\n\t<meta name=\"description\" content=\"Hi Fluent experts,I am trying to make the UDF for the Realizable k-epsilon turbulent viscosity based on the paper of Shih et al. and that expressed in the Fluent theory guide.The UDF code is for 2D simulation as follows:#include &quot;udf.h&quot;#include &quot;math.h&quot;DEFINE_TURBULENT_VISCOSITY(tur_vis,c,t){ real mu_tur; real S11, S12, S22, W12, W12r, S; real SMU, WAS, PHI, USTAR;\" \/>\n\t<meta name=\"robots\" content=\"max-image-preview:large\" \/>\n\t<link rel=\"canonical\" href=\"https:\/\/innovationspace.ansys.com\/forum\/forums\/topic\/problem-with-the-udf-and-the-default-turbulent-viscosity-of-realizable-k-e\/\" \/>\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=\"Problem with the UDF and the default turbulent viscosity of Realizable k-e | Ansys Learning Forum\" \/>\n\t\t<meta property=\"og:description\" content=\"Hi Fluent experts,I am trying to make the UDF for the Realizable k-epsilon turbulent viscosity based on the paper of Shih et al. and that expressed in the Fluent theory guide.The UDF code is for 2D simulation as follows:#include &quot;udf.h&quot;#include &quot;math.h&quot;DEFINE_TURBULENT_VISCOSITY(tur_vis,c,t){ real mu_tur; real S11, S12, S22, W12, W12r, S; real SMU, WAS, PHI, USTAR;\" \/>\n\t\t<meta property=\"og:url\" content=\"https:\/\/innovationspace.ansys.com\/forum\/forums\/topic\/problem-with-the-udf-and-the-default-turbulent-viscosity-of-realizable-k-e\/\" \/>\n\t\t<meta property=\"article:published_time\" content=\"2024-10-23T00:37:01+00:00\" \/>\n\t\t<meta property=\"article:modified_time\" content=\"2024-10-23T00:37:01+00:00\" \/>\n\t\t<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n\t\t<meta name=\"twitter:title\" content=\"Problem with the UDF and the default turbulent viscosity of Realizable k-e | Ansys Learning Forum\" \/>\n\t\t<meta name=\"twitter:description\" content=\"Hi Fluent experts,I am trying to make the UDF for the Realizable k-epsilon turbulent viscosity based on the paper of Shih et al. and that expressed in the Fluent theory guide.The UDF code is for 2D simulation as follows:#include &quot;udf.h&quot;#include &quot;math.h&quot;DEFINE_TURBULENT_VISCOSITY(tur_vis,c,t){ real mu_tur; real S11, S12, S22, W12, W12r, S; real SMU, WAS, PHI, USTAR;\" \/>\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\\\/problem-with-the-udf-and-the-default-turbulent-viscosity-of-realizable-k-e\\\/#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\\\/problem-with-the-udf-and-the-default-turbulent-viscosity-of-realizable-k-e\\\/#listItem\",\"name\":\"Problem with the UDF and the default turbulent viscosity of Realizable k-e\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/innovationspace.ansys.com\\\/forum#listItem\",\"name\":\"Home\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/innovationspace.ansys.com\\\/forum\\\/forums\\\/topic\\\/problem-with-the-udf-and-the-default-turbulent-viscosity-of-realizable-k-e\\\/#listItem\",\"position\":3,\"name\":\"Problem with the UDF and the default turbulent viscosity of Realizable k-e\",\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/innovationspace.ansys.com\\\/forum\\\/topics\\\/#listItem\",\"name\":\"Topics\"}}]},{\"@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\\\/problem-with-the-udf-and-the-default-turbulent-viscosity-of-realizable-k-e\\\/#webpage\",\"url\":\"https:\\\/\\\/innovationspace.ansys.com\\\/forum\\\/forums\\\/topic\\\/problem-with-the-udf-and-the-default-turbulent-viscosity-of-realizable-k-e\\\/\",\"name\":\"Problem with the UDF and the default turbulent viscosity of Realizable k-e | Ansys Learning Forum\",\"description\":\"Hi Fluent experts,I am trying to make the UDF for the Realizable k-epsilon turbulent viscosity based on the paper of Shih et al. and that expressed in the Fluent theory guide.The UDF code is for 2D simulation as follows:#include \\\"udf.h\\\"#include \\\"math.h\\\"DEFINE_TURBULENT_VISCOSITY(tur_vis,c,t){ real mu_tur; real S11, S12, S22, W12, W12r, S; real SMU, WAS, PHI, USTAR;\",\"inLanguage\":\"en-US\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/innovationspace.ansys.com\\\/forum\\\/#website\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/innovationspace.ansys.com\\\/forum\\\/forums\\\/topic\\\/problem-with-the-udf-and-the-default-turbulent-viscosity-of-realizable-k-e\\\/#breadcrumblist\"},\"datePublished\":\"2024-10-23T00:37:01+00:00\",\"dateModified\":\"2024-10-23T00:37:01+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":"Problem with the UDF and the default turbulent viscosity of Realizable k-e | Ansys Learning Forum","description":"Hi Fluent experts,I am trying to make the UDF for the Realizable k-epsilon turbulent viscosity based on the paper of Shih et al. and that expressed in the Fluent theory guide.The UDF code is for 2D simulation as follows:#include \"udf.h\"#include \"math.h\"DEFINE_TURBULENT_VISCOSITY(tur_vis,c,t){ real mu_tur; real S11, S12, S22, W12, W12r, S; real SMU, WAS, PHI, USTAR;","canonical_url":"https:\/\/innovationspace.ansys.com\/forum\/forums\/topic\/problem-with-the-udf-and-the-default-turbulent-viscosity-of-realizable-k-e\/","robots":"max-image-preview:large","keywords":"","webmasterTools":{"miscellaneous":""},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"BreadcrumbList","@id":"https:\/\/innovationspace.ansys.com\/forum\/forums\/topic\/problem-with-the-udf-and-the-default-turbulent-viscosity-of-realizable-k-e\/#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\/problem-with-the-udf-and-the-default-turbulent-viscosity-of-realizable-k-e\/#listItem","name":"Problem with the UDF and the default turbulent viscosity of Realizable k-e"},"previousItem":{"@type":"ListItem","@id":"https:\/\/innovationspace.ansys.com\/forum#listItem","name":"Home"}},{"@type":"ListItem","@id":"https:\/\/innovationspace.ansys.com\/forum\/forums\/topic\/problem-with-the-udf-and-the-default-turbulent-viscosity-of-realizable-k-e\/#listItem","position":3,"name":"Problem with the UDF and the default turbulent viscosity of Realizable k-e","previousItem":{"@type":"ListItem","@id":"https:\/\/innovationspace.ansys.com\/forum\/topics\/#listItem","name":"Topics"}}]},{"@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\/problem-with-the-udf-and-the-default-turbulent-viscosity-of-realizable-k-e\/#webpage","url":"https:\/\/innovationspace.ansys.com\/forum\/forums\/topic\/problem-with-the-udf-and-the-default-turbulent-viscosity-of-realizable-k-e\/","name":"Problem with the UDF and the default turbulent viscosity of Realizable k-e | Ansys Learning Forum","description":"Hi Fluent experts,I am trying to make the UDF for the Realizable k-epsilon turbulent viscosity based on the paper of Shih et al. and that expressed in the Fluent theory guide.The UDF code is for 2D simulation as follows:#include \"udf.h\"#include \"math.h\"DEFINE_TURBULENT_VISCOSITY(tur_vis,c,t){ real mu_tur; real S11, S12, S22, W12, W12r, S; real SMU, WAS, PHI, USTAR;","inLanguage":"en-US","isPartOf":{"@id":"https:\/\/innovationspace.ansys.com\/forum\/#website"},"breadcrumb":{"@id":"https:\/\/innovationspace.ansys.com\/forum\/forums\/topic\/problem-with-the-udf-and-the-default-turbulent-viscosity-of-realizable-k-e\/#breadcrumblist"},"datePublished":"2024-10-23T00:37:01+00:00","dateModified":"2024-10-23T00:37:01+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":"Problem with the UDF and the default turbulent viscosity of Realizable k-e | Ansys Learning Forum","og:description":"Hi Fluent experts,I am trying to make the UDF for the Realizable k-epsilon turbulent viscosity based on the paper of Shih et al. and that expressed in the Fluent theory guide.The UDF code is for 2D simulation as follows:#include &quot;udf.h&quot;#include &quot;math.h&quot;DEFINE_TURBULENT_VISCOSITY(tur_vis,c,t){ real mu_tur; real S11, S12, S22, W12, W12r, S; real SMU, WAS, PHI, USTAR;","og:url":"https:\/\/innovationspace.ansys.com\/forum\/forums\/topic\/problem-with-the-udf-and-the-default-turbulent-viscosity-of-realizable-k-e\/","article:published_time":"2024-10-23T00:37:01+00:00","article:modified_time":"2024-10-23T00:37:01+00:00","twitter:card":"summary_large_image","twitter:title":"Problem with the UDF and the default turbulent viscosity of Realizable k-e | Ansys Learning Forum","twitter:description":"Hi Fluent experts,I am trying to make the UDF for the Realizable k-epsilon turbulent viscosity based on the paper of Shih et al. and that expressed in the Fluent theory guide.The UDF code is for 2D simulation as follows:#include &quot;udf.h&quot;#include &quot;math.h&quot;DEFINE_TURBULENT_VISCOSITY(tur_vis,c,t){ real mu_tur; real S11, S12, S22, W12, W12r, S; real SMU, WAS, PHI, USTAR;"},"aioseo_meta_data":{"post_id":"390945","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 16:22:00","updated":"2024-10-28 16:22:00","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\tProblem with the UDF and the default turbulent viscosity of Realizable k-e\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":"Problem with the UDF and the default turbulent viscosity of Realizable k-e","link":"https:\/\/innovationspace.ansys.com\/forum\/forums\/topic\/problem-with-the-udf-and-the-default-turbulent-viscosity-of-realizable-k-e\/"}],"acf":[],"custom_fields":[{"0":{"_bbp_author_ip":["2405:4802:1d98:5380:6009:7671:3516:d1ea"],"_btv_view_count":["318"],"_bbp_topic_status":["unanswered"],"_bbp_subscription":["199","470751"],"_bbp_topic_id":["390945"],"_bbp_forum_id":["27792"],"_bbp_engagement":["199","470751"],"_bbp_voice_count":["2"],"_bbp_reply_count":["3"],"_bbp_last_reply_id":["391190"],"_bbp_last_active_id":["391190"],"_bbp_last_active_time":["2024-10-24 09:37:59"]},"test":"8cee373bfd26bd2932f3181fb04663e46ab6ae2a"}],"_links":{"self":[{"href":"https:\/\/innovationspace.ansys.com\/forum\/wp-json\/wp\/v2\/topics\/390945","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\/390945\/revisions"}],"wp:attachment":[{"href":"https:\/\/innovationspace.ansys.com\/forum\/wp-json\/wp\/v2\/media?parent=390945"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}