IGLib
1.7.2
The IGLib base library EXTENDED - with other lilbraries and applications.
|
Classes | |
class | SpinStateCollection |
A nested class providing the indexed property functionality for the _spinState list. More... | |
Public Member Functions | |
IsingModel () | |
The constructors starts the state list in an extremely ordered state. We also need to instantiate the fake indexed SpinState property. More... | |
void | TryTurnRandomSpin () |
Tries to turn a random spin in the lattice. If the energy change is positive and the dice roll falls above the exponential curve defined by the beta parameter, the change is discarded. More... | |
void | SimulatedAnnealingWithPlot () |
Anneals the Ising model while plotting the results. More... | |
void | SimulatedAnnealing () |
Anneals the Ising model, no plotting. More... | |
double | ConfigurationEnergy () |
Calculates the configuration energy by accounting for every bond in the lattice. Takes into account the B-vK boundary conditions. More... | |
double | AverageConfigEnergy () |
Calculates the average configuration energy at a certain temperature. More... | |
void | AvgConfigEnergyVsTemp (double initTemp, double finalTemp, double nSamples) |
Calculates the average configuration energy on a temperature range and writes the results to a file. More... | |
double | MagMoment () |
Calculates the magnetization by accounting for each spin in the lattice. More... | |
double | AverageMagMoment () |
Calculates the average magnetization at a certain temperature. More... | |
void | AvgMagMomentVsTemp (double initTemp, double finalTemp, double nSamples) |
Calculates the average magnetization on a temperature range and writes the results to a file. More... | |
double | AverageSusceptibilityN () |
Calculates the average susceptibility times N at a certain temperature. More... | |
void | AvgSusceptibilityNVsTemp (double initTemp, double finalTemp, double nSamples) |
Calculates the average susceptibility times N on a temperature range and writes the results to a file. More... | |
double | EnergyVariance () |
Calculates the expected value of energy squared minus square of the expected value of energy. More... | |
double | AvgEnergyVariance () |
Calculates the average energy variance, used when calculating the specific heat. More... | |
void | AvgSpecificHeatNVsTemp (double initTemp, double finalTemp, double nSamples) |
Calculates the average specific heat times N at a certain temperature range and writes the results to a file. More... | |
double | OnlineEnergyVariance () |
Calculates the online energy variance. More... | |
double | AvgOnlineEnergyVariance () |
Calculates the average online energy variance, used when calculating the specific heat. More... | |
void | AvgSpecificHeatNVsTemp2 (double initTemp, double finalTemp, double nSamples) |
Calculates the average specific heat times N at a certain temperature range and writes the results to a file. More... | |
![]() | |
PlotZedgraphCurve | NewCurveFromPlottableData (PlotterZedGraph plotter, int x, int y) |
Creates a new PlotZedgraphCurve object from the available plottable data. More... | |
void | LoadPlottableDataToCurve (PlotZedgraphCurve curve, int x, int y) |
Copies the calculated data to the existing PlotZedgraphCurve object. Enough space must be available on the curve object's list. More... | |
Protected Attributes | |
double | _initialBeta = 0.005 |
double | _finalBeta = 30 |
int | _stepsAtTemperature = 5000 |
int | _coolingLevels = 7 |
double | _gamma |
The factor for which the inverse temperature beta rises after each cooling level. The inverse alpha, where alpha is the analogous factor asocciated with the gradual fall of the temperature. More... | |
int | _plotEveryNShifts = 50 |
![]() | |
string | _title |
Properties | |
int | LatticeXDim [get, set] |
Rectangular lattice's x-dimension. More... | |
int | LatticeYDim [get, set] |
Rectangular lattice's y-dimension. More... | |
double | Beta [get, set] |
The parameter beta of the falling exponential (Boltzmann) distribution. The "inverse" temperature. More... | |
double | Temperature [get, set] |
Temperature is an inverse with beta. Boltzmann constant = 1. More... | |
double | J [get, set] |
Coupling constant between spins: 1 -> paramagnetism (same direction: lower energy), -1 -> diamagnetism. More... | |
double | H [get, set] |
Coupling constant between a spin and the external magnetic field: 1 -> (same direction: lower energy). More... | |
int | StateChosenSpin [get, set] |
The state of the spin that's been chosen by the RNG. This property should make the code more readable. More... | |
int | StateAboveSpin [get, set] |
The state of the spin above the chosen spin. This property should make the code more readable. More... | |
int | StateBelowSpin [get, set] |
The state of the spin below the chosen spin. This property should make the code more readable. More... | |
int | StateLeftSpin [get, set] |
The state of the spin left of the chosen spin. This property should make the code more readable. More... | |
int | StateRightSpin [get, set] |
The state of the spin right of the chosen spin. This property should make the code more readable. More... | |
double | InitialBeta [get, set] |
The initial inverse temperature for the simulated annealing process. More... | |
double | InitialTemperature [get, set] |
The initial temperature for the simulated annealing process. More... | |
double | FinalBeta [get, set] |
The final inverse temperature for the simulated annealing process. More... | |
double | FinalTemperature [get, set] |
The final temperature for the simulated annealing process. More... | |
int | StepsAtTemperature [get, set] |
How many spin turns the method will make at a certain temperature. More... | |
int | CoolingLevels [get, set] |
How granular the cooling will be. Example: T0 = 1000, TN=100, CoolingLevels = 10: 1000, 900, 800, ..., 200, 100. More levels means higher reliability, but also more time wasted. More... | |
int | PlotEveryNShifts [get, set] |
How often the plotting window should refresh. A smaller number means more often and makes it more interesting. However, a bigger number makes the whole calculation much faster. More... | |
int | NumOfAnnealingsToAvgOver [get, set] |
How many terms should be added together before averaging takes place. Used by all the averaging methods. More... | |
![]() | |
string | Title [get, set] |
The plottable model's name. Also used as a plot title. More... | |
List< double[]> | PlottableData [get, set] |
The main solution array, which is used by the plotter. More... | |
Private Member Functions | |
void | UpdateLatticeRowCurves () |
Used by the main thread. Updates the points shown by the plotting thread to the most recent state. More... | |
void | ShowPlot () |
This method runs on the plotting thread. Its only job is to display the plotting window. More... | |
Private Attributes | |
List< List< int > > | _spinState |
SpinStateCollection | SpinState |
Holds the states (1 or -1) of all the spins in the lattice. Each spin's position in the lattice can be inferred from the indices, since the lattice is rectangular. The indices are cyclic (periodic boundary condition). An indexed property. More... | |
List< PlotZedgraphCurve > | _latticeRowCurve |
A list of all the rows of spins in the spin lattice. Each row is represented by a PlotZedGraphCurve object. More... | |
PlotHQ | _plothq1 |
A PlotHQ object used by the plotting thread. More... | |
int | _latticeXDim = 100 |
int | _latticeYDim = 100 |
double | _beta = 0.3 |
double | _j = 1 |
double | _h = 0 |
Random | _rng = new Random() |
An all-purpose RNG. More... | |
double | _diceRoll |
A random real number between 0 and 1. Used for the simulated annealing (Boltzmann) criterion. More... | |
int | _randomSpinX |
The RNG chooses a random spin. This is its x-index. More... | |
int | _randomSpinY |
The RNG chooses a random spin. This is its y-index. More... | |
double | _energyChange |
The difference between the new and the old energy. More... | |
readonly object | _locker = new object() |
A locker for wait/pulse methods. More... | |
bool | _go = false |
A blocking condition for the wait/pulse methods. More... | |
int | _numOfAnnealingsToAvgOver = 10 |
|
inline |
The constructors starts the state list in an extremely ordered state. We also need to instantiate the fake indexed SpinState property.
|
inlineprivate |
Used by the main thread. Updates the points shown by the plotting thread to the most recent state.
|
inlineprivate |
This method runs on the plotting thread. Its only job is to display the plotting window.
References IG.Gr.ZedGraphWindow.GraphControl, IG.MPetekLib.Algorithms.Plotting.PlotHQ.Plotter, IG.Gr.PlotterZedGraph.SetBounds(), IG.MPetekLib.Algorithms.Plotting.PlotHQ.ShowPlot(), IG.Gr.PlotterZedGraph.Title, and IG.MPetekLib.Algorithms.Plotting.PlotHQ.Window.
|
inline |
Tries to turn a random spin in the lattice. If the energy change is positive and the dice roll falls above the exponential curve defined by the beta parameter, the change is discarded.
|
inline |
Anneals the Ising model while plotting the results.
References IG.MPetekLib.Algorithms.Plotting.PlotHQ.Plotter, IG.Gr.PlotterZedGraph.Update(), and IG.MPetekLib.Algorithms.Plotting.PlotHQ.Window.
Referenced by IG.MPetekLib.Application.Scripts.CompPhys._03AnnealingIsingModel.Run().
|
inline |
Anneals the Ising model, no plotting.
|
inline |
Calculates the configuration energy by accounting for every bond in the lattice. Takes into account the B-vK boundary conditions.
|
inline |
Calculates the average configuration energy at a certain temperature.
|
inline |
Calculates the average configuration energy on a temperature range and writes the results to a file.
initTemp | Initial temperature. |
finalTemp | Final temperature. |
nSamples | The number of samples on the temperature range. |
Referenced by IG.MPetekLib.Application.Scripts.CompPhys._04IsingAvgEnergy.Run().
|
inline |
Calculates the magnetization by accounting for each spin in the lattice.
|
inline |
Calculates the average magnetization at a certain temperature.
|
inline |
Calculates the average magnetization on a temperature range and writes the results to a file.
initTemp | Initial temperature. |
finalTemp | Final temperature. |
nSamples | The number of samples on the temperature range. |
|
inline |
Calculates the average susceptibility times N at a certain temperature.
|
inline |
Calculates the average susceptibility times N on a temperature range and writes the results to a file.
initTemp | Initial temperature. |
finalTemp | Final temperature. |
nSamples | The number of samples on the temperature range. |
|
inline |
Calculates the expected value of energy squared minus square of the expected value of energy.
|
inline |
Calculates the average energy variance, used when calculating the specific heat.
|
inline |
Calculates the average specific heat times N at a certain temperature range and writes the results to a file.
initTemp | Initial temperature. |
finalTemp | Final temperature. |
nSamples | The number of samples on the temperature range. |
|
inline |
Calculates the online energy variance.
|
inline |
Calculates the average online energy variance, used when calculating the specific heat.
|
inline |
Calculates the average specific heat times N at a certain temperature range and writes the results to a file.
initTemp | Initial temperature. |
finalTemp | Final temperature. |
nSamples | The number of samples on the temperature range. |
Referenced by IG.MPetekLib.Application.Scripts.CompPhys._05IsingAvgMagnetization.Run().
|
private |
|
private |
Holds the states (1 or -1) of all the spins in the lattice. Each spin's position in the lattice can be inferred from the indices, since the lattice is rectangular. The indices are cyclic (periodic boundary condition). An indexed property.
|
private |
A list of all the rows of spins in the spin lattice. Each row is represented by a PlotZedGraphCurve object.
|
private |
A PlotHQ object used by the plotting thread.
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
An all-purpose RNG.
|
private |
A random real number between 0 and 1. Used for the simulated annealing (Boltzmann) criterion.
|
private |
The RNG chooses a random spin. This is its x-index.
|
private |
The RNG chooses a random spin. This is its y-index.
|
private |
The difference between the new and the old energy.
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
The factor for which the inverse temperature beta rises after each cooling level. The inverse alpha, where alpha is the analogous factor asocciated with the gradual fall of the temperature.
|
protected |
|
private |
A locker for wait/pulse methods.
|
private |
A blocking condition for the wait/pulse methods.
|
private |
|
getset |
Rectangular lattice's x-dimension.
|
getset |
Rectangular lattice's y-dimension.
|
getset |
The parameter beta of the falling exponential (Boltzmann) distribution. The "inverse" temperature.
|
getset |
Temperature is an inverse with beta. Boltzmann constant = 1.
|
getset |
Coupling constant between spins: 1 -> paramagnetism (same direction: lower energy), -1 -> diamagnetism.
Referenced by IG.MPetekLib.Application.Scripts.CompPhys._04IsingAvgEnergy.Run(), and IG.MPetekLib.Application.Scripts.CompPhys._05IsingAvgMagnetization.Run().
|
getset |
Coupling constant between a spin and the external magnetic field: 1 -> (same direction: lower energy).
Referenced by IG.MPetekLib.Application.Scripts.CompPhys._03AnnealingIsingModel.Run(), IG.MPetekLib.Application.Scripts.CompPhys._05IsingAvgMagnetization.Run(), and IG.MPetekLib.Application.Scripts.CompPhys._04IsingAvgEnergy.Run().
|
getsetprivate |
The state of the spin that's been chosen by the RNG. This property should make the code more readable.
|
getsetprivate |
The state of the spin above the chosen spin. This property should make the code more readable.
|
getsetprivate |
The state of the spin below the chosen spin. This property should make the code more readable.
|
getsetprivate |
The state of the spin left of the chosen spin. This property should make the code more readable.
|
getsetprivate |
The state of the spin right of the chosen spin. This property should make the code more readable.
|
getset |
The initial inverse temperature for the simulated annealing process.
|
getset |
The initial temperature for the simulated annealing process.
Referenced by IG.MPetekLib.Application.Scripts.CompPhys._03AnnealingIsingModel.Run(), IG.MPetekLib.Application.Scripts.CompPhys._05IsingAvgMagnetization.Run(), and IG.MPetekLib.Application.Scripts.CompPhys._04IsingAvgEnergy.Run().
|
getset |
The final inverse temperature for the simulated annealing process.
|
getset |
The final temperature for the simulated annealing process.
Referenced by IG.MPetekLib.Application.Scripts.CompPhys._03AnnealingIsingModel.Run(), IG.MPetekLib.Application.Scripts.CompPhys._05IsingAvgMagnetization.Run(), and IG.MPetekLib.Application.Scripts.CompPhys._04IsingAvgEnergy.Run().
|
getset |
How many spin turns the method will make at a certain temperature.
Referenced by IG.MPetekLib.Application.Scripts.CompPhys._03AnnealingIsingModel.Run(), IG.MPetekLib.Application.Scripts.CompPhys._05IsingAvgMagnetization.Run(), and IG.MPetekLib.Application.Scripts.CompPhys._04IsingAvgEnergy.Run().
|
getset |
How granular the cooling will be. Example: T0 = 1000, TN=100, CoolingLevels = 10: 1000, 900, 800, ..., 200, 100. More levels means higher reliability, but also more time wasted.
Referenced by IG.MPetekLib.Application.Scripts.CompPhys._03AnnealingIsingModel.Run(), IG.MPetekLib.Application.Scripts.CompPhys._05IsingAvgMagnetization.Run(), and IG.MPetekLib.Application.Scripts.CompPhys._04IsingAvgEnergy.Run().
|
getset |
How often the plotting window should refresh. A smaller number means more often and makes it more interesting. However, a bigger number makes the whole calculation much faster.
Referenced by IG.MPetekLib.Application.Scripts.CompPhys._03AnnealingIsingModel.Run().
|
getset |
How many terms should be added together before averaging takes place. Used by all the averaging methods.
Referenced by IG.MPetekLib.Application.Scripts.CompPhys._05IsingAvgMagnetization.Run().