


{"id":362416,"date":"2024-04-16T09:06:58","date_gmt":"2024-04-16T09:06:58","guid":{"rendered":"\/forum\/forums\/reply\/362416\/"},"modified":"2024-04-16T09:06:58","modified_gmt":"2024-04-16T09:06:58","slug":"362416","status":"publish","type":"reply","link":"https:\/\/innovationspace.ansys.com\/forum\/forums\/reply\/362416\/","title":{"rendered":"Reply To: Finding Lift force in CG motion UDF"},"content":{"rendered":"<p>&lt;p&gt;Hi, thanks for replying. this is the latest UDF I am using,&lt;\/p&gt;&lt;div&gt;#include &#8220;udf.h&#8221;&lt;\/div&gt;&lt;div&gt;#define MASS 0.0143&lt;\/div&gt;&lt;div&gt;&nbsp;&lt;\/div&gt;&lt;div&gt;\/* Declare a global variable to store the lift force *\/&lt;\/div&gt;&lt;div&gt;static real lift = 0.0;&lt;\/div&gt;&lt;div&gt;&nbsp;&lt;\/div&gt;&lt;div&gt;\/* Function to compute the CG motion, including flapping motion *\/&lt;\/div&gt;&lt;div&gt;DEFINE_CG_MOTION(paperfreq, dt, vel, omega, time, dtime)&lt;\/div&gt;&lt;div&gt;{&lt;\/div&gt;&lt;div&gt;&nbsp; &nbsp; Domain *d = Get_Domain(1); \/\/ Assuming single phase flow&lt;\/div&gt;&lt;div&gt;&nbsp; &nbsp; Thread *t_object = Lookup_Thread(d, 7); \/\/ Airfoil&#8217;s thread ID&lt;\/div&gt;&lt;div&gt;&nbsp; &nbsp; real force[2], moment[2], cg[2]; \/\/ Initialize arrays&lt;\/div&gt;&lt;div&gt;&nbsp; &nbsp; real x=0;&lt;\/div&gt;&lt;div&gt;&nbsp; &nbsp; NV_S(vel, =, 0.0);&lt;\/div&gt;&lt;div&gt;&nbsp; &nbsp; \/* Compute force and moment at the boundary *\/&lt;\/div&gt;&lt;div&gt;&nbsp; &nbsp; Compute_Force_And_Moment(d, t_object, cg, force, moment, FALSE);&lt;\/div&gt;&lt;div&gt;&nbsp;&lt;\/div&gt;&lt;div&gt;&nbsp; &nbsp; \/* Update global variable for lift force *\/&lt;\/div&gt;&lt;div&gt;&nbsp; &nbsp; lift = force[1];&lt;\/div&gt;&lt;div&gt;&nbsp;&lt;\/div&gt;&lt;div&gt;&nbsp; &nbsp; real w, a, pi;&lt;\/div&gt;&lt;div&gt;&nbsp; &nbsp; pi = 3.14159265;&lt;\/div&gt;&lt;div&gt;&nbsp; &nbsp; a = (pi * 15) \/ 180; \/\/ Pitch amplitude in radians&lt;\/div&gt;&lt;div&gt;&nbsp; &nbsp; w = 0.62832; \/\/ Angular velocity in rad\/s&lt;\/div&gt;&lt;div&gt;&nbsp;&lt;\/div&gt;&lt;div&gt;&nbsp; &nbsp; \/* Define the flapping motion *\/&lt;\/div&gt;&lt;div&gt;&nbsp; &nbsp; omega[2] = -a * 2 * pi * 2.97 * cos(2 * pi * 2.97 * time); \/\/ Pitching motion&lt;\/div&gt;&lt;div&gt;&nbsp; &nbsp; vel[1]=lift*dtime\/MASS;&lt;\/div&gt;&lt;div&gt;&nbsp; &nbsp; x=vel[1];&lt;\/div&gt;&lt;div&gt;&nbsp; &nbsp;&nbsp;&lt;\/div&gt;&lt;div&gt;Message(&#8220;lift:%f x:%f\\n&#8221;,lift,x);&lt;\/div&gt;&lt;div&gt;}&lt;\/div&gt;&lt;p&gt;The problem is, if i use the vel[1], the lift force goes very high, so does the velocity. This makes the airfoil go outside domain and it creates floating point exception error. If I dont use the vel[1], and I print the lift force using Message, it shows correct lift value.&nbsp;&lt;br&gt;&lt;br&gt;What I need is, change the location of the airfoil based on the lift force. If there is any other way to give it a y-displacement it is also ok. I am giving it a flapping motion, which generates various lift force based on time and I need the latest lift force to update the airfoil location before going to next time step.&lt;\/p&gt;<\/p>\n","protected":false},"template":"","class_list":["post-362416","reply","type-reply","status-publish","hentry"],"aioseo_notices":[],"acf":[],"_links":{"self":[{"href":"https:\/\/innovationspace.ansys.com\/forum\/wp-json\/wp\/v2\/replies\/362416","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\/362416\/revisions"}],"wp:attachment":[{"href":"https:\/\/innovationspace.ansys.com\/forum\/wp-json\/wp\/v2\/media?parent=362416"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}