clear all
close all

DynamicPath = 'DynamicResults/';

Depths =         [150];
PolyLengths =  [135];


WaveHeights = [4];
WaveAmps = WaveHeights/2;
WavePers = [10];

CurrentFactors = .5;

fh1 =  figure('Position',[520   173   766   925],'PaperOrientation','portrait','PaperPosition',[0 0 8.5 11]);

fh2 =  figure('Position',[520   173   766   925],'PaperOrientation','portrait','PaperPosition',[0 0 8.5 11]);


for i = length(WaveAmps):-1:1

for j = 1:length(CurrentFactors);

for m = 1:length(Depths)

  m
  ENV.depth = Depths(m);
  ENV.tf = 240; 
  ENV.dt = .1;
  ENV.ramptime = 30;
  ENV.xwaveamp = WaveAmps(i);
  ENV.xwaveperiod = WavePers(i);
  ENV.xwavephase = 0;
  ENV.xwind = 1;
  ENV.dynamiclambda = -.5;

  ENV.currentscale = CurrentFactors(j);

  LAYOUT.em_length = 15;
  LAYOUT.poly_nodespace = .5;  %meters per node
  LAYOUT.poly_length = PolyLengths(m)
  LAYOUT.em_length = 15;
  LAYOUT.shockle_length = 3;
  LAYOUT.shockle_nodespace = 0.5; %meters per node

  filename = [DynamicPath make_filename(ENV,LAYOUT)]
 
  
  load([filename '.mat']);
  
  figure(fh1)
  subplot(2,2,m)
  plot(x_s,z_s);
  xlabel('meters');
  ylabel('meters');
  title([num2str(ENV.depth+.5) 'm Mooring, 6m waves, 1s position snapshots']);
  subplot(2,2,m+2)
  plot(t,T_t);
  xlabel('time (s)');
  ylabel('Tension (lbs)');
  legend('Anchor Tensions');
  
  figure(fh2)
  subplot(1,2,m)
  plot(ENV.xcurrent(:,2),-ENV.xcurrent(:,1),'-o')
  if(ENV.depth <100)
      hold all;
      plot([0 1],[-50 -50],'k-');
  end
  ylim([-200 0]);
  xlabel('Current Speed');
  ylabel('Depth (m)');
  
  
end   %End of m-loop (Mooring Depths)

end   %End of j-loop (current factors)

end   %End of i-loop (sea state)

figure(fh1)
print('-dpdf','DynamicResultsSampler');

figure(fh2)
print('-dpdf','CurrentProfiles');

MeanTensions = mean(T_t);
MaxTensions = MeanTensions+4*std(T_t);

fh1 =  figure('Position',[520   173   766   925],'PaperOrientation','portrait','PaperPosition',[0 0 8.5 11]);
plot(t,T_t(:,[1 5 7]));
xlabel('time (s)');
ylabel('Tension (lbs)');
legend(['Buoy Tension (mean = ' num2str(MeanTensions(1),2) ' lbs , max = ' num2str(MaxTensions(1),2) ' lbs'], ...
       ['Shockle Tension (mean = ' num2str(MeanTensions(5),3) ' lbs , max = ' num2str(MaxTensions(5),3) ' lbs'], ...
       ['Anchor Tension (mean = ' num2str(MeanTensions(7),3) ' lbs , max = ' num2str(MaxTensions(7),3) ' lbs']);
title('Dynamic Results for 0.5 m/s linear current and 4 meter significant wave height with peak period = 10s');
print('-dpdf','DynamicResultsExample');


  

