• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

wexlergroup / FreeBird.jl / 14781113628

01 May 2025 06:34PM UTC coverage: 94.924% (-0.2%) from 95.122%
14781113628

push

github

web-flow
Merge pull request #95 from eyob-tewelde/website_typos

Corrected typos and updated language on the tutorial page for clarity

1440 of 1517 relevant lines covered (94.92%)

141343.95 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

90.85
/src/SamplingSchemes/nested_sampling.jl
1
"""
2
    mutable struct NestedSamplingParameters <: SamplingParameters
3

4
The `NestedSamplingParameters` struct represents the parameters used in the nested sampling scheme.
5

6
# Fields
7
- `mc_steps::Int64`: The number of total Monte Carlo moves to perform.
8
- `initial_step_size::Float64`: The initial step size, which is the fallback step size if MC routine fails to accept a move.
9
- `step_size::Float64`: The on-the-fly step size used in the sampling process.
10
- `step_size_lo::Float64`: The lower bound of the step size.
11
- `step_size_up::Float64`: The upper bound of the step size.
12
- `accept_range::Tuple{Float64, Float64}`: The range of acceptance rates for adjusting the step size.
13
e.g. (0.25, 0.75) means that the step size will decrease if the acceptance rate is below 0.25 and increase if it is above 0.75.
14
- `fail_count::Int64`: The number of failed MC moves in a row.
15
- `allowed_fail_count::Int64`: The maximum number of failed MC moves allowed before resetting the step size.
16
- `random_seed::Int64`: The seed for the random number generator.
17
"""
18
mutable struct NestedSamplingParameters <: SamplingParameters
19
    mc_steps::Int64
40✔
20
    initial_step_size::Float64
21
    step_size::Float64
22
    step_size_lo::Float64
23
    step_size_up::Float64
24
    accept_range::Tuple{Float64, Float64}
25
    fail_count::Int64
26
    allowed_fail_count::Int64
27
    random_seed::Int64
28
end
29

30
function NestedSamplingParameters(;
14✔
31
            mc_steps::Int64=200,
32
            initial_step_size::Float64=0.01,
33
            step_size::Float64=0.1,
34
            step_size_lo::Float64=1e-6,
35
            step_size_up::Float64=1.0,
36
            accept_range::Tuple{Float64, Float64}=(0.25, 0.75),
37
            fail_count::Int64=0,
38
            allowed_fail_count::Int64=100,
39
            random_seed::Int64=1234,
40
            )
41
    NestedSamplingParameters(mc_steps, initial_step_size, step_size, step_size_lo, step_size_up, accept_range, fail_count, allowed_fail_count, random_seed)  
8✔
42
end
43

44
"""
45
    mutable struct LatticeNestedSamplingParameters <: SamplingParameters
46

47
The `LatticeNestedSamplingParameters` struct represents the parameters used in the lattice nested sampling scheme.
48

49
# Fields
50
- `mc_steps::Int64`: The number of total Monte Carlo moves to perform.
51
- `energy_perturbation::Float64`: The energy perturbation used in the sampling process.
52
- `fail_count::Int64`: The number of failed MC moves in a row.
53
- `allowed_fail_count::Int64`: The maximum number of failed MC moves allowed before resetting the step size.
54
- `random_seed::Int64`: The seed for the random number generator.
55
"""
56
mutable struct LatticeNestedSamplingParameters <: SamplingParameters
57
    mc_steps::Int64
32✔
58
    energy_perturbation::Float64
59
    fail_count::Int64
60
    allowed_fail_count::Int64
61
    random_seed::Int64
62
end
63

64
function LatticeNestedSamplingParameters(;
14✔
65
            mc_steps::Int64=100,
66
            energy_perturbation::Float64=1e-12,
67
            fail_count::Int64=0,
68
            allowed_fail_count::Int64=10,
69
            random_seed::Int64=1234,
70
            )
71
    LatticeNestedSamplingParameters(mc_steps, energy_perturbation, fail_count, allowed_fail_count, random_seed)  
8✔
72
end
73

74

75

