-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpart_gen_pequeno.py
111 lines (76 loc) · 2.08 KB
/
part_gen_pequeno.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# #!/usr/bin/env python3
# # -*- coding: utf-8 -*-
# """
# Created on Sun Jan 27 22:47:50 2019
# Este programa é para colocar as partículas em seus lugares iniciais
# @author: gabriel
# """
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sun Jan 27 22:47:50 2019
Este programa é para colocar as partículas em seus lugares iniciais
@author: gabriel
"""
import numpy as np
import matplotlib.pyplot as plt
from random import randint
ff = 1 # formato da região ff = x/y
Lx = 200
arquivo2 = 'parp.csv'
arquivo1 = 'molp.csv'
ratio = 0.5
N1 = 1000
N2 = 30
L1 = Lx
L2 = Lx/ff
spac = 0.999*((L1*L2)/(N1))**0.5
d1 = int(L1/spac)
d2 = int(L2/spac)
N1 = d1*d2
sx = L1*.99/(d1+1)
sy = L2*.99*ratio/(d2+1)
# Posição das partículas
p1 = np.zeros([N1,2])
#posição de referência
refe = np.array([0.01,0.01])
print("d1*spac = {}, L1 = {}, d2*spac = {}, L2 = {}\n".format(d1*sx+refe[0],L1, d2*sy+refe[1], L2))
print("N1 = {}, spac = {}, {}\n".format(N1,sx,sy))
cont = 0
for i in range(d1):
for j in range(d2):
p1[cont,:] = [i*sx+refe[0],j*sy+refe[1]]
cont = cont+1
np.random.shuffle(p1)
with open(arquivo1,'w') as file:
for i in range(N1):
file.write('{},{}\n'.format(p1[i,0],p1[i,1]))
plt.scatter(p1[:,0],p1[:,1], label='pequeno1')
L1 = Lx
L2 = Lx/ff
spac = 0.99*((L1*L2)/(N2))**0.5
d1 = int(L1/spac)
d2 = int(L2/(spac))
sx = L1*.99/(d1+1)
sy = L2*.99*(1-ratio)/(d2+1)
N2 = d1*d2
# Posição das partículas
p1 = np.zeros([N2,2])
#posição de referência
refe = np.array([0.01+sx/2, L2 + 0.01+sy/2])
print("d1*spac = {}, L1 = {}, d2*spac = {}, L2 = {}\n".format(d1*sx+refe[0],L1, d2*sy-refe[1], L2))
print("N2 = {}, spac = {} {}\n".format(N2,sx,sy))
cont = 0
for i in range(d1):
for j in range(d2,0,-1):
p1[cont,:] = [i*sx+refe[0],-j*sy+refe[1]]
cont = cont+1
np.random.shuffle(p1)
with open(arquivo2,'w') as file:
for i in range(N2):
file.write('{},{}\n'.format(p1[i,0],p1[i,1]))
Ntot = N1 + N2
print('Ntot = {}'.format(Ntot))
plt.scatter(p1[:,0],p1[:,1], label='pequeno2')
plt.legend()
plt.show()