Skip to content

Commit 72f98b8

Browse files
authored
New scheduler building logic ; Arianna.jl dependency to v0.2.1 (#79)
This PR is using `Arianna.jl` new dependency which introduces a new way to schedule outputs in simulation. Created the `build_sched(scheduler_params, steps, burn)` helper function to eliminate duplicated [if/else](url) structures block for observables and outputs. The new scheduler is called in TOML by the keyword : `multi_origins`. e.g : `scheduler_params = {multi_origins = {tmax = x , tw = y , N = z}}`
1 parent 257300f commit 72f98b8

2 files changed

Lines changed: 22 additions & 16 deletions

File tree

src/ParticlesMC.jl

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,24 @@ function compute_energy_particle(system::Particles, ids::AbstractVector)
112112
return map(i -> compute_energy_particle(system, i), ids)
113113
end
114114

115+
"""
116+
Helper for building scheduler based on TOML schedul parameters
117+
"""
118+
119+
function parse_schedule(scheduler_params, steps, burn)
120+
if haskey(scheduler_params, "multi_origins")
121+
tw = scheduler_params["multi_origins"]["tw"]
122+
N = scheduler_params["multi_origins"]["N"]
123+
return build_schedule(steps, MultiOrigins(tw, N), burn=burn)
124+
elseif haskey(scheduler_params, "log_base")
125+
interval = get(scheduler_params, "linear_interval", 1)
126+
block = build_schedule(interval, 0, 2.0)
127+
return build_schedule(steps, burn, block)
128+
else
129+
interval = get(scheduler_params, "linear_interval", 1)
130+
return build_schedule(steps, burn, interval)
131+
end
132+
end
115133

116134
export energy
117135
#export nearest_image_distance
@@ -256,13 +274,7 @@ ParticlesMC implemented in Comonicon.
256274
for observable in get(sim, "observable", [])
257275
alg = observable["algorithm"]
258276
scheduler_params = observable["scheduler_params"]
259-
interval = get(scheduler_params, "linear_interval", 1)
260-
if "log_base" in keys(scheduler_params)
261-
block = build_schedule(interval, 0, 2.0)
262-
sched = build_schedule(steps, burn, block)
263-
else
264-
sched = build_schedule(steps, burn, interval)
265-
end
277+
sched = parse_schedule(scheduler_params, steps, burn)
266278
if alg == "ComputeRotation"
267279
parameters = get(observable, "parameters", Dict())
268280
theta_T = Float64.(get(parameters, "theta_T", [π/4]))
@@ -284,13 +296,7 @@ ParticlesMC implemented in Comonicon.
284296
dependencies = get(output, "dependencies", nothing)
285297
callbacks = get(output, "callbacks", [])
286298
fmt = get(output, "fmt", "XYZ")
287-
interval = scheduler_params["linear_interval"]
288-
if "log_base" in keys(scheduler_params)
289-
block = build_schedule(interval, 0, 2.0)
290-
sched = build_schedule(steps, burn, block)
291-
else
292-
sched = build_schedule(steps, burn, interval)
293-
end
299+
sched = parse_schedule(scheduler_params, steps, burn)
294300
if alg == "StoreCallbacks"
295301
callbacks = map(c -> eval(Meta.parse("$c")), callbacks)
296302
algorithm = (

src/rotation.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# Compute on-the-fly rotation tracker.
44
# Two algorithms :
55
# 1. ComputeRotation : updates system.Φ (simulation.observable)
6-
# 2. StoreΦTrajectory : writes system.Φ to disk
6+
# 2. StorePhiTrajectory : writes system.Φ to disk
77
# system.Φ[k][m] = rotation vector for molecule m under theta_T[k]
88

99
using LinearAlgebra
@@ -126,7 +126,7 @@ end
126126

127127
function Arianna.make_step!(simulation::Simulation, algorithm::ComputeRotation)
128128

129-
collect(eachindex(simulation.chains) |> Transducers.Map(c -> begin
129+
tcollect(eachindex(simulation.chains) |> Transducers.Map(c -> begin
130130
system = simulation.chains[c]
131131
state = algorithm.states[c]
132132
N_mol = system.Nmol

0 commit comments

Comments
 (0)