Skip to content

Commit 3a80df3

Browse files
committed
Change all input/launch files to comply with new version
1 parent 1311e86 commit 3a80df3

10 files changed

Lines changed: 72 additions & 36 deletions

File tree

examples/lj-mixture/run-validation.py

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,12 @@ def create_params(parameters: dict, path_to_params: str) -> None:
116116
117117
[[simulation.output]]
118118
algorithm = "StoreCallbacks"
119-
callbacks = ["energy", "acceptance"]
119+
callbacks = ["energy"]
120+
scheduler_params = {{linear_interval = 100}}
121+
122+
[[simulation.output]]
123+
algorithm = "StoreAcceptance"
124+
dependencies = ["Metropolis"]
120125
scheduler_params = {{linear_interval = 100}}
121126
122127
[[simulation.output]]
@@ -128,12 +133,12 @@ def create_params(parameters: dict, path_to_params: str) -> None:
128133

129134

130135
def run_simulations(output_path: str) -> None:
131-
df = pd.read_csv("reference-data.csv")
136+
df_ref = pd.read_csv("reference-data.csv")
132137

133138
path_to_config = "config.exyz"
134139
path_to_params = "params.toml"
135140
data = []
136-
for i, row in df.iterrows():
141+
for i, row in df_ref.iterrows():
137142
workdir = f"./tmp/{i}"
138143
os.makedirs(workdir, exist_ok=True)
139144

@@ -168,17 +173,31 @@ def run_simulations(output_path: str) -> None:
168173
)
169174

170175
# Post-process the energies
171-
energies = pd.read_csv(f"{workdir}/energy.dat", sep="\\s+", names=["i", "e"])[
176+
energies = pd.read_csv(f"{workdir}/chains/1/energy.dat", sep="\\s+", names=["i", "e"])[
172177
"e"
173178
]
174179
# Remove the first half as equilibration, just to be sure
175180
energies = energies[int(len(energies) / 2) :]
181+
182+
moves = {
183+
1: "displacement",
184+
2: "swap",
185+
}
176186

177-
df_acceptance_rates = pd.read_csv(
178-
f"{workdir}/acceptance.dat", sep="\\s+", names=["i", "move", "swap"]
179-
)
180-
displacement_acceptance = float(df_acceptance_rates["move"].iloc[-1][1:-2])
181-
swap_acceptance = float(df_acceptance_rates["swap"].iloc[-1][:-1])
187+
dfs = []
188+
189+
for move_id, move_name in moves.items():
190+
path = f"{workdir}/moves/{move_id}/acceptance.dat"
191+
df = pd.read_csv(path, sep=r"\s+", names=["i", move_name])
192+
dfs.append(df)
193+
194+
# Merge all on column "i"
195+
df_acceptance_rates = dfs[0]
196+
for df in dfs[1:]:
197+
df_acceptance_rates = df_acceptance_rates.merge(df, on="i")
198+
199+
displacement_acceptance = float(df_acceptance_rates["displacement"].iloc[-1])
200+
swap_acceptance = float(df_acceptance_rates["swap"].iloc[-1])
182201

183202
# Compute long-range corrections from the cutoff
184203
# Formula from Gromacs https://manual.gromacs.org/current/reference-manual/functions/long-range-vdw.html
@@ -207,8 +226,7 @@ def run_simulations(output_path: str) -> None:
207226
"acceptance_rate_swap": swap_acceptance,
208227
}
209228
)
210-
211-
df.merge(pd.DataFrame(data)).to_csv(output_path)
229+
df_ref.merge(pd.DataFrame(data)).to_csv(output_path)
212230

213231

214232
def plot_results(path_to_energies: str) -> None:

examples/movie/params.toml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,12 @@ parameters = {sigma = 0.05}
2020

2121
[[simulation.output]]
2222
algorithm = "StoreCallbacks"
23-
callbacks = ["energy", "acceptance"]
23+
callbacks = ["energy"]
24+
scheduler_params = {linear_interval = 500}
25+
26+
[[simulation.output]]
27+
algorithm = "StoreAcceptance"
28+
dependencies = ["Metropolis"]
2429
scheduler_params = {linear_interval = 500}
2530

