Matlab program for reaction diffusion system

Click For Summary
The discussion focuses on modeling a reaction-diffusion system in MATLAB, specifically with four particles on a 15-site lattice. The user has successfully implemented random walks for the particles but is struggling to determine when two particles occupy the same lattice point for annihilation. They suggest that creating a class to represent the particles could streamline the process, allowing for better management of particle identities and movement. The current random walk setup may complicate the annihilation detection. Overall, the user seeks advice on improving their program to facilitate particle interactions and annihilation.
yaboidjaf
Messages
5
Reaction score
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.
 
Physics news on Phys.org
It might be easier to create a class that will represent the particles. The class can have a particle-identity and walk method. Another method could be used to test if particles are on the same site.
 

Similar threads

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