trying to style that shit
parent
3913467108
commit
f674ec4ab9
|
|
@ -24,7 +24,7 @@ using .Laplacian
|
||||||
# Returns
|
# Returns
|
||||||
- `du`: calculated derivatives put back into the du array
|
- `du`: calculated derivatives put back into the du array
|
||||||
"""
|
"""
|
||||||
function fhn!(du, u, p::FHNParams, t)
|
function fhn!(du, u, p::CombinedPDEParams, t)
|
||||||
N = p.N
|
N = p.N
|
||||||
u_mat = reshape(u[1:N^2], N, N)
|
u_mat = reshape(u[1:N^2], N, N)
|
||||||
v_mat = reshape(u[N^2+1:end], N, N)
|
v_mat = reshape(u[N^2+1:end], N, N)
|
||||||
|
|
@ -48,7 +48,6 @@ function fhn!(du, u, p::FHNParams, t)
|
||||||
end
|
end
|
||||||
|
|
||||||
function step_fhn!(U, V, params_obs::Observable; dx=1)
|
function step_fhn!(U, V, params_obs::Observable; dx=1)
|
||||||
"""
|
|
||||||
p = params_obs[]
|
p = params_obs[]
|
||||||
|
|
||||||
# Flatten initial condition (activation u, recovery v)
|
# Flatten initial condition (activation u, recovery v)
|
||||||
|
|
@ -68,23 +67,6 @@ function step_fhn!(U, V, params_obs::Observable; dx=1)
|
||||||
U .= u_new
|
U .= u_new
|
||||||
V .= v_new
|
V .= v_new
|
||||||
|
|
||||||
return U
|
|
||||||
"""
|
|
||||||
|
|
||||||
params = params_obs[]
|
|
||||||
|
|
||||||
Δu = laplacian(U, params.dx)
|
|
||||||
Δv = laplacian(V, params.dx)
|
|
||||||
|
|
||||||
u = U[2:end-1, 2:end-1]
|
|
||||||
v = V[2:end-1, 2:end-1]
|
|
||||||
|
|
||||||
fu = params.Du .* Δu .+ u .- (u .^ 3) ./ 3 .- v
|
|
||||||
fv = params.Dv .* Δv .+ params.ϵ .* (u .+ params.a .- params.b .* v)
|
|
||||||
|
|
||||||
U[2:end-1, 2:end-1] .+= 0.1 .* fu
|
|
||||||
V[2:end-1, 2:end-1] .+= 0.1 .* fv
|
|
||||||
|
|
||||||
return U
|
return U
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,6 @@
|
||||||
|
|
||||||
|
module Templates
|
||||||
|
|
||||||
# initial conditions for different patterns
|
# initial conditions for different patterns
|
||||||
function zebra_conditions(N)
|
function zebra_conditions(N)
|
||||||
# Turing-spot parameters
|
# Turing-spot parameters
|
||||||
|
|
@ -61,7 +63,7 @@ function column_ic(N)
|
||||||
|
|
||||||
u[col_start:col_end, :] .= -0.01
|
u[col_start:col_end, :] .= -0.01
|
||||||
|
|
||||||
return vec(u), vec(v)
|
return u, v
|
||||||
end
|
end
|
||||||
|
|
||||||
function two_rows_edge_distance_ic(N)
|
function two_rows_edge_distance_ic(N)
|
||||||
|
|
@ -194,5 +196,9 @@ function coral_ic(N)
|
||||||
u[i-2:i+2, j-2:j+2] .= -0.534522 .+ 0.2 * rand(5, 5)
|
u[i-2:i+2, j-2:j+2] .= -0.534522 .+ 0.2 * rand(5, 5)
|
||||||
end
|
end
|
||||||
|
|
||||||
return vec(u), vec(v)
|
return u, v
|
||||||
|
end
|
||||||
|
|
||||||
|
export blocks_ic, column_ic, squiggle_ic, three_circles_random_ic, circle_ic, center_band_ic, two_rows_edge_distance_ic
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
@ -1,11 +1,13 @@
|
||||||
module Visualization
|
module Visualization
|
||||||
|
|
||||||
include("../src/utils/constants.jl")
|
include("utils/constants.jl")
|
||||||
|
include("utils/templates.jl")
|
||||||
include("gray_scott_solver.jl")
|
include("gray_scott_solver.jl")
|
||||||
include("fhn_solver.jl")
|
include("fhn_solver.jl")
|
||||||
|
|
||||||
using Observables, Makie, GLMakie
|
using Observables, Makie, GLMakie
|
||||||
using .Constants
|
using .Constants
|
||||||
|
using .Templates
|
||||||
using .GrayScottSolver: step_gray_scott!
|
using .GrayScottSolver: step_gray_scott!
|
||||||
using .FHNSolver: step_fhn!
|
using .FHNSolver: step_fhn!
|
||||||
|
|
||||||
|
|
@ -68,7 +70,7 @@ end
|
||||||
function build_ui(U, V, param_obs_map::NamedTuple, params_obs, heat_obs)
|
function build_ui(U, V, param_obs_map::NamedTuple, params_obs, heat_obs)
|
||||||
|
|
||||||
reset!(U, V, heat_obs)
|
reset!(U, V, heat_obs)
|
||||||
fig = Figure(size=(800, 800))
|
fig = Figure(size=(1200, 800))
|
||||||
|
|
||||||
gh = GridLayout(fig[1, 1])
|
gh = GridLayout(fig[1, 1])
|
||||||
dropdown = Menu(fig, options=collect(zip(["Gray-Scott", "FHN"], [:gray_scott, :fhn])))
|
dropdown = Menu(fig, options=collect(zip(["Gray-Scott", "FHN"], [:gray_scott, :fhn])))
|
||||||
|
|
@ -89,10 +91,15 @@ function build_ui(U, V, param_obs_map::NamedTuple, params_obs, heat_obs)
|
||||||
btn_step = Button(buttongrid[1, 1], width=50, label="Step")
|
btn_step = Button(buttongrid[1, 1], width=50, label="Step")
|
||||||
btn_start = Button(buttongrid[1, 2], width=50, label=run_label)
|
btn_start = Button(buttongrid[1, 2], width=50, label=run_label)
|
||||||
btn_reset = Button(buttongrid[1, 3], width=50, label="Reset")
|
btn_reset = Button(buttongrid[1, 3], width=50, label="Reset")
|
||||||
slidergrid = SliderGrid(fig[3, 1], (label="Speed", range=1:1:100, format="{}x", width=350, startvalue=stepsize[]))
|
slidergrid = SliderGrid(fig[3, 1], (label="Speed", range=1:1:50, format="{}x", width=350, startvalue=stepsize[]))
|
||||||
|
|
||||||
speed_slider = slidergrid.sliders[1].value
|
speed_slider = slidergrid.sliders[1].value
|
||||||
|
|
||||||
|
gh[1, 2] = templategrid = GridLayout(ax.scene, tellwidth=false)
|
||||||
|
btn_zebra = Button(templategrid[1, 1], width=100, label="Zebra Stripes")
|
||||||
|
btn_cheetah = Button(templategrid[1, 2], width=100, label="Cheetah Spots")
|
||||||
|
btn_coral = Button(templategrid[1, 3], width=100, label="Coral Pattern")
|
||||||
|
|
||||||
# place all the parameter boxes
|
# place all the parameter boxes
|
||||||
gh[2, 2] = textboxgrid = GridLayout(ax.scene, tellwidth=false)
|
gh[2, 2] = textboxgrid = GridLayout(ax.scene, tellwidth=false)
|
||||||
|
|
||||||
|
|
@ -108,11 +115,12 @@ function build_ui(U, V, param_obs_map::NamedTuple, params_obs, heat_obs)
|
||||||
param_box!(textboxgrid, 4, "a", param_obs_map.a, col=2)
|
param_box!(textboxgrid, 4, "a", param_obs_map.a, col=2)
|
||||||
param_box!(textboxgrid, 5, "b", param_obs_map.b, col=2)
|
param_box!(textboxgrid, 5, "b", param_obs_map.b, col=2)
|
||||||
|
|
||||||
rowsize!(gh, 1, Fixed(50)) # small row for the menu
|
rowsize!(gh, 1, 50) # small row for the menu
|
||||||
rowsize!(gh, 2, Relative(1.0))
|
rowsize!(gh, 2, Relative(1.0))
|
||||||
for c in 1:4
|
for c in 1:4
|
||||||
colsize!(textboxgrid, c, Relative(1.0 / 4.0))
|
colsize!(textboxgrid, c, Relative(1.0 / 6.0))
|
||||||
end
|
end
|
||||||
|
#rowsize!(fig, 1, Relative(0.8))
|
||||||
|
|
||||||
# Events ##############################################################
|
# Events ##############################################################
|
||||||
# Timer and state for animation
|
# Timer and state for animation
|
||||||
|
|
@ -129,7 +137,7 @@ function build_ui(U, V, param_obs_map::NamedTuple, params_obs, heat_obs)
|
||||||
@warn "Invalid input for $s"
|
@warn "Invalid input for $s"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
# Button Listeners
|
# Control Listeners
|
||||||
on(btn_step.clicks) do _
|
on(btn_step.clicks) do _
|
||||||
multi_step!((U, V), stepsize[], heat_obs, params_obs; step_method=step_method[])
|
multi_step!((U, V), stepsize[], heat_obs, params_obs; step_method=step_method[])
|
||||||
end
|
end
|
||||||
|
|
@ -150,6 +158,26 @@ function build_ui(U, V, param_obs_map::NamedTuple, params_obs, heat_obs)
|
||||||
reset!(U, V, heat_obs)
|
reset!(U, V, heat_obs)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Template Control
|
||||||
|
on(btn_zebra.clicks) do _
|
||||||
|
U, V = Templates.column_ic(params_obs[].N)
|
||||||
|
heat_obs[] = copy(U)
|
||||||
|
end
|
||||||
|
|
||||||
|
# Template Control
|
||||||
|
on(btn_cheetah.clicks) do _
|
||||||
|
U = 0.05 .* (2 .* rand(params_obs[].N, params_obs[].N) .- 1) # noise in [-0.05, 0.05]
|
||||||
|
V = 0.05 .* (2 .* rand(params_obs[].N, params_obs[].N) .- 1)
|
||||||
|
heat_obs[] = copy(U)
|
||||||
|
end
|
||||||
|
|
||||||
|
# Template Control
|
||||||
|
on(btn_coral.clicks) do _
|
||||||
|
U, V = Templates.coral_ic(params_obs[].N)
|
||||||
|
heat_obs[] = copy(U)
|
||||||
|
end
|
||||||
|
|
||||||
on(spoint) do pt
|
on(spoint) do pt
|
||||||
r = 5
|
r = 5
|
||||||
if pt === nothing
|
if pt === nothing
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue