Skip to content

Instantly share code, notes, and snippets.

@robertrueger robertrueger/README
Last active Aug 29, 2015

Embed
What would you like to do?
SSMC run for physics.stackexchange.com question 102109
https://physics.stackexchange.com/questions/102109/numerical-ising-model-wolff-algorithm-and-correlations
0 1 1
1 0.642262 0.719488
2 0.492513 0.602067
3 0.417063 0.542904
4 0.369244 0.505408
5 0.332864 0.476882
6 0.313574 0.461756
7 0.291556 0.444491
8 0.274858 0.431398
9 0.254207 0.415205
10 0.242887 0.406329
11 0.233118 0.398669
12 0.217178 0.386169
13 0.206638 0.377904
14 0.200766 0.3733
15 0.19255 0.366857
16 0.188302 0.363527
17 0.181936 0.358535
18 0.172186 0.35089
19 0.166228 0.346218
20 0.159786 0.341167
21 0.151329 0.334535
22 0.145895 0.330275
23 0.143881 0.328695
24 0.140691 0.326194
25 0.136523 0.322926
26 0.130973 0.318573
27 0.128455 0.316599
28 0.125666 0.314412
29 0.124211 0.313271
30 0.119808 0.309819
31 0.117618 0.308101
32 0.115771 0.306653
33 0.117766 0.308218
34 0.112178 0.303836
35 0.107945 0.300517
36 0.106303 0.299229
37 0.102954 0.296603
38 0.102967 0.296613
39 0.0998489 0.294169
40 0.0987621 0.293316
41 0.0945095 0.289982
42 0.0936083 0.289275
43 0.0918202 0.287873
44 0.0890461 0.285698
45 0.0883906 0.285184
46 0.0877204 0.284658
47 0.0860993 0.283387
48 0.085383 0.282825
49 0.0834081 0.281277
50 0.0801443 0.278718
51 0.0756773 0.275215
52 0.0748549 0.27457
53 0.0739087 0.273828
54 0.0721812 0.272474
55 0.0720452 0.272367
56 0.069891 0.270678
57 0.0705823 0.27122
58 0.0693456 0.27025
59 0.0692557 0.27018
60 0.0667103 0.268184
61 0.0671144 0.268501
62 0.0661129 0.267715
63 0.0649916 0.266836
64 0.0652947 0.267074
65 0.0646423 0.266562
66 0.0633734 0.265567
67 0.0620564 0.264534
68 0.06223 0.264671
69 0.0606607 0.26344
70 0.0586665 0.261876
71 0.0588791 0.262043
72 0.0581212 0.261449
73 0.0571406 0.26068
74 0.0576581 0.261086
75 0.0569634 0.260541
76 0.055428 0.259337
77 0.0544377 0.25856
78 0.0540721 0.258274
79 0.0532338 0.257616
80 0.0517749 0.256472
81 0.0534058 0.257751
82 0.0546124 0.258697
83 0.054094 0.258291
84 0.05206 0.256696
85 0.0525328 0.257067
86 0.0496592 0.254814
87 0.0492335 0.25448
88 0.0489358 0.254246
89 0.0475195 0.253136
90 0.0475169 0.253134
91 0.0476636 0.253249
92 0.0475686 0.253174
93 0.0463152 0.252191
94 0.0465385 0.252366
95 0.0454475 0.251511
96 0.0447897 0.250995
97 0.0419206 0.248745
98 0.0423076 0.249049
99 0.0423095 0.24905
100 0.0419979 0.248806
101 0.0416273 0.248515
102 0.0406852 0.247777
103 0.0402941 0.24747
104 0.0402561 0.24744
105 0.0390314 0.24648
106 0.0371113 0.244974
107 0.0382532 0.24587
108 0.0372196 0.245059
109 0.0381345 0.245777
110 0.0372046 0.245048
111 0.0372528 0.245085
112 0.0360573 0.244148
113 0.0364524 0.244458
114 0.0347285 0.243106
115 0.0328629 0.241643
116 0.0328377 0.241623
117 0.0332726 0.241964
118 0.0338415 0.24241
119 0.0318232 0.240828
120 0.0319069 0.240893
121 0.0312893 0.240409
122 0.0323094 0.241209
123 0.02896 0.238583
124 0.0286337 0.238327
125 0.0268624 0.236938
126 0.0262644 0.236469
127 0.026173 0.236397
128 0.0248991 0.235398
129 0.0246576 0.235209
130 0.0237807 0.234521
131 0.024693 0.235237
132 0.0257492 0.236065
133 0.0243184 0.234943
134 0.0249288 0.235422
135 0.0241497 0.234811
136 0.0244344 0.235034
137 0.0245281 0.235108
138 0.0237604 0.234506
139 0.0236842 0.234446
140 0.0229629 0.23388
141 0.0221637 0.233254
142 0.020879 0.232246
143 0.020343 0.231826
144 0.0200866 0.231625
145 0.0195809 0.231228
146 0.0205539 0.231991
147 0.0208342 0.232211
148 0.0191981 0.230928
149 0.0189916 0.230766
150 0.0192397 0.230961
151 0.0185437 0.230415
152 0.017847 0.229869
153 0.016731 0.228994
154 0.0171549 0.229326
155 0.0167832 0.229035
156 0.0163203 0.228672
157 0.0160771 0.228481
158 0.0158781 0.228325
159 0.0168449 0.229083
160 0.0162612 0.228625
161 0.0171421 0.229316
162 0.0175602 0.229644
163 0.017691 0.229746
164 0.0156701 0.228162
165 0.0170157 0.229217
166 0.016973 0.229183
167 0.0180629 0.230038
168 0.0182043 0.230149
169 0.0168568 0.229092
170 0.0170451 0.22924
171 0.0168852 0.229115
172 0.0178882 0.229901
173 0.0166464 0.228927
174 0.0160093 0.228428
175 0.0150551 0.22768
176 0.0150715 0.227692
177 0.0146679 0.227376
178 0.0150329 0.227662
179 0.0146196 0.227338
180 0.0142269 0.22703
181 0.012382 0.225583
182 0.0111042 0.224582
183 0.0114029 0.224816
184 0.0100853 0.223783
185 0.0102119 0.223882
186 0.00948087 0.223309
187 0.00972065 0.223497
188 0.010048 0.223753
189 0.00877009 0.222751
190 0.00906697 0.222984
191 0.00876182 0.222745
192 0.00984648 0.223595
193 0.00991199 0.223647
194 0.0100253 0.223736
195 0.0101003 0.223794
196 0.00994603 0.223673
197 0.0116219 0.224987
198 0.0111727 0.224635
199 0.0106956 0.224261
200 0.0104673 0.224082
201 0.0096356 0.22343
202 0.00933698 0.223196
203 0.00876608 0.222748
204 0.00795819 0.222115
205 0.00835463 0.222426
206 0.00796006 0.222116
207 0.00836422 0.222433
208 0.00859 0.22261
209 0.00981265 0.223569
210 0.00940333 0.223248
211 0.0101676 0.223847
212 0.0106718 0.224242
213 0.00988489 0.223625
214 0.00893147 0.222878
215 0.00840184 0.222463
216 0.00841994 0.222477
217 0.0075857 0.221823
218 0.00922656 0.223109
219 0.00873195 0.222721
220 0.0094902 0.223316
221 0.0097863 0.223548
222 0.00916522 0.223061
223 0.00898285 0.222918
224 0.00881305 0.222785
225 0.0098694 0.223613
226 0.0111514 0.224618
227 0.00989769 0.223635
228 0.0101163 0.223807
229 0.00894698 0.22289
230 0.00907701 0.222992
231 0.00979771 0.223557
232 0.00897419 0.222911
233 0.00913794 0.22304
234 0.00762098 0.22185
235 0.00861222 0.222627
236 0.00940211 0.223247
237 0.0087922 0.222769
238 0.00910687 0.223015
239 0.00888696 0.222843
240 0.00894459 0.222888
241 0.00906958 0.222986
242 0.00900827 0.222938
243 0.00758701 0.221824
244 0.00766005 0.221881
245 0.00794369 0.222103
246 0.00797646 0.222129
247 0.00721188 0.221529
248 0.00696925 0.221339
249 0.0077016 0.221913
250 0.00709523 0.221438
251 0.0058906 0.220493
252 0.00653328 0.220997
253 0.00718758 0.22151
254 0.00706493 0.221414
255 0.00719903 0.221519
# Best fit parameters were:
# -------------------------
A = 0.71203972
beta = 0.24313612
# Estimating the size of the error bars on supplied data.
# This may take a while.
# The fit command can be made to run very substantially faster if the 'withouterrors' option is set.
# Estimate of error bars on supplied data, based on their fit to model function = 0.0029633922
# Hessian matrix of log-probability distribution:
# -----------------------------------------------
hessian = [ [-1502004.6,2639145.1] , [2639145.1,-5625025.3] ]
# Covariance matrix of probability distribution:
# ----------------------------------------------
covariance = [ [3.7911459e-06,1.77872695e-06] , [1.77872692e-06,1.01231872e-06] ]
# Correlation matrix of probability distribution:
# ----------------------------------------------
correlation = [ [1,0.90795725] , [0.90795724,1] ]
# Uncertainties in best-fit parameters are:
# -----------------------------------------
sigma_A = 0.0019470865
sigma_beta = 0.0010061405
# Summary:
# --------
A = (0.71203972 +/- 0.0019470865)
beta = (0.24313612 +/- 0.0010061405)
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
set terminal pdf
set output 'sscorr_fit.pdf'
set xlabel '$| \vec r_j - \vec r_i |$'
set xrange[0:256]
set ylabel '$\langle s_i s_j \rangle$'
set yrange [0:1]
A = 1
beta = 0.25
ss(x) = A/x**beta
fit [1:50] ss() 'sscorr.log' using 1:3 via A,beta
plot 'sscorr.log' using 1:3 with lines title 'Monte Carlo', ss(x) title 'fit'
set terminal pngcairo size 1000,600
set output 'sscorr_plot.png'
set grid x y
set arrow from graph 0, first 0 to graph 1, first 0 nohead lw 2
set title 'spin-spin correlation'
plot 'sscorr.log' u 1:2 with linespoints title '<s1s2> - <m>^2', \
'sscorr.log' u 1:3 with linespoints title '<s1s2> '
#! /bin/bash
# Copyright (c) 2012, Robert Rueger <rueger@itp.uni-frankfurt.de>
#
# This file is part of SSMC.
#
# SSMC is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# SSMC 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. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with SSMC. If not, see <http://www.gnu.org/licenses/>.
# ========================= CLI MODE =========================
# (read parameters from the command line)
if [ $# -eq 19 ]; then
echo "ssmcsim called in cli mode ..."
time ./ssmcsim $1 $2 $3 $4 $5 $6 $7 $8 $9 ${10} ${11} ${12} \
${13} ${14} ${15} ${16} ${17} ${18} ${19}
exit
fi
# ======================= SCRIPT MODE ========================
# (read parameters from this script)
echo "ssmcsim called in script mode ..."
# ----------------- SIMULATION PARAMETERS --------------------
# type of system to be simulated?
system_type=3
# -- 1: one-dimensional Ising-Model with single-flip Metropolis-Algorithm
# -- 2: two-dimensional Ising-Model with single-flip Metropolis-Algorithm
# -- 3: two-dimensional field-free Ising-Model with Wolff-Algorithm
# -- 4: 2d Ising-Model with long range dipole interaction (Metropolis-Alg.)
# -- 5: like 4 but improved
# -- 6: 2d Ising-Model with dip-dip-int on a honeycomb lattice
# size of the system?
N=512
# periodic boundary conditions?
periodic=1
# initial conditions?
init=u
# -- r: initialize spins randomly
# -- u: all spins up at t=0
# -- d: all spins down at t=0
# -- e: 50:50 up/down (for B=0 and very low temperatures)
# -- c: checkerboard (2d)
# -- s: enery minimizing stripes
# -- [uint]: stripes of manually defined width
# number of MC steps for thermalization?
drysweeps=100
# number of bins?
bins=1000
# number of measurements per bin?
binwidth=10
# do measurements every ... MC steps
intersweeps=1
# strength of nearest-neighbour-coupling?
J=1
# strength of dipole-dipole-coupling (only relevant for system_type 4, 5 and 6)
g=0
# external magnetic field
B=0
# temperature
T=2.26918531421
# ------------------ DATA ANALYSIS OPTIONS --------------------
# do you want SSMCSIM to call the plotting scripts automatically?
# (requires gnuplot and pyxplot)
run_plots=1
# do you want to take images of the system?
images=100
# -- 0: dont take images
# -- n: take an image every n mcsteps
# do you want to calculate magnetization autocorrelation?
calc_autocorr=1
# do you want to calculate spin-spin correlations?
calc_sscorr=1
# "special" mode?
smode_perbin=0
smode_permcs=0
# do you want the special treatment for systems with spontaneous magnetization?
finite_size_correction=2
# -- 0: disabled
# -- 1: use absolute magnetization
# -- 2: determine automatically
# ----------------------- EXECUTION --------------------------
time ./ssmcsim $system_type $N $periodic \
$init $drysweeps $bins $binwidth $intersweeps \
$run_plots $images \
$calc_autocorr $calc_sscorr \
$smode_perbin $smode_permcs \
$finite_size_correction \
$J $g $B $T
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.