Last active
December 11, 2017 23:09
-
-
Save charlesreid1/cf463ac48844e6828636e331e76c5fe8 to your computer and use it in GitHub Desktop.
pseudocode
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
N=10000; | |
d=1e-6; %Diameter of particle | |
mu=1e-3; %viscosity of water | |
T=293; %temprature | |
KB=1.38e-23; %Boltzman const | |
pi=3.1415; | |
% drag Coeff -strength of random force exerting on particl | |
g=3*pi*mu*d; %Drag coef | |
disp (g); | |
tt=1000; % Maximum time | |
dt=tt/N; %time step | |
t=(0:dt:tt); % t is a vector | |
k=sqrt((2*3*T*KB*g)/dt); | |
% Outer loop: number of random walks | |
for i=1:Nwalks | |
x=zeros(1,N); % place to store x locations | |
y=zeros(1,N); % place to store y locations | |
x(1)=0.0; | |
y(1)=0.0; | |
% Inner loop: number of steps in the random walk | |
for j=1:N-1 | |
x(j+1) = x(j) + ((k*randn*dt)/g); | |
y(j+1) = y(j) + ((k*randn*dt)/g); | |
% Compute mean statistics for this random walk | |
% (e.g., MSD) | |
for n=0:1:sqrt(length(x)) | |
MSD(n+1)=mean((x(n+1:end)-x(1:end-n)).^2+(y(n+1:end)-y(1:end-n)).^2); | |
end; | |
% Compute mean statistics for all random walks | |
% (no statistical bias) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment