From 6bc2c3f06d032b3f616a204bc6d75c75d0184e51 Mon Sep 17 00:00:00 2001 From: Niki Laptop <2212719@stud.hs-mannheim.de> Date: Sun, 8 Jun 2025 19:08:56 +0200 Subject: [PATCH] add reset functionality --- scripts/run_simulation.jl | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/scripts/run_simulation.jl b/scripts/run_simulation.jl index 6eb584e..943c4cf 100644 --- a/scripts/run_simulation.jl +++ b/scripts/run_simulation.jl @@ -88,6 +88,7 @@ fig[2, 1] = buttongrid = GridLayout(tellwidth=false) btn_step = Button(buttongrid[1, 1], label="Step") btn_start = Button(buttongrid[1, 2], label="Start") btn_stop = Button(buttongrid[1, 3], label="Stop") +btn_reset = Button(buttongrid[1, 4], label="Reset") fig[3, 1] = textboxgrid = GridLayout(tellwidth=false) @@ -97,6 +98,15 @@ box_u = Textbox(textboxgrid[1, 1], validator=Float64, placeholder="word") # box_kill = Textbox(textboxgrid[1, 4], validator=Float64, placeholder="word") # Timer and state for animation running = Observable(false) +function reset!(U, V, heat_obs) + U .= 1.0 + V .= 0.0 + center = size(U, 1) รท 2 + radius = 10 + U[center-radius:center+radius, center-radius:center+radius] .= 0.50 + V[center-radius:center+radius, center-radius:center+radius] .= 0.25 + heat_obs[] = copy(U) +end function animation_loop() while running[] @@ -108,6 +118,7 @@ end on(box_u.stored_string) do s try Du[] = parse(Float64, s) + println("Change Du ", Du[]) catch @warn "Invalid input for Du: $s" end @@ -128,4 +139,9 @@ on(btn_stop.clicks) do _ running[] = false end +on(btn_reset.clicks) do _ + running[] = false + reset!(U, V, heat_obs) + +end display(fig)