


{"id":360651,"date":"2024-04-05T10:27:57","date_gmt":"2024-04-05T10:27:57","guid":{"rendered":"\/forum\/forums\/reply\/360651\/"},"modified":"2024-04-05T10:27:57","modified_gmt":"2024-04-05T10:27:57","slug":"360651","status":"publish","type":"reply","link":"https:\/\/innovationspace.ansys.com\/forum\/forums\/reply\/360651\/","title":{"rendered":"Reply To: coupled simulation of vehicle and fluid tank"},"content":{"rendered":"<p>&lt;div&gt;&lt;div&gt;#include &#8220;udf.h&#8221;&lt;\/div&gt;&lt;br&gt;&lt;div&gt;DEFINE_SOURCE(moment_source, c, t, dS, eqn)&lt;\/div&gt;&lt;div&gt;{&lt;\/div&gt;&lt;div&gt;&nbsp; &nbsp; real time = CURRENT_TIME; \/\/ Get the current simulation time&lt;\/div&gt;&lt;div&gt;&nbsp; &nbsp; real moment = 0.0; \/\/ Initialize moment to zero&lt;\/div&gt;&lt;div&gt;&nbsp; &nbsp; real CG[ND_ND]; \/\/ Center of gravity coordinates&lt;\/div&gt;&lt;div&gt;&nbsp; &nbsp; real cellCG[ND_ND]; \/\/ Cell center coordinates&lt;\/div&gt;&lt;br&gt;&lt;div&gt;&nbsp; &nbsp; C_CENTROID(CG, c, t); \/\/ Get CG of the domain&lt;\/div&gt;&lt;div&gt;&nbsp; &nbsp; C_CENTROID(cellCG, c, t); \/\/ Get cell center coordinates&lt;\/div&gt;&lt;br&gt;&lt;div&gt;&nbsp; &nbsp; real distance_from_CG = cellCG[2] &#8211; CG[2]; \/\/ Distance along z-axis&lt;\/div&gt;&lt;br&gt;&lt;div&gt;&nbsp; &nbsp; \/* Check if time is within the specified duration *\/&lt;\/div&gt;&lt;div&gt;&nbsp; &nbsp; if (time &lt;= 2.0)&lt;\/div&gt;&lt;div&gt;&nbsp; &nbsp; {&lt;\/div&gt;&lt;div&gt;&nbsp; &nbsp; &nbsp; &nbsp; \/* Apply moment only to cells at CG *\/&lt;\/div&gt;&lt;div&gt;&nbsp; &nbsp; &nbsp; &nbsp; if (distance_from_CG = 0.0)&lt;\/div&gt;&lt;div&gt;&nbsp; &nbsp; &nbsp; &nbsp; {&lt;\/div&gt;&lt;div&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; moment = 5000.0; \/\/ Apply 5000 Nm moment&lt;\/div&gt;&lt;div&gt;&nbsp; &nbsp; }&lt;\/div&gt;&lt;br&gt;&lt;div&gt;&nbsp; &nbsp; dS[eqn] = 0.0; \/\/ Reset the source term&lt;\/div&gt;&lt;div&gt;&nbsp; &nbsp; return moment; \/\/ Return the moment as the source term&lt;\/div&gt;&lt;div&gt;}&lt;\/div&gt;&lt;\/div&gt;&lt;p&gt;and hooked as the souce term of fluid domain under cell conditions.&lt;\/p&gt;&lt;p&gt;this UDF is giving very less value of force&#8230; could&nbsp; you please check it whether syntex and logic is correct or not.&lt;\/p&gt;<\/p>\n","protected":false},"template":"","class_list":["post-360651","reply","type-reply","status-publish","hentry"],"aioseo_notices":[],"acf":[],"_links":{"self":[{"href":"https:\/\/innovationspace.ansys.com\/forum\/wp-json\/wp\/v2\/replies\/360651","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/innovationspace.ansys.com\/forum\/wp-json\/wp\/v2\/replies"}],"about":[{"href":"https:\/\/innovationspace.ansys.com\/forum\/wp-json\/wp\/v2\/types\/reply"}],"version-history":[{"count":0,"href":"https:\/\/innovationspace.ansys.com\/forum\/wp-json\/wp\/v2\/replies\/360651\/revisions"}],"wp:attachment":[{"href":"https:\/\/innovationspace.ansys.com\/forum\/wp-json\/wp\/v2\/media?parent=360651"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}