%% Analytical solution from Chanson 2006 for the 1D Dam Break Dry Bed Test
% Tim Leijnse
% Made for 1D Dam Break Dry Bed Test to give the analytical solution

function [x,h] = analytical_1Ddrybed(dx, t_end, dtout)
h0 = 1; % neem een initiele waterdiepte van 1m
g = 9.81;
c0 = sqrt(g * h0);

x = (-50):dx:(50);
t = 0:dtout:t_end;

h = zeros(length(t),length(x));
u = zeros(length(t),length(x));

for j=1:length(t)
    for i=1:length(x)
        h(j,i) = h0 * (2/3 - x(i)/(3*t(j)*c0))^2;
        u(j,i) = 2/3 * (c0 + x(i)/t(j));

         if x(i)> 2*c0*t(j)
            h(j,i) = 0;
        elseif x(i)< -1*c0*t(j)
            h(j,i) = 1;
        end
        
    end
end
x = x+50;
% x = x(1:end-1);
% h = h(end,1:end-1);
h = h(end,:);