2631
[[simulation.output]]

examples/ortho-terphenyl/2-equilibrate-at-different-temperatures/params-template.toml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,12 @@ policy = "DoubleUniform"
6969

7070
[[simulation.output]]
7171
algorithm = "StoreCallbacks"
72-
callbacks = ["energy", "acceptance"]
72+
callbacks = ["energy"]
73+
scheduler_params = {linear_interval = 1000}
74+
75+
[[simulation.output]]
76+
algorithm = "StoreAcceptance"
77+
dependencies = ["Metropolis"]
7378
scheduler_params = {linear_interval = 1000}
7479

7580
[[simulation.output]]

examples/ortho-terphenyl/3-run-production/params-template.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ policy = "DoubleUniform"
6969

7070
[[simulation.output]]
7171
algorithm = "StoreCallbacks"
72-
callbacks = ["energy", "acceptance"]
72+
callbacks = ["energy"]
7373
scheduler_params = {linear_interval = 1000}
7474

7575
[[simulation.output]]

examples/ortho-terphenyl/4-compute-correlation-functions/compute-observables.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def compute_fskt() -> pd.DataFrame:
2020
df_list = []
2121
for T in temperatures:
2222
print(f"T = {T}")
23-
traj = Trajectory(f"../3-run-production/{T}/trajectories/1/trajectory.xyz")
23+
traj = Trajectory(f"../3-run-production/{T}/chains/1/trajectory.xyz")
2424

