def onClickCalculate(self): if not self.LOCK_FLAG: self.LOCK_FLAG = True # pObj = self.w.find_all() # print("pObj") # print(pObj) points = [] if self.grey is not None: data = np.asarray(self.grey) # print(len(data)) Coords = poisson(self.x_s, self.y_s, 2, 100, data) else: Coords = poisson(1080, 680, 5, 20) for coord in Coords: points.append((coord[0] + self.RADIUS, coord[1] + self.RADIUS)) vp = Voronoi(points) vp.process() lines = vp.get_res() self.drawLinesOnCanvas(lines)
def sor(n, epsilon, checkerBoard=True): ''' Calls the update method to the model and calls the method to plot and save data for a cut of charged wire algined in z axis. Parameters: ----------- n: Type Integer size of the model epsilon:Type float precision for model to converge ''' model = poisson(n, epsilon) #update the model for the sepcified method. if (checkerBoard): model.generate_SOR_CheckerBoard() else: model.generate_SOR()
def chargedWire(n, method, epsilon, checkerBoard=True): ''' Calls the update method to the model and calls the method to plot and save data for a charged wire aligned in the z axis. Parameters: ----------- n: Type Integer size of the model method: String either jacobi update or gauss-seidel update, if invalid jacobi is used epsilon:Type float precision for model to converge ''' model = poisson(n, epsilon) model.setChargedWire3D() model.setBoundaries3D(model.lattice) #update the model using specified methods if (method == "gauss"): if (checkerBoard): model.gaussSeidel_CheckerBoard() else: model.gaussSeidelUpdate_roll() else: model.jacobiUpdate() #generate the required data files model.generateMagneticData() #plot the potential of cut of charged wire potential = model.getPotential() im = plt.imshow(potential, cmap="magma") plt.colorbar(im) plt.title(f"Potential plot for charged wire size={n}") plt.savefig( f"figures/magneticField/size{n}/potentialChargedWire_{n}_{epsilon}.png" ) plt.show()
def monopole(n, method, epsilon, checkerBoard=True): ''' Calls the update method to the model and calls the method to plot and save data for a monopole charge in 3D. Parameters: ----------- n: Type Integer size of the model method: String either jacobi update or gauss-seidel update, if invalid jacobi is used epsilon:Type float precision for model to converge ''' model = poisson(n, epsilon) model.setPointCharge3D() model.setBoundaries3D(model.lattice) #carry out updates for a point charge in 3D, monopole charge if (method == "gauss"): if (checkerBoard): model.gaussSeidel_CheckerBoard() else: model.gaussSeidelUpdate_roll() else: model.jacobiUpdate() #generate and calculate the required data files model.generateElectricData() #plot the potential of the monopole potential = model.getPotential() im = plt.imshow(potential) plt.colorbar(im) plt.title(f"Potential plot for monopole size={n}") plt.savefig(f"figures/ElectricField/size{n}/monopole_{n}_{epsilon}.png") plt.show()
# Poisson TIPO = "Poisson" pass else: # Binomial Negativa TIPO = "Binomial Negativa" pass if (TIPO == "Poisson"): l = B resultado = 0 esperanza = l varianza = l if (p0m == 'NA'): TIPO = 'Poisson' resultado = poisson(l, k) else: esperanzaGral = l varianzaGral = l if (p0m == 0): TIPO = 'Poisson Zero Truncada' resultado = poissonmod(l, k, 0) esperanza = l / (1 - poisson(l, 0)) segundomomento = varianzaGral + pow(esperanzaGral, 2) segundomomenotrun = segundomomento / (1 - poisson(l, 0)) varianza = segundomomenotrun - pow(esperanza, 2) else: TIPO = 'Poisson Zero Mod' resultado = poissonmod(l, k, p0m) esperanza = ((1 - p0m) / (1 - poisson(l, 0))) * esperanzaGral
def __init__(self, reloj, media_llegada_cliente, id): duracion = Truncate(poisson(media_llegada_cliente)) hora = Truncate((reloj + duracion), 2) nombre = "Llegada Cliente " + str(id) super().__init__(duracion, hora, nombre, id)