Mathematica Asked on August 18, 2021
Are there any configurations to fix it?
Test code:
Clear["`*"];
fun[matrix_, n_, β_, {i_, j_}] := Block[{p, E1, mat = matrix},
p = matrix[[i, j]];
E1 = -Total[
p {matrix[[Mod[i - 1, n, 1], j]], matrix[[Mod[i + 1, n, 1], j]],
matrix[[i, Mod[j - 1, n, 1]]],
matrix[[i, Mod[j + 1, n, 1]]]}];
mat[[i, j]] =
If[E1 >= 0, -p,
RandomChoice[{Exp[2 E1 β], 1 - Exp[2 E1 β]} -> {-p,
p}]];
mat
];
Ising[β_, n_, step_]:=
Block[{mat = RandomChoice[{1, -1}, {n, n}], f},
f := RandomInteger[{1, n}, 2];
NestList[fun[#, n, β, f] &, mat, step]
];
ClearSystemCache[];
Mean[First /@
Table[AbsoluteTiming[
fun[RandomChoice[{1, -1}, {100, 100}], 100, 0.8,
RandomInteger[{1, 100}, 2]];], 3746]]
Ising[0.8, 100, 10^5]; // AbsoluteTiming
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP