Internal APIs

Documentation for SpinMonteCarlo.jl's internals (not exported).

Driver

SpinMonteCarlo.postprocFunction
postproc(model::Model, param::Parameter, obs::MCObservableSet)

Post process of observables. For example, Specific heat will be calculated from energy, energy^2, and temperature.

source
SpinMonteCarlo.postprocMethod
postproc(model::Ising, param::Parameter, obs::MCObservableSet)

Observables to be calculated

In the following, $m$ is total magnetization per site and $\epsilon$ is total energy per site.

  • "Binder Ratio"
    • \[R := \frac{\left \langle m^4 \right \rangle}{\left \langle m^2 \right\rangle^2}\]

  • "Susceptibility"
    • \[\chi := \frac{N}{T}\left(\left\langle m^2\right\rangle\right)\]

  • "Connected Susceptibility"
    • \[\frac{N}{T}\left(\left\langle m^2\right\rangle - \left\langle |m| \right\rangle^2\right)\]

  • "Specific Heat"
    • \[\frac{N}{T^2}\left(\left\langle \epsilon^2\right\rangle - \left\langle \epsilon \right\rangle^2\right)\]

source
SpinMonteCarlo.postprocMethod
postproc(model::Potts, param::Parameter, obs::MCObservableSet)

Observables to be calculated

In the following, $m$ is total magnetization per site and $\epsilon$ is total energy per site.

  • "Binder Ratio"
    • \[R := \frac{\left \langle m^4 \right \rangle}{\left \langle m^2 \right\rangle^2}\]

  • "Susceptibility"
    • \[\chi := \frac{N}{T}\left(\left\langle m^2\right\rangle\right)\]

  • "Connected Susceptibility"
    • \[\frac{N}{T}\left(\left\langle m^2\right\rangle - \left\langle |m| \right\rangle^2\right)\]

  • "Specific Heat"
    • \[\frac{N}{T^2}\left(\left\langle \epsilon^2\right\rangle - \left\langle \epsilon \right\rangle^2\right)\]

source
SpinMonteCarlo.postprocMethod
postproc(model::Clock, param::Parameter, obs::MCObservableSet)

Observables to be calculated

In the following, $m$ is total magnetization per site and $\epsilon$ is total energy per site.

  • "Binder Ratio x"
    • \[\frac{\left \langle m_x^4 \right \rangle}{\left \langle m_x^2 \right\rangle^2}\]

  • "Binder Ratio y"
    • \[\frac{\left \langle m_y^4 \right \rangle}{\left \langle m_y^2 \right\rangle^2}\]

  • "Binder Ratio"
    • \[\frac{\left \langle |m|^4 \right \rangle}{\left \langle |m|^2 \right\rangle^2}\]

  • "Susceptibility x"
    • \[\frac{N}{T}\left(\left\langle m_x^2\right\rangle\right)\]

  • "Susceptibility y"
    • \[\frac{N}{T}\left(\left\langle m_y^2\right\rangle\right)\]

  • "Susceptibility y"
    • \[\frac{N}{T}\left(\left\langle |m|^2\right\rangle\right)\]

  • "Connected Susceptibility x"
    • \[\frac{N}{T}\left(\left\langle m_x^2\right\rangle - \left\langle |m_x| \right\rangle^2\right)\]

  • "Connected Susceptibility y"
    • \[\frac{N}{T}\left(\left\langle m_y^2\right\rangle - \left\langle |m_y| \right\rangle^2\right)\]

  • "Connected Susceptibility"
    • \[\frac{N}{T}\left(\left\langle |m|^2\right\rangle - \left\langle |m| \right\rangle^2\right)\]

  • "Specific Heat"
    • \[\frac{N}{T^2}\left(\left\langle \epsilon^2\right\rangle - \left\langle \epsilon \right\rangle^2\right)\]

source
SpinMonteCarlo.postprocMethod
postproc(model::XY, param::Parameter, obs::MCObservableSet)

Observables to be calculated

