close all
clear all

ResultsPath = 'QuadDampingOnlyResults/';

ResultsPath = 'NoDampingResults/';

cabfile_name = 'SpringMassModel';

ENV.depth = 100;
ENV.xcurrent = 0.1;
ENV.xwind = 0.1;

LAYOUT.title = cabfile_name;

dt = 15;  %meters
h = 1;  %meters
LAYOUT.Ku = 270;  %N/m
LAYOUT.Kl = 62;  %N/m
W_weight = -200*4.45;  %N (negative means heavy in water
LAYOUT.Lu = 10;  %meters

LAYOUT.mass = 390;

[LAYOUT.Ll LAYOUT.EAu LAYOUT.EAl] = ComputeUnstrechedLowerLength(W_weight,LAYOUT.Ku,LAYOUT.Kl,LAYOUT.Lu,ENV.depth,dt,h);


   Amplitudes = [1 3];
   Periods = 3:1:20;


   for i = 1:length(Amplitudes)
   ENV.amp = Amplitudes(i);

   for j = 1:length(Periods)
   ENV.period = Periods(j);
   
   ENV.dt = .05;
   ENV.steps = 0;    
   ENV.tf = 1*5*ENV.period;
   
   ENV.input_type = 'velocity';
   
   filenm = make_filename(ENV,LAYOUT,cabfile_name);


   Results = load([ResultsPath filenm '.mat']);
   figure
   plot(Results.t,Results.z_t);
   title(['Period = ' num2str(ENV.period) ' s']);

   N = length(Results.t);
   idx = round(N/2):N;
   MassMotionAmp(i,j) = (max(Results.z_t(idx,3))-min(Results.z_t(idx,3)))/2;
   BuoyMotionAmp(i,j) = (max(Results.z_t(idx,4))-min(Results.z_t(idx,4)))/2;
   
   UpperMassForceAmp(i,j) =  (max(Results.T_t(idx,3))-min(Results.T_t(idx,3)))/2;
   LowerMassForceAmp(i,j) =  (max(Results.T_t(idx,2))-min(Results.T_t(idx,2)))/2;
   
end
end

figure('Position',[ 300   200   560   420]);
subplot(3,1,1)
plot(Periods,MassMotionAmp)
subplot(3,1,2)
plot(Periods,UpperMassForceAmp)
subplot(3,1,3)
plot(Periods,LowerMassForceAmp)

[Periods'  MassMotionAmp' UpperMassForceAmp']




