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
margin = radius + 2
rels = [
(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, 1 / 4), (3 / 4, 1 / 4), (1 / 2, 1 / 2),
(1 / 4, 3 / 4), (3 / 4, 3 / 4), (1 / 2, 1 / 8)
]
for (px, py) in rels
cx = clamp(round(Int, px * 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
U[x, y] = 0.50
V[x, y] = 0.25
@ -86,7 +86,7 @@ end
function param_box!(grid, row, labeltxt, observable::Observable)
Label(grid[row, 1], labeltxt)
box = Textbox(grid[row, 2], validator=Float64, width=50,
placeholder=labeltxt, stored_string="$(observable[])")
placeholder=labeltxt, stored_string="$(observable[])")
on(box.stored_string) do s
try
observable[] = parse(Float64, s)
@ -108,8 +108,9 @@ function build_ui(U, V, Du, Dv, F, k, params_obs, heat_obs)
run_label = Observable("Run")
stepsize = Observable(30)
spoint = select_point(ax.scene)
# Controls
# # Controls
fig[2, 1] = buttongrid = GridLayout(ax.scene, tellwidth=false)
btn_step = Button(buttongrid[1, 1], width=60, label="Step")
btn_start = Button(buttongrid[1, 2], width=60, label=run_label)
@ -117,8 +118,8 @@ function build_ui(U, V, Du, Dv, F, k, params_obs, heat_obs)
btn_Jaguar = Button(buttongrid[1, 4], width=60, label="Jaguar")
slidergrid = SliderGrid(fig[3, 1], (label="Speed", range=1:100,
format="{}x", width=350,
startvalue=stepsize[]))
format="{}x", width=350,
startvalue=stepsize[]))
speed_slider = slidergrid.sliders[1].value
gh[1, 2] = textboxgrid = GridLayout(ax.scene, tellwidth=false)
@ -159,12 +160,13 @@ function build_ui(U, V, Du, Dv, F, k, params_obs, heat_obs)
Du[] = 0.142
Dv[] = 0.078
F[] = 0.0617
k[] = 0.062
F[] = 0.0617
k[] = 0.062
if !running[]
running[] = true
U .= 1.0; V .= 0.0
U .= 1.0
V .= 0.0
@async while running[]
multi_step!((U, V), stepsize[], heat_obs, params_obs)
sleep(0.0015)
@ -179,7 +181,27 @@ function build_ui(U, V, Du, Dv, F, k, params_obs, heat_obs)
running[] = false
reset!(U, V, heat_obs)
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
end