close all
clear all

g = 9.81;
rho = 1025;
%h = 250;

U = 5:30;  %m/s  Wind Speed
Hs = .21*U.^2/g;  %meters
A = Hs/2;
w = 0.877*g./U;

dp = 4;  %Post Diameter
lp = 10;  %Post Length
dl = .1;

Cd = 1;  %Drag coefficient of 2D circular section.



%T = [5 11.5 16 19];  %(seconds)  P-M Spectrum
%lambda = [26 130 250 365];  %(meters) P-M Spectrum
%w = 2*pi./T;


ki = w.^2/g;
kf = zeros(1,length(w));



for h = 25:25:125

for i = 1:length(w)
  kf(i) = wave_num(h,w(i),g);
end

y = 0;
Ui = w.*A.*exp(ki*y)
Uidot = w.^2.*A.*exp(ki*y)

Uf = (g*A.*kf./w).*cosh(kf*(y+h))./cosh(kf*h);
Vf = (g*A.*kf./w).*sinh(kf*(y+h))./cosh(kf*h);
Ufdot = w.*(g*A.*kf./w).*cosh(kf*(y+h))./cosh(kf*h);

figure(1)
plot(Hs,Ui,Hs,Uf)
hold on

figure(2)
plot(Hs,Uidot,Hs,Ufdot)
hold on

Fxi = zeros(1,length(w));
Fxf = zeros(1,length(w));
for y = dl/2:-dl:-lp+dl/2
Ui = w.*A.*exp(ki*y);
Uf = (g*A.*kf./w).*cosh(kf*(y+h))./cosh(kf*h);   
Fxi = Fxi + Cd*.5*rho*dp*dl.*Ui.^2;
Fxf = Fxf + Cd*.5*rho*dp*dl.*Uf.^2;
end
figure(3)
plot(Hs,Fxi/4.45,Hs,Fxf/4.45)
hold on
end



figure(1)
title('Effect of water depth on Maximum Wave Induced Horizontal Water Velocity');
ylabel('Horizontal Water Velocity (m/s)');
xlabel('Wave Height (m)');
print -depsc2 HorizVel

figure(2)
title('Effect of water depth on Maximum Wave Induced Horizontal Water Accel');
ylabel('Horizontal Water Accel (m^2/s)');
xlabel('Wave Height (m)');
print -depsc2 HorizAccel

figure(3)
title('Effect of water depth on Maximum Horizontal Drag Force (Cyl:  10m long X 5m diam)');
ylabel('Hozizontal Wave Drag Force (lbs)');
xlabel('Wave Height (m)');
print -depsc2 HorizForce