2525
cf = pp.SelfIntermediateScatteringFast(
2626
traj,

test/gerhard_energy_distribution.jl

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ steps = 1000
2929
burn = 0
3030
block = [0, 10]
3131
sampletimes = build_schedule(steps, burn, block)
32-
callbacks = (callback_energy, callback_acceptance)
3332

3433
# NO SWAPS
3534
pswap = 0.0
@@ -41,7 +40,8 @@ pool = (
4140

4241
algorithm_list = (
4342
(algorithm=Metropolis, pool=pool, seed=seed, parallel=false, sweepstep=system.N),
44-
(algorithm=StoreCallbacks, callbacks=(callback_energy, callback_acceptance), scheduler=sampletimes),
43+
(algorithm=StoreCallbacks, callbacks=(energy,), scheduler=sampletimes),
44+
(algorithm=StoreAcceptance, dependencies=(Metropolis,), scheduler=sampletimes),
4545
(algorithm=StoreTrajectories, scheduler=sampletimes, fmt=EXYZ()),
4646
(algorithm=StoreLastFrames, scheduler=[steps], fmt=EXYZ()),
4747
(algorithm=PrintTimeSteps, scheduler=build_schedule(steps, burn, steps ÷ 10)),
@@ -72,7 +72,8 @@ pool = (
7272
)
7373
algorithm_list = (
7474
(algorithm=Metropolis, pool=pool, seed=seed, parallel=false, sweepstep=system.N),
75-
(algorithm=StoreCallbacks, callbacks=(callback_energy, callback_acceptance), scheduler=sampletimes),
75+
(algorithm=StoreCallbacks, callbacks=(energy,), scheduler=sampletimes),
76+
(algorithm=StoreAcceptance, dependencies=(Metropolis,), scheduler=sampletimes),
7677
(algorithm=StoreTrajectories, scheduler=sampletimes, fmt=LAMMPS()),
7778
(algorithm=StoreLastFrames, scheduler=[steps], fmt=EXYZ()),
7879
(algorithm=PrintTimeSteps, scheduler=build_schedule(steps, burn, steps ÷ 10)),
@@ -105,7 +106,8 @@ pool = (
105106
)
106107
algorithm_list = (
107108
(algorithm=Metropolis, pool=pool, seed=seed, parallel=false, sweepstep=system.N),
108-
(algorithm=StoreCallbacks, callbacks=(callback_energy, callback_acceptance), scheduler=sampletimes),
109+
(algorithm=StoreCallbacks, callbacks=(energy,), scheduler=sampletimes),
110+
(algorithm=StoreAcceptance, dependencies=(Metropolis,), scheduler=sampletimes),
109111
(algorithm=StoreTrajectories, scheduler=sampletimes, fmt=LAMMPS()),
110112
(algorithm=StoreLastFrames, scheduler=[steps], fmt=LAMMPS()),
111113
(algorithm=PrintTimeSteps, scheduler=build_schedule(steps, burn, steps ÷ 10)),

test/molecules_test.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ callbacks = (callback_energy, callback_acceptance)
4343
path = "data/test/particles/Molecules/T$temperature/N$N/M$M/seed$seed"
4444
algorithm_list = (
4545
(algorithm=Metropolis, pool=pool, seed=seed, parallel=false, sweepstep=N),
46-
(algorithm=StoreCallbacks, callbacks=(callback_energy, callback_acceptance), scheduler=sampletimes),
47-
(algorithm=StoreTrajectories, scheduler=sampletimes, fmt=XYZ()),
46+
(algorithm=StoreCallbacks, callbacks=(energy,), scheduler=sampletimes),
47+
(algorithm=StoreAcceptance, dependencies=(Metropolis,), scheduler=sampletimes), (algorithm=StoreTrajectories, scheduler=sampletimes, fmt=XYZ()),
4848
(algorithm=StoreLastFrames, scheduler=[steps], fmt=XYZ()),
4949
(algorithm=PrintTimeSteps, scheduler=build_schedule(steps, burn, steps ÷ 10), fmt=XYZ())
5050
)

test/params.toml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,14 @@ parameters = {sigma = 0.05}
2020

2121
[[simulation.output]]
2222
algorithm = "StoreCallbacks"
23-
callbacks = ["energy", "acceptance"]
23+
callbacks = ["energy"]
2424
scheduler_params = {linear_interval = 100}
2525

26+
[[simulation.output]]
27+
algorithm = "StoreAcceptance"
28+
dependencies = ["Metropolis"]
29+
scheduler_params = {linear_interval = 500}
30+
2631
[[simulation.output]]
2732
algorithm = "StoreTrajectories"
2833
scheduler_params = {linear_interval = 100}

test/runtests.jl

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ end
4646
burn = 0
4747
block = [0, 1, 2, 4, 8]
4848
sampletimes = build_schedule(steps, burn, block)
49-
callbacks = (callback_energy, callback_acceptance)
5049

5150
# NO SWAPS
5251
pswap = 0.0
@@ -57,7 +56,8 @@ end
5756
)
5857
algorithm_list = (
5958
(algorithm=Metropolis, pool=pool, seed=seed, parallel=false, sweepstep=system_el.N),
60-
(algorithm=StoreCallbacks, callbacks=(callback_energy, callback_acceptance), scheduler=sampletimes),
59+
(algorithm=StoreCallbacks, callbacks=(energy,), scheduler=sampletimes),
60+
(algorithm=StoreAcceptance, dependencies=(Metropolis,), scheduler=sampletimes),
6161
(algorithm=StoreTrajectories, scheduler=sampletimes, fmt=EXYZ()),
6262
(algorithm=StoreLastFrames, scheduler=[steps], fmt=LAMMPS()),
6363
(algorithm=PrintTimeSteps, scheduler=build_schedule(steps, burn, steps ÷ 10)),
@@ -81,9 +81,9 @@ end
8181
run!(simulation)
8282

8383
## Read energy data and compare
84-
path_energy_el = joinpath(path_el, "energy.dat")
85-
path_energy_ll = joinpath(path_ll, "energy.dat")
86-
path_energy_vl = joinpath(path_vl, "energy.dat")
84+
path_energy_el = joinpath(path_el, "chains/1/energy.dat")
85+
path_energy_ll = joinpath(path_ll, "chains/1/energy.dat")
86+
path_energy_vl = joinpath(path_vl, "chains/1/energy.dat")
8787
energy_el= readdlm(path_energy_el)[:, 2]
8888
energy_ll = readdlm(path_energy_ll)[:, 2]
8989
energy_vl = readdlm(path_energy_vl)[:, 2]
@@ -103,7 +103,8 @@ end
103103
)
104104
algorithm_list = (
105105
(algorithm=Metropolis, pool=pool, seed=seed, parallel=false, sweepstep=system_el.N),
106-
(algorithm=StoreCallbacks, callbacks=(callback_energy, callback_acceptance), scheduler=sampletimes, fmt=XYZ()),
106+
(algorithm=StoreCallbacks, callbacks=(energy,), scheduler=sampletimes),
107+
(algorithm=StoreAcceptance, dependencies=(Metropolis,), scheduler=sampletimes),
107108
(algorithm=StoreTrajectories, scheduler=sampletimes, fmt=XYZ()),
108109
(algorithm=StoreLastFrames, scheduler=[steps], fmt=XYZ()),
109110
(algorithm=PrintTimeSteps, scheduler=build_schedule(steps, burn, steps ÷ 10), fmt=XYZ()),
@@ -121,8 +122,8 @@ end
121122
run!(simulation)
122123

123124
## Read energy data and compare
124-
path_energy_el = joinpath(path_el, "energy.dat")
125-
path_energy_ll = joinpath(path_ll, "energy.dat")
125+
path_energy_el = joinpath(path_el, "chains/1/energy.dat")
126+
path_energy_ll = joinpath(path_ll, "chains/1/energy.dat")
126127
energy_el= readdlm(path_energy_el)[:, 2]
127128
energy_ll = readdlm(path_energy_ll)[:, 2]
128129
@test isapprox(energy_el, energy_ll, atol=1e-6)
@@ -154,7 +155,6 @@ end
154155
burn = 0
155156
block = [0, 1, 2, 4, 8]
156157
sampletimes = build_schedule(steps, burn, block)
157-
callbacks = (callback_energy, callback_acceptance)
158158

159159
# NO SWAPS
160160
pswap = 0.0
@@ -165,7 +165,8 @@ end
165165
)
166166
algorithm_list = (
167167
(algorithm=Metropolis, pool=pool, seed=seed, parallel=false, sweepstep=system_el.N),
168-
(algorithm=StoreCallbacks, callbacks=(callback_energy, callback_acceptance), scheduler=sampletimes),
168+
(algorithm=StoreCallbacks, callbacks=(energy,), scheduler=sampletimes),
169+
(algorithm=StoreAcceptance, dependencies=(Metropolis,), scheduler=sampletimes),
169170
(algorithm=StoreTrajectories, scheduler=sampletimes, fmt=EXYZ()),
170171
(algorithm=StoreLastFrames, scheduler=[steps], fmt=EXYZ()),
171172
(algorithm=PrintTimeSteps, scheduler=build_schedule(steps, burn, steps ÷ 10)),
@@ -183,8 +184,8 @@ end
183184
run!(simulation)
184185

185186
## Read energy data and compare
186-
path_energy_el = joinpath(path_el, "energy.dat")
187-
path_energy_ll = joinpath(path_ll, "energy.dat")
187+
path_energy_el = joinpath(path_el, "chains/1/energy.dat")
188+
path_energy_ll = joinpath(path_ll, "chains/1/energy.dat")
188189
energy_el= readdlm(path_energy_el)[:, 2]
189190
energy_ll = readdlm(path_energy_ll)[:, 2]
190191
@test isapprox(energy_el, energy_ll, atol=1e-6)

test/simple_test.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ callbacks = (callback_energy, callback_acceptance)
4949

5050
algorithm_list = (
5151
(algorithm=Metropolis, pool=pool, seed=seed, parallel=false, sweepstep=length(system_ll)),
52-
(algorithm=StoreCallbacks, callbacks=(callback_energy, callback_acceptance), scheduler=sampletimes),
53-
(algorithm=StoreTrajectories, scheduler=sampletimes, fmt=XYZ()),
52+
(algorithm=StoreCallbacks, callbacks=(energy,), scheduler=sampletimes),
53+
(algorithm=StoreAcceptance, dependencies=(Metropolis,), scheduler=sampletimes), (algorithm=StoreTrajectories, scheduler=sampletimes, fmt=XYZ()),
5454
(algorithm=StoreLastFrames, scheduler=[steps], fmt=XYZ()),
5555
(algorithm=PrintTimeSteps, scheduler=build_schedule(steps, burn, steps ÷ 10)),
5656
)

0 commit comments

Comments
 (0)