76
"""
77
    abstract type MCRoutine
78

79
An abstract type representing a Monte Carlo routine.
80

81
Currently, the following concrete types are supported:
82
- `MCRandomWalkMaxE`: A type for generating a new walker by performing a random walk for decorrelation on the
83
highest-energy walker.
84
- `MCRandomWalkClone`: A type for generating a new walker by cloning an existing walker and performing a random walk
85
for decorrelation.
86
- `MCNewSample`: A type for generating a new walker from a random configuration. Currently, it is intended to use 
87
this routine for lattice gas systems.
88
- `MCMixedMoves`: A type for generating a new walker by performing random walks and swapping atoms. Currently, it is
89
intended to use this routine for multi-component systems. The actual number of random walks and swaps to perform is
90
determined by the weights of the fields `walks_freq` and `swaps_freq`. See [`MCMixedMoves`](@ref).
91
- `MCRejectionSampling`: A type for generating a new walker by performing rejection sampling. Currently, it is intended
92
to use this routine for lattice gas systems.
93
"""
94
abstract type MCRoutine end
95

96
"""
97
    struct MCRandomWalkMaxE <: MCRoutine
98
A type for generating a new walker by performing a random walk for decorrelation on the highest-energy walker.
99
"""
100
struct MCRandomWalkMaxE <: MCRoutine 
101
    dims::Vector{Int64}
102
    function MCRandomWalkMaxE(dims::Vector{Int64}=[1, 2, 3])
154✔
103
        new(dims)
176✔
104
    end
105
end
106

107
"""
108
    struct MCRandomWalkClone <: MCRoutine
109
A type for generating a new walker by cloning an existing walker and performing a random walk for decorrelation.
110
"""
111
struct MCRandomWalkClone <: MCRoutine 
112
    dims::Vector{Int64}
113
    function MCRandomWalkClone(;dims::Vector{Int64}=[1, 2, 3])
84✔
114
        new(dims)
48✔
115
    end
116
end
117

118
"""
119
    struct MCNewSample <: MCRoutine
120
A type for generating a new walker from a random configuration. Currently, it is intended to use this routine for lattice gas systems.
121
"""
122
struct MCNewSample <: MCRoutine end
32✔
123

124
""" 
125
    struct MCMixedMoves <: MCRoutine
126
A type for generating a new walker by performing random walks and swapping atoms. Currently, it is intended to use this routine for
127
multi-component systems. The actual number of random walks and swaps to perform is determined by the weights of the fields `walks_freq` and `swaps_freq`.
128
For example, if `walks_freq=4` and `swaps_freq=1`, then the probability of performing a random walk is 4/5, and the probability of performing a swap is 1/5.
129

130
# Fields
131
- `walks_freq::Int`: The frequency of random walks to perform.
132
- `swaps_freq::Int`: The frequency of atom swaps to perform.
133
"""
134
mutable struct MCMixedMoves <: MCRoutine
135
    walks_freq::Int
16✔
136
    swaps_freq::Int
137
end
138

139
"""
140
    struct MCRejectionSampling <: MCRoutine
141
A type for generating a new walker by performing rejection sampling. Currently, it is intended to use this routine for lattice gas systems.
142
"""
143
struct MCRejectionSampling <: MCRoutine end
8✔
144

145
"""
146
    sort_by_energy!(liveset::LJAtomWalkers)
147

148
Sorts the walkers in the liveset by their energy in descending order.
149

150
# Arguments
151
- `liveset::LJAtomWalkers`: The liveset of walkers to be sorted.
152

153
# Returns
154
- `liveset::LJAtomWalkers`: The sorted liveset.
155
"""
156
function sort_by_energy!(liveset::AbstractLiveSet)
424✔
157
    sort!(liveset.walkers, by = x -> x.energy, rev=true)
2,276✔
158
    # println("after sort ats[1].system_data.energy: ", ats[1].system_data.energy)
159
    return liveset
424✔
160
end
161

162
"""
163
    update_iter!(liveset::AtomWalkers)
164

165
Update the iteration count for each walker in the liveset.
166

167
# Arguments
168
- `liveset::AtomWalkers`: The set of walkers to update.
169

170
"""
171
function update_iter!(liveset::AbstractLiveSet)
410✔
172
    for at in liveset.walkers
410✔
173
        at.iter += 1
1,206✔
174
    end
1,206✔
175
end
176

177

