diff --git a/pack.sh b/pack.sh index f266802..00ee4bc 100755 --- a/pack.sh +++ b/pack.sh @@ -1,5 +1,5 @@ #!/bin/bash -read -e -p "Enter particle generator file: " VAR1 +read -e -p "Enter particle generator file or position files: " VAR1 if [ "$VAR1" = "" ]; then echo "No particle generator given." diff --git a/part_gen_denso.py b/part_gen_denso.py index 6852eed..c646a89 100644 --- a/part_gen_denso.py +++ b/part_gen_denso.py @@ -37,16 +37,17 @@ def density_map(x,dimx,dimy,tam): tol = 1 -ff = 1 # formato da região ff = x/y -Lx = 100 +ff = 1/8 # formato da região ff*x = y +Lx = 10000 arquivo1 = 'molp.csv' arquivo2 = 'parp.csv' -N1 = 1000 -N2 = 10 + +N2 = 100 L1 = Lx -L2 = Lx/ff +L2 = Lx*ff + print("Formato da região: {} x {}".format(L1,L2)) spac = 2**(1/6) N1 = int((int((tol*L1-spac)/spac)+ (int((tol*L1-spac)/spac)-2))*int((tol*L2-spac)/(spac**2*(3/4)))/2) @@ -87,13 +88,19 @@ def density_map(x,dimx,dimy,tam): r2 = float(input(">> Raio da partícula 2: ")) if N2 > 0: - d1 = int(np.sqrt(N2*(L1*tol-2*r2)/(L2*tol-2*r2))) - d2 = int(N2/d1) - sx = (L1*tol-2*r2)/d1 - sy = (L2*tol-2*r2)/d2 - - N2 = d1*d2 - # Posição das partículas + N2obj = N2 + N2 = N2 - 1 + i = 0 + while N2 < N2obj: + N2 = N2obj + i + i = i + 1 + d1 = int(np.sqrt(N2*(L1*tol-2*r2)/(L2*tol-2*r2))) + d2 = int(N2/d1) + sx = (L1*tol-2*r2)/d1 + sy = (L2*tol-2*r2)/d2 + N2 = d1*d2 + + # Posição das partículas p2 = np.zeros([N2,2]) #posição de referência @@ -133,6 +140,11 @@ def density_map(x,dimx,dimy,tam): np.random.shuffle(p1) +aux = input("Numero maximo de partículas N1 (max atual: {}): ".format(N1)) +if aux != '': + p1 = p1[0:N1,:] + N1 = len(p1) + with open(arquivo1,'w') as file: for i in range(len(p1)): file.write('{},{}\n'.format(p1[i,0],p1[i,1])) @@ -140,7 +152,12 @@ def density_map(x,dimx,dimy,tam): ax.scatter(p1[:,0],p1[:,1], s=(np.pi*1**2),label='arquivo1') if N2 > 0: - np.random.shuffle(p2) + np.random.shuffle(p2) + + aux = input("Numero maximo de partículas N2 (max atual: {}): ".format(N2)) + if aux != '': + p2 = p1[0:N2,:] + N2 = len(p2) with open(arquivo2,'w') as file: for i in range(len(p2)): @@ -155,6 +172,7 @@ def density_map(x,dimx,dimy,tam): print('N1 = {}\n'.format(len(p1))) print("Arquivos {} e {}\n".format(arquivo1,arquivo2)) + ax.set_aspect(aspect=1) ax.legend() plt.show() diff --git a/visualizar.py b/visualizar.py new file mode 100644 index 0000000..6a5d83e --- /dev/null +++ b/visualizar.py @@ -0,0 +1,29 @@ +import numpy as np +import os +import matplotlib.pyplot as plt + +fig = plt.figure() +ax = fig.add_subplot(111) + + +lab = 'arq' +aux = 0 +outro = 'a' +while outro != 'n': + file_name = input('Entre o arquivo:\n') + while not os.path.isfile(file_name): + file_name = input('Entre o arquivo:\n') + + data = np.genfromtxt(file_name,delimiter=',') + ax.scatter(data[:,0],data[:,1], label=lab+str(aux)) + + outro = input('adicionar outro arquivo? s/n ') + aux += 1 + +ax.set_aspect(aspect=1) + +plt.legend() +plt.show() + + +