Diffusion Limited Aggregation Matlab Problem

Click For Summary

Homework Help Overview

The discussion revolves around a project on diffusion limited aggregation (DLA) using MATLAB. The original poster describes their familiarity with the theoretical aspects but struggles with the coding implementation, particularly in simulating a random walk within a 9 x 9 matrix to visualize fractal patterns.

Discussion Character

  • Exploratory, Problem interpretation, Assumption checking

Approaches and Questions Raised

  • Participants discuss the structure of the random walk code, with some suggesting improvements and clarifications on how to handle boundary conditions and particle interactions. Questions arise about how to properly code the conditions for a particle to join the seed and how to ensure it starts from a random position.

Discussion Status

There is an ongoing exploration of coding strategies, with some participants providing suggestions for refining the random walk logic and addressing the conditions for particle aggregation. Multiple interpretations of the problem are being considered, and guidance has been offered regarding the need for function calls and proper plotting of particle positions.

Contextual Notes

Participants note the constraints of the 9 x 9 matrix and the requirement for the random walk particle to interact with the seed particle under specific conditions. There is also mention of the need for clarity in the original poster's goals and the background information provided.

leviathanX777
Messages
39
Reaction score
0

Homework Statement



Hello, I have this project due for next Friday. I need help. Its on diffusion limited aggregation. A topic which is unfamiliar to me. I know exactly how to do the problem, but I don't know how to code it correctly. Basically I allow a seed particle to be in a location in a 9 x 9 matrix. Another particle is put into this matrix with a random location. basically just have to show that my code gives an image like the usual fractal images.



Homework Equations



None.



The Attempt at a Solution



Here's my code for the random walk;

% Daniel Lordan_108576939_ComputationalProject_MinimumGoal
clear all % clears all variables

xD = 0; % Holds vector of the previous values x has taken
yD = 0; % Holds vector of the previous values y has taken
rD = 0; % Used when calculating the distance form origin
x_position = 0; % Start position at origin
y_position = 0; % Start position at origin

num_steps = 2000;
n = 9;
% Sets n equal to nine

xx = round(rand(n));
% creates a 9 x 9 array of zeros or ones ie creates an array of random
% numbers between 0 and 1

% this is just to generate some data for a 2-D "top-view" plot,

colormap([0 0 0;1 1 1])
% creates a colormap of black and white

imagesc(xx)
% plots the matrix xx as an image

axis square
% makes the plot square, as opposed to the usual rectangle

save(['E:\Matlab Project\matrix_xx.txt'], 'xx', '-ASCII','-TABS')
% save the content of xx into a txt file

perm_col = randperm(4);
% this generates a column vector containing a random permutation of the
% integers from 1 to 4

dir_mov = perm_col(1);
% the first element of perm_col will be a random number between 1 and 4
% and could be used to determine the direction of the next random walk step

for ctr = 1:(num_steps-1)
direction = randperm(4); % Direction is chossen randomly from numers 1, 2, 3, 4
if direction(1) == 1
x_position = x_position + 1; % Go East
elseif direction(1) == 2
x_position = x_position -1; % Go West
elseif direction(1) == 3
y_position = y_position + 1; % Go North
elseif direction(1) == 4
y_position = y_position -1; % Go South
end

end

plot(xD, yD)
hold on

Is that the correct coding for a random walk and how would I bring the actual dla into this problem. Thanks for anyone's help. It will be greatly appreciated as I'm freaking out and I know that I won't be able to do this.
 
Physics news on Phys.org
It seems okay, seeing as how you are simply using Matlab's randomization to do your own. Just looking ahead, you'll have to figure out what to do if you are at the wall of your matrix.
 
How would you possible code if the particle hits the center one and joins and also if it doesn't and you have to add more?
 
the code you have written is doing literally nothing!
where's code to plot the particle current position??

now to incorporate DLA, compare the upcoming position of particle with that of static particles, if it is same as that of the static particle, then stop further motion, if it is not carry on!
in this life is simpler as you are using a matrix, so just comparing the M(i,j) would do the job...
All the best
 
Okay, it seems to me like you should make that random walk a function call. You can then also make other function calls that will add, subtract, or keep constant your particle count. I thought that all you were asking about was the random walk. I don't really understand what else you are asking about, you'll have to rephrase it and provide the necessary background information (what you've got, what you're working towards, etc.).
 
Alrighty, I'm not sure if this code for a random walk is good or not but it shows something.

clf %Clears figures
clear all %Clears all variables

%Defining position and mass of immobile seed particle in the center:
X_seed = 1;
Y_seed = 1;
M1 = 1; %Mass of seed particle

%Defining variables:
num_steps = 2000;
n = 9;
M2 = M1; %Mass of incoming particle
M = M1 + M2; %Mass of the seed particle and the random walk particles
%Random walk of new entering particle:
x_position = 0;
y_position = 0;
xx = round(rand(n));
%Creates a 9 x 9 array of zeros or ones ie creates an array of random
%numbers between 0 and 1

perm_col = randperm(4);
%this generates a column vector containing a random permutation of the
%integers from 1 to 4

dir_mov = perm_col(1);
%The first element of perm_col will be a random number between 1 and 4
%and could be used to determine the direction of the next random walk step

for ctr = 1:(num_steps-1)
direction = randperm(4); %Direction is chossen randomly from numbers 1, 2, 3, 4
if direction(1) == 1
x_position = x_position + 1; %Particle Goes East
elseif direction(1) == 2
x_position = x_position -1; %Particle Goes West
elseif direction(1) == 3
y_position = y_position + 1; %Particle Goes North
elseif direction(1) == 4
y_position = y_position -1; %Particle Goes South
end
if ( x_position == X_seed && y_position == Y_seed )

M1 = M1 + M2;
end
if ( x_position == X_seed && y_position == Y_seed )

M1 = M1 + M2;
end
if ( x_position == X_seed && y_position == Y_seed -1 )

M1 = M1 + M2;
end
if ( x_position == X_seed && y_position == Y_seed -1 )

M1 = M1 + M2;
end
break

endplot (X_seed,Y_seed,'MarkerFaceColor',[1 0 0],'MarkerSize',20,'Marker','o',...
'Color',[1 1 1]);

hold on
plot (x_position,y_position,'MarkerFaceColor',[0 0 0],'Marker','+')

hold off

there's a few problems though, I'm starting the random walk particle at (0,0) but it needs to come into the plane at a random poisition as well. How would I do that? Also I say that the seed particle's position is the same as the random walk one. But it has to land next to it i.e. north, south, east or west so it'll stick on.
 

Similar threads

  • · Replies 1 ·
Replies
1
Views
6K
  • · Replies 41 ·
2
Replies
41
Views
10K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K
Replies
2
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 32 ·
2
Replies
32
Views
4K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 3 ·
Replies
3
Views
5K
Replies
1
Views
3K