Okay cool!
Here’s how I animated it (there was a using Printf
for the string formatting before this):
julia> anim = @animate for i in 1:1000:length(t)
plot(F_s; label="F_s")
plot!(f_s[i]; label=@sprintf("f_s at t = %.2f s", t[i]), ylims=(0.0,1.5))
end;
julia> gif(anim, "Desktop/probs.gif"; fps=10)
2 Likes
This subtraction you’re doing is not the one that is being described in the differential equation though is it?. It’s “construct a new distribution by repeatedly choose a random value from F(v) and a random value from f(v) and subtracting them” right? (Of course maybe that’s what the notation means, but if so it’s a truly terrible notation for the ambiguity)
@jonniedie Would you mind if I could take a look at what your code looks likes exactly to get the animation? Here is the entirety of my code, but I am not reproducing your animation:
v_col = 1
dt = 10^(-5) # timestep
t = range(0, 1.0, step=dt)
f_s0 = Particles(Uniform(0,1))
f_s = [f_s0]
F_s = Particles(Chi(3))
for it in 1:length(t)-1
push!(f_s, dt*v_col*(F_s - f_s[it]) + f_s[it])
end
#plot(t, f_s)
anim = @animate for i in 1:1000:length(t)
plot(F_s; label="F_s")
plot!(f_s[i]; label=@sprintf("f_s at t = %.2f s", t[i]), ylims=(0.0,1.5))
end;
gif(anim, "Simple_BGK.gif"; fps=10)
1 Like
Oh, you might need this line to set the plot defaults
But I did everything in the REPL, so I don’t have any way of easily pulling it together.
1 Like
Thank you so much!
Quick question, the way I discretized the value right now is explicitly. If I want to create two side by side subplots (one of the explicit method, one of the implicit method) and create an animation, would it be the same way as creating two subplots regularly?
Yep! The @animate
loop can handle subplots too.
1 Like