- #1
yaboidjaf
- 7
- 0
I'm trying to model a reaction-diffusion system on MATLAB and am struggling.
I'm starting off with 4 particles on a lattice with 15 sites for ease, will take it to a larger scale when I've got the simple version down. the idea is to get randomly walking particles to eventually meet each other and annihiilate.
here's my program
%% getting annihilation to work for 4 particles on 15 lattice sites
clear all
array = round(15*rand(1,4)) % 2 particle system on 10 lattice sites
jump = rand(1,4) % generate 2 random numbers, one for each particle
for x = 1:4
if jump(x) <= 0.5 %if the corresponding number is less than 0.5, the particle moves left, else right.
array(x) = array(x) - 1;
else
array(x) = array(x) + 1;
end
end
so i have the particles all conducting random walks (not sure if it's the best way), but I'm not sure how to go about identifying whether two particles are on the same lattice point and how to go about getting them to annihilate. i have a feeling the way my walks are set up it would be difficult to do so.
I'm starting off with 4 particles on a lattice with 15 sites for ease, will take it to a larger scale when I've got the simple version down. the idea is to get randomly walking particles to eventually meet each other and annihiilate.
here's my program
%% getting annihilation to work for 4 particles on 15 lattice sites
clear all
array = round(15*rand(1,4)) % 2 particle system on 10 lattice sites
jump = rand(1,4) % generate 2 random numbers, one for each particle
for x = 1:4
if jump(x) <= 0.5 %if the corresponding number is less than 0.5, the particle moves left, else right.
array(x) = array(x) - 1;
else
array(x) = array(x) + 1;
end
end
so i have the particles all conducting random walks (not sure if it's the best way), but I'm not sure how to go about identifying whether two particles are on the same lattice point and how to go about getting them to annihilate. i have a feeling the way my walks are set up it would be difficult to do so.