Skip to content

elohimfr/sk_model

master
Switch branches/tags
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 

skmodel.c

This program simulates the Sherrington-Kirkpatrick (SK) model of spin glasses without external field () and under . In this case, the Hamiltonian of the SK model is given by

where or . The interaction is independently distributed according to a Gaussian distribution given by

where and are the mean and the standard deviation of , respectively.

The program uses the single-spin flip Metropolis Monte Carlo algorithm. So, at each time step (i.e., Monte Carlo step) we choose one spin uniformly at random and accept or reject the proposed spin flip according to the acceptance rates of the Metropolis algorithm. For a system of N spins, a sweep of the system consists of N time steps. Before computing the observables of the model, a transient period of a given number of sweeps is performed and discarded.

To compute the observables of the SK model, we distinguish between the time average (a.k.a. thermal averge) and the configurational average. The time average is the average over a given number of sweeps for a given fixed configuration of interactions . We sample the observables once every sweep, but not every time step, and average the samples over the given number of sweeps. The configurational average is the averge taken over a given number of different configurations . For example, if we allow L sweeps for the time average and M configurations for the configurational average, an observable A is calculated as

where denotes the time average, denotes the configurational average, and is the sample of A in the ith sweep and th configuration.

Please cite the following paper when you use this code.

Ezaki T, Fonseca dos Reis E, Watanabe T, Sakaki M, Masuda N. Closer to critical resting-state neural dynamics in individuals with higher fluid intelligence. Communications Biology 3:1 (2020).

How to use

  1. Download skmodel.c.

  2. Download mt19937ar.c in the same folder.

  3. Set the parameters.

The user has to set the following parameters in the code before compiling.

Parameters:

  • Number of spins (N);
  • L, i.e., number of sweeps for the time average given a fixed configuration of (tdim);
  • M, i.e., number of configurations for the configurational average (conf_num);
  • Number of sweeps in the transient period (thermal);
  • The minimum value of (mu_min), maximum value of (mu_max), and the step (mu_step) between the maximum and minimum values of . Therefore, the number of values of that are scanned is 1+(mu_max-mu_min)/mu_step.
  • The minimum value of (sd_min), maximum value of (sd_max), and the step (sd_step) between the maximum and minimum values of . Therefore, the number of values of that are scanned is 1+(sd_max-sd_min)/sd_step.
  1. Compile and run

The program uses GSL libraries. So, the user must link the libraries (-lgsl -lgslcblas -lm). For intance, if using gcc, type in the terminal:

gcc -Wall skmodel.c -o skmodel_program -lgsl -lgslcblas -lm

Then, run the program:

./skmodel_program
  1. Output

The program outputs the following observables:

  • spin glass susceptibility (Xsg),
  • uniform susceptibility (Xuni),
  • spin glass order parameter (q),
  • magnetization (m),
  • specific heat (c).

The outputs of the program are multiple .txt files, one for each pair of (mu, sd). Each .txt file contains only one line with seven values in this order: mu, sd, Xsg, Xuni, q, m, c. If the user sets n values for the mu array and m values for the sd array, the program outputs nm .txt files. The files are named as: file_0_0.txt, file_0_1.txt, ..., file_1_0.txt, file_1_1.txt... The reason for generating multiple .txt files is for parallelizing the program as explained next.

  1. Parallelizing

The program has a built-in naive parallelization for scanning the values of and . In other words, after compiling the code, if the user runs the same program on different cores in the same node, the total computation time will decrease proportionally to the number of cores.

  1. Gather the outputs
  • Download the jupyter notebook sk_heatmap.ipynb in the folder where the outputs are.
  • Open the notebook.
  • Set the parameters accordingly, as indicated in the notebook.
  • Run the python code.
  • A figure for each measure is produced.

About

Phase diagram of the Sherrington-Kirkpatrick (SK) model

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published