%solution for problem 3 in assignment 1.

D=[10^-9,10^-8,10^-7,10^-6,10^-5,10^-4,10^-3]; %diameter in meters
%Stokes settling:
g=9.81;%gravitational constant
mu=1.79*10^-3;%dynamic viscosity
ro_water=1000;%density of fresh water
ro=2650*2;%denisty of particle
ws=g*(ro-ro_water)*D.^2/18/mu; 

%Brownian motion:
Kb=1.38*10^-23;%Bolzman's constant
m=pi/6*D.^3*ro;%mass of particle
T=273;%Temperature in K
v_Brown=sqrt(3*Kb*T./m);

loglog(D,v_Brown,'b-o',D,ws,'k-o')

%find at what D both are equal
D=(3*Kb*T/((g*(ro-ro_water)/18/mu)^2*(ro*pi/6)))^(1/7)