Code help for the diffusion/dispersion coefficient.
10 views (last 30 days)
Show older comments
B. Consider an array of (n x n) particles initially equally positioned apart from each other by dx=1 and dy=1. Allow these particles to move walk randomly with time in a space much greater than the originally occupied space of (ndx x ndy). Calculate the average square distance between the particles and plot its ratio to the time step . This is the diffusion/dispersion coefficient.
I understand the programming but what iam stuck is with the maths of the problem i understand how to define the initial conditions by this method n=3;
x=1:n
y=1:n
[X,Y]=meshgrid(x,y)
x=reshape(X,1,n^2)
y=reshape(Y,1,n^2)
what is dont understand is how to incorporate the moving particles in time and space, i dont understand this if someone can make it simple i will be able to implement this in programming, just in simple words of what x and y will be used? will be so grateful for the help i dont need the code i just need explanation.
0 Comments
Accepted Answer
Image Analyst
on 7 Sep 2013
Jerry, you need to specify where the 3 particles start. For example, all along the x axis with y = 0:
x = [0, 1, 2];
y = [0, 0, 0];
That's your starting point and you need to add rows for the new x and y locations for each iteration. For example (untested)
numberOfParticles = 3;
numberOfIterations = 10000;
x = zeros(numberOfIterations, numberOfParticles);
y = zeros(numberOfIterations, numberOfParticles);
x(1, :) = 1 : numberOfParticles;
y(1, :) = zeros(1, numberOfParticles);
for k = 2 : numberOfIterations
x(k, :) = x(k-1, :) + rand(1, numberOfParticles);
and so on. You might want to plot the data either after each iteration or just after the whole experiment of 10,000 iterations has run.
2 Comments
Felipe Rios
on 21 Nov 2018
Hi Jerry; I need to estimate the dispersion coefficient from GPS drifters deployed at sea. Do you happen to have a code that I could use?
More Answers (1)
Walter Roberson
on 7 Sep 2013
Add an extra dimension to your x and y vectors, representing time step.
x = zeros(n.^2, numtimes);
y = zeros(n.^2, numtimes);
x(:,1) = .... initial vector for x
y(:,1) = .... initial vector for y
then loop, updating x(:,K) from x(:,K-1)
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!