In the following, $m$ is total magnetization per site and $\epsilon$ is total energy per site.

  • "Binder Ratio x"
    • \[\frac{\left \langle m_x^4 \right \rangle}{\left \langle m_x^2 \right\rangle^2}\]

  • "Binder Ratio y"
    • \[\frac{\left \langle m_y^4 \right \rangle}{\left \langle m_y^2 \right\rangle^2}\]

  • "Binder Ratio"
    • \[\frac{\left \langle |m|^4 \right \rangle}{\left \langle |m|^2 \right\rangle^2}\]

  • "Susceptibility x"
    • \[\frac{N}{T}\left(\left\langle m_x^2\right\rangle\right)\]

  • "Susceptibility y"
    • \[\frac{N}{T}\left(\left\langle m_y^2\right\rangle\right)\]

  • "Susceptibility y"
    • \[\frac{N}{T}\left(\left\langle |m|^2\right\rangle\right)\]

  • "Connected Susceptibility x"
    • \[\frac{N}{T}\left(\left\langle m_x^2\right\rangle - \left\langle |m_x| \right\rangle^2\right)\]

  • "Connected Susceptibility y"
    • \[\frac{N}{T}\left(\left\langle m_y^2\right\rangle - \left\langle |m_y| \right\rangle^2\right)\]

  • "Connected Susceptibility"
    • \[\frac{N}{T}\left(\left\langle |m|^2\right\rangle - \left\langle |m| \right\rangle^2\right)\]

  • "Specific Heat"
    • \[\frac{N}{T^2}\left(\left\langle \epsilon^2\right\rangle - \left\langle \epsilon \right\rangle^2\right)\]

source
SpinMonteCarlo.postprocMethod
postproc(model::AshkinTeller, param::Parameter, obs::MCObservableSet)

Observables to be calculated

In the following, $m$ is total magnetization per site and $\epsilon$ is total energy per site.

  • "Binder Ratio"
    • \[R := \frac{\left \langle m^4 \right \rangle}{\left \langle m^2 \right\rangle^2}\]

  • "Susceptibility"
    • \[\chi := \frac{N}{T}\left(\left\langle m^2\right\rangle\right)\]

  • "Connected Susceptibility"
    • \[\frac{N}{T}\left(\left\langle m^2\right\rangle - \left\langle |m| \right\rangle^2\right)\]

  • "Binder Ratio sigma"
    • Binder ratio with respct to $\sigma$
  • "Susceptibility sigma"
    • Susceptibility with respct to $\sigma$
  • "Connected Susceptibility sigma"
    • Connected susceptibility with respct to $\sigma$
  • "Binder Ratio tau"
    • Binder ratio with respct to $\tau$
  • "Susceptibility tau"
    • Susceptibility with respct to $\tau$
  • "Connected Susceptibility tau"
    • Connected susceptibility with respct to $\tau$
  • "Specific Heat"
    • \[\frac{N}{T^2}\left(\left\langle \epsilon^2\right\rangle - \left\langle \epsilon \right\rangle^2\right)\]

source
SpinMonteCarlo.postprocMethod
postproc(model::QuantumXXZ, param::Parameter, obs::MCObservableSet)

Observables to be calculated

In the following, $s$ is sign of weight, $m$ is total magnetization per site, and $\epsilon$ is total energy per site.

  • "Magnetization"
    • \[\left\langle m s\right\rangle\Big/\left\langle s \right\rangle\]

  • "|Magnetization|"
    • \[\left\langle |m| s\right\rangle\Big/\left\langle s \right\rangle\]

  • "Magnetization^2"
    • \[\left\langle m^2 s\right\rangle\Big/\left\langle s \right\rangle\]

  • "Magnetization^4"
    • \[\left\langle m^4 s\right\rangle\Big/\left\langle s \right\rangle\]

  • "Energy"
    • \[\left\langle \epsilon s\right\rangle\Big/\left\langle s \right\rangle\]

  • "Energy^2"
    • \[\left\langle \epsilon^2 s\right\rangle\Big/\left\langle s \right\rangle\]

  • "Binder Ratio"
    • \[\frac{\left \langle m^4 \right \rangle}{\left \langle m^2 \right\rangle^2}\]

  • "Susceptibility"
    • \[\frac{N}{T}\left(\left\langle m^2\right\rangle\right)\]

  • "Connected Susceptibility"
    • \[\frac{N}{T}\left(\left\langle m^2\right\rangle - \left\langle |m| \right\rangle^2\right)\]

  • "Specific Heat"
    • \[\frac{N}{T^2}\left(\left\langle \epsilon^2\right\rangle - \left\langle \epsilon \right\rangle^2\right)\]

