Implementing your algorithm

To run your own Monte Carlo algorithm with Carlo, you need to implement the AbstractMC interface documented in this file. For an example implementation showcasing all the features, take a look at the Ising example implementation.

Carlo.AbstractMCType

This type is an interface for implementing your own Monte Carlo algorithm that will be run by Carlo.

source

The following methods all need to be defined for your Monte Carlo algoritm type (here referred to as YourMC <: AbstractMC). See Parallel run mode for a slightly different interface that allows inner MPI parallelization of your algorithm.

Carlo.init!Function
Carlo.init!(mc::YourMC, ctx::MCContext, params::AbstractDict)

Executed when a simulation is started from scratch.

source
Carlo.sweep!Function
Carlo.sweep!(mc::YourMC, ctx::MCContext)

Perform one Monte Carlo sweep or update to the configuration.

Note

Doing measurements is supported during this step as some algorithms require doing so for efficiency. Remember to check for is_thermalized in that case.

source
Carlo.measure!Function
Carlo.measure!(mc::YourMC, ctx::MCContext)

Perform one Monte Carlo measurement.

source
Carlo.write_checkpointFunction
Carlo.write_checkpoint(mc::YourMC, out::HDF5.Group)

Save the complete state of the simulation to out.

source
Carlo.register_evaluablesFunction
Carlo.register_evaluables(mc::Type{YourMC}, eval::AbstractEvaluator, params::AbstractDict)

This function is used to calculate postprocessed quantities from quantities that were measured during the simulation. Common examples are variances or ratios of observables.

See evaluables for more details.

source

Interfacing with Carlo features

The MCContext type, passed to your code by some of the functions above enables to use some features provided by Carlo.

Carlo.measure!Method
measure!(ctx::MCContext, name::Symbol, value)

Measure a sample for the observable named name. The sample value may be either a scalar or vector of a float type.

source