% Compare water depth for steady uniform flow with zero bed slope
% Andries Paarlberg/ modified by A. Omer
% 21-11-2017

clear all;
close all;

if isempty('vs_ini')
    run('d:\openearth\matlab\oetsettings.m')
end

caseid  = 'str01';
datadir = '../dflowfmoutput/';
ncmap1   = [datadir caseid '_his.nc'];
% ncmap2   = [datadir caseid '_20151101_001000_rst.nc'];
% ncmap3   = [datadir caseid '_20151101_002000_rst.nc'];
ncmap   = [datadir caseid '_map.nc'];

info = ncinfo(ncmap);
info1 = ncinfo(ncmap1);
% info2=ncinfo(ncmap2);
% info3=ncinfo(ncmap3);

%ncdisp(ncmap);
time=ncread(ncmap1,'time');
time=time(2:end);

%1
Name = ncread(ncmap1,'cross_section_name');
cross_Section_x_coordinate = ncread(ncmap1,'cross_section_x_coordinate');
bedload = ncread(ncmap1,'cross_section_bedload_sediment_transport'); 

bedload = abs(bedload);



%% analytical solution
oned = 0.0002*0.08*2650*0.6;%kg/s  
twod = 0.0002*1.6*2650*0.6;%kg/s 

oned1(1:20)= oned;
twod1(1:20)= twod;

 plot(time,diff(bedload(1,:))/60,'--gs',time,diff(bedload(2,:))/60,'bo',time,diff(bedload(3,:))/60,'rx',time,diff(bedload(3,:))/60,'b<',time,diff(bedload(3,:))/60,'m-.+',time,diff(bedload(3,:))/60,'b.',time,oned1,'K-+',time,twod1,'K-');
 grid on
% 
 legend('2dMulti-1stCell','2dMulti-ghost','2dsingle-1stCell','2dsingle-ghost','1d-1stCell','1d-ghost','Analytical-1d','Analytical-2d','Location','East');

%plot(time,oned1,'K-+',time,twod1,'K-');

%grid on

%legend('2dMulti-1stCell','2dMulti-ghost','2dsingle-1stCell','2dsingle-ghost','1d-1stCell','1d-ghost','Analytical-1d','Analytical-2d','Location','East');


xlabel(' time  [seconds]')

ylabel(' bedload sediment transport [kg/s]')

print(gcf,'-dpng',[caseid '.png'])