178
"""
179
    nested_sampling_step!(liveset::AtomWalkers, ns_params::NestedSamplingParameters, mc_routine::MCRoutine)
180

181
Perform a single step of the nested sampling algorithm using the Monte Carlo random walk routine.
182

183
Arguments
184
- `liveset::AtomWalkers`: The set of atom walkers.
185
- `ns_params::NestedSamplingParameters`: The parameters for nested sampling.
186
- `mc_routine::MCRoutine`: The Monte Carlo routine for generating new samples. See [`MCRoutine`](@ref).
187

188
Returns
189
- `iter`: The iteration number after the step.
190
- `emax`: The highest energy recorded during the step.
191
- `liveset`: The updated set of atom walkers.
192
- `ns_params`: The updated nested sampling parameters.
193
"""
194
function nested_sampling_step!(liveset::AtomWalkers, ns_params::NestedSamplingParameters, mc_routine::MCRoutine)
192✔
195
    sort_by_energy!(liveset)
192✔
196
    ats = liveset.walkers
192✔
197
    lj = liveset.lj_potential
192✔
198
    iter::Union{Missing,Int} = missing
192✔
199
    emax::Union{Missing,typeof(0.0u"eV")} = liveset.walkers[1].energy
192✔
200
    if mc_routine isa MCRandomWalkMaxE
192✔
201
        to_walk = deepcopy(ats[1])
320✔
202
    elseif mc_routine isa MCRandomWalkClone
32✔
203
        to_walk = deepcopy(rand(ats[2:end]))
48✔
204
    else
205
        error("Unsupported MCRoutine type: $mc_routine")
8✔
206
    end
207
    if length(mc_routine.dims) == 3
184✔
208
        accept, rate, at = MC_random_walk!(ns_params.mc_steps, to_walk, lj, ns_params.step_size, emax)
168✔
209
    elseif length(mc_routine.dims) == 2
16✔
210
        accept, rate, at = MC_random_walk_2D!(ns_params.mc_steps, to_walk, lj, ns_params.step_size, emax; dims=mc_routine.dims)
8✔
211
        # @info "Doing a 2D random walk"
212
    elseif length(mc_routine.dims) == 1
8✔
213
        error("Unsupported dimensions: $(mc_routine.dims)")
8✔
214
    end
215
    # accept, rate, at = MC_random_walk!(ns_params.mc_steps, to_walk, lj, ns_params.step_size, emax)
216
    # @info "iter: $(liveset.walkers[1].iter), acceptance rate: $(round(rate; sigdigits=4)), emax: $(round(typeof(1.0u"eV"), emax; sigdigits=10)), is_accepted: $accept, step_size: $(round(ns_params.step_size; sigdigits=4))"
217
    if accept
176✔
218
        push!(ats, at)
176✔
219
        popfirst!(ats)
176✔
220
        update_iter!(liveset)
176✔
221
        ns_params.fail_count = 0
176✔
222
        iter = liveset.walkers[1].iter
176✔
223
    else
224
        # @warn "Failed to accept MC move"
225
        emax = missing
×
226
        ns_params.fail_count += 1
×
227
    end
228
    adjust_step_size(ns_params, rate)
238✔
229
    return iter, emax, liveset, ns_params
176✔
230
end
231

232
"""
233
    nested_sampling_step!(liveset::AtomWalkers, ns_params::NestedSamplingParameters, mc_routine::MCMixedMoves)
234

235
Perform a single step of the nested sampling algorithm using the Monte Carlo mixed moves routine.
236

237
Arguments
238
- `liveset::AtomWalkers`: The set of atom walkers.
239
- `ns_params::NestedSamplingParameters`: The parameters for nested sampling.
240
- `mc_routine::MCMixedMoves`: The Monte Carlo mixed moves routine.
241

242
Returns
243
- `iter`: The iteration number after the step.
244
- `emax`: The highest energy recorded during the step.
245
- `liveset`: The updated set of atom walkers.
246
- `ns_params`: The updated nested sampling parameters.
247
"""
248
function nested_sampling_step!(liveset::AtomWalkers, ns_params::NestedSamplingParameters, mc_routine::MCMixedMoves)
8✔
249
    sort_by_energy!(liveset)
8✔
250
    ats = liveset.walkers
8✔
251
    lj = liveset.lj_potential
8✔
252
    iter::Union{Missing,Int} = missing
8✔
253
    emax::Union{Missing,typeof(0.0u"eV")} = liveset.walkers[1].energy
8✔
254

255
    # clone one of the lower energy walkers
256
    to_walk = deepcopy(rand(ats[2:end]))
16✔
257
    # determine whether to perform a random walk or a swap
258
    swap_prob = mc_routine.swaps_freq / (mc_routine.walks_freq + mc_routine.swaps_freq)
8✔
259
    
260
    # @show mc_routine