source

Lattice

Random number generator

SpinMonteCarlo.makerngFunction
makerng(param::Parameter)

Create the random number generator requested by param.

param["RNG"], when present, must be an RNG type, not an RNG instance. It needs only the constructor the other keys call for: T(seed) when param["Seed"] is given, and T() when it is not. Random.RandomDevice and Random.TaskLocalRNG, for instance, provide the latter but not the former, so they work only without "Seed".

When param has both "Seed" and "ID", a child seed is derived for that ID. runMC(params) sets these IDs when autoID=true; runMC(model, param) does not derive child seeds because the model already owns its RNG. That derivation is arithmetic, so "Seed" must be an integer whenever "ID" is present.

source
SpinMonteCarlo.childseedFunction
childseed(seed::Integer, id::Integer)

Derive a deterministic child seed from an integer seed and an integer ID.

This uses a fixed SplitMix64 finalizer rather than Base.hash, whose values Julia does not promise to keep stable, so derivation reproduces across Julia versions. Child seed derivation is used by makerng(param) only when param has an "ID" key, such as IDs set by runMC(params) with autoID=true. Passing a model directly to runMC(model, param) does not derive a child seed.

source

Model

SpinMonteCarlo.LocalLoopOperatorType

(Imaginary-temporary and spatial) local operator as a perturbation with assigned loop element.

Fields

  • let_type : assigned loop element
  • isdiagonal : operator is diagonal or not
    • in other words, two states connecting this perturbation are equivalent to each other or not.
  • time : imaginary time ($\tau/\beta \in [0,1)$) which this perturbation acts on.
  • space : spin or bond which this perturbation acts on. denotes space spin if space <= nspins or space - nspins bond otherwise.
  • subspace : subspin(s) index
  • bottom_id :: index of node of union find assigned to a loop
  • top_id :: index of node of union find assigned to the other loop
source

Observables

SpinMonteCarlo.linear_interceptFunction
linear_intercept(xs, ys)

Fit y = a + b*x by unweighted ordinary least squares and return (a, stderror_of_a). The error is a 1-sigma standard error.

Throws ArgumentError if fewer than three points are given, since the standard error needs at least one degree of freedom (dof = n - 2), or if any input is non-finite.

source

Utility

SpinMonteCarlo.@gen_convert_parameterMacro
@gen_convert_parameter(model_typename, (keyname, size_fn, default)...)

Generates convert_parameter(model::model_typename, param::Parameter).

Example

@gen_convert_parameter(A, ("A", numbondtypes, 1.0), ("B", 1, 1))

generates a function equivalent to the following:

doc"""
    convert_parameter(model::A, param::Parameter)

# Keynames

- "A": a vector with `numbondtypes(model)` elements (default: 1)
- "B": a scalar (default: 1.0)

"""
function convert_parameter(model::A, param::Parameter)
    ## if `size_fn` is a `Function`,
    ## result is a vector whose size is `size_fn(model)`.
    ## `param["A"]` can take a scalar or a vector.
    a = get(param, "A", 1.0)
    as = zeros(Float64, numbondtypes(model))
    as .= a

    ## otherwise,
    ## result is a scalar.
    b = convert(Int, get(param, "B", 1))

    return as, b
end
source
SpinMonteCarlo.SWInfoType

Information of clusters in Swendsen-Wang algorithm.

Fields

  • activated_bonds : The number of activated (connected) bonds of each cluster.
  • clustersize : The number of sites in each cluster.
  • clusterspin : Spin variable of each cluster (e.g., 1 or -1 for Ising).
  • clustermag : Signed magnetization of each cluster before cluster flips.
source
SpinMonteCarlo.root!Function
root!(u::UnionFind, n::Integer)

Returns the root node of the cluster where n belongs. This may changes graph connection by "Path halving" method.

source
SpinMonteCarlo.root_path_halving!Function
root_path_halving!(u::UnionFind, n::Integer)

Returns the root node of the cluster where n belongs. This may changes graph connection by "Path halving" method.

source
SpinMonteCarlo.root_path_splitting!Function
root_path_splitting!(u::UnionFind, n::Integer)

Returns the root node of the cluster where n belongs. This may changes graph connection by "Path splitting" method.

source