Hi all,
I'm working on a model of self-organised critical systems following [B. Drossel and F. Schwabl, Physical Review Letters 69, 1629 (1992)] forest fire model to create a cellular automaton which counts the total number of fires within the lattice.
Given a matrix (100 x 100) with randomly generated integer values in range [0,2], on each timestep t, the matrix values will be updated according to 3 rules which change the values within the matrix, 0 -> 1 if rule1, 1 -> 2 if rule 2 etc. This would run over t time steps and then I would run the code "sample" number of times to create a pdf of the total count of each site.
I have attached the nb. Advice on increasing efficiency of the calculations is also more than welcome.
What I am trying to do next is create a dataset which notes the time taken for a 2 in the matrix to change back to a 2 after a series of rules has changed it cyclically from 2->0->1->2. Essentially looking at the wait times between the 2's occuring at a specific site.
To do this, I created a dataset:
wait = Dataset[{<|"run,i,j" -> {y, i, j}, "t" -> ii|>}];
Aiming to note which run of the code, where in the matrix the value 2 lies, and at what timestep it appears on. I would like to be able to append only the t values for a given value of {y, i , j} without duplication.
My first attempt to test these changes went like this:
n = 20;
sample = 4;
t = 10;
n = 20;
wait = Dataset[{<|"run,i,j" -> {y, i, j}, "t" -> ii|>}];
Nmat = Table[RandomInteger[{0, 1}], {n}, {n}];
For[y = 1, y < sample + 1, y++,
For[ii = 1, ii < t + 1, ii++,
For[i = 1, i < n + 1, i++,
For[j = 1, j < n + 1, j++,
If[Nmat[[i, j]] == 1,
(*Add a value into the dataset noting the run and matrix \
component*)
If[MemberQ[waittimes[[All, 1]], {y, i, j}],
]
]
]
]
]
]
However I get stuck on changing the values within the specifi row of the dataset. For example if a 2 occurs at "run,i,j" = {1,1,1} for t = 1 and then t = 5, I would like to append only the t column within the dataset where the specific row is {1,1,1}
Any help is more than welcome!