261
    if rand() > swap_prob
8✔
262
        accept, rate, at = MC_random_walk!(ns_params.mc_steps, to_walk, lj, ns_params.step_size, emax)
2✔
263
        @info "Swap move performed at iter: $(liveset.walkers[1].iter), accepted: $accept"
2✔
264
        # @info "iter: $(liveset.walkers[1].iter), acceptance rate: $(round(rate; sigdigits=4)), emax: $(round(typeof(1.0u"eV"), emax; sigdigits=10)), is_accepted: $accept, step_size: $(round(ns_params.step_size; sigdigits=4))"
265
    else
266
        accept, rate, at = MC_random_swap!(ns_params.mc_steps, to_walk, lj, emax)
6✔
267
        # @info "iter: $(liveset.walkers[1].iter), acceptance rate: $(round(rate; sigdigits=4)), emax: $(round(typeof(1.0u"eV"), emax; sigdigits=10)), is_accepted: $accept, step_size: swap"
268
    end
269
    
270
    if accept
8✔
271
        push!(ats, at)
8✔
272
        popfirst!(ats)
8✔
273
        update_iter!(liveset)
8✔
274
        ns_params.fail_count = 0
8✔
275
        iter = liveset.walkers[1].iter
8✔
276
    else
277
        # @warn "Failed to accept MC move"
278
        emax = missing
×
279
        ns_params.fail_count += 1
×
280
    end
281
    adjust_step_size(ns_params, rate)
8✔
282
    return iter, emax, liveset, ns_params
8✔
283
end
284

285
"""
286
    nested_sampling_step!(liveset::LatticeGasWalkers, ns_params::LatticeNestedSamplingParameters, mc_routine::MCRoutine)
287

288
Perform a single step of the nested sampling algorithm.
289

290
This function takes a `liveset` of lattice gas walkers, `ns_params` containing the parameters for nested sampling, and `mc_routine` representing the Monte Carlo 
291
routine for generating new samples. It performs a single step of the nested sampling algorithm by updating the liveset with a new walker.
292

293
## Arguments
294
- `liveset::LatticeGasWalkers`: The liveset of lattice gas walkers.
295
- `ns_params::LatticeNestedSamplingParameters`: The parameters for nested sampling.
296
- `mc_routine::MCRoutine`: The Monte Carlo routine for generating new samples.
297

298
## Returns
299
- `iter`: The iteration number of the liveset after the step.
300
- `emax`: The maximum energy of the liveset after the step.
301
"""
302
function nested_sampling_step!(liveset::LatticeGasWalkers, 
192✔
303
                               ns_params::LatticeNestedSamplingParameters, 
304
                               mc_routine::MCRoutine)
305
    sort_by_energy!(liveset)
192✔
306
    ats = liveset.walkers
192✔
307
    h = liveset.hamiltonian
192✔
308
    iter::Union{Missing,Int} = missing
192✔
309
    emax::Union{Missing,Float64} = liveset.walkers[1].energy.val
192✔
310
    if mc_routine isa MCRandomWalkMaxE
192✔
311
        to_walk = deepcopy(ats[1])
368✔
312
    elseif mc_routine isa MCRandomWalkClone
8✔
313
        to_walk = deepcopy(rand(ats[2:end]))
16✔
314
    else
315
        error("Unsupported MCRoutine type: $mc_routine")
×
316
    end
317
    accept, rate, at = MC_random_walk!(ns_params.mc_steps, to_walk, h, emax; energy_perturb=ns_params.energy_perturbation)
192✔
318

319
    # @info "iter: $(liveset.walkers[1].iter), acceptance rate: $rate, emax: $emax, is_accepted: $accept"
320
    if accept
192✔
321
        push!(ats, at)
166✔
322
        popfirst!(ats)
166✔
323
        update_iter!(liveset)
166✔
324
        ns_params.fail_count = 0
166✔
325
        iter = liveset.walkers[1].iter
166✔
326
    else
327
        # @warn "Failed to accept MC move"
328
        emax = missing
26✔
329
        ns_params.fail_count += 1
26✔
330
    end
331
    # adjust_step_size(ns_params, rate)
332
    return iter, emax, liveset, ns_params
192✔
333
end
334

