# Diffusion Limited Aggregation Matlab Problem

• leviathanX777
In summary, the conversation is about a project on diffusion limited aggregation, where the goal is to code a random walk that results in a fractal-like image. The code provided includes the random walk function, but it is unclear how to incorporate DLA into the problem. Suggestions are made to compare the upcoming position of the particle with that of static particles in the matrix and to make the random walk a function call. The conversation also includes a code for a random walk with an immobile seed particle in the center, but there are some issues with this code such as starting the random walk particle at a random position and ensuring it lands next to the seed particle for it to stick.
leviathanX777

## 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.

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.

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.

## 1. What is Diffusion Limited Aggregation (DLA)?

Diffusion Limited Aggregation is a mathematical model used to simulate the growth of fractal patterns. It is based on the concept of diffusion, where particles move randomly and aggregate when they come into contact with other particles. This process results in the formation of complex, branching structures.

## 2. What is the significance of DLA in scientific research?

DLA has applications in various fields of science, such as physics, chemistry, and biology. It can be used to study the growth of crystals, the behavior of gases, and the formation of biological structures. DLA is also used in computer graphics to create realistic and intricate patterns.

## 3. How is DLA simulated in Matlab?

In Matlab, DLA can be simulated by representing particles as points on a grid and using a random walk algorithm to simulate their movement. The particles aggregate when they come into contact with other particles or a predefined boundary. The simulation is repeated multiple times to obtain an accurate representation of the fractal pattern.

## 4. What are some challenges faced in simulating DLA in Matlab?

One of the main challenges in simulating DLA in Matlab is the computational time and memory required. As the simulation progresses, the number of particles and their interactions increase, resulting in longer simulation times and higher memory usage. Additionally, accurately representing the boundary conditions and particle movements can be complex and require advanced programming techniques.

## 5. How can DLA simulations in Matlab be improved?

To improve DLA simulations in Matlab, one can optimize the code for efficiency, use parallel processing techniques, and implement advanced algorithms to reduce simulation time and memory usage. It is also important to carefully select the parameters used in the simulation to accurately represent the desired fractal pattern. Additionally, incorporating advanced visualization tools can enhance the understanding and interpretation of the simulation results.

• MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
937
Replies
1
Views
2K
• MATLAB, Maple, Mathematica, LaTeX
Replies
41
Views
8K
• Engineering and Comp Sci Homework Help
Replies
1
Views
1K
• MATLAB, Maple, Mathematica, LaTeX
Replies
32
Views
2K
Replies
1
Views
1K
• MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
4K
Replies
1
Views
5K
• MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
450
• Engineering and Comp Sci Homework Help
Replies
1
Views
1K