//aoavane.sce Rev 1
//www.basicairdata.eu 2013 (c) JLJ
//Example file for angle of attack mechanical vane preliminary design
//Main reference article J. Wieringa (1967),Evaluation and Design of Wind Vanes, Royal Netherlands Meteorological Institute, De Bilt 
//basicairdata blogspot
clear;
//Initialitation section
//Physical parameters
rv=0.6;//[m]Aerodynamic arm effective lenght
rwdivrv=0.25; //Ratio of counterweight center of gravity (cog) distance and fin aerodinamic center cog distance 
rw=rv*rwdivrv; //[m]Countergeight distance from shaft
mv=8e-3;//8e-3 Initial value.Windvane weight[kg]
uv=21;// 21 Experimental value . Weight to fin area ratio
S=mv/uv; //Calculated fin surface
J=mv*rv^2*(1+rwdivrv)  //Intertia of vane
//Aerodynamic parameters
rho=1.225;//[kg/m^3] Standard condition air density
av=6.28;//Torque parameter , brutal approximation for small angles, of course yield in early design phase . Flat plate airfoil assumed, 
u=30; //[m/s] Relative wind speed
//Effect due to finite fin neglected
L=0.05;  //decay distance raio 
alfamin=0.1/360*6.28;//Minimun desired readable angle
//Friction parameter
Dm=20e-6;//[Nms/rad] For a single bearing this value that should be taken from bearing producer d/s or site

q=0.5*rho*u^2; //Dynamic pressure Pa
Fvdivbeta=6.28*q*S;//[N/rad]
N=rv*Fvdivbeta;//[Nm/rad] Windvane torque coef.
D=rv*N/u; //[Nm/rad s]Aerodynamic damping
D0=(N*4*J)^0.5; //   
//Undamped oscillation period
wn=(N/J)^0.5;//[Nm/m^2/kg] [N/m/kg] [kg*m/s^2] [1/s^2] [1/s]  
wd=((N/J)-(D/2/J)^2)^0.5 ;   
zeta=rv*N/u/D0; //Classical defined damping of the system
wdsecond=wn*(1-zeta^2)^0.5; //Redundant calculation, following classical parameter definition
Kv=av/(uv*(1+rwdivrv))//Vane quality factor
zetadamping=(0.63*Dm*Kv^0.5)/(u*av*S*rv^1.5);//Damping contribution due to friction on the shaft
//Stick to the reference
zetar=0.395*rho/1.25*(av*rv^3*S/J)^0.5;
utl=7.37*log(1/L)*J/(av*rv^2*S)//[m] Decay distance
printf("Vane parameters\n")
printf("Windvane weight grams %.2f\n",mv*1e3)
printf("rv lenght %.2f mm\n",rv*1e3)
printf("rw lenght %.2f mm\n\n",rv*rwdivrv*1e3)

printf("Vane calculated parameters\n")
printf("Fin surface %.2f mm^2\n",S*1e6)
printf("Vane inertia %f kgm^2\n",J)
printf("Natural frequency %.2f rad/s\n",wn)
printf("Damped frequency %.2f rad/S \n",wd)
printf("Damping ratio zeta %.3f\n",zetar)
printf("Decay distance %.1f [m]\n\n",utl)

printf("Shaft at test condition with no friction\n")
printf("Relative wind speed  %.2f m/s\n",u)
printf("Alfa value  %.2f degrees\n",alfamin/6.28*360)
printf("Aerodynamic Torque %.2e Nm \n\n",N*alfamin)

printf("Shaft at test condition with viscous friction\n")
printf("Viscous friction term Dm %.3e Nms/rad\n",Dm)
printf("Damping ratio increase due to viscous friction %.3f \n",zetadamping)

printf("Total damping ratio %.3f\n",zetar+zetadamping)






