diff --git a/src/run.jl b/src/run.jl index af311e2..4daa814 100644 --- a/src/run.jl +++ b/src/run.jl @@ -6,7 +6,7 @@ function run_sim( dir::String; duration::Float64, snapshot_at::Float64=0.1, - n_steps_before_verlet_list_update::Int64=1000, + n_steps_before_verlet_list_update::Int64=100, seed::Int64=42, n_bundle_snapshots::Int64=100, ) @@ -94,7 +94,7 @@ function run_sim( save_data = true open("$runs_dir/run_vars_$next_bundle.json", "w") do f - JSON3.pretty(f, run_vars) + JSON3.write(f, run_vars) end else save_data = false diff --git a/src/setup.jl b/src/setup.jl index 2834dc8..be5a27c 100644 --- a/src/setup.jl +++ b/src/setup.jl @@ -38,7 +38,12 @@ function generate_particles(bundle::Bundle, N::Int64) end 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 v >= 0 @@ -83,11 +88,21 @@ function init_sim(; bundle = Bundle(N, 1) 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) open("$dir/sim_consts.json", "w") do f - JSON3.pretty(f, sim_consts) + JSON3.write(f, sim_consts) end save_bundle(dir, bundle, 1, 0.0)