Skip to content

Commit

Permalink
part gen denso act
Browse files Browse the repository at this point in the history
  • Loading branch information
g7fernandes committed Nov 5, 2019
1 parent 131b1ff commit b3ccca1
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 14 deletions.
2 changes: 1 addition & 1 deletion pack.sh
Original file line number Diff line number Diff line change
@@ -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."
Expand Down
44 changes: 31 additions & 13 deletions part_gen_denso.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -133,14 +140,24 @@ 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]))

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)):
Expand All @@ -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()
Expand Down
29 changes: 29 additions & 0 deletions visualizar.py
Original file line number Diff line number Diff line change
@@ -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()



0 comments on commit b3ccca1

Please sign in to comment.