I want to solve an SDE which evolves in time and the user can interact with the parameters of the problem. It is a bit similar to the following apart from the fact that it does not work… Hence, I would need a last push to complete my simulation…
I would like timer_sde to be updated and plotted every 0.1s and I would like the widget to feed back J,sigma,... to the stepper
using Plots, Interact
N = 10
timer_sde = Observable(rand(N))
function step!(x,iter,sigma,dt, J)
for ii=1:iter
@. x = x .+ (-x .+ J .* sum(x)) .* dt + (sigma) .* sqrt(dt) .* randn(length(x))
end
end
@async while true
sleep(0.1)
step!(timer_sde,100,0.1,0.1, 0.1)
end
@manipulate for sigma = 0:0.1:4, J = 0:0.1:5, y = timer_sde
plot(y)
end
using Interact, GR, Statistics
N = 200
x = rand(N)
timer_sde = Observable(0.0)
function stepp!(x,iter,dt::Float64,sigma = 0.1,J = 1.0)
for ii=1:iter
x .= x .+ (-x .+ J .* mean(x)) .* dt .+ (sigma) .* sqrt(dt) .* randn(N)
end
end
@async while true
sleep(0.02)
timer_sde[] = timer_sde[] + 1
end
# gr(size=(1000,300), html_output_format=:png)
@manipulate for sigma = 0:0.1:1, J = 0:0.1:1, t = timer_sde
stepp!(x,10,0.1,sigma, J);
GR.plot(x,ylim=(-2,2),size=(1000,300),xlabel="N")
end