mirror of
https://gitlab.rlp.net/mobitar/ReCo.jl.git
synced 2024-11-08 22:21:08 +00:00
Added debug variable
This commit is contained in:
parent
8440c25a65
commit
5b016f7b68
2 changed files with 36 additions and 23 deletions
|
@ -17,33 +17,40 @@ function animate(sol::Solution, args, name_part::String; framerate::Int64=10)
|
||||||
animation_path = "exports/$name_part.mkv"
|
animation_path = "exports/$name_part.mkv"
|
||||||
|
|
||||||
record(fig, animation_path; framerate=framerate) do io
|
record(fig, animation_path; framerate=framerate) do io
|
||||||
|
circles = Vector{Circle}(undef, args.N)
|
||||||
|
colors = Vector{RGBAf}(undef, args.N)
|
||||||
|
|
||||||
|
if args.debug
|
||||||
segments_x = zeros(2 * args.N)
|
segments_x = zeros(2 * args.N)
|
||||||
segments_y = zeros(2 * args.N)
|
segments_y = zeros(2 * args.N)
|
||||||
|
|
||||||
circles = Vector{Circle}(undef, args.N)
|
|
||||||
interaction_circles = Vector{Circle}(undef, args.N)
|
interaction_circles = Vector{Circle}(undef, args.N)
|
||||||
skin_circles = Vector{Circle}(undef, args.N)
|
skin_circles = Vector{Circle}(undef, args.N)
|
||||||
|
|
||||||
colors = Vector{RGBAf}(undef, args.N)
|
|
||||||
interaction_colors = Vector{RGBAf}(undef, args.N)
|
interaction_colors = Vector{RGBAf}(undef, args.N)
|
||||||
skin_colors = Vector{RGBAf}(undef, args.N)
|
skin_colors = Vector{RGBAf}(undef, args.N)
|
||||||
|
end
|
||||||
|
|
||||||
@showprogress 0.5 for frame in 1:args.n_frames
|
@showprogress 0.5 for frame in 1:args.n_frames
|
||||||
@simd for i in 1:args.N
|
@simd for i in 1:args.N
|
||||||
circles[i] = Circle(Point2(sol.center[i, frame]), args.particle_diameter / 2)
|
circles[i] = Circle(Point2(sol.center[i, frame]), args.particle_diameter / 2)
|
||||||
|
|
||||||
|
color = get(ColorSchemes.rainbow, rem2pi(sol.φ[i, frame] / (2 * π), RoundDown))
|
||||||
|
colors[i] = RGBAf(color)
|
||||||
|
|
||||||
|
if args.debug
|
||||||
interaction_circles[i] = Circle(Point2(sol.center[i, frame]), args.interaction_r)
|
interaction_circles[i] = Circle(Point2(sol.center[i, frame]), args.interaction_r)
|
||||||
skin_circles[i] = Circle(Point2(sol.center[i, frame]), args.skin_r)
|
skin_circles[i] = Circle(Point2(sol.center[i, frame]), args.skin_r)
|
||||||
|
|
||||||
color = get(ColorSchemes.rainbow, rem2pi(sol.φ[i, frame] / (2 * π), RoundDown))
|
interaction_colors[i] = RGBAf(color, 0.12)
|
||||||
|
skin_colors[i] = RGBAf(color, 0.06)
|
||||||
colors[i] = RGBAf(color)
|
end
|
||||||
interaction_colors[i] = RGBAf(color, 0.15)
|
|
||||||
skin_colors[i] = RGBAf(color, 0.05)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if frame > 1
|
if frame > 1
|
||||||
empty!(ax)
|
empty!(ax)
|
||||||
|
|
||||||
|
if args.debug
|
||||||
@simd for i in 1:(args.N)
|
@simd for i in 1:(args.N)
|
||||||
segments_x[2 * i - 1] = sol.center[i, frame - 1][1]
|
segments_x[2 * i - 1] = sol.center[i, frame - 1][1]
|
||||||
segments_x[2 * i] = sol.center[i, frame][1]
|
segments_x[2 * i] = sol.center[i, frame][1]
|
||||||
|
@ -53,13 +60,17 @@ function animate(sol::Solution, args, name_part::String; framerate::Int64=10)
|
||||||
end
|
end
|
||||||
|
|
||||||
linesegments!(ax, segments_x, segments_y; color=colors)
|
linesegments!(ax, segments_x, segments_y; color=colors)
|
||||||
|
end
|
||||||
else
|
else
|
||||||
println("Started recording!")
|
println("Started recording!")
|
||||||
end
|
end
|
||||||
|
|
||||||
poly!(ax, circles; color=colors)
|
poly!(ax, circles; color=colors)
|
||||||
|
|
||||||
|
if args.debug
|
||||||
poly!(ax, interaction_circles; color=interaction_colors)
|
poly!(ax, interaction_circles; color=interaction_colors)
|
||||||
poly!(ax, skin_circles; color=skin_colors)
|
poly!(ax, skin_circles; color=skin_colors)
|
||||||
|
end
|
||||||
|
|
||||||
ax.title = "t = $(round(sol.t[frame], digits=3))"
|
ax.title = "t = $(round(sol.t[frame], digits=3))"
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@ function run(;
|
||||||
framerate::Int64=0,
|
framerate::Int64=0,
|
||||||
save_data::Bool=false,
|
save_data::Bool=false,
|
||||||
n_steps_before_verlet_list_update::Int64=100,
|
n_steps_before_verlet_list_update::Int64=100,
|
||||||
|
debug::Bool=false,
|
||||||
)
|
)
|
||||||
|
|
||||||
Random.seed!(42)
|
Random.seed!(42)
|
||||||
|
@ -49,6 +50,7 @@ function run(;
|
||||||
skin_r² = skin_r^2,
|
skin_r² = skin_r^2,
|
||||||
verlet_list = [PreVector(Int64, N - 1) for i in 1:(N - 1)],
|
verlet_list = [PreVector(Int64, N - 1) for i in 1:(N - 1)],
|
||||||
n_frames = floor(Int64, integration_steps / n_steps_before_save) + 1,
|
n_frames = floor(Int64, integration_steps / n_steps_before_save) + 1,
|
||||||
|
debug = debug,
|
||||||
)
|
)
|
||||||
|
|
||||||
sol, end_time = simulate(args, δt, T, n_steps_before_verlet_list_update, n_steps_before_save)
|
sol, end_time = simulate(args, δt, T, n_steps_before_verlet_list_update, n_steps_before_save)
|
||||||
|
|
Loading…
Reference in a new issue