From 792fe7b437e7926c51a089fc61f974f48718d906 Mon Sep 17 00:00:00 2001 From: Mo8it Date: Tue, 8 Feb 2022 22:18:44 +0100 Subject: [PATCH] Add snapshot plot documentation --- README.adoc | 13 ++++++++++--- src/Visualization/Animation.jl | 5 +++-- src/Visualization/SnapshotPlot.jl | 21 +++++++++++++++++++-- 3 files changed, 32 insertions(+), 7 deletions(-) diff --git a/README.adoc b/README.adoc index e22f65f..6d16465 100644 --- a/README.adoc +++ b/README.adoc @@ -85,13 +85,20 @@ To generate an animation of a simulation, run the following: animate(sim_dir) ---- -The method's documentation includes all possible optional arguments. +The method's documentation includes all possible optional arguments and where the output can be found. === Snapshot plot -//TODO +To plot only one snapshot of a simulation, run the following: -== Run reinforcement learning +[source,julia] +---- +plot_snapshot(sim_dir) +---- + +This will ask for the number of the snapshot to plot out of the total number of snapshots. The method's documentation includes all possible optional arguments and where the output can be found. + +== Run reinforcement learning process Run a reinforcement learning process and return the environment helper and the the path of the process directory relative to the directory `ReCo.jl`: [source,julia] diff --git a/src/Visualization/Animation.jl b/src/Visualization/Animation.jl index c1055fd..428ed33 100644 --- a/src/Visualization/Animation.jl +++ b/src/Visualization/Animation.jl @@ -156,11 +156,12 @@ Animate a simulation. The output is `sim_dir/animation.mkv`. # Arguments +- `sim_dir::String`: Simulation directory. - `framerate::Int64=$DEFAULT_FRAMERATE`: Framerate -- `show_center_of_mass::Bool=$DEFAULT_SHOW_CENTER_OF_MASS`: Show center of mass as transparent white circle. +- `show_center_of_mass::Bool=$DEFAULT_SHOW_CENTER_OF_MASS`: Show the center of mass as transparent white circle. - `show_interaction_circle::Bool=$DEFAULT_SHOW_INTERACTION_CIRCLE`: Show the interaction radius with a circle around every particle. - `show_skin_circle::Bool=$DEFAULT_SHOW_SKIN_CIRCLE`: Show the skin radius with a circle around every particle. -- `show_frame_diff::Bool=$DEFAULT_SHOW_FRAME_DIFF`: Show translation of particles between two frames as lines connecting the old and new position. This is helpful to recognize unwanted jumps. +- `show_frame_diff::Bool=$DEFAULT_SHOW_FRAME_DIFF`: Show the translation of particles between two frames as lines connecting the old and new position. This is helpful to recognize unwanted jumps. - `show_progress::Bool=$DEFAULT_SHOW_PROGRESS`: Show animation progress bar. """ function animate( diff --git a/src/Visualization/SnapshotPlot.jl b/src/Visualization/SnapshotPlot.jl index dfa0f48..180f81d 100644 --- a/src/Visualization/SnapshotPlot.jl +++ b/src/Visualization/SnapshotPlot.jl @@ -11,6 +11,9 @@ using ..ReCo: ReCo include("common.jl") include("common_CairoMakie.jl") +const DEFAULT_SHOW_CENTER_OF_MASS = false +const DEFAULT_SHOW_KAPPA = true + function get_wanted_snapshot_number(total_n_snapshots::Int64) print("There are $total_n_snapshots snapshots. Enter the wanted snapshot number: ") answer = readline() @@ -20,8 +23,22 @@ function get_wanted_snapshot_number(total_n_snapshots::Int64) return snapshot end +""" + plot_snapshot(sim_dir::String; ) + +Plot one snapshot of a simulation. + +The method will ask for the number of the snapshot to plot out of the total number of snapshots. The output is `sim_dir/graphics/N.pdf` with `N` as the number of the chosen snapshot. + +# Arguments +- `sim_dir::String`: Simulation directory. +- `show_center_of_mass::Bool=$DEFAULT_SHOW_CENTER_OF_MASS`: Show the center of mass as a transparent black circle. +- `show_κ::Bool=$DEFAULT_SHOW_KAPPA`: Show κ as the ratio of the eigenvalues of the gyration tensor. +""" function plot_snapshot( - sim_dir::String; show_center_of_mass::Bool=false, show_eigvals_ratio::Bool=true + sim_dir::String; + show_center_of_mass::Bool=DEFAULT_SHOW_CENTER_OF_MASS, + show_κ::Bool=DEFAULT_SHOW_KAPPA, ) bundles_info = ReCo.BundlesInfo(sim_dir) wanted_snapshot_out_of_total = get_wanted_snapshot_number( @@ -42,7 +59,7 @@ function plot_snapshot( cs_view = view(bundle.c, :, bundle_snapshot) center_of_mass = ReCo.center_of_mass(cs_view, sim_consts.half_box_len) - if show_eigvals_ratio + if show_κ eigvals_ratio = ReCo.gyration_tensor_eigvals_ratio( cs_view, sim_consts.half_box_len, center_of_mass )