335
"""
336
    nested_sampling_step!(liveset::LatticeGasWalkers, ns_params::LatticeNestedSamplingParameters, mc_routine::MCNewSample)
337

338
Perform a single step of the nested sampling algorithm.
339

340
This function takes a `liveset` of lattice gas walkers, `ns_params` containing the parameters for nested sampling, and `mc_routine` representing the Monte Carlo routine for generating new samples. It performs a single step of the nested sampling algorithm by updating the liveset with a new walker.
341

342
## Arguments
343
- `liveset::LatticeGasWalkers`: The liveset of lattice gas walkers.
344
- `ns_params::LatticeNestedSamplingParameters`: The parameters for nested sampling.
345
- `mc_routine::MCNewSample`: The Monte Carlo routine for generating new samples.
346

347
## Returns
348
- `iter`: The iteration number of the liveset after the step.
349
- `emax`: The maximum energy of the liveset after the step.
350
- `liveset::LatticeGasWalkers`: The updated liveset after the step.
351
- `ns_params::LatticeNestedSamplingParameters`: The updated nested sampling parameters after the step.
352
"""
353
function nested_sampling_step!(liveset::LatticeGasWalkers, 
8✔
354
                               ns_params::LatticeNestedSamplingParameters, 
355
                               mc_routine::MCNewSample)
356
    sort_by_energy!(liveset)
8✔
357
    ats = liveset.walkers
8✔
358
    h = liveset.hamiltonian
8✔
359
    iter::Union{Missing,Int} = missing
8✔
360
    emax::Union{Missing,Float64} = liveset.walkers[1].energy.val
8✔
361

362
    to_walk = deepcopy(ats[1])
16✔
363

364
    accept, at = MC_new_sample!(to_walk, h, emax; energy_perturb=ns_params.energy_perturbation)
8✔
365

366
    # @info "iter: $(liveset.walkers[1].iter), emax: $emax, is_accepted: $accept"
367
    if accept
8✔
368
        push!(ats, at)
4✔
369
        popfirst!(ats)
4✔
370
        update_iter!(liveset)
4✔
371
        ns_params.fail_count = 0
4✔
372
        iter = liveset.walkers[1].iter
4✔
373
    else
374
        # @warn "Failed to accept MC move"
375
        emax = missing
4✔
376
        ns_params.fail_count += 1
4✔
377
    end
378
    # adjust_step_size(ns_params, rate)
379
    return iter, emax, liveset, ns_params
8✔
380
end
381

382

383
function nested_sampling_step!(liveset::LatticeGasWalkers, 
8✔
384
                               ns_params::LatticeNestedSamplingParameters, 
385
                               mc_routine::MCRejectionSampling)
386
    sort_by_energy!(liveset)
8✔
387
    ats = liveset.walkers
8✔
388
    h = liveset.hamiltonian
8✔
389
    iter::Union{Missing,Int} = missing
8✔
390
    emax::Union{Missing,Float64} = liveset.walkers[1].energy.val
8✔
391

392
    to_walk = deepcopy(ats[1])
16✔
393

394
    accept, at = MC_rejection_sampling!(to_walk, h, emax; energy_perturb=ns_params.energy_perturbation)
8✔
395

396
    # @info "iter: $(liveset.walkers[1].iter), emax: $emax, is_accepted: $accept"
397
    if accept
8✔
398
        push!(ats, at)
8✔
399
        popfirst!(ats)
8✔
400
        update_iter!(liveset)
8✔
401
        ns_params.fail_count = 0
8✔
402
        iter = liveset.walkers[1].iter
8✔
403
    else
404
        # @warn "Failed to accept MC move"
405
        emax = missing
×
406
        ns_params.fail_count += 1
×
407
    end
408
    # adjust_step_size(ns_params, rate)
409
    return iter, emax, liveset, ns_params
8✔
410
end
411

412

413

414
"""
415
    nested_sampling(liveset::AtomWalkers, ns_params::NestedSamplingParameters, n_steps::Int64, mc_routine::MCRoutine; args...)
416

417
Perform a nested sampling loop for a given number of steps.
418

419
# Arguments
420
- `liveset::AtomWalkers`: The initial set of walkers.
421
- `ns_params::NestedSamplingParameters`: The parameters for nested sampling.
422
- `n_steps::Int64`: The number of steps to perform.
423
- `mc_routine::MCRoutine`: The Monte Carlo routine to use.
424

425
# Returns
426
- `df`: A DataFrame containing the iteration number and maximum energy for each step.
427
- `liveset`: The updated set of walkers.
428
- `ns_params`: The updated nested sampling parameters.
429
"""
430
function nested_sampling(liveset::AtomWalkers, 
24✔
431
                                ns_params::NestedSamplingParameters, 
432
                                n_steps::Int64, 
433
                                mc_routine::MCRoutine,
434
                                save_strategy::DataSavingStrategy)
