Belousov-Zhabotinsky

Belousov-Zhabotinsky

A simple modification of the Belousov-Zhabotinsky reaction

Prepare a two-dimensional grid with memory to store the values of a two-state system.

float [][][] a;

float [][][] b;

float [][][] c;

Initialize the system to simulate temporal oscillation.

int r = 0, q = 1;

 if (r == 0) {
    r = 1; 
    q = 0;
  } else {
    r = 0; 
    q = 1;
  }

a = new float [width][height][2];
b = new float [width][height][2];
c = new float [width][height][2];
a[x][y][r] = random(1);
b[x][y][r] = random(1);
c[x][y][r] = random(1);

Use modular arithmetic to simulate a torus:

for (int i = x - 1; i <= x+1; i++) {
        for (int j = y - 1; j <= y+1; j++) {
          c_a += a[(i+width)%width][(j+height)%height][r];
          c_b += b[(i+width)%width][(j+height)%height][r];
          c_c += c[(i+width)%width][(j+height)%height][r];
        }

Divide the cells by a 3 x 3 grid, representing the neighborhood of each cell.

c_a /= 9
c_b /= 9
c_c /= 9

Now apply the differential system of equations.

a[x][y][q] = constrain(c_b + (c_b) * (c_b - c_c), 0, c_b);
b[x][y][q] = constrain(c_a + (c_a) * (c_c - c_a), 0, c_c);
c[x][y][q] = constrain(c_c + (c_c) * (c_a - c_b), 0, c_a);
© 2020 ODOMOJULI