# UDF for flapping of the aifoil

 Register Blogs Members List Search Today's Posts Mark Forums Read

June 21, 2023, 13:42
UDF for flapping of the aifoil
#1
New Member

CFD
Join Date: May 2022
Posts: 11
Rep Power: 3
Hello, I am trying to simulate the effet of trailing edge flap. I have created a udf based on cg motion but i am facing problems. The rotor has 4 zones, 3 zones each containing the trailing edge flaps for each blade (three blades) and one zone containing the remaining. I am rotating the main domain Zone1 with all the blades with sliding mesh method and all other zones are rotating relative to the first zone. So far no problems. Now as the domain with blades is rotating along z-axis (0,0,1), At the same time I want to flap the trailing edge with a function lets say sin theta degrees where theta is azimuthal. when the blade is between 0 and 180 degrees, i want the trailing edge to flap with function A and when 180 to 360, function B.
I m using the dynamic mesh method with a rigid body and the trailing edge is not deforming. initially, i am giving the cg points x and y as the point about which the trailing edge will flap for each blade and hooking the udf in the dynamic mesh.
Attached Images
 Domain.jpg (104.3 KB, 5 views) Blade.jpg (171.3 KB, 5 views)

 June 21, 2023, 22:40 #2 Senior Member   Alexander Join Date: Apr 2013 Posts: 2,363 Rep Power: 34 show UDF you are using __________________ best regards ****************************** press LIKE if this message was helpful

 June 22, 2023, 04:13 #3 New Member   CFD Join Date: May 2022 Posts: 11 Rep Power: 3 #include "udf.h" DEFINE_CGMOTION(flapping_motion, dt, vel, omega, time, dtime) { Thread *t; face_t f; real flapping_amplitude = 1.0; // flapping amplitude /* apply flapping motion */ thread_loop_c(t, dt) { begin_f_loop(f, t) { real NV_VEC(p), NV_VEC(axis_z); real theta, flapping_motion; /* flapping motion based on the azimuthal position */ C_CENTROID(p, f, t); theta = atan2(p[1], p[0]); if ((theta >= 0.0 && theta <= M_PI / 3.0) || (theta >= 5.0 * M_PI / 3.0 && theta <= 2.0 * M_PI)) flapping_motion = flapping_amplitude * sin(3.0 * theta); else if (theta >= M_PI / 3.0 && theta <= 5.0 * M_PI / 3.0) flapping_motion = -flapping_amplitude * sin(3.0 * theta); else flapping_motion = 0.0; /* Define the blade axis */ NV_D(axis_z, =, 1.0); /* Apply the flapping motion to the face motion */ NV_S(domega, =, 0.0); NV_S(vel, =, 0.0); NV_S(omega, =, flapping_motion * axis_z); } end_f_loop(f, t) } }

 June 22, 2023, 22:34 #4 Senior Member   Alexander Join Date: Apr 2013 Posts: 2,363 Rep Power: 34 compile code Code: ```#include "udf.h" DEFINE_CG_MOTION(flapping_motion, dt, vel, omega, time, dtime) { Thread *t; face_t f; real flapping_amplitude = 1.0; // flapping amplitude /* apply flapping motion */ if (!Data_Valid_P()) return; /* get the thread pointer for which this motion is defined */ t = DT_THREAD(dt); begin_f_loop(f, t) { real NV_VEC(p), NV_VEC(axis_z); real theta, flapping_motion; /* flapping motion based on the azimuthal position */ F_CENTROID(p, f, t); theta = atan2(p[1], p[0]); if ((theta >= 0.0 && theta <= M_PI / 3.0) || (theta >= 5.0 * M_PI / 3.0 && theta <= 2.0 * M_PI)) flapping_motion = flapping_amplitude * sin(3.0 * theta); else if (theta >= M_PI / 3.0 && theta <= 5.0 * M_PI / 3.0) flapping_motion = -flapping_amplitude * sin(3.0 * theta); else flapping_motion = 0.0; /* Define the blade axis */ NV_D(axis_z, =, 0.0, 0.0, 1.0); /* Apply the flapping motion to the face motion */ NV_S(omega, =, 0.0); NV_S(vel, =, 0.0); omega = axis_z; NV_S(omega, *=, flapping_motion); } end_f_loop(f, t) }``` satyamshk2 likes this. __________________ best regards ****************************** press LIKE if this message was helpful

June 24, 2023, 15:36
#5
New Member

CFD
Join Date: May 2022
Posts: 11
Rep Power: 3
The provided udf is not showing any error but the trailing edge is also not moving.
It is showing this warning of no motion
Warning: incorrect cg motion UDF flapping_airfoil on zone 27 (assuming no motion)

In my case, the center of the flap is different than the center of the flapping zone as can be seen in the picture. In the dynamic mesh zone, I am giving that flap center(not flapping zone center) initially as cg location. The flap center is the small flap leading edge circle's center.
theta_offset = atan2(0.37076, 0.6641); // Initial angle offset, x and y of the flap centroid
theta = atan2(p[1], p[0]) - theta_offset;

What mistake am I doing?
even if the udf is taking a different center, I should see the zone motion, which I can not.
Also, flapping the trailing edge about its centroid will not give correct value of the flapping center. In the dynamic mesh zone, i am using flap as rigid body so no connection with the flapping zone. I think, i should find the centroid of that flap and its offset from the rotation centre and then calculate azimuthal angle as per the the coordinates.

I was trying another udf to rotate the trailing edge by a fixed angle when it passes through 181 degrees azimuthal.
In this udf, i am calculating the azimuthal from time as i know the time-step.
#include "udf.h"
#include <math.h>

#define rotation_angle 2.0*M_PI/180 /* Desired rotation angle in degrees */
#define time_conversion_factor 0.00165835760852502 /* Conversion factor from time step to degrees */

DEFINE_CG_MOTION(case2d, dt, vel, omega, time, dtime)
{
real alpha_dot, angle;

angle = fmod((time / time_conversion_factor) * 5, 360); /* Calculate the angle using the time and conversion factor 5degree is the time step size */

if (angle > 180.0 && angle < 360.0)
{
if (angle == 181.0)

alpha_dot = (rotation_angle / dtime ); /* Rotate the complete angle in one time step */

else

alpha_dot = 0.0;

}
else
{
alpha_dot = 0.0;
}

omega[0] = 0.0;
omega[1] = 0.0;
omega[2] = alpha_dot;
}
The same problem. None of the above are working.
Thanks
Attached Images
 Flap center.JPG (57.5 KB, 3 views)

Last edited by satyamshk2; June 26, 2023 at 04:14. Reason: attachment