Hi,
i am currently doing my bachelors in chemistry and i am trying to simulate a reaction with a cellular automaton. It works fine, but is too slow. So i introduced ray.
I now have the issue, that my computation runs out of sync. Its an iterative process, so all processes need to wait for each other to finish in order to start over. All processes are dependent on the result of the calculation of the other processes of the previous step. I am only using numpy arrays for the calculation.
This is the main iteration-loop:
for i in range(1, n):
# these are the two processes calculating the concentration of x and y for half of the cell each
temp_L_x, temp_L_y = Proc_L.remote()
temp_R_x, temp_R_y = Proc_R.remote()
#i tought that this ensures, that the total concentration of the whole automaton Cges_x and Cges_y of this iterationstep is calculated after both processes have finished:
Cges_x, Cges_y = End_Iter_Konz.remote(temp_L_x, temp_L_y, temp_R_x, temp_R_y)
Cx[:, :] = ray.get(Cges_x)
Cy[:, :] = ray.get(Cges_y)
#loop to print the concentration with matplotlib
if i % 5 == 0:
draw_figure.remote(i, h, Cx)
draw_figure.remote(i, h, Cy)
h += 1 # numbering of the images
This is one example of the calculation process:
@ray.remote(num_returns=2)
def Proc_R():
Cx_diff_gesamt[:, slice:] = XXXXXXXX
Cy_diff_gesamt[:, slice:] = XXXXXXX
Cx[:, slice:] = XXXXXXX + Cx_diff_gesamt[:, slice:] * dt
Cy[:, slice:] = XXXXXXXXX + Cy_diff_gesamt[:, slice:] * dt
return Cx[:, slice:], Cy[:, slice:]
The issue i am now having is, that the output (the matplotlib picture) fails to stay in sync. The longer the iterationprocess goes on, the worse it gets. Here is an example how it looks:
I am relatively new to python especially to parallelisation. Help would be very appreciated!
Thanks for your help!