CFD Online Discussion Forums

CFD Online Discussion Forums (
-   Fluent UDF and Scheme Programming (
-   -   DEFINE_CG_MOTION for flapping wing UDF (

xyzch001 December 14, 2011 09:51

DEFINE_CG_MOTION for flapping wing UDF
Hi everybody!
I'm a graduate student of mechanical engineering working at a Fluent project for my thesys. I have to write a UDF in order to give a motion law to a flapping wing. By using the UDF "DEFINE_CG_MOTION" I need to specify an angular velocity d(theta)/dt so that the oscillation angle of the flapping wing is: theta(t)=25*sin(2*pi*frequency*t+arcsin(3/5))-15
If I use the derivate d(theta)/dt=50*frequency*pi*cos(2*pi*frequency*t+arcsin(3/5)) I lose the constant "-15" so that the oscillation angle is no more from +10 deg to -40 deg. As a matter of fact the positive peak amplitude must be +10 deg and the negative one must be -40 deg.
How can I solve the problem?
Thank you so much! December 15, 2011 04:47

Hello xyh001
one point about the writing udf that i remember and i think you should be contain it, its your argument must be in radian!
sorry i don't understood clearly your problem.
i hope its be useful.

xyzch001 December 15, 2011 09:38

Hi! Thank you for your answer! Yes I already know that the argument must be in radian...I wrote the previous formula in degrees for convenience. That is not a problem...The problem is to find a trigonometric function that after being derived, gives me the desired theta(t). December 15, 2011 10:04

sorry i asked this questions , i curious about your problem!
and what's the problem with those function that you mention for theta(t) and d(theta)/dt...?
in every time-step you have t ,so you can calculate the theta and the angular velocity with those formula.

xyzch001 December 15, 2011 10:28

The problem is that when you derive theta to find the angular velocity you lose the constant, so when Fluent integrates the velocity (DEFINE_CG_MOTION requires the angular velocity, not the angle(t)) it loses the constant "-15", giving the symmetrical function 25*sin(2*pi*frequency*t+arcsin(3/5)). But unfortunately I want an asymmetrical function ranging from +10deg to -40deg. December 15, 2011 13:15

you can use this function:
arcsin(3/6)=30 deg;
then you got theta=10 deg in t= 0 sec and theta=-40 deg in t=0.33 sec
with time-step=0.0001 sec.
if your flap in your grid have theta=10 deg you haven't problem, but if your flap have theta= 0 deg in t=0 in your grid you must first use cg-motion with diffrent function as udf to move your flap to 10 degree without solve the flow equation just use the Grid motion in Solve panel and then when your flap got the 10 deg use udf with this function to move your flap to -40 deg and solve the equation.
i hope its useful.

xyzch001 December 15, 2011 14:14

Hi! If I use your function I get +33.13 deg for t=0 and -33.13 deg for t=0.33. What am I doing wrong? Anyway the frequency f of the flapping is 6. Thank you December 16, 2011 05:40

ok! with f=6 for your flap ; use same function with different coefficient!
this gave you theta=10 at t=0 and theta=40 at t=2.7662, be sure its true.
you can plot your function in so many software such as MATLAB. and you can see how your function behave with different t or f or other coefficient. that's easy.

xyzch001 December 16, 2011 05:57

Yes it works! you're great man! but my flap is theta=0 for t=0 how can I solve the problem? How can I use the "grid motion"? thanks a lot!! December 16, 2011 06:45

in this case you must move your flap smoothly to theta=10 deg with different function and UDF with Cg-motion macro , without solve the flow equation. that's means you must hook your cg-motion UDF with for example this function to move the flap.
hook the UDF with this function and then go to the solve> mesh motion in FLUENT,with time-step=0.0001 in 0.01 sec your flap got 10 deg and then unload your UDF and load the second UDF with previous function to move flap in 10 deg to -40 deg.
if you do this your grid maybe change badly and you got bad quality it's depended how small your time-step is.
you have second choice to have 10 deg in t=0 sec.
you can change your geometry with theta=10 for flap and mesh it again.
its depend your self to choice one of this solution for your flap got 10 deg in t=0.
your welcome.

xyzch001 December 18, 2011 15:45

Finally I found the solution: this is the function that gives me the desired flapping angles: theta[t] = 0.8409*sin(w*t - 0.2563) + 0.6643*cos(w*t + 0.7741) - 0.000001868*Sin(0.7629*w*t + 0.1884) +0.3773*cos(-0.000002463*w*t + 2.338)
It has no constants so that, when I derive it to find the omega[t] and then Fluent integrates it,Fluent gets back the original theta[t]. I used Matlab "Curve fitting toolbox" to find this function by interpolation of many points.
Anyway thank you for your help!

sanjay January 12, 2012 00:10

can this be simulated in STAR CCM+ ??:rolleyes:

xyzch001 January 12, 2012 06:48

Hi, I don't know STAR CCM+, but I think you can do it.

imbaasat March 30, 2012 11:46

for flapping wing, following is required:

1. use GRID_MOTION instead of CG_MOTION.
2. use sinusoidal function with temporal effect.
3. make one & half wave in wing span direction.

hippiekyle June 20, 2012 12:35


Originally Posted by imbaasat (Post 352346)
for flapping wing, following is required:

1. use GRID_MOTION instead of CG_MOTION.
2. use sinusoidal function with temporal effect.
3. make one & half wave in wing span direction.

What's the difference between GRID_MOTION and CG_MOTION ? June 21, 2012 10:40


Originally Posted by hippiekyle (Post 367490)
What's the difference between GRID_MOTION and CG_MOTION ?

GRID_MOTION used for non-rigid object but CG_MOTION used for move the rigid center of gravity object.

hippiekyle June 21, 2012 11:37

I made a fin I want to flap by subtracting the volume from the domain. So it's not an actual volume. More of a void with no slip boundary conditions. Since it has no volume, I should use GRID_MOTION? Or should I remake the the fin with a volume? I want it to be rigid, but I'm not taking gravity into account.

Amit soni September 1, 2015 06:48

DEFINE_CG_MOTION for flapping flight
I am doing flapping wing motion in 3-d but I am not able to see the wings flapping after simulation. I am using this udf code
#include "udf.h"
DEFINE_CG_MOTION(wing_mov , dt , vel , omega ,time , dtime)

omega[0] = 3*cos(1.2*time);
omega[1] = 0;
omega[2] = 0;

would suggest if something I have to define in code and how to give the dynamic meshing boundary condition.

I used this condition.

arunraj May 14, 2016 14:23

curve fitting
Hi everyone,

Can somebody please tell me how to write omega[2] equation for asymmetric function. The angles are in degree but in fluent it will be implemented in radians.


If we differentiate this function the constant would be zero which is not correct. Pleas let me know how to include this 30 degree. Its bit confusing as there is no explanation.

or is it easy to keep my aerfoil initially at 30 degree. But I am not sure whether i have keep in clockwise or anticlockwise.

arunraj May 14, 2016 14:34

Hi all,

I understood the logic now. Basically we have convert a sin curve which has constant into another sin curve without constant by adding phase difference. I doesnt seem to be a easy task. What is the best way to do this.

All times are GMT -4. The time now is 02:20.