## Fluids

#### Figure eight motion UDF

• CameronLaw
Subscriber

Hi all, I've been trying to write a UDF in FLUENT that describes the figure of eight motion of hummingbird flight.

My idea has been to use these three equations that gives angles that cover 3 degrees of freedom, then divide these by time to get angular velocity. To do this I've used the CG_MOTION macro and used a rigid body dynamic mesh for the wing.

However this doesn't give anything resembling a figure of eight motion. In fact as time increases it is inevitable that the angular velocity will decrease quickly to effectively zero.

So my question is; do you think I'm using CG_MOTION correctly? Is this the best macro to create a figure of eight motion? And also is there anything in my logic here about how I'm getting angular velocity that is obviously wrong?

Here is my UDF:

#include "udf.h"

DEFINE_CG_MOTION(complex_wing, dt, vel, omega, time, dtime)
{
real pi, f, theta, phi_m, phi_0, alpha_m, alpha_0, phi_alpha, delta_m_1, delta_m_2, phi, alpha_star, delta;

pi = 3.14159265359;
f = 48 *  (2 * pi); /* flapping frequency */
theta = 0 * (pi / 180); /* mean stroke plane angle */
phi_m = 90 * (pi / 180); /* sweep angle amplitude */
phi_0 = 0 * (pi / 180); /* sweep angle offset */
alpha_m = 0 * (pi / 180);/* inclination angle amplitude */
alpha_0 = 0 * (pi / 180);/* inclination angle offset */
phi_alpha = 10 * (pi / 180); /* inclination angle phase shift */
delta_m_1 = 0 * (pi / 180); /* deviation angle amplitude for oval trajectory*/
delta_m_2 = 30 * (pi / 180); /* deviation angle amplitude for figure of eight trajectory */

phi = phi_0 + (phi_m * cos(2 * pi * f * time)); /* sweep angle */

// alpha_star = alpha_0 + (((pi / 2) - alpha_m) * sin(2 * pi * f * (time - phi_alpha))); /* inclination angle, ignore for now */

delta = delta_m_2 * sin(4 * pi * f * time); /* deviation angle */

//omega[3] = alpha_star; // ignore this for now
omega[2] = delta;
omega[1] = phi;
}

Any advice you can give will be greatly appreciated thank you.

Kind regards,

Cameron

• Rob
Ansys Employee

Have a think about the motion, and the maths. If time is always increasing you need to review how time or cos(time) interact with the rest of the equation(s).

• DrAmine
Ansys Employee
And to add are you dividing with time intervall? It does not seem so.
• CameronLaw
Subscriber

Thanks for the reply, just to clarify do you mean the timestep when you say time interval? As I've tried dividing by dtime instead but the resulting motion is wildly different depending on the size of the timestep I use. Giving huge angular velocities if my timestep is small.

• DrAmine
Ansys Employee
Omega vector is angular speed and not the angle vector. Probably you need to derivate it from the equations you posted.
• CameronLaw
Subscriber

I've been under the impression that dividing the angle by time at every timestep would give me the angular speed and that would inform the motion. Have I misunderstood how this macro or omega works?

• CameronLaw
Subscriber

I thought I would update this as I recently solved it. Slightly embarrassing as it is a really simple oversight on my part.

My equations gave me angle as a function of time, so obviously by differentiating them I was able to get angular velocity as a function of time.

Also as I'm writing this I've also noticed that Amine literally gave me that answer but I misunderstood at the time, so apologies about that.