not stable yet
parent
6ec7b9009f
commit
c1c5c34770
|
|
@ -7,15 +7,21 @@ using .Constants
|
|||
N = 128
|
||||
dx = 1.0
|
||||
# diffusion rates of substance 'u' and 'v'
|
||||
Du, Dv = Observable(0.16), Observable(0.08)
|
||||
Du, Dv = Observable(0.142), Observable(0.078)
|
||||
# feed rate of 'u' and kill rate of 'v'
|
||||
F, k = Observable(0.060), Observable(0.062)
|
||||
F, k = Observable(0.0617), Observable(0.062)
|
||||
dt = 1.0
|
||||
params_obs = Observable(GSParams(N, dx, Du[], Dv[], F[], k[]))
|
||||
|
||||
|
||||
function current_params()
|
||||
println(params_obs)
|
||||
end
|
||||
|
||||
function update_params!(params_obs, u, v, feed, kill)
|
||||
old = params_obs[]
|
||||
params_obs[] = GSParams(old.N, old.dx, u, v, feed, kill)
|
||||
current_params()
|
||||
end
|
||||
|
||||
# Whenever a value gets changed via the textbox, update params object to reflect changes in simulation
|
||||
|
|
@ -27,8 +33,40 @@ 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
|
||||
|
||||
jitter_amount = 5 # maximale Verschiebung in Pixeln
|
||||
margin = radius + 2 # Abstand zum Rand
|
||||
|
||||
# Manuell definierte gleichverteilte Positionen (6 Punkte)
|
||||
positions = [
|
||||
(1/4, 1/4),
|
||||
(3/4, 1/4),
|
||||
(1/2, 1/2),
|
||||
(1/4, 3/4),
|
||||
(3/4, 3/4),
|
||||
(1/2, 1/8)
|
||||
]
|
||||
|
||||
centers = []
|
||||
|
||||
for (px, py) in positions
|
||||
# Position relativ zu Feldgröße + Jitter
|
||||
cx = clamp(round(Int, px * N) + rand(-jitter_amount:jitter_amount), margin, N - margin)
|
||||
cy = clamp(round(Int, py * N) + rand(-jitter_amount:jitter_amount), margin, N - margin)
|
||||
|
||||
push!(centers, (cx, cy))
|
||||
|
||||
for x in (cx - radius):(cx + radius)
|
||||
for y in (cy - radius):(cy + radius)
|
||||
if x > 0 && x ≤ N && y > 0 && y ≤ N
|
||||
if sqrt((x - cx)^2 + (y - cy)^2) ≤ radius
|
||||
U[x, y] = 0.5
|
||||
V[x, y] = 0.25
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Observable holding current U for heatmap
|
||||
heat_obs = Observable(U)
|
||||
|
|
@ -124,12 +162,47 @@ param_box!(4, "kill", k)
|
|||
# Timer and state for animation
|
||||
running = Observable(false)
|
||||
function reset!(U, V, heat_obs)
|
||||
current_params()
|
||||
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
|
||||
|
||||
num_spots = 6
|
||||
jitter_amount = 5 # maximale Verschiebung in Pixeln
|
||||
margin = radius + 2 # Abstand zum Rand
|
||||
|
||||
# Manuell definierte gleichverteilte Positionen (6 Punkte)
|
||||
positions = [
|
||||
(1/4, 1/4),
|
||||
(3/4, 1/4),
|
||||
(1/2, 1/2),
|
||||
(1/4, 3/4),
|
||||
(3/4, 3/4),
|
||||
(1/2, 1/8)
|
||||
]
|
||||
|
||||
centers = []
|
||||
|
||||
for (px, py) in positions
|
||||
# Position relativ zu Feldgröße + Jitter
|
||||
cx = clamp(round(Int, px * N) + rand(-jitter_amount:jitter_amount), margin, N - margin)
|
||||
cy = clamp(round(Int, py * N) + rand(-jitter_amount:jitter_amount), margin, N - margin)
|
||||
|
||||
push!(centers, (cx, cy))
|
||||
|
||||
for x in (cx - radius):(cx + radius)
|
||||
for y in (cy - radius):(cy + radius)
|
||||
if x > 0 && x ≤ N && y > 0 && y ≤ N
|
||||
if sqrt((x - cx)^2 + (y - cy)^2) ≤ radius
|
||||
U[x, y] = 0.5
|
||||
V[x, y] = 0.25
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
heat_obs[] = copy(U)
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ struct FHNParams
|
|||
end
|
||||
|
||||
struct GSParams
|
||||
N::Int # grid size
|
||||
N::Int64 # grid size
|
||||
dx::Float64 # grid spacing
|
||||
Du::Float64 # diffusion rate U
|
||||
Dv::Float64 # diffusion rate V
|
||||
|
|
|
|||
Loading…
Reference in New Issue