%Program to solve Taylor and Dyer's (1977) equation (as presented in Dyer 1986)
%written by Emmanuel Boss, University of Maine, 2003
%Inputs:
A=[5.0 0.32 0.1 0.001];
B=[1.4 0.56 0.2 0.2];
u_star=[0.04 0.1 0.04 0.04]; %shear velocity in same units as velocity.
C0=[0.1 0.1 0.14 0.14]; %concentration at z0, at same units as C.
z0=[0.01 0.01 0.001 0.00001]; %Roughness height 
k=0.408; %von Karman's constant


z_over_z0=[1:1:10000];
%solution for normalized concentration and velocity:
for i=1:4
Log_C_over_C0=-B(i)*(log(z_over_z0)+1/B(i)*log(1+A(i)*B(i)/(1-B(i))*((z_over_z0).^(1-B(i))-1)));
u=u_star(i)/k*(log(z_over_z0)+1/B(i)*log(1+A(i)*B(i)/(1-B(i))*((z_over_z0).^(1-B(i))-1)));
u_unstrat=u_star(i)/k*log(z_over_z0);

C_over_C0=exp(Log_C_over_C0);

figure(1)
loglog(C_over_C0,z_over_z0)
hold on
figure(2)
semilogy(k*u/u_star(i),z_over_z0)
hold on
semilogy(k*u_unstrat/u_star(i),z_over_z0,'--')
figure(3)
semilogy(C_over_C0.*u,z_over_z0)
hold on
end
figure(1)
hold off
figure(2)
hold off
figure(3)
hold off