Internal APIs
Documentation for SpinMonteCarlo.jl's internals (not exported).
Driver
SpinMonteCarlo.accumulateObservables! — Function
accumulateObservables!(model, obs::MCObservableSet, localobs::Dict)Accumulates localobs into obs. For example, obs["Energy"] << localobs["Energy"].
SpinMonteCarlo.postproc — Function
postproc(model::Model, param::Parameter, obs::MCObservableSet)Post process of observables. For example, Specific heat will be calculated from energy, energy^2, and temperature.
SpinMonteCarlo.postproc — Method
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)\]
SpinMonteCarlo.postproc — Method
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)\]
SpinMonteCarlo.postproc — Method
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)\]
SpinMonteCarlo.postproc — Method
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)\]
SpinMonteCarlo.postproc — Method
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)\]
SpinMonteCarlo.postproc — Method
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)\]
Lattice
SpinMonteCarlo.generatelattice — Function
generatelattice(param::Parameter)generates Lattice from Parameter.
SpinMonteCarlo.numsitetypes — Function
numsitetypes(lat::Lattice)
numsitetypes(model::Model)Returns the number of sitetypes.
SpinMonteCarlo.numbondtypes — Function
numbondtypes(lat::Lattice)
numbondtypes(model::Model)Returns the number of bondtypes.
Random number generator
SpinMonteCarlo.makerng — Function
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.
SpinMonteCarlo.childseed — Function
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.
Model
SpinMonteCarlo.LoopElementType — Type
Enumtype including LET_*
SpinMonteCarlo.LET_Cut — Constant
Loop element depicted as
|
o
|or matrix
1 1 |+>
1 1 |->SpinMonteCarlo.LET_FMLink — Constant
Loop element depicted as
| |
|--|
| |or matrix
1 0 0 0 |++>
0 0 0 0 |+->
0 0 0 0 |-+>
0 0 0 1 |-->SpinMonteCarlo.LET_AFLink — Constant
Loop element depicted as
| |
|~~|
| |or matrix
0 0 0 0 |++>
0 1 0 0 |+->
0 0 1 0 |-+>
0 0 0 0 |-->SpinMonteCarlo.LET_Vertex — Constant
Loop element depicted as
| |
~~~~
~~~~
| |or matrix
0 0 0 0 |++>
0 1 1 0 |+->
0 1 1 0 |-+>
0 0 0 0 |-->SpinMonteCarlo.LET_Cross — Constant
Loop element depicted as
| |
\/
/\
| |or matrix
1 0 0 0 |++>
0 0 1 0 |+->
0 1 0 0 |-+>
0 0 0 1 |-->SpinMonteCarlo.LocalLoopOperator — Type
(Imaginary-temporary and spatial) local operator as a perturbation with assigned loop element.
Fields
let_type: assigned loop elementisdiagonal: 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. denotesspacespin if space <= nspins orspace - nspinsbond otherwise.subspace: subspin(s) indexbottom_id:: index of node of union find assigned to a looptop_id:: index of node of union find assigned to the other loop
Observables
SpinMonteCarlo.linear_intercept — Function
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.
Utility
SpinMonteCarlo.default_estimator — Function
default_estimator(model, updatemethod!)Determines estimator to be used when param["Estimator"] is not set.
SpinMonteCarlo.@gen_convert_parameter — Macro
@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
endSpinMonteCarlo.SWInfo — Type
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 forIsing).clustermag: Signed magnetization of each cluster before cluster flips.
SpinMonteCarlo.UnionFind — Type
Union-find algorithm.
SpinMonteCarlo.addnode! — Function
addnode!(u::UnionFind)Adds a new node into u and returns the number of nodes including the added node.
SpinMonteCarlo.unify! — Function
unify!(u, n1, n2)Connects n1 and n2 nodes using union by weight and returns the root.
SpinMonteCarlo.clusterize! — Function
clusterize!(u::UnionFind)Assigns cluster ID to each node and returns the number of clusters.
SpinMonteCarlo.clusterid — Function
clusterid(u::UnionFind, i::Integer)Returns the index of the cluster where i node belongs.
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.
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.
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.