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/)
-   -   Fluent UDF Mesh Motion Issue: Blade Pitch w/ Respect to Azimuth Angle (https://www.cfd-online.com/Forums/fluent-udf/251155-fluent-udf-mesh-motion-issue-blade-pitch-w-respect-azimuth-angle.html)

recmvp July 30, 2023 15:50

Fluent UDF Mesh Motion Issue: Blade Pitch w/ Respect to Azimuth Angle
 
3 Attachment(s)
Hello all,

I'm trying to write a UDF to orient the blade angle of each VAWT blade based on its azimuth angle around the central axis. The code snippets that are included do not let me apply the UDF to the mesh motion of the blade fluid zone (cell zone conditions -> fluid -> blade1_fluid_zone -> mesh motion). I have included an image of the mesh setup. I have tried both DEFINE_CG_MOTION and DEFINE_GRID_MOTION with no success at this point.

I have run this simulation in the past with mesh motion working, but have never used a UDF to implement the blade rotation. What has worked in the past for me is having the fluid zone, which encompasses the 4 blades fluid zones as well, rotate at the prescribed VAWT RPM. For fixed blade operation this is fine. I have also been able to rotate the individual blades, allowing for the constant angle of attacks for 90 degrees of azimuth angle rotation. Now I am struggling to implement a udf that will set the angle of the blade's fluid zone based on its azimuth angle.

Please let me know if you need any more additional information. UDF's are a rather new tool to me, but I will try my best to understand and learn from any suggestions you have.

I have also included a video of the 90 degrees of VAWT rotation that had the blades orienting themselves. This is what I am trying to do for 360+ degrees of rotation.


Here is the code for the grid motion function

#include "udf.h"

DEFINE_GRID_MOTION(test_blade_rotation, domain, dt, time, dtime)
{
real angle;
real pi = 3.14159265358979323846;
real azimuth_angle;
real central_axis_angle;
real blade_angle_offset = 10.0; // Adjust this value as per your turbine configuration
real xc, yc, r, theta;

/* Get the current simulation time */
real current_time = time + dtime;

/* Get the azimuth angle relative to the turbine central axis */
central_axis_angle = 360.0 * current_time; // Adjust if the central axis rotates with time

Thread *t;
face_t f;
Node *v;

/* Loop over all cell zones representing individual blades */
thread_loop_c(t, domain)
{
/* Calculate the azimuth angle of the cell zone relative to the turbine central axis */
azimuth_angle = central_axis_angle + THREAD_ID(t) * 90.0;

if (azimuth_angle >= 360.0)
azimuth_angle -= 360.0;

/* Calculate the blade angle for each cell zone */
angle = azimuth_angle + blade_angle_offset;

/* Ensure that the blade angle is within [0, 360) degrees */
if (angle >= 360.0)
angle -= 360.0;

/* Loop over all faces in the current cell zone */
begin_f_loop(f, t)
{
f_node_loop(f, t, v)
{
xc = NODE_X(v);
yc = NODE_Y(v);

/* Calculate the distance from the central axis */
r = sqrt(xc * xc + yc * yc);

/* Calculate the angle (theta) of the node relative to the central axis */
theta = atan2(yc, xc) * 180.0 / pi;

/* Calculate the local blade angle for the node */
real local_blade_angle = angle + theta;

/* Ensure that the local blade angle is within [0, 360) degrees */
if (local_blade_angle >= 360.0)
local_blade_angle -= 360.0;

/* Rotate the node position based on the local blade angle */
real new_x = r * cos(local_blade_angle * pi / 180.0);
real new_y = r * sin(local_blade_angle * pi / 180.0);

/* Update the node position */
NODE_X(v) = new_x;
NODE_Y(v) = new_y;
}
}
end_f_loop(f, t)
}
}

Here is my less developed, more just a last-ditch effort CG motion

#include "udf.h"

DEFINE_CG_MOTION(rotating_blades, dt, vel, omega, time, dtime)
{
real theta; // Blade angle relative to the global central axis
real omega_blade; // Blade angular velocity
real theta_global; // Global central axis angle
real theta_local; // Blade angle relative to its local axis

Thread *t;
cell_t c;

// Specify the global central axis angle (e.g., based on the wind direction)
theta_global = 10.0; // Modify this value as needed

// Specify the blade angular velocity (e.g., based on wind speed and turbine design)
omega_blade = 157.08; // Modify this value as needed

// Loop over all cell threads (assuming blades are in separate threads)
thread_loop_c (t, dt)
{
// Get the thread-specific blade angle relative to the global central axis
theta = theta_global + omega_blade * time;

// Loop over all cells in the current thread
begin_c_loop(c, t)
{
// Calculate the blade angle relative to the local axis for the current cell
// Assuming the local axis of the blade is aligned with the z-axis (adjust as needed)
theta_local = theta - C_Y(c) * RAD_TO_DEG; // Assuming blade orientation along the Y-coordinate

// Rotate the cell around its local axis based on the calculated angle
C_ROT(c, C_R(c), C_P(c), C_Y(c), theta_local);
}
end_c_loop(c, t)
}
}


All times are GMT -4. The time now is 05:46.