1
0
Fork 0
mirror of https://gitlab.rlp.net/mobitar/ReCo.jl.git synced 2024-12-21 00:51:21 +00:00

Added parent_dir

This commit is contained in:
MoBit 2021-12-03 13:02:33 +01:00
parent c21d94be44
commit 02a6dd9489
2 changed files with 20 additions and 5 deletions

View file

@ -6,7 +6,7 @@ function run_sim(
dir::String; dir::String;
duration::Float64, duration::Float64,
snapshot_at::Float64=0.1, snapshot_at::Float64=0.1,
n_steps_before_verlet_list_update::Int64=1000, n_steps_before_verlet_list_update::Int64=100,
seed::Int64=42, seed::Int64=42,
n_bundle_snapshots::Int64=100, n_bundle_snapshots::Int64=100,
) )
@ -94,7 +94,7 @@ function run_sim(
save_data = true save_data = true
open("$runs_dir/run_vars_$next_bundle.json", "w") do f open("$runs_dir/run_vars_$next_bundle.json", "w") do f
JSON3.pretty(f, run_vars) JSON3.write(f, run_vars)
end end
else else
save_data = false save_data = false

View file

@ -38,7 +38,12 @@ function generate_particles(bundle::Bundle, N::Int64)
end end
function init_sim(; function init_sim(;
N::Int64, v::Float64, δt::Float64=1e-5, packing_ratio::Float64=0.5, comment::String="" N::Int64,
v::Float64,
δt::Float64=1e-5,
packing_ratio::Float64=0.5,
comment::String="",
parent_dir::String="",
) )
@assert N > 0 @assert N > 0
@assert v >= 0 @assert v >= 0
@ -83,11 +88,21 @@ function init_sim(;
bundle = Bundle(N, 1) bundle = Bundle(N, 1)
save_snapshot!(bundle, 1, 0.0, particles) save_snapshot!(bundle, 1, 0.0, particles)
dir = "exports/$(now())_N=$(N)_v=$(v)_#$(rand(1000:9999))$comment" particles = nothing
dir = "exports"
if length(parent_dir) > 0
dir *= "/$parent_dir"
end
dir *= "/$(now())_N=$(N)_v=$(v)_#$(rand(1000:9999))"
if length(comment) > 0
dir *= "_$comment"
end
mkpath(dir) mkpath(dir)
open("$dir/sim_consts.json", "w") do f open("$dir/sim_consts.json", "w") do f
JSON3.pretty(f, sim_consts) JSON3.write(f, sim_consts)
end end
save_bundle(dir, bundle, 1, 0.0) save_bundle(dir, bundle, 1, 0.0)