% Calc for current force on a surface of changing area. 
% 
% This is based on the needs for FOCE "windmill" over a range of current
% 
% copyright (c) 2004 by W.J.Kirkwood of MBARI
% November 23, 2004
% Last Modified 11/23/04
%
% ///////////// ASSUME ALL CALCS IN CM-SEC \\\\\\\\\\\\\\\\\
% 
%clean up from last activity 
clear all ; clf;
%
% Input of ranges for calc including current and area 
% (For the purposes of this calc these are fixed in code - upgrade for user
% input planned in future version) 
%
Current = 1:1:50 ;
Area = 2:5:100; 
Cd = .4:.1:1.5;
%
% generate the algorithms for varying current forces 
% formula based on F = 1/2 V**2 rho Cd A 
% Three different calcs are required to characterize the possibilities
% for the variosu options: Area changes, Drag chnages, and Velocty chgs 
% along with combinations of each.
%
% set seawater density
rho = 1.165;
%
% Loops with answers for each variation 
% 
% Area = 5 and Current fixed = 10 
Area_fixed = 5;
Current_fixed = 10;
Force_C = .5 * rho * Area_fixed * ( Current_fixed ^ 2 ) .* Cd;
%
% Cd = 1 and Current fixed = 10 
Drag_fixed = 1;
Current_fixed2 = 10;
Force_A = .5 * rho * Drag_fixed* ( Current_fixed2 ^ 2 ) .* Area;
%
% Cd = 1 and Area fixed = 5 
Drag_fixed2 = 1;
Area_fixed2 = 10;
Force_V = .5 * rho * Drag_fixed2 * Area_fixed2 .* ( Current .^ 2 ) ;  
%
% plots
figure(1)
subplot(111),plot(Cd,Force_C),ylabel('F C_d')
figure(2)
subplot(221),plot(Cd,Force_C),ylabel('F C_d')
subplot(222),plot(Area,Force_A),ylabel('F Area')
subplot(223),plot(Current,Force_V),ylabel('F Velocity');
%
% 3 dimensional effects of variables
%
% Cd = 1 
Drag_fixed2 = 1;
for i = 1:1:50
Force_AC(i) = .5 * rho * Drag_fixed2 * ( Current(i) .^ 2 ) ;
end
Force_AC
%
% Add component of changing area as Windmill X-section thins into the
% current
DegNum = 0:(1.571/90):1.571;
DegNum(91)
for k = 1:1:91
    KosNum(k) = cos(DegNum(k));
end
%
%Matirces expansion based on multiple variables
%
for j = 1:1:50
    for AreaTest = 1:5:100
    Force_AV(j) = AreaTest * Force_AC(j);
    end
end
Force_AV
%
figure(3)
subplot(111),plot(Current,Force_AC,':rd','LineWidth',2,...
                'MarkerEdgeColor','k',...
                'MarkerFaceColor','g',...
                'MarkerSize',3),ylabel('F A_C');
      
figure(4)
subplot(111),plot(DegNum,KosNum,'--bd','LineWidth',1,...
                'MarkerEdgeColor','k',...
                'MarkerFaceColor','g',...
                'MarkerSize',3),ylabel('KosNum');
            
figure (5)
plot3 (Force_AC, Force_AV, Force_V,':r')
grid on
axis square;

                
            