Title: | Monte Carlo for Classical Ising Model |
---|---|
Description: | Classical Ising Model is a land mark system in statistical physics.The model explains the physics of spin glasses and magnetic materials, and cooperative phenomenon in general, for example phase transitions and neural networks.This package provides utilities to simulate one dimensional Ising Model with Metropolis and Glauber Monte Carlo with single flip dynamics in periodic boundary conditions. Utility functions for exact solutions are provided. |
Authors: | Mehmet Suzen [aut, cre] |
Maintainer: | Mehmet Suzen <[email protected]> |
License: | GPL (>= 3) |
Version: | 0.2.5 |
Built: | 2024-12-05 07:08:04 UTC |
Source: | CRAN |
Given a vector of flip sites, 1s or -1s, representing up and down spins respectively, flip any of the site randomly. The function uses default RNG (Marsienne-Twister) unless changed by the user, within R, to generate a vector that contains 1s or -1s. This function calls 'flipConfig1D' C function.
flipConfig1D(x)
flipConfig1D(x)
x |
1D Spin sites on the lattice |
Returns vector that contains 1s or -1s.
Mehmet Suzen <[email protected]>
n <- 10 # 10 spin sites mySites <- genConfig1D(n) # Generate sites # now flip mySitesNew <- flipConfig1D(mySites)
n <- 10 # 10 spin sites mySites <- genConfig1D(n) # Generate sites # now flip mySitesNew <- flipConfig1D(mySites)
Given a vector of flip sites, 1s or -1s, representing up and down spins respectively, flip any of the site randomly. The function uses default RNG (Marsienne-Twister) unless changed by the user, within R, to generate a vector that contains 1s or -1s. This function is a pure R implementation
flipConfig1D_R(x)
flipConfig1D_R(x)
x |
1D Spin sites on the lattice |
Returns vector that contains 1s or -1s.
Mehmet Suzen <[email protected]>
n <- 10 # 10 spin sites mySites <- genConfig1D_R(n) # Generate sites # now flip mySitesNew <- flipConfig1D_R(mySites)
n <- 10 # 10 spin sites mySites <- genConfig1D_R(n) # Generate sites # now flip mySitesNew <- flipConfig1D_R(mySites)
Given a vector of flip sites, 1s or -1s, representing up and down spins respectively, flip any of the site randomly, repeat it many times. The function uses default RNG (Marsienne-Twister) unless changed by the user, within R, to generate a vector that contains 1s or -1s. This function calls 'flipConfig1Dmany' C function.
flipConfig1Dmany(x, upperF)
flipConfig1Dmany(x, upperF)
x |
1D spin sites on the lattice. |
upperF |
The number of times |
Returns vector that contains 1s or -1s.
Mehmet Suzen <[email protected]>
n <- 10 # 10 spin sites mySites <- genConfig1D(n) # Generate sites # now flip 100 times mySitesNew <- flipConfig1Dmany(mySites, 100)
n <- 10 # 10 spin sites mySites <- genConfig1D(n) # Generate sites # now flip 100 times mySitesNew <- flipConfig1Dmany(mySites, 100)
The function uses default RNG (Marsienne-Twister) unless changed by the user, within R, to generate a vector that contains 1 or -1. This reflects spin sites. This function calls 'genConfig1D' C function.
genConfig1D(n)
genConfig1D(n)
n |
The number of spin sites on the lattice. |
Returns vector that contains 1s or -1s.
Mehmet Suzen <[email protected]>
n <- 10 # 10 spin sites genConfig1D(n)
n <- 10 # 10 spin sites genConfig1D(n)
The function uses default RNG (Marsienne-Twister) unless changed by the user, within R, to generate a vector that contains 1 or -1. This reflects spin sites. This function is pure R implementation.
genConfig1D_R(n)
genConfig1D_R(n)
n |
The number of spin sites on the lattice. |
Returns vector that contains 1s or -1s.
Mehmet Suzen <[email protected]>
n <- 10 # 10 spin sites genConfig1D_R(n)
n <- 10 # 10 spin sites genConfig1D_R(n)
Generate a single spin state from uniform distribution.
genUniform(n)
genUniform(n)
n |
dummy argument |
Returns randomly 1 or -1 from uniform distribution.
Mehmet Suzen <[email protected]>
genUniform()
genUniform()
Given a vector of flip sites, 1s or -1s, representing up and down spins respectively, and an other flip sites, perform Metropolis Monte Carlo applying periodic boundary conditions, i.e., cyclic. This function calls the C function 'isPerform1D'.
isPerform1D(ikBT, x, J, H, nstep, ensembleM, probSel)
isPerform1D(ikBT, x, J, H, nstep, ensembleM, probSel)
ikBT |
1/kB*T (Boltzmann factor) |
x |
1D Spin sites on the lattice. |
J |
Interaction strength |
H |
External field |
nstep |
Number of MC steps requested |
ensembleM |
Value of the theoretical magnetization (could be thermodynamic limit value) |
probSel |
Which transition probability to use. 1 for Metropolis 2 for Glauber |
Returns a pair list containing values for omegaM, Fluctuating metric vector for Magnetisation (length of naccept), naccept, number of MC steps accepted and nreject, number of MC steps rejected and times as accepted time steps. Times corresponds to times where flips occur, this is so-called transition times ('metropolis time' or 'single flip time') to judge the timings between two accepted steps.
Mehmet Suzen <[email protected]>
n <- 10 # 10 spin sites mySites <- genConfig1D(n) # Generate sites output <- isPerform1D(1.0, mySites, 1.0, 0.0, 10, 0.5, 1) # Metropolis output <- isPerform1D(1.0, mySites, 1.0, 0.0, 10, 0.5, 2) # Glauber
n <- 10 # 10 spin sites mySites <- genConfig1D(n) # Generate sites output <- isPerform1D(1.0, mySites, 1.0, 0.0, 10, 0.5, 1) # Metropolis output <- isPerform1D(1.0, mySites, 1.0, 0.0, 10, 0.5, 2) # Glauber
Given a vector of flip sites, 1s or -1s, representing up and down spins respectively and the usual thermodynamic parameters ikBt, J and H. Perform 1 step metropolis Monte Carlo, applying periodic boundary conditions, i.e., cyclic. This function calls the C function 'isStep1D'. Importance sampling is applied.
isStep1D(ikBT, x, J, H, probSel)
isStep1D(ikBT, x, J, H, probSel)
ikBT |
1/kB*T (Boltzmann factor) |
x |
1D Spin sites on the lattice. |
J |
Interaction strength |
H |
External field |
probSel |
Which transition probability to use. 1 for Metropolis 2 for Glauber |
A pair list, flip states (vec) and if step is accepted (accept).
Mehmet Suzen <[email protected]>
n <- 10 # 10 spin sites mySites <- genConfig1D(n) # Generate sites # only short-range part isStep1D(1.0, mySites, 1.0, 0.0, 1) # Metropolis isStep1D(1.0, mySites, 1.0, 0.0, 2) # Glauber
n <- 10 # 10 spin sites mySites <- genConfig1D(n) # Generate sites # only short-range part isStep1D(1.0, mySites, 1.0, 0.0, 1) # Metropolis isStep1D(1.0, mySites, 1.0, 0.0, 2) # Glauber
Given a vector of flip sites, 1s or -1s, representing up and down spins respectively, return nearest neighbour energy, applying periodic boundary conditions, i.e., cyclic. This function calls the C function 'lattice1DenergyNN'.
lattice1DenergyNN(x)
lattice1DenergyNN(x)
x |
1D Spin sites on the lattice |
Returns the nearest neighbour energy.
Mehmet Suzen <[email protected]>
n <- 10 # 10 spin sites mySites <- genConfig1D(n) # Generate sites # now flip mySitesNew <- lattice1DenergyNN(mySites)
n <- 10 # 10 spin sites mySites <- genConfig1D(n) # Generate sites # now flip mySitesNew <- lattice1DenergyNN(mySites)
Given a vector of flip sites, 1s or -1s, representing up and down spins respectively, return nearest neighbour energy, applying periodic boundary conditions, i.e., cyclic. This function is a pure R implementation.
lattice1DenergyNN_R(x)
lattice1DenergyNN_R(x)
x |
1D Spin sites on the lattice |
Returns the nearest neighbour energy.
Mehmet Suzen <[email protected]>
n <- 10 # 10 spin sites mySites <- genConfig1D_R(n) # Generate sites nnEnergy <- lattice1DenergyNN(mySites)
n <- 10 # 10 spin sites mySites <- genConfig1D_R(n) # Generate sites nnEnergy <- lattice1DenergyNN(mySites)
Given a vector of flip sites, 1s or -1s, representing up and down spins respectively, return the sum. This function calls the C function 'sumVec'.
sumVec(x)
sumVec(x)
x |
1D Spin sites on the lattice |
Returns the sum, corresponding the long-range part.
Mehmet Suzen <[email protected]>
n <- 10 # 10 spin sites mySites <- genConfig1D(n) # Generate sites sumVecs <- sumVec(mySites)
n <- 10 # 10 spin sites mySites <- genConfig1D(n) # Generate sites sumVecs <- sumVec(mySites)
Given a vector of flip sites, 1s or -1s, representing up and down spins respectively, return the sum. This function calls the C function 'sumVec'.
sumVec_R(x)
sumVec_R(x)
x |
1D Spin sites on the lattice |
Returns the sum, corresponding the long-range part.
Mehmet Suzen <[email protected]>
n <- 10 # 10 spin sites mySites <- genConfig1D_R(n) # Generate sites sumVecs <- sumVec_R(mySites)
n <- 10 # 10 spin sites mySites <- genConfig1D_R(n) # Generate sites sumVecs <- sumVec_R(mySites)
Given a vector of flip sites, 1s or -1s, representing up and down spins respectively, return total energy, applying periodic boundary conditions, i.e., cyclic. This function calls the C function 'totalEnergy1D'.
totalEnergy1D(x, J, H)
totalEnergy1D(x, J, H)
x |
1D Spin sites on the lattice. |
J |
The strength of interaction. |
H |
The value of the external field. |
Returns the total energy.
Mehmet Suzen <[email protected]>
n <- 10 # 10 spin sites mySites <- genConfig1D(n) # Generate sites # only short-range part myTotalEnergy <- totalEnergy1D(mySites, 1.0, 0.0)
n <- 10 # 10 spin sites mySites <- genConfig1D(n) # Generate sites # only short-range part myTotalEnergy <- totalEnergy1D(mySites, 1.0, 0.0)
Given a vector of flip sites, 1s or -1s, representing up and down spins respectively, return total energy, applying periodic boundary conditions, i.e., cyclic. This function is pure R implementation.
totalEnergy1D_R(x, J, H)
totalEnergy1D_R(x, J, H)
x |
1D Spin sites on the lattice. |
J |
The strength of interaction. |
H |
The value of the external field. |
Return the total energy.
Mehmet Suzen <[email protected]>
n <- 10 # 10 spin sites mySites <- genConfig1D_R(n) # Generate sites # only short-range part myTotalEnergy <- totalEnergy1D_R(mySites, 1.0, 0.0)
n <- 10 # 10 spin sites mySites <- genConfig1D_R(n) # Generate sites # only short-range part myTotalEnergy <- totalEnergy1D_R(mySites, 1.0, 0.0)
Compute transfer matrix
transferMatrix(ikBt, J, H)
transferMatrix(ikBt, J, H)
ikBt |
1/kB*T (Boltzmann factor) |
J |
Interaction strength |
H |
External field |
Returns transfer matrix and its eigenvalues in a pair list.
Mehmet Suzen <[email protected]>
transferMatrix(1.0, 1.0, 0)
transferMatrix(1.0, 1.0, 0)
Given a vector of flip sites, 1s or -1s, representing up and down spins respectively, and an other flip sites, return the transition probability, applying periodic boundary conditions, i.e., cyclic. This function calls the C function 'transitionProbability1D'.
transitionProbability1D(ikBT, x, xflip, J, H, probSel)
transitionProbability1D(ikBT, x, xflip, J, H, probSel)
ikBT |
1/kB*T (Boltzmann factor) |
x |
1D Spin sites on the lattice. |
xflip |
1D Spin sites on the lattice: after a flip. |
J |
Interaction strength |
H |
External field |
probSel |
Which transition probability to use. 1 for Metropolis 2 for Glauber |
Returns transition probability.
Mehmet Suzen <[email protected]>
n <- 10 # 10 spin sites mySites <- genConfig1D(n) # Generate sites mySitesNew <- flipConfig1D(mySites) # only short-range part transitionProbability1D(1.0, mySites, mySitesNew, 1.0, 0.0, 1) # Metropolis transitionProbability1D(1.0, mySites, mySitesNew, 1.0, 0.0, 2) # Glauber
n <- 10 # 10 spin sites mySites <- genConfig1D(n) # Generate sites mySitesNew <- flipConfig1D(mySites) # only short-range part transitionProbability1D(1.0, mySites, mySitesNew, 1.0, 0.0, 1) # Metropolis transitionProbability1D(1.0, mySites, mySitesNew, 1.0, 0.0, 2) # Glauber
Given a vector of flip sites, 1s or -1s, representing up and down spins respectively, and an other flip sites, return the transition probability, applying periodic boundary conditions, i.e., cyclic. This function is pure R implementation.
transitionProbability1D_R(ikBT, x, xFlip, J, H)
transitionProbability1D_R(ikBT, x, xFlip, J, H)
ikBT |
1/kB*T (Boltzmann factor) |
x |
1D Spin sites on the lattice. |
xFlip |
1D Spin sites on the lattice: after a flip. |
J |
Interaction strength |
H |
External field |
Returns transition probability.
Mehmet Suzen <[email protected]>
n <- 10 # 10 spin sites mySites <- genConfig1D_R(n) # Generate sites mySitesNew <- flipConfig1D_R(mySites) # only short-range part transitionProbability1D_R(1.0, mySites, mySitesNew, 1.0, 0.0)
n <- 10 # 10 spin sites mySites <- genConfig1D_R(n) # Generate sites mySitesNew <- flipConfig1D_R(mySites) # only short-range part transitionProbability1D_R(1.0, mySites, mySitesNew, 1.0, 0.0)