This is an old revision of the document!
Programming: Monte-Carlo simulation of spin-glass model
Write a complete Monte-Carlo simulation program for the Sherrington–Kirkpatrick model of spin glass.
The model is defined by the Hamiltonian, \[H=-\sum_{i<j}J_{i,j}s_i s_j,\] where $s_i=\pm 1$ with $i=0,..,N-1$ are the $N$ spins of the system.
System representation
Both structure ($h_i$,$J_{i,j}$) and state ($s_i$) data are stored in one dimensional arrays.
int sz = 64; int * spin = new int[sz]; double * h = new double [sz]; double * j = new double [sz*(sz-1)/2];
Data storage
For portability of data, we use HDF5 library. Here, we try the C++ binding of the library.
#include <H5Cpp.h> #include <vector> using namespace H5; H5File("params_hj.h5",H5F_ACC_RDONLY).createDataSet("dset",PredType::NATIVE_DOUBLE,DataSpace(2,std::vector<hsize_t>({4,6}).data()));