def decisionTimes(N, NN, MCS, plotting=False): #pass an object instead? or dont decisionTime = [] adt = [] sim = Simulation(N, NN, MCS, plotting) sim.run() #for j in range(sim.time): #decisionTime[j] = (sim.dT[j]) decisionTime.append(sim.dT) adt.append(sim.adT) lst = [] for i in decisionTime: for j in i: lst.append(j) lst2 = [] for i in adt: for j in i: lst2.append(j) dt = np.asarray(lst).ravel() adt = np.asarray(lst2).ravel() return dt, adt
def decisionProbas(): cB = 0 switch_probas = [2e-4, 2e-3, 2e-2, 2e-1] for i in switch_probas: sim = Simulation(500, 10000, 2000000, cB=cB, clusterd=True, random=False, plotting=False, switch_proba=i) sim.run() adt = sim.adT adt = np.asarray(adt) plt.loglog(range(len(adt)), 3 / adt, '+', label='p: %g ' % (i)) plt.xlabel('$\\tau$') plt.ylabel('$P(\\tau)$') plt.title('Decision times for different noises p') plt.legend() plt.show()
def probas(N, NN, MCS, switch_proba): cB = 0 sim = Simulation(N, NN, MCS, cB=cB, clusterd=True, random=False, plotting=False, switch_proba=switch_proba) A, B, C, M = sim.run() plt.figure() plt.title('Magnetization with a noise p=%g' % (switch_proba)) plt.xlabel('Monte Carlo Cycles') plt.ylabel('Magnetization m') plt.plot(range(len(M)), M) plt.ylim([-1.05, 1.05]) plt.ticklabel_format(axis='x', style='sci', scilimits=[0, 0]) plt.show()
def partABC(N, NN, MCS, plotting=True): sim = Simulation(N, NN, MCS, plotting=plotting) A, B, C, M = sim.run() M = np.asarray(M) plt.figure() plt.plot(range(len(M)), M) plt.xlabel('Monte Carlo Cycles') plt.ylabel('Magnetization m') plt.title('The magnetization of Monte Carlo cycles') plt.ylim([-1.05, 1.05]) plt.ticklabel_format(axis='x', style='sci', scilimits=[0, 0]) plt.show() dtlen = int(len(M) / 2) dts = np.linspace(1, dtlen, dtlen) g = G(dts, M) plt.figure() plt.plot(dts, g) plt.title('Auto correlation') plt.xlabel('$\Delta t$') plt.ylabel('$G(\Delta t)$') plt.ticklabel_format(axis='x', style='sci', scilimits=[0, 0]) plt.show()
def clustered(cB, N, NN, MCS, random=False, plotting=False): sim = Simulation(N, NN, MCS, cB, clusterd=True, random=random, plotting=plotting) A, B, C, M = sim.run() plt.figure() plt.plot(range(len(M)), M) plt.xlabel('Monte Carlo Cycles') plt.ylabel('Magnetization m') plt.ylim([-1.05, 1.05]) plt.ticklabel_format(axis='x', style='sci', scilimits=[0, 0]) plt.show() dt = sim.dT dt = np.asarray(dt) adt = sim.adT adt = np.asarray(adt) return dt, adt