CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (https://www.cfd-online.com/Forums/fluent-udf/)
-   -   rotating and pitching UDF - need someone to double-check this (https://www.cfd-online.com/Forums/fluent-udf/131078-rotating-pitching-udf-need-someone-double-check.html)

daysley March 8, 2014 11:00

rotating and pitching UDF - need someone to double-check this
 
1 Attachment(s)
Hi everyone,

I'm looking to simulate a turbine (see attached pic) with airfoils that rotate about an axis and change angle of attack at the same time (in a sinusoidal sense). Currently i have three zones, the large stationary zone, the rotating turbine zone and then the airfoil zones. i thought if i set the turbine zone rotating at x rad/s and then set up a udf motion for the airfoil zone relative to the turbine zone it would allow me to change the angle of attack whilst rotating? however this doenst happen, so i wanted to know whether im using the correct udf macro? should i be using DEFINE_CG_MOTION() i.e. dynamic zone? or is my code wrong?

here is what i have as my code:

Code:


#include "udf.h"
 
DEFINE_ZONE_MOTION(sine_motion,omega,axis,origin,velocity,time,dtime)
{
    real posx, posy, rad, angle, angvel, pi;
   
   
    rad = 0.4572;
    pi = 3.141592654;
    angvel = 10;

        angle = angvel * time * (180 / pi );
        *omega = cos(10 * time);
        posx = rad * cos(angle);

/*where posx and posy are the position of the airfoils rotational origin as the turbine rotates*/

        posy = rad * sin(angle);
   
        origin = (posx, posy, 0);
       

    return;
}

what i aim for this to do is "flap" the airfoil about its quarter chord, whilst rotating around a fixed global axis. so i thought the "origin = (posx, posy, 0);" would allow the rotation origin to change as the mesh rotated but it doesnt?


thanks in advance for the help :)

mahditorabiasr March 17, 2014 07:43

Re: Rotating and Pitching UDF
 
Here It is a UDF for simultaneous Rotating and Pitching.
be noticed that the UDF should be set for the blades (considering initial angular its position)
and the "Releative specification" option should be set to the rotor's rotating frame.



#include "udf.h"

DEFINE_ZONE_MOTION(pitching_blade,omega,axis,origi n,velocity,time,dtime)
{
real theta0, thetap1, omegac, omegar, radius, pi;

pi = 3.141592654;
omegar = 10;
/* pitching velocity of blade [radians/s] */
omegac = 5;
/* angular velocity of rotor [radians/s] */
theta0 = pi/2.; /* initial angular position of blade origin [radians] */
radius = .5; /* radius of rotor [m] */
thetap1 = omegac*(time+dtime); /* angular change from initial position at t+dt */
*omega = omegar; /*
pitching velocity of blade */

/* time-varying origin of the local rotor zone coordinates in meters */
origin[0] =
radius*cos(theta0+thetap1);
origin[1] =
radius*sin(theta0+thetap1);
origin[2] = 0.0;
}



In your case *omega variable should represent the sinusoidal time function.

daysley April 7, 2014 17:16

Thank you mahditorabiasr

I will try this method now so thanks in advance

mahditorabiasr April 8, 2014 00:06

Welcome daysley,
please let me know if I can be of any further help.

daysley April 12, 2014 13:18

Quote:

Originally Posted by mahditorabiasr (Post 484543)
Welcome daysley,
please let me know if I can be of any further help.

Hi Mahditorabiasr

I've been playing around with the udf you wrote but i'm having some problems when running it in Ansys. as the turbine rotor rotates, the blades rotate away from their position in the mesh as though the changing origin is incorrectly changing? I don't suppose you have any idea why it would do this do you? everything seems right in the code and the motion is set relative to the rotating zone?

does it have anything to do with the line:

Code:

thetap1 = omegac * (time + dtime)
i dont understand why it is time +dtime?

thanks in advance i've attached my altered code all i have changed is the Pi function and radius etc. :)

Code:

#include "udf.h"

DEFINE_ZONE_MOTION(pitching_blade,omega,axis,origi n,velocity,time,dtime)
{
real theta0, thetap1, omegac, omegar, radius, pi;

omegar = sin(time) /* arbitrary sine function*/
omegac = 10.94 ; /* pitching velocity of blade [radians/s] */
theta0 = M_PI/2.; /* initial angular position of blade origin [radians] */
radius = .4572; /* radius of rotor */
thetap1 = omegac*(time+dtime); /* angular change from initial position at t+dt */
*omega = omegar; /* pitching velocity of blade */

/* time-varying origin of the local rotor zone coordinates in meters */
origin[0] = radius*cos(theta0+thetap1);
origin[1] = radius*sin(theta0+thetap1);
origin[2] = 0.0;
}


mahditorabiasr April 15, 2014 11:58

Quote:

Originally Posted by daysley (Post 485707)
Hi Mahditorabiasr

I've been playing around with the udf you wrote but i'm having some problems when running it in Ansys. as the turbine rotor rotates, the blades rotate away from their position in the mesh as though the changing origin is incorrectly changing? I don't suppose you have any idea why it would do this do you? everything seems right in the code and the motion is set relative to the rotating zone?

does it have anything to do with the line:

Code:

thetap1 = omegac * (time + dtime)
i dont understand why it is time +dtime?

thanks in advance i've attached my altered code all i have changed is the Pi function and radius etc. :)

Code:

#include "udf.h"

DEFINE_ZONE_MOTION(pitching_blade,omega,axis,origi n,velocity,time,dtime)
{
real theta0, thetap1, omegac, omegar, radius, pi;

omegar = sin(time) /* arbitrary sine function*/
omegac = 10.94 ; /* pitching velocity of blade [radians/s] */
theta0 = M_PI/2.; /* initial angular position of blade origin [radians] */
radius = .4572; /* radius of rotor */
thetap1 = omegac*(time+dtime); /* angular change from initial position at t+dt */
*omega = omegar; /* pitching velocity of blade */

/* time-varying origin of the local rotor zone coordinates in meters */
origin[0] = radius*cos(theta0+thetap1);
origin[1] = radius*sin(theta0+thetap1);
origin[2] = 0.0;
}


Dear Daysle,
Sorry for late reply.

let me ask whether you have defined separated UDFs or not?
Be sure that you have a UDF for each blade including initial angular position for each ("theta0").
In addition any little difference from the real values in your initial mesh can lead to incorrect position.

Answering your question, "thetap1" returns the angular position in next time step("dtime" is equal to time step which you have set in Fluent).
Code:

thetap1 = omegac*(time+dtime)

airbus January 9, 2015 21:44

Hello everyone
I'm working on incompressible unsteady force measurement of two-dimensional naca0012 under pitch-up, hold and pitch-down motion at a constant velocity about 50 m/s

Recently I examined the model in static mode at various AOA in Fluent , but i've a problem for write a correct""UDF"" for Dynamic mode test

I'll so grateful to help me for doing this part
Thank you

davd4696@gmail.com November 1, 2016 04:42

Hi folks, I know this is a relatively old thread but I also want to run a model with pitch controlled blades and this was the only thread I could find in relation to it, I am not very firmilar with C programming language so I wanted to use the UDf you have written (below) to form the basis of my own. however when I copy and paste the udf into NOtepad++ and save as .c and try intrepret it in fluent 14.5 I get the following error message
Error: C:\\Users\\User\\Desktop\\UDF\\pitching_blade.c: line 8: parse error.
Could comeone explain with this error is relation to, I believe it is to do with defining the constant but I am not sure thanks.


#include "udf.h"

DEFINE_ZONE_MOTION(pitching_blade,omega,axis,origi n,velocity,time,dtime)
{
real theta0, thetap1, omegac, omegar, radius, pi;

omegar = sin(time) /* arbitrary sine function*/
omegac = 10.94; /* pitching velocity of blade [radians/s] */
theta0 = M_PI/2.0; /* initial angular position of blade origin [radians] */
radius = 0.4572; /* radius of rotor */
thetap1 = omegac*(time+dtime); /* angular change from initial position at t+dt */
*omega = omegar; /* pitching velocity of blade */

/* time-varying origin of the local rotor zone coordinates in meters */
origin[0] = radius*cos(theta0+thetap1);
origin[1] = radius*sin(theta0+thetap1);
origin[2] = 0.0;
}

RAJU REDDY November 20, 2016 04:33

Quote:

Originally Posted by davd4696@gmail.com (Post 623665)
Hi folks, I know this is a relatively old thread but I also want to run a model with pitch controlled blades and this was the only thread I could find in relation to it, I am not very firmilar with C programming language so I wanted to use the UDf you have written (below) to form the basis of my own. however when I copy and paste the udf into NOtepad++ and save as .c and try intrepret it in fluent 14.5 I get the following error message
Error: C:\\Users\\User\\Desktop\\UDF\\pitching_blade.c: line 8: parse error.
Could comeone explain with this error is relation to, I believe it is to do with defining the constant but I am not sure thanks.


#include "udf.h"

DEFINE_ZONE_MOTION(pitching_blade,omega,axis,origi n,velocity,time,dtime)
{
real theta0, thetap1, omegac, omegar, radius, pi;

omegar = sin(time) /* arbitrary sine function*/
omegac = 10.94; /* pitching velocity of blade [radians/s] */
theta0 = M_PI/2.0; /* initial angular position of blade origin [radians] */
radius = 0.4572; /* radius of rotor */
thetap1 = omegac*(time+dtime); /* angular change from initial position at t+dt */
*omega = omegar; /* pitching velocity of blade */

/* time-varying origin of the local rotor zone coordinates in meters */
origin[0] = radius*cos(theta0+thetap1);
origin[1] = radius*sin(theta0+thetap1);
origin[2] = 0.0;
}

Hii!! Glynn,
Define 'pi' value first and don't include dtime in thetap1 and define the axis of rotation as
N3V_D(axis,=,radius*cos(theta0+thetap1),radius*sin (theta0+thetap1),1.0);
I hope this will solve your problem.If you need anything more just let me know.Thank you
Try this code:
DEFINE_ZONE_MOTION(pitching_blade,omega,axis,origi n,velocity,time,dtime)
{
real theta0, thetap1, omegac, omegar, radius, pi;
pi=3.14
omegar = sin(time) /* arbitrary sine function*/
omegac = 10.94; /* pitching velocity of blade [radians/s] */
theta0 = pi/2.0; /* initial angular position of blade origin [radians] */
radius = 0.4572; /* radius of rotor */
thetap1 = omegac*(time);
/* time-varying origin of the local rotor zone coordinates in meters */
origin[0] = radius*cos(theta0+thetap1);
origin[1] = radius*sin(theta0+thetap1);
origin[2] = 0.0;
N3V_D(axis,=,radius*cos(theta0+thetap1),radius*sin (theta0+thetap1),1.0);
*omega = omegar; /* pitching velocity of blade */
}

classified November 23, 2016 01:45

Rgarding rolling motion of tank
 
1 Attachment(s)
Hi...
I am working on a problem which involves a half filled tank and which is under rolling motion. I had set a VOF model for 2 phases ( Water and air).
For applying rolling motion I wrote a udf as follows:
************************************************** ***************
#include "udf.h"
#include "dynamesh_tools.h"
DEFINE_ZONE_MOTION (oscillation, omega, axis, origin, velocity, time, dtime)
{
*omega=(0.3323*cos(3.81*time)); //here 3.81 is frequency of rotation
return;
}
************************************************** **************
After that this i interpreted this udf in ansys fluent
Then I choosed for cell zone condition on fluent window and surface body under zone selection box. then to this "surface body" zone i ticked on mesh motion and hooked the above udf.
but the results are not satisfactory...
PLEASE TELL ME WHETHER MY APPROACH IS RIGHT?
OR IF WRONG THE HOW CAN I GIVE ROLLING MOTION TO TANK..
I AM A NEW USER SO HAVING A BIT OF KNOWLEDGE.


Thanks in advance



edit : I am verifying the result with pressure measurement at a point and comparing with available literature. For measuring pressure I had used 'point' under 'surface'

Farhan Khan November 10, 2018 05:12

Blade motion on Cycloidal path
 
Hi,
Can anybody please help me ?
I am writing a udf for individual blade motion on sine wave like path. I have tried different udfs posted on cfdonline but none of them work. For all, the error remains same; which is; the blades moves away from rotor while turbine rotates.
Please help me in this.

JW0202 September 11, 2022 06:30

UDF for rotation and pitch angle
 
Quote:

Originally Posted by davd4696@gmail.com (Post 623665)
Hi folks, I know this is a relatively old thread but I also want to run a model with pitch controlled blades and this was the only thread I could find in relation to it, I am not very firmilar with C programming language so I wanted to use the UDf you have written (below) to form the basis of my own. however when I copy and paste the udf into NOtepad++ and save as .c and try intrepret it in fluent 14.5 I get the following error message
Error: C:\\Users\\User\\Desktop\\UDF\\pitching_blade.c: line 8: parse error.
Could comeone explain with this error is relation to, I believe it is to do with defining the constant but I am not sure thanks.


#include "udf.h"

DEFINE_ZONE_MOTION(pitching_blade,omega,axis,origi n,velocity,time,dtime)
{
real theta0, thetap1, omegac, omegar, radius, pi;

omegar = sin(time) /* arbitrary sine function*/
omegac = 10.94; /* pitching velocity of blade [radians/s] */
theta0 = M_PI/2.0; /* initial angular position of blade origin [radians] */
radius = 0.4572; /* radius of rotor */
thetap1 = omegac*(time+dtime); /* angular change from initial position at t+dt */
*omega = omegar; /* pitching velocity of blade */

/* time-varying origin of the local rotor zone coordinates in meters */
origin[0] = radius*cos(theta0+thetap1);
origin[1] = radius*sin(theta0+thetap1);
origin[2] = 0.0;
}

Dear you need to define value of PI first as 3.14

JW0202 September 11, 2022 06:38

Udf
 
2 Attachment(s)
Quote:

Originally Posted by mahditorabiasr (Post 480451)
Here It is a UDF for simultaneous Rotating and Pitching.
be noticed that the UDF should be set for the blades (considering initial angular its position)
and the "Releative specification" option should be set to the rotor's rotating frame.



#include "udf.h"

DEFINE_ZONE_MOTION(pitching_blade,omega,axis,origi n,velocity,time,dtime)
{
real theta0, thetap1, omegac, omegar, radius, pi;

pi = 3.141592654;
omegar = 10;
/* pitching velocity of blade [radians/s] */
omegac = 5;
/* angular velocity of rotor [radians/s] */
theta0 = pi/2.; /* initial angular position of blade origin [radians] */
radius = .5; /* radius of rotor [m] */
thetap1 = omegac*(time+dtime); /* angular change from initial position at t+dt */
*omega = omegar; /*
pitching velocity of blade */

/* time-varying origin of the local rotor zone coordinates in meters */
origin[0] =
radius*cos(theta0+thetap1);
origin[1] =
radius*sin(theta0+thetap1);
origin[2] = 0.0;
}



In your case *omega variable should represent the sinusoidal time function.

Hello all,
I have used same format to simulate pitch movement of blade. My udf is as follows.


#include "udf.h"

DEFINE_ZONE_MOTION(pitching_blade,omega,axis,origi n,velocity,time,dtime)
{
real theta0, thetap1, omegac, radius, pi, tme, ea;

pi = 22/7;
/*omegar = 1; /* pitching velocity of blade [radians/s] */
omegac = 0.3; /* angular velocity of rotor [radians/s] */
theta0 = 0; /* initial angular position of blade origin [radians] */
radius = 0.335; /* radius of rotor [m] */
tme = pi/omegac; /*time to reach or cover 180 degrees of rotation [radian/s]*/
ea = 20*2*pi/180; /*since our function is -20sintheta, so this extreme angles would be twice of that value [radians]*/
thetap1 = omegac*(time+dtime); /* angular change from initial position at t+dt */
*omega = (ea/tme)*((-sin(theta0+thetap1))/(fabs(sin(theta0+thetap1)))); /* pitching velocity of blade */

/* time-varying origin of the local rotor zone coordinates in meters */
origin[0] = radius*cos(theta0+thetap1);
origin[1] = radius*sin(theta0+thetap1);
origin[2] = 0.0;
}

I am getting my movement right but problem is that pitching zone origin is not right. It leaves its position during rotation. Video of simulation is attached. Any help would be appreciated.

rdhkpatel September 11, 2022 11:04

What does rigid body orientation mean
 
how orientation angle is calculated in fluent dynamic meshing setup?


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