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