Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
exercise:prog:spinglass [2020/08/17 01:17] – chunchung | exercise:prog:spinglass [2020/11/06 03:15] (current) – [System representation] chunchung | ||
---|---|---|---|
Line 7: | Line 7: | ||
=====System representation===== | =====System representation===== | ||
+ | Both structure ($h_i$, | ||
+ | <code c++> | ||
+ | int sz = 64; | ||
+ | int * spin = new int[sz]; | ||
+ | double * h = new double [sz]; | ||
+ | double * j = new double [sz*(sz-1)/ | ||
+ | </ | ||
+ | Since the coupling involves two spins, it is instinctive to use a two-dimensional array for '' | ||
+ | |||
+ | Since we are using %%C++%%, we will use the '' | ||
+ | <code c++> | ||
+ | std:: | ||
+ | std:: | ||
+ | std:: | ||
+ | </ | ||
+ | For couplings, we use '' | ||
+ | <code c++> | ||
+ | struct Link { | ||
+ | int n0; | ||
+ | int n1; | ||
+ | }; | ||
+ | std:: | ||
+ | </ | ||
+ | |||
+ | =====Data storage===== | ||
+ | For portability of data, we use [[https:// | ||
+ | <code c++> | ||
+ | #include < | ||
+ | #include < | ||
+ | |||
+ | std:: | ||
+ | std:: | ||
+ | |||
+ | void load_params(std:: | ||
+ | { | ||
+ | using namespace H5; | ||
+ | H5File f(filename, | ||
+ | // read h | ||
+ | DataSet d = f.openDataSet(" | ||
+ | hsize_t sz; | ||
+ | d.getSpace().getSimpleExtentDims(& | ||
+ | h.resize(sz); | ||
+ | d.read(h.data(), | ||
+ | // read j | ||
+ | d = f.openDataSet(" | ||
+ | d.getSpace().getSimpleExtentDims(& | ||
+ | j.resize(sz); | ||
+ | d.read(j.data(), | ||
+ | } | ||
+ | </ | ||
+ | =====All-to-all network===== |