Enclosure A: User Defined Functions For ANSYS Fluent Define - Sdof - Properties
Enclosure A: User Defined Functions For ANSYS Fluent Define - Sdof - Properties
Enclosure A: User Defined Functions For ANSYS Fluent Define - Sdof - Properties
DEFINE_SDOF_PROPERTIES
# include " udf . h "
DEFINE_CG_MOTION
Rotational Motion
Translational Motion
if ( time < t1 ) {
vel [0] = a * time ;
}
else if ( time > t1 && time <= t2 ) {
i
vel [0] = u ;
}
else if ( time > t2 && time <= t3 ) {
vel [0] = u - a *( time - t2 ) ;
}
else {
vel [0]=0;
}
}
DEFINE_EXECUTE_AT_END
// UDF extracting the viscous and pressure forces in the x - and y - direction
as well as the location of the centre of pressure
D EF IN E _E XE CUTE_AT_END ( save_results_udf )
{
FILE * fp = NULL ;
FILE * fp2 = NULL ;
char filename []= " force_history . txt " ;
real flow_time = RP_Get_Real ( " flow - time " ) ;
double NV_VEC ( viscous ) ;
double NV_VEC ( pressure ) ;
double NV_VEC ( force ) ;
double NV_VEC ( total_force ) ;
double area = 0.;
double NV_VEC ( A ) ;
double NV_VEC ( Wall_Shear_Force ) ;
double num_y = 0.;
double num_x = 0.;
double den_x = 0.;
double den_y = 0.;
double NV_VEC ( cp ) ;
real x [ ND_ND ];
int IDplate = 18; // Plate ID
face_t f ;
Thread * f_thread ;
Domain * d ;
begin_f_loop (f , f_thread )
// loop through the faces on the plate
{
F_AREA (A ,f , f_thread ) ;
// calculate the area of the current face
F_CENTROID (x ,f , f_thread ) ;
// calculate the centre point of the current face
Wall_Shear_Force [0] = - F_STORAGE_R_N3V (f , f_thread ,
SV_WALL_SHEAR ) [0];
// wall shear stress in the x - direction for current face
Wall_Shear_Force [1] = - F_STORAGE_R_N3V (f , f_thread ,
SV_WALL_SHEAR ) [1];
// wall shear stress in the x - direction for current face
Revised Model
% %%%%%%% Revised 2 D model of a flat plate in free fall . %%%%%%%%
clc ; clear all ; close all % clear command windows , workspace and figures
v
w = [0 0]; % velocity of fluid surround the plate [ m / s ]
v = w-u; % initial relative fluid velocity [ m / s ]
theta = -30* pi /180; % initial orientational angle [ deg ]
omega = 0; % initial angular velocity of plate [ rad / s ]
domega = 0; % initial angular acceleration of plate [ rad / s ]
dalpha_dt = 0; % intial change in angle of attack [ rad / s ]
% INITIAL CALCULATIONS
phi = atan ( v (2) / v (1) ) ; % relative fluid velocity angle [ m / s ]
alpha = 2* c1 / pi * atan ( cot ( pi / c2 * theta - pi /2 - phi ) ) ;
% angle of attack [ rad ]
CD_unsteady = ( pi / a2 + CD0 ) - CD0 / a2 * cos ( a1 * abs ( alpha ) + pi /2) .^2 - CD90 /...
a2 * sin ( a1 * abs ( alpha ) + pi /2) .^6; % approx of unsteady drag
CD_steady = CD0 + abs (( CD90 - CD0 ) * sin ( alpha ) .^3) ;
% steady drag
if CD_steady < CD_unsteady
CD = CD_unsteady ; % use unsteady drag coefficient
else
CD = CD_steady ; % use steady drag coefficient
end
dalpha_dt_rounded = round ( abs ( dalpha_dt ) *180/ pi /5) *5;
% round dalpha / dt
dalpha_dt_vec_index = find ( dalpha_dt_matrix == dalpha_dt_rounded ) ;
% find index of nearest ang . vel .
if isempty ( dalpha_dt_vec_index ) == 1
dalpha_dt_vec_index = 11; % limit dalpha / dt to 90 deg / s
end
%%
toc
coefficient_matrix.mat
alpha_start_matrix.mat
alpha_start_matrix = [0 1.6 3.2 9.0 7.5 9.0 11.0 13.0 14.0 15.0 17.0 18.0
18.0 20.0 20.0 21.0 24.5 25.6 25.0];
alpha_end_matrix.mat
alpha_end_matrix = [0 12.0 15.7 18.9 21.8 24.7 27.6 30.6 33.7 36.8 39.8
42.7 45.3 47.6 49.7 52.7 55.0 57.8 61.0];
Enclosure C
k =1;
for theta = - pi /2 : pi /32 : pi /2
T = [ cos ( theta ) sin ( theta ) ; - sin ( theta ) cos ( theta ) ];
% Transformation matrix [ -]
g = 9.81; % Gravitational acceleration [ m / s ^2]
rho_f = 998.2; % Density of fluid [ kg / m ^3]
pos = [0 -1]; % Position of plate [ m ]
P0 = 100000; % Reference pressure [ Pa ]
endplate_low = [1/2* L * cos ( theta ) + pos (1) 1/2* L * sin ( theta ) + pos (2) ];
% Position of midpoint of small edge of plates
endplate_high = [ -1/2* L * cos ( theta ) + pos (1) -1/2* L * sin ( theta ) + pos (2) ];
% Position of midpoint of small edge of plate
vec = [ -1/2* h * sin ( theta ) 1/2* h * cos ( theta ) ];
% Vector from midpoint to corner
corner (1 ,:) = endplate_high + vec ; % Location of 1 st corner
corner (2 ,:) = endplate_low + vec ; % Location of 2 nd corner
corner (3 ,:) = endplate_low - vec ; % Location of 3 rd corner
corner (4 ,:) = endplate_high - vec ; % Location of 4 th corner
xi
corner
y = corner (i ,2) ; %y - position of current
corner
if i ==1 || i ==3
dx = L / n ; % Cell length
X = L; % Length of edge
else
dx = h / n ; % Cell length
X = h; % Length of edge
end
if i == 1 || i == 3
num_x = num_x + pos_point_local (1) * Fp_local (2) ;
% Numerator in cpx
den_x = den_x + Fp_local (2) ; % Denominator in cpx
num_y = 0; % Numerator in cpy
den_y = 0; % Denominator in cpy
else
num_x = 0; % Numerator in cpx
den_x = 0; % Denominator in cpx
num_y = num_y + pos_point_local (2) * Fp_local (1) ;
% Numerator in cpy
den_y = den_y + Fp_local (1) ; % Denominator in cpy
end
Fp_vec (i ,:) = Fp ; % Save force vector
end
cp (i ,:) = [ num_x / den_x num_y / den_y ]; % Calculate cp
end
cp ( isnan ( cp ) ) = 0;
cp_vec ( k ) = sum ( cp (: ,1) ) /4;
theta_vec ( k ) = theta ;
k = k +1;
end
plot ( theta_vec *180/ pi , cp_vec /L , k ) ; hold on ;
xlim ([ -90 90])
set ( gca , xtick , -90:15:90)