% Calc for acid pump control 
% 
% This is based on Ed Peltzers calcs for the HCL concentration and
% predicted currents
% 
% copyright (c) 2005 by W.J.Kirkwood of MBARI
% February 2, 2005 
% Last Modified 2/2/05 
% Revision: NC 
%
% ///////////// ASSUME ALL CALCS IN CM-SEC \\\\\\\\\\\\\\\\\
% 
% clean up from last activity 
clear all ; clf;
%
% Variable Declarations
% 
% p
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
%
%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(221),plot(Current,Force_AC),ylabel('F AC');