435
    df = DataFrame(iter=Int[], emax=Float64[])
24✔
436
    for i in 1:n_steps
24✔
437
        print_info = i % save_strategy.n_info == 0
152✔
438
        write_walker_every_n(liveset.walkers[1], i, save_strategy)
152✔
439
        iter, emax, liveset, ns_params = nested_sampling_step!(liveset, ns_params, mc_routine)
152✔
440
        @debug "n_step $i, iter: $iter, emax: $emax"
152✔
441
        if ns_params.fail_count >= ns_params.allowed_fail_count
152✔
442
            @warn "Failed to accept MC move $(ns_params.allowed_fail_count) times in a row. Reset step size!"
×
443
            ns_params.fail_count = 0
×
444
            ns_params.step_size = ns_params.initial_step_size
×
445
        end
446
        if !(iter isa typeof(missing))
152✔
447
            push!(df, (iter, emax.val))
190✔
448
            if print_info
152✔
449
                @info "iter: $(liveset.walkers[1].iter), emax: $emax, step_size: $(round(ns_params.step_size; sigdigits=4))"
144✔
450
            end
451
        elseif iter isa typeof(missing) && print_info
×
452
            @info "MC move failed, step: $(i), emax: $(liveset.walkers[1].energy), step_size: $(round(ns_params.step_size; sigdigits=4))"
×
453
        end
454
        write_df_every_n(df, i, save_strategy)
152✔
455
        write_ls_every_n(liveset, i, save_strategy)
152✔
456
    end
280✔
457
    return df, liveset, ns_params
24✔
458
end
459

460
"""
461
    nested_sampling(liveset::LatticeGasWalkers, ns_params::LatticeNestedSamplingParameters, n_steps::Int64, mc_routine::MCRoutine, save_strategy::DataSavingStrategy)
462

463
Perform a nested sampling loop on a lattice gas system for a given number of steps.
464

465
# Arguments
466
- `liveset::LatticeGasWalkers`: The initial set of walkers.
467
- `ns_params::LatticeNestedSamplingParameters`: The parameters for nested sampling.
468
- `n_steps::Int64`: The number of steps to perform.
469
- `mc_routine::MCRoutine`: The Monte Carlo routine to use.
470
- `save_strategy::DataSavingStrategy`: The strategy for saving data.
471

472
# Returns
473
- `df`: A DataFrame containing the iteration number and maximum energy for each step.
474
- `liveset`: The updated set of walkers.
475
- `ns_params`: The updated nested sampling parameters.
476
"""
477
function nested_sampling(liveset::LatticeGasWalkers,
32✔
478
                                ns_params::LatticeNestedSamplingParameters, 
479
                                n_steps::Int64, 
480
                                mc_routine::MCRoutine,
481
                                save_strategy::DataSavingStrategy)
482

483
    df = DataFrame(iter=Int[], emax=Float64[], config=Any[])
32✔
484
    for i in 1:n_steps
32✔
485
        # write_walker_every_n(liveset.walkers[1], i, save_strategy)
486
        
487
        config = liveset.walkers[1].configuration.components
176✔
488

489
        iter, emax, liveset, ns_params = nested_sampling_step!(liveset, ns_params, mc_routine)
176✔
490
        @debug "n_step $i, iter: $iter, emax: $emax"
176✔
491
        if ns_params.fail_count >= ns_params.allowed_fail_count
176✔
492
            @warn "Failed to accept MC move $(ns_params.allowed_fail_count) times in a row. Break!"
×
493
            ns_params.fail_count = 0
×
494
            break
×
495
        end
496
        if !(iter isa typeof(missing))
176✔
497
            push!(df, (iter, emax, config))
150✔
498
            @info "iter: $(liveset.walkers[1].iter), emax: $emax"
300✔
499
        elseif iter isa typeof(missing)
26✔
500
            @info "MC move failed, step: $(i), emax: $(liveset.walkers[1].energy)"
26✔
501
        end
502
        write_df_every_n(df, i, save_strategy)
176✔
503
        write_ls_every_n(liveset, i, save_strategy)
176✔
504
    end
176✔
505
    return df, liveset, ns_params
32✔
506
end
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc