add feature that you can drop disbalanced concentration at click point, to kickstart reaction there
parent
6ec7b9009f
commit
5140a2f32c
|
|
@ -94,14 +94,41 @@ ax.aspect = DataAspect()
|
|||
|
||||
spoint = select_point(ax.scene)
|
||||
|
||||
function coord_to_index(x, y, N)
|
||||
ix = clamp(round(Int, x), 1, N)
|
||||
iy = clamp(round(Int, y), 1, N)
|
||||
return ix, iy
|
||||
end
|
||||
r = 5
|
||||
|
||||
on(spoint) do pt
|
||||
if pt === nothing
|
||||
return
|
||||
end
|
||||
x, y = pt
|
||||
i, j = coord_to_index(x, y, N)
|
||||
|
||||
# get corners of square that will get filled with concentration
|
||||
imin = max(i - r, 1)
|
||||
imax = min(i + r, N)
|
||||
jmin = max(j - r, 1)
|
||||
jmax = min(j + r, N)
|
||||
|
||||
# set disbalanced concentration of U and V
|
||||
U[imin:imax, jmin:jmax] .= 0.5
|
||||
V[imin:imax, jmin:jmax] .= 0.25
|
||||
|
||||
heat_obs[] = copy(U)
|
||||
end
|
||||
|
||||
# # Controls
|
||||
run_label = Observable("Run")
|
||||
fig[2, 1] = buttongrid = GridLayout(tellwidth=false)
|
||||
btn_step = Button(buttongrid[1, 1], label="Step")
|
||||
fig[2, 1] = buttongrid = GridLayout(ax.scene, tellwidth=false)
|
||||
btn_step = Button(buttongrid[1, 1], width=50, label="Step")
|
||||
btn_start = Button(buttongrid[1, 2], width=50, label=run_label)
|
||||
btn_reset = Button(buttongrid[1, 3], label="Reset")
|
||||
btn_reset = Button(buttongrid[1, 3], width=50, label="Reset")
|
||||
|
||||
gh[1, 2] = textboxgrid = GridLayout(tellwidth=false)
|
||||
gh[1, 2] = textboxgrid = GridLayout(ax.scene, tellwidth=false)
|
||||
rowsize!(gh, 1, Relative(1.0))
|
||||
function param_box!(row, labeltxt, observable)
|
||||
Label(textboxgrid[row, 1], labeltxt)
|
||||
|
|
@ -148,7 +175,7 @@ end
|
|||
|
||||
on(btn_start.clicks) do _
|
||||
@async while running[]
|
||||
multi_step!((U, V), 30)
|
||||
multi_step!((U, V), 60)
|
||||
sleep(0.05) # ~20 FPS
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in New Issue