CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (http://www.cfd-online.com/Forums/fluent-udf/)
-   -   UDF code (http://www.cfd-online.com/Forums/fluent-udf/105297-udf-code.html)

 yahya_azizi July 27, 2012 04:27

UDF code

1 Attachment(s)
How should I define two rotations for a moving wing?

This code only simulates the roll but when I add pitch the motion becomes completely wrong.

#include "udf.h"
#include "dynamesh_tools.h"

real w, pi, Aroll, Apitch, roll, droll, pitch, dpitch, yaw, dyaw, frequency, T;
real Ar, Ap, Ay;

DEFINE_CG_MOTION(code, dt, v_cg, omega, time, dtime)

{

NV_S(v_cg, =, 0.0);
NV_S(omega, =, 0.0);

if (!Data_Valid_P())
{
Message("Wrong\n");
return;
}

frequency = 3.0;

pi = 3.141592654;

/* define motion variables */

Ar = 30.0; /*roll amplitude*/
Ap = 5.0; /*pitch amplitude*/
Ay = 0.0; /*yaw amplitude*/

Aroll = Ar*pi/180.0; /*conversion to radians*/
Apitch = Ap*pi/180.0; /*conversion to radians*/

T=1.0/frequency;

roll = Aroll*sin(w*time + pi/2);
droll = w*Aroll*cos(w*time + pi/2);

pitch = Apitch*sin(w*time+pi/2);
dpitch = w*Apitch*cos(w*time+pi/2);

/*euler angles initial frame mod 1*/

omega[0] = droll;
omega[1] = 0;
omega[2] = 0;

Message("time:%f omegax:%f omegay:%f omegaz:%f \n", time, omega[0], omega[1],omega[2]);

}

 duri July 27, 2012 09:03

Quote:
 Originally Posted by yahya_azizi (Post 373865) droll = w*Aroll*cos(w*time + pi/2); dpitch = w*Apitch*cos(w*time+pi/2); }
I hope both droll and dpitch is droll/dt and dpitch/dt, looks to be direct differentiation. You need to use droll*dtime and dpitch*dtime to determine delta omega.
Make sure that the cg location is correct because rotation takes place about cg and not about the origin.

 yahya_azizi July 27, 2012 14:27

It still doesn't work. The problem is that when I use roll or pitch separately the wing motion is ok but when I consider both of them simultaneously the motion becomes wrong.

 santhosh kumar k August 6, 2012 07:59