This is Spinner, a collection of numerical routines for spin systems simulations. Spinner is free software, you can redistribute it and/or modify it under the terms of the GNU General Public License.
WARNING: This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
NOTE: This library is in early stage of development. Contributions are welcome.
Spin systems, such as the Ising or the Heisenberg model, are defined on a graph where each vertex
The system object can hold spin variables of different kinds, such as Ising variables (
Read the documentation for a detailed explanation.
Here are the building instructions:
git clone <spinner repo>
cd spinner
autoreconf -i
./configure
make
sudo make install
The default installation prefix is /usr/local/lib
.
Here is an example code that, at different temperatures, samples:
- an Ising system
- on a cubic lattice in 2D with side 50 (
N=2500
sites) - with ferromagnetic interactions
- every
10*N
steps using the Metropolis algorithm
#include <stdio.h>
#include <spinner/spinner.h>
int main()
{
size_t N = 2500, n_temps = 50, n_probes = 1000+1, i;
float temp, temp_start = 0.1, temp_finish=5.0, temp_step, beta;
float h_mean, m_mean, h_var, m_var;
FILE * f;
spnr_graph_t *graph = spnr_graph_alloc (spnr_cubic, spnr_ferr, N, 2);
spnr_sys_t *sys = spnr_sys_alloc (graph, spnr_ising, 2);
spnr_step_t *step = spnr_step_alloc (spnr_metropolis,
spnr_sys_spin_size(sys));
spnr_data_t *data = spnr_data_alloc (n_probes);
temp_step = (temp_finish - temp_start) / (float) (n_temps-1);
f = fopen ("results.txt", "w");
for (i = 0; i < n_temps; ++i)
{
temp = temp_start + i * temp_step;
beta = 1.0 / temp;
spnr_data_run_and_probe (data, sys, step, temp, 10);
spnr_data_mean_calc (data, &h_mean, &m_mean);
spnr_data_var_calc (data, &h_var, &m_var);
fprintf (f, "%f %+f %+f %+f %+f\n", temp, h_mean, m_mean,
beta * beta * N * h_var, beta * N * m_var);
}
fclose (f);
spnr_data_free (data);
spnr_step_free (step);
spnr_sys_free (sys);
spnr_graph_free (graph);
}
To compile:
gcc -I /usr/local/include/ program.c -o program -L /usr/local/lib -lspinner -lm
Upon execution, it will produce a file. Using gnuplot
with the following command
plot "results.txt" using 1:4 with lines
yelds
Here are the planned features for this library. For now, only some of them are in place.
- Variables
- Ising
- n-vector (XY, Heisenberg)
- Potts
- Graphs
- Cubic lattice
- Fully connected
- Random graph
- Interactions
- Ferromagnetic
- Antiferromagnetic
- Spin glass (bimodal)
- Steppers
- Metropolis
- Heat-Bath
- Wolff
- Swendsen–Wang
- Utilities
- Simulation data object
- Parallelization
- Parallel tempering