diff --git a/scripts/run_simulation.jl b/scripts/run_simulation.jl index af80c61..84e01c2 100644 --- a/scripts/run_simulation.jl +++ b/scripts/run_simulation.jl @@ -6,7 +6,9 @@ using .Constants # Parameters and initial conditions N = 128 dx = 1.0 +# diffusion rates of substance 'u' and 'v' Du, Dv = Observable(0.16), Observable(0.08) +# feed rate of 'u' and kill rate of 'v' F, k = Observable(0.060), Observable(0.062) dt = 1.0 params_obs = Observable(GSParams(N, dx, Du[], Dv[], F[], k[])) @@ -16,6 +18,7 @@ function update_params!(params_obs, u, v, feed, kill) params_obs[] = GSParams(old.N, old.dx, u, v, feed, kill) end +# Whenever a value gets changed via the textbox, update params object to reflect changes in simulation lift(Du, Dv, F, k) do u, v, F, k update_params!(params_obs, u, v, F, k) end @@ -23,6 +26,7 @@ U = ones(N, N) V = zeros(N, N) center = N รท 2 radius = 10 +# set a cube in the center with starting concentrations for 'u' and 'v' U[center-radius:center+radius, center-radius:center+radius] .= 0.50 V[center-radius:center+radius, center-radius:center+radius] .= 0.25 @@ -85,8 +89,11 @@ gh = GridLayout(fig[1, 1]) ax = Axis(gh[1, 1]) hm = Makie.heatmap!(ax, heat_obs, colormap=:viridis) +Makie.deactivate_interaction!(ax, :rectanglezoom) ax.aspect = DataAspect() +spoint = select_point(ax.scene) + # # Controls run_label = Observable("Run") fig[2, 1] = buttongrid = GridLayout(tellwidth=false) @@ -126,32 +133,26 @@ function reset!(U, V, heat_obs) heat_obs[] = copy(U) end -function animation_loop() - while running[] - # step!(U, V) +on(running) do r + run_label[] = r ? "Pause" : "Run" +end + +# Button Listeners +on(btn_step.clicks) do _ + multi_step!((U, V), 30) +end + +on(btn_start.clicks) do _ + running[] = !running[] +end + +on(btn_start.clicks) do _ + @async while running[] multi_step!((U, V), 30) sleep(0.05) # ~20 FPS end end -on(running) do r - run_label[] = r ? "Pause" : "Run" - end - - -on(btn_step.clicks) do _ - multi_step!((U, V), 30) -end -on(btn_start.clicks) do _ - running[] = !running[] -end -on(btn_start.clicks) do _ - @async while running[] - animation_loop() - end -end - - on(btn_reset.clicks) do _ running[] = false reset!(U, V, heat_obs)