# Section 5: the Ising array of an orthogonal matrix U has spins a, b in {-1,1}^N and energy -Omega, with Omega = . Summing over a, # the partition function is the sum over b of the products of 2cosh(beta (Ub)_i), so everything is exact with 2^N terms. For the plain # design matrices we compute the number of crystalline states (Omega = N), the next values of Omega, and the local maxima of the specific # heat per row wire c = beta^2 Var(Omega)/N, with their temperatures, to be compared with the crystallization temperature T_c predicted # by beta + log(crystalline states)/N = 2 log 2 + Psi(beta), with Psi the paramagnetic free energy of the Hadamard arrays. Usage: python3 arrays.py [largest order for the specific heat, default 23] import numpy as np, sys from designs import SETS, matrices def vectors(U, chunk=1 << 16): n = len(U) for start in range(0, 1 << n, chunk): idx = np.arange(start, min(start + chunk, 1 << n), dtype=np.int64) yield (((idx[:, None] >> np.arange(n)) & 1)*2.0 - 1) @ U.T def levels(U): n = len(U); crystal = 0; best = [] for X in vectors(U): w = np.abs(X).sum(1); crystal += int((w > n - 1e-9).sum()); best = sorted(set(np.round(np.concatenate([best, np.unique(np.round(w, 9))[-4:]]), 9)))[-4:] return crystal, best def heat(U, betas): # log of the partition function and its first 2 derivatives, by a stable weighted sum over b n = len(U); out = [] for beta in betas: parts = [] for X in vectors(U): t = np.tanh(beta*X); lz = (np.abs(beta*X) + np.log1p(np.exp(-2*np.abs(beta*X)))).sum(1) parts.append((lz, (X*t).sum(1), (X*X*(1 - t*t)).sum(1))) lz = np.concatenate([p[0] for p in parts]); mu = np.concatenate([p[1] for p in parts]); s2 = np.concatenate([p[2] for p in parts]) w = np.exp(lz - lz.max()); w /= w.sum(); mean = (w*mu).sum(); var = (w*(s2 + mu*mu)).sum() - mean**2 out.append((mean/n, beta*beta*var/n)) return out def psi(beta): r = np.sqrt(1 + 4*beta*beta); return (r - 1 - np.log((1 + r)/2))/2 def crystallization(c, n): lo, hi = 0.5, 60.0 for _ in range(80): mid = (lo + hi)/2 if mid + np.log(c)/n - 2*np.log(2) - psi(mid) > 0: hi = mid else: lo = mid return 1/lo def maxima(U, lo=0.06, hi=1.0, step=0.02): T = np.arange(lo, hi + 1e-9, step); c = [x[1] for x in heat(U, 1/T)]; found = [] for k in range(1, len(T) - 1): if c[k] > c[k - 1] and c[k] >= c[k + 1]: fine = np.arange(T[k] - step, T[k] + step + 1e-9, step/10); hf = heat(U, 1/fine); j = int(np.argmax([x[1] for x in hf])) found.append((fine[j], hf[j][1], hf[j][0])) return found if __name__ == "__main__": top = int(sys.argv[1]) if len(sys.argv) > 1 else 23 for name, (v, D) in SETS.items(): if v > 23: continue U = matrices(v, D)[0]; crystal, best = levels(U) print("%-26s crystalline states %d, predicted T_c = %.4f, top values of Omega/N: %s" % (name, crystal, crystallization(crystal, v), " ".join("%.5f" % (x/v) for x in best[::-1])), flush=True) if v <= top: for T, c, m in maxima(U): print(" specific heat maximum %.4f at T = %.3f, where m = %.4f" % (c, T, m), flush=True)