Merge branch 'feat/diff_model' into feat/diff_Jaguar

feat/diff_Jaguar
Nikola Sebastian Munder 2025-06-12 18:23:29 +02:00
commit 5b1a6f92b0
1 changed files with 33 additions and 11 deletions

View File

@ -68,13 +68,13 @@ function starting_points!(U, V)
jitter = 5 jitter = 5
margin = radius + 2 margin = radius + 2
rels = [ rels = [
(1/4, 1/4), (3/4, 1/4), (1/2, 1/2), (1 / 4, 1 / 4), (3 / 4, 1 / 4), (1 / 2, 1 / 2),
(1/4, 3/4), (3/4, 3/4), (1/2, 1/8) (1 / 4, 3 / 4), (3 / 4, 3 / 4), (1 / 2, 1 / 8)
] ]
for (px, py) in rels for (px, py) in rels
cx = clamp(round(Int, px * N) + rand(-jitter:jitter), margin, N - margin) cx = clamp(round(Int, px * N) + rand(-jitter:jitter), margin, N - margin)
cy = clamp(round(Int, py * N) + rand(-jitter:jitter), margin, N - margin) cy = clamp(round(Int, py * N) + rand(-jitter:jitter), margin, N - margin)
for x in (cx - radius):(cx + radius), y in (cy - radius):(cy + radius) for x in (cx-radius):(cx+radius), y in (cy-radius):(cy+radius)
if 1 x N && 1 y N && hypot(x - cx, y - cy) radius if 1 x N && 1 y N && hypot(x - cx, y - cy) radius
U[x, y] = 0.50 U[x, y] = 0.50
V[x, y] = 0.25 V[x, y] = 0.25
@ -108,8 +108,9 @@ function build_ui(U, V, Du, Dv, F, k, params_obs, heat_obs)
run_label = Observable("Run") run_label = Observable("Run")
stepsize = Observable(30) stepsize = Observable(30)
spoint = select_point(ax.scene)
# Controls # # Controls
fig[2, 1] = buttongrid = GridLayout(ax.scene, tellwidth=false) fig[2, 1] = buttongrid = GridLayout(ax.scene, tellwidth=false)
btn_step = Button(buttongrid[1, 1], width=60, label="Step") btn_step = Button(buttongrid[1, 1], width=60, label="Step")
btn_start = Button(buttongrid[1, 2], width=60, label=run_label) btn_start = Button(buttongrid[1, 2], width=60, label=run_label)
@ -164,7 +165,8 @@ function build_ui(U, V, Du, Dv, F, k, params_obs, heat_obs)
if !running[] if !running[]
running[] = true running[] = true
U .= 1.0; V .= 0.0 U .= 1.0
V .= 0.0
@async while running[] @async while running[]
multi_step!((U, V), stepsize[], heat_obs, params_obs) multi_step!((U, V), stepsize[], heat_obs, params_obs)
sleep(0.0015) sleep(0.0015)
@ -179,7 +181,27 @@ function build_ui(U, V, Du, Dv, F, k, params_obs, heat_obs)
running[] = false running[] = false
reset!(U, V, heat_obs) reset!(U, V, heat_obs)
end end
on(spoint) do pt
r = 5
if pt === nothing
return
end
x, y = pt
println("params_obs[].N, ", params_obs[].N)
i, j = coord_to_index(x, y, params_obs[].N)
# get corners of square that will get filled with concentration
imin = max(i - r, 1)
imax = min(i + r, params_obs[].N)
jmin = max(j - r, 1)
jmax = min(j + r, params_obs[].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
return fig return fig
end end