Monte Carlo (MC)
This is plain simple Monte Carlo (MC). It can for example be used to simulate the Ising model (see 2D Ising model).
You can initialize a Monte Carlo simulation of a given model
simply through
mc = MC(model)
Allowed keywords are:
beta
: inverse temperaturesweeps
: number of measurement sweepsthermalization
: number of thermalization (warmup) sweepsglobal_moves
: wether global moves should be proposedglobal_rate
: frequency for proposing global movesseed
: initialize MC with custom seed
Afterwards, you can run the simulation by
run!(mc)
Note that you can just do another run!(mc, sweeps=1000)
to continue the simulation.
Examples
You can find example simulations of the 2D Ising model under Getting started and here: 2D Ising model.
Exports
MonteCarlo.replay!
— Functionreplay(mc::MC[, configurations::Iterable = mc.configs; kwargs...])
Replays previously generated configurations and measures observables along the way.
Keyword Arguments:
verbose = true
: If true, print progress messaged to stdout.safe_every::TimePeriod
: Set the interval for regularly scheduled saves.safe_before::Date
: If this date is passed,replay!
will generate a
resumable save file and exit
grace_period = Minute(5)
: Buffer between the current time andsafe_before
.
The time required to generate a save file should be included here.
filename
: Name of the save file. The default is based onsafe_before
.measure_rate = 1
: Rate at which measurements are taken. Note that this is
based on the recorded configurations, not actual sweeps.
MonteCarlo.run!
— Methodrun!(mc::MC[; kwargs...])
Runs the given Monte Carlo simulation mc
. Returns SUCCESS::ExitCode = 0
if the simulation finished normally or various other codes if failed or cancelled. See ExitCode
.
Keyword Arguments:
verbose = true
: If true, print progress messaged to stdout.thermalization
: Number of thermalization sweeps. Uses the value passed to
DQMC
by default.
sweeps
: Number of measurement sweeps. Uses the value passed toDQMC
by
default.
safe_every::TimePeriod
: Set the interval for regularly scheduled saves.safe_before::Date
: If this date is passed,run!
will generate a resumable
save file and exit
grace_period = Minute(5)
: Buffer between the current time andsafe_before
.
The time required to generate a save file should be included here.
resumable_filename
: Name of the resumable save file. The default is based on
safe_before
.
overwrite = false
: If set to true a file with the same name as
resumable_filename
will be overwritten. (This will create a temporary backup)
See also: resume!
MonteCarlo.MC
— TypeMonte Carlo simulation
MonteCarlo.MC
— MethodMC(m::M; kwargs...) where M<:Model
Create a Monte Carlo simulation for model m
with keyword parameters kwargs
.
MonteCarlo.MC
— MethodMC(m::M, params::Dict)
MC(m::M, params::NamedTuple)
Create a Monte Carlo simulation for model m
with (keyword) parameters as specified in the dictionary/named tuple params
.
Potential extensions
Pull requests are very much welcome!
- Heat bath (instead of Metropolis) option