def scaling_above(): critical = [] for i in range(2, 260): model = RelaxModel(0.5, i, i * i + 4000) model.start() critical.append(model.critical_z()) print(model.critical_z())
def write_in_ava_size(): avalanche_size = [] for i in range(len(length)): model = RelaxModel(0.5, length[i], time) model.start() avalanche_size.append(model.ava_size_list.copy()) with open('avalanche_size.txt', 'wb') as fp: pickle.dump(avalanche_size, fp)
def ave_tc(self): for i in range(len(self.lengths_of_system)): ave_tc = 0.0 model = RelaxModel(0.5, self.lengths_of_system[i], self.times) model.start() model.cross_over_time() for j in range(len(model.ave_slop)): self.ave_tc = self.ave_tc + model.ave_slop[i]*(i+1) self.ave_tc_list.append(ave_tc)
def ave_height_f(): for i in range(len(length)): model = RelaxModel(0.5,length[i],times) model.start() useful_height = model.heights[cross_over_time[i]+1:] ave = sum(useful_height)/len(useful_height) ave_height.append(ave) print('done 1') return ave_height
def sigma_f(): for i in range(len(length)): model = RelaxModel(0.5, length[i], times) model.start() useful_height = model.heights[cross_over_time[i] + 1:] ave = sum(useful_height) / len(useful_height) hh = [x * x for x in useful_height] sigma = (sum(hh) / len(useful_height) - ave**2)**(0.5) sigma_h.append((sigma)) print(sigma_h) return sigma_h
def ave_tc(number_of_piles): lengths_of_system = [4, 8, 16, 32, 64, 128, 256] all_tc_list = [] times = 100000 for i in range(len(lengths_of_system)): ave_tc_list = [] for j in range(number_of_piles): model = RelaxModel(0.5, lengths_of_system[i], times) model.start() model.cross_over_time() ave_tc_list.append(model.t_c) all_tc_list.append(sum(ave_tc_list) / len(ave_tc_list)) return all_tc_list
def h_tilde(M): length = [4, 8] times = 100000 h_tilde = [] for i in range(len(length)): h_data_base = [0] * times for j in range(M): model = RelaxModel(0.5, length[i], times) model.start() h_data_base = list(map(add, h_data_base, model.heights)) h_data_base = [x / M for x in h_data_base] h_data_base = [round(i, 3) for i in h_data_base] h_tilde.append(h_data_base) return h_tilde
def plot_ave_slop(length,times): data_base = [] fig = plt.figure() ax = fig.add_subplot(1, 1, 1) for i in range(len(length)): model = RelaxModel(0.5, length[i], times) model.start() data_base.append(model.ave_slop) for i in range(len(data_base)): ax.plot(range(times), data_base[i], label='L=%a' % (length[i]), linewidth=0.5) ax.set_xscale('log') plt.legend() plt.xlabel('Grains driven into system') plt.ylabel('Height of system') plt.show()
def height_prob_f(): for i in range(len(length)): media = [] model = RelaxModel(0.5, length[i], times) model.start() useful_height = model.heights[cross_over_time[i]+1:] maximum = max(useful_height)+1 minimum = min(useful_height) for j in range(minimum,maximum): P = useful_height.count(j)/len(useful_height) media.append(P) Prob.append(media.copy()) maxmin.append(range(minimum, maximum)) print('done all') return Prob,maxmin
def plot_figure_data(self): for i in range(len(self.lengths_of_system)): model = RelaxModel(0.5,self.lengths_of_system[i],self.times) model.start() self.data_base_height.append(model.heights)
from Oslo_model import RelaxModel ''' # Question 1 ------------------------------------------------------------------------- ''' model_16 = RelaxModel(0.5, 16, 100000) model_16.start() print(sum(model_16.heights) / len(model_16.heights)) model_32 = RelaxModel(0.5, 32, 100000) model_32.start() print(sum(model_32.heights) / len(model_32.heights))