From 97f6c69049ac3a0f611c5eaac95ac01f008630f1 Mon Sep 17 00:00:00 2001 From: cyfraysse Date: Wed, 20 May 2026 15:16:09 +0200 Subject: [PATCH 01/12] add phi field in the Molecules struct to be callable --- src/molecules.jl | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/molecules.jl b/src/molecules.jl index 399d08f..0f2d683 100644 --- a/src/molecules.jl +++ b/src/molecules.jl @@ -78,7 +78,11 @@ Returns function System(position, species, molecule, density::T, temperature::T, model_matrix, bonds; molecule_species=nothing, list_type=EmptyList, list_parameters=nothing) where {T<:AbstractFloat} @assert length(position) == length(species) N = length(position) +<<<<<<< HEAD Φ = Vector{Vector{SVector{3,T}}}() # empty, filled by ComputeRotation +======= + phi = Vector{Vector{SVector{3,T}}}() # empty, filled by ComputeRotation +>>>>>>> a55744b (add phi field in the Molecules struct to be callable) Nmol = length(unique(molecule)) start_mol, length_mol = get_first_and_counts(molecule) molecule_species = something(molecule_species, ones(Int, N)) @@ -87,7 +91,11 @@ function System(position, species, molecule, density::T, temperature::T, model_m energy = zeros(T, 1) maxcut = maximum([model.rcut for model in model_matrix]) neighbour_list = list_type(box, maxcut, N; list_parameters=list_parameters) +<<<<<<< HEAD system = Molecules(position, Φ, species, molecule, molecule_species, start_mol, length_mol, density, temperature, energy, model_matrix, d, N, Nmol,box, neighbour_list, bonds) +======= + system = Molecules(position, phi, species, molecule, molecule_species, start_mol, length_mol, density, temperature, energy, model_matrix, d, N, Nmol,box, neighbour_list, bonds) +>>>>>>> a55744b (add phi field in the Molecules struct to be callable) build_neighbour_list!(system) local_energy = [compute_energy_particle(system, i, neighbour_list) for i in eachindex(position)] energy = sum(local_energy) / 2 From 78661cb0d40914cf8026bed90f122a8d297edc76 Mon Sep 17 00:00:00 2001 From: cyfraysse Date: Thu, 28 May 2026 16:16:12 +0200 Subject: [PATCH 02/12] Implementation of threshold method, closer to initial ParticlesMC philosophy --- src/molecules.jl | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/molecules.jl b/src/molecules.jl index 0f2d683..399d08f 100644 --- a/src/molecules.jl +++ b/src/molecules.jl @@ -78,11 +78,7 @@ Returns function System(position, species, molecule, density::T, temperature::T, model_matrix, bonds; molecule_species=nothing, list_type=EmptyList, list_parameters=nothing) where {T<:AbstractFloat} @assert length(position) == length(species) N = length(position) -<<<<<<< HEAD Φ = Vector{Vector{SVector{3,T}}}() # empty, filled by ComputeRotation -======= - phi = Vector{Vector{SVector{3,T}}}() # empty, filled by ComputeRotation ->>>>>>> a55744b (add phi field in the Molecules struct to be callable) Nmol = length(unique(molecule)) start_mol, length_mol = get_first_and_counts(molecule) molecule_species = something(molecule_species, ones(Int, N)) @@ -91,11 +87,7 @@ function System(position, species, molecule, density::T, temperature::T, model_m energy = zeros(T, 1) maxcut = maximum([model.rcut for model in model_matrix]) neighbour_list = list_type(box, maxcut, N; list_parameters=list_parameters) -<<<<<<< HEAD system = Molecules(position, Φ, species, molecule, molecule_species, start_mol, length_mol, density, temperature, energy, model_matrix, d, N, Nmol,box, neighbour_list, bonds) -======= - system = Molecules(position, phi, species, molecule, molecule_species, start_mol, length_mol, density, temperature, energy, model_matrix, d, N, Nmol,box, neighbour_list, bonds) ->>>>>>> a55744b (add phi field in the Molecules struct to be callable) build_neighbour_list!(system) local_energy = [compute_energy_particle(system, i, neighbour_list) for i in eachindex(position)] energy = sum(local_energy) / 2 From 8dc10ff0c96b888b748d92cf5646491bdc17274e Mon Sep 17 00:00:00 2001 From: cyfraysse Date: Mon, 1 Jun 2026 15:04:22 +0200 Subject: [PATCH 03/12] =?UTF-8?q?changed=20variables=20'phi'=20to=20'?= =?UTF-8?q?=CE=A6'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/rotation.jl | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/rotation.jl b/src/rotation.jl index 09a08bf..f6cae74 100644 --- a/src/rotation.jl +++ b/src/rotation.jl @@ -151,7 +151,12 @@ function Arianna.finalise(::ComputeRotation, ::Simulation) end ##### Store rotation vector trajectory ##### ########## ########## +<<<<<<< HEAD function write_phi_frame(file::IOStream, t::Int, N_mol::Int, Φs::Vector{<:SVector}) +======= +function write_phi_frame(file::IOStream, t::Int, N_mol::Int, + Φs::Vector{<:SVector}) +>>>>>>> 1261e92 (changed variables 'phi' to 'Φ') println(file, N_mol) println(file, "t=$t") for m in 1:N_mol @@ -186,7 +191,11 @@ function Arianna.initialise(algorithm::StorePhiTrajectories, simulation::Simulat for c in eachindex(simulation.chains) system = simulation.chains[c] n_θ = length(system.Φ) +<<<<<<< HEAD algorithm.paths[c] = [joinpath(algorithm.dirs[c], "phitrajectories_$k.dat") +======= + algorithm.paths[c] = [joinpath(algorithm.dirs[c], "Φtrajectories_$k.dat") +>>>>>>> 1261e92 (changed variables 'phi' to 'Φ') for k in 1:n_θ] algorithm.files[c] = open.(algorithm.paths[c], "w") end From c28d263e62391cb68451679b2ba43a8fd9c5156a Mon Sep 17 00:00:00 2001 From: cyfraysse Date: Thu, 28 May 2026 16:59:54 +0200 Subject: [PATCH 04/12] initialise system.phi --- src/rotation.jl | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/rotation.jl b/src/rotation.jl index f6cae74..7953a1d 100644 --- a/src/rotation.jl +++ b/src/rotation.jl @@ -114,9 +114,15 @@ function Arianna.initialise(algorithm::ComputeRotation, simulation::Simulation) state.Φ_acc = [[zero(SVector{3,T}) for _ in 1:N_mol] for _ in 1:n_θ] state.initialized = true +<<<<<<< HEAD resize!(system.Φ, n_θ) # a posteriori as we know n_θ for k in 1:n_θ system.Φ[k] = [zero(SVector{3,T}) for _ in 1:N_mol] +======= + resize!(system.phi, n_θ) # a posteriori as we know n_θ + for k in 1:n_θ + system.phi[k] = [zero(SVector{3,T}) for _ in 1:N_mol] +>>>>>>> 366591a (initialise system.phi) end end end From d8f8802681574a2d08d23b2a38d0d6df150880b9 Mon Sep 17 00:00:00 2001 From: cyfraysse Date: Thu, 28 May 2026 17:35:39 +0200 Subject: [PATCH 05/12] add multithreads scheme copying Arianna way of implementing it --- src/rotation.jl | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/src/rotation.jl b/src/rotation.jl index 7953a1d..09a08bf 100644 --- a/src/rotation.jl +++ b/src/rotation.jl @@ -114,15 +114,9 @@ function Arianna.initialise(algorithm::ComputeRotation, simulation::Simulation) state.Φ_acc = [[zero(SVector{3,T}) for _ in 1:N_mol] for _ in 1:n_θ] state.initialized = true -<<<<<<< HEAD resize!(system.Φ, n_θ) # a posteriori as we know n_θ for k in 1:n_θ system.Φ[k] = [zero(SVector{3,T}) for _ in 1:N_mol] -======= - resize!(system.phi, n_θ) # a posteriori as we know n_θ - for k in 1:n_θ - system.phi[k] = [zero(SVector{3,T}) for _ in 1:N_mol] ->>>>>>> 366591a (initialise system.phi) end end end @@ -157,12 +151,7 @@ function Arianna.finalise(::ComputeRotation, ::Simulation) end ##### Store rotation vector trajectory ##### ########## ########## -<<<<<<< HEAD function write_phi_frame(file::IOStream, t::Int, N_mol::Int, Φs::Vector{<:SVector}) -======= -function write_phi_frame(file::IOStream, t::Int, N_mol::Int, - Φs::Vector{<:SVector}) ->>>>>>> 1261e92 (changed variables 'phi' to 'Φ') println(file, N_mol) println(file, "t=$t") for m in 1:N_mol @@ -197,11 +186,7 @@ function Arianna.initialise(algorithm::StorePhiTrajectories, simulation::Simulat for c in eachindex(simulation.chains) system = simulation.chains[c] n_θ = length(system.Φ) -<<<<<<< HEAD algorithm.paths[c] = [joinpath(algorithm.dirs[c], "phitrajectories_$k.dat") -======= - algorithm.paths[c] = [joinpath(algorithm.dirs[c], "Φtrajectories_$k.dat") ->>>>>>> 1261e92 (changed variables 'phi' to 'Φ') for k in 1:n_θ] algorithm.files[c] = open.(algorithm.paths[c], "w") end From 3726f552714d1b25c72a4a670666efc4336a7230 Mon Sep 17 00:00:00 2001 From: cyfraysse Date: Mon, 1 Jun 2026 16:49:00 +0200 Subject: [PATCH 06/12] using both the new scheduler and rotation formalism --- src/ParticlesMC.jl | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/src/ParticlesMC.jl b/src/ParticlesMC.jl index 9aa4921..b6d525c 100644 --- a/src/ParticlesMC.jl +++ b/src/ParticlesMC.jl @@ -112,6 +112,25 @@ function compute_energy_particle(system::Particles, ids::AbstractVector) return map(i -> compute_energy_particle(system, i), ids) end +""" + Helper for building scheduler based on TOML schedul parameters +""" + +function build_sched(scheduler_params, steps, burn) + if haskey(scheduler_params, "tmax") && haskey(scheduler_params, "tw") && haskey(scheduler_params, "N") + tmax = scheduler_params["tmax"] + tw = scheduler_params["tw"] + N = scheduler_params["N"] + return build_schedule(tmax, MultiOrigins(tw, N), burn=burn) + elseif haskey(scheduler_params, "log_base") + interval = get(scheduler_params, "linear_interval", 1) + block = build_schedule(interval, 0, 2.0) + return build_schedule(steps, burn, block) + else + interval = get(scheduler_params, "linear_interval", 1) + return build_schedule(steps, burn, interval) + end +end export energy #export nearest_image_distance @@ -256,13 +275,7 @@ ParticlesMC implemented in Comonicon. for observable in get(sim, "observable", []) alg = observable["algorithm"] scheduler_params = observable["scheduler_params"] - interval = get(scheduler_params, "linear_interval", 1) - if "log_base" in keys(scheduler_params) - block = build_schedule(interval, 0, 2.0) - sched = build_schedule(steps, burn, block) - else - sched = build_schedule(steps, burn, interval) - end + sched = build_sched(scheduler_params, steps, burn) if alg == "ComputeRotation" parameters = get(observable, "parameters", Dict()) theta_T = Float64.(get(parameters, "theta_T", [π/4])) @@ -284,13 +297,7 @@ ParticlesMC implemented in Comonicon. dependencies = get(output, "dependencies", nothing) callbacks = get(output, "callbacks", []) fmt = get(output, "fmt", "XYZ") - interval = scheduler_params["linear_interval"] - if "log_base" in keys(scheduler_params) - block = build_schedule(interval, 0, 2.0) - sched = build_schedule(steps, burn, block) - else - sched = build_schedule(steps, burn, interval) - end + sched = build_sched(scheduler_params, steps, burn) if alg == "StoreCallbacks" callbacks = map(c -> eval(Meta.parse("$c")), callbacks) algorithm = ( From a703ca8eeb6150e6e63aeab99eeb68ac09264e3d Mon Sep 17 00:00:00 2001 From: cyfraysse Date: Mon, 1 Jun 2026 17:06:07 +0200 Subject: [PATCH 07/12] changed rotation file name Greek letter are annoying for post processing --- src/rotation.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rotation.jl b/src/rotation.jl index 09a08bf..c3936c8 100644 --- a/src/rotation.jl +++ b/src/rotation.jl @@ -3,7 +3,7 @@ # Compute on-the-fly rotation tracker. # Two algorithms : # 1. ComputeRotation : updates system.Φ (simulation.observable) -# 2. StoreΦTrajectory : writes system.Φ to disk +# 2. StorePhiTrajectory : writes system.Φ to disk # system.Φ[k][m] = rotation vector for molecule m under theta_T[k] using LinearAlgebra From 642bed2ca42dba2f2ae9ba7555653c983317d9ed Mon Sep 17 00:00:00 2001 From: cyfraysse Date: Tue, 2 Jun 2026 12:11:51 +0200 Subject: [PATCH 08/12] used a Dict for multi_origins parser --- src/ParticlesMC.jl | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/ParticlesMC.jl b/src/ParticlesMC.jl index b6d525c..5c1dbc2 100644 --- a/src/ParticlesMC.jl +++ b/src/ParticlesMC.jl @@ -117,10 +117,10 @@ end """ function build_sched(scheduler_params, steps, burn) - if haskey(scheduler_params, "tmax") && haskey(scheduler_params, "tw") && haskey(scheduler_params, "N") - tmax = scheduler_params["tmax"] - tw = scheduler_params["tw"] - N = scheduler_params["N"] + if haskey(scheduler_params, "multi_origins") + tmax = scheduler_params["multi_origins"]["tmax"] + tw = scheduler_params["multi_origins"]["tw"] + N = scheduler_params["multi_origins"]["N"] return build_schedule(tmax, MultiOrigins(tw, N), burn=burn) elseif haskey(scheduler_params, "log_base") interval = get(scheduler_params, "linear_interval", 1) From 267ebb6cd8fc2a3940e42cc9e36586e54f7ac07a Mon Sep 17 00:00:00 2001 From: cyfraysse Date: Wed, 3 Jun 2026 14:22:49 +0200 Subject: [PATCH 09/12] collect --> tcollect to better manage multithreads --- src/rotation.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rotation.jl b/src/rotation.jl index c3936c8..64daf76 100644 --- a/src/rotation.jl +++ b/src/rotation.jl @@ -126,7 +126,7 @@ end function Arianna.make_step!(simulation::Simulation, algorithm::ComputeRotation) - collect(eachindex(simulation.chains) |> Transducers.Map(c -> begin + tcollect(eachindex(simulation.chains) |> Transducers.Map(c -> begin system = simulation.chains[c] state = algorithm.states[c] N_mol = system.Nmol From 621c8e45315703d46a7014a0e1799667a9ef3e59 Mon Sep 17 00:00:00 2001 From: cyfraysse Date: Tue, 9 Jun 2026 11:06:06 +0200 Subject: [PATCH 10/12] change name 'build_sched' for 'parse_schedule' --- src/ParticlesMC.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ParticlesMC.jl b/src/ParticlesMC.jl index 5c1dbc2..58b70f8 100644 --- a/src/ParticlesMC.jl +++ b/src/ParticlesMC.jl @@ -116,7 +116,7 @@ end Helper for building scheduler based on TOML schedul parameters """ -function build_sched(scheduler_params, steps, burn) +function parse_schedule(scheduler_params, steps, burn) if haskey(scheduler_params, "multi_origins") tmax = scheduler_params["multi_origins"]["tmax"] tw = scheduler_params["multi_origins"]["tw"] From 6b3579e658b437e9a97b05769e90c4549fe114b0 Mon Sep 17 00:00:00 2001 From: cyfraysse Date: Tue, 9 Jun 2026 12:12:44 +0200 Subject: [PATCH 11/12] remove tmax which is steps --- src/ParticlesMC.jl | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/ParticlesMC.jl b/src/ParticlesMC.jl index 58b70f8..71e94f3 100644 --- a/src/ParticlesMC.jl +++ b/src/ParticlesMC.jl @@ -118,10 +118,9 @@ end function parse_schedule(scheduler_params, steps, burn) if haskey(scheduler_params, "multi_origins") - tmax = scheduler_params["multi_origins"]["tmax"] tw = scheduler_params["multi_origins"]["tw"] N = scheduler_params["multi_origins"]["N"] - return build_schedule(tmax, MultiOrigins(tw, N), burn=burn) + return build_schedule(steps, MultiOrigins(tw, N), burn=burn) elseif haskey(scheduler_params, "log_base") interval = get(scheduler_params, "linear_interval", 1) block = build_schedule(interval, 0, 2.0) From 2ca71890fceaed62ec4637893a533dfde4b760bb Mon Sep 17 00:00:00 2001 From: cyfraysse Date: Tue, 9 Jun 2026 12:14:32 +0200 Subject: [PATCH 12/12] change call build_sched for parse_schedule --- src/ParticlesMC.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ParticlesMC.jl b/src/ParticlesMC.jl index 71e94f3..0760b26 100644 --- a/src/ParticlesMC.jl +++ b/src/ParticlesMC.jl @@ -274,7 +274,7 @@ ParticlesMC implemented in Comonicon. for observable in get(sim, "observable", []) alg = observable["algorithm"] scheduler_params = observable["scheduler_params"] - sched = build_sched(scheduler_params, steps, burn) + sched = parse_schedule(scheduler_params, steps, burn) if alg == "ComputeRotation" parameters = get(observable, "parameters", Dict()) theta_T = Float64.(get(parameters, "theta_T", [π/4])) @@ -296,7 +296,7 @@ ParticlesMC implemented in Comonicon. dependencies = get(output, "dependencies", nothing) callbacks = get(output, "callbacks", []) fmt = get(output, "fmt", "XYZ") - sched = build_sched(scheduler_params, steps, burn) + sched = parse_schedule(scheduler_params, steps, burn) if alg == "StoreCallbacks" callbacks = map(c -> eval(Meta.parse("$c")), callbacks) algorithm = (