def sample(self): def ppf_x(t): return self.x_field * (t - 0.5) def ppf_y(t): return self.y_field * (t - 0.5) x = monte_carlo(ppf_x) y = monte_carlo(ppf_y) return lens_to_hemisphere(x, y)
def sample(self): def ppf_theta(t): return math.acos(1 - t) def ppf_phi(t): return 2 * math.pi * t theta = monte_carlo(ppf_theta) phi = monte_carlo(ppf_phi) return np.array([ math.sin(theta) * math.cos(phi), math.sin(theta) * math.sin(phi), math.cos(theta) ])
def sample(self): def ppf_phi(t): return 2 * math.pi * t def ppf_u(t): #u = cos(theta) return 1 + ( 1 / self.kappa) * math.log(t + (1 - t) * math.exp(-2 * self.kappa)) phi = monte_carlo(ppf_phi) u = monte_carlo(ppf_u) return np.array([ math.sqrt(1 - u**2) * math.cos(phi), math.sqrt(1 - u**2) * math.sin(phi), u ])
def sample(self): def ppf(t): if t < self.R: return 'R' elif t < self.G + self.R: return 'G' else: return 'B' return monte_carlo(ppf)
n_bloc=10 n_ite = 100 scale=2 size = 10 dimension = 2 e_aa = 0 e_ab = 0.21 e_bb = 0 proportion_b = 0.5 Temperature=297 #EN kelvin systeme = mc.system (size,dimension) systeme.set_maille([(0,0),(0.5,0.5)]) systeme.set_link_energy([e_aa,e_ab,e_bb]) systeme.initiate_map () print ("Système crée en ", time()-a, " secondes") fn.monte_carlo(systeme,proportion_b,3,n_bloc,n_ite,scale) print(systeme.get_sum_of_energy()) <<<<<<< HEAD ======= #fn.monte_carlo(systeme,proportion_b,2,n) #fn.monte_carlo(systeme,proportion_b,1,n) fn.monte_carlo(systeme,proportion_b,4,n) print("final energy =" , float(systeme.get_sum_of_energy())) >>>>>>> parent of 64409e6... temps de résidence OK (i guess :p) print ("Fin de la simulation. Elle aura durée ",time()-a, " secondes")