22 """Generates discretization of circle so that area of all nodes are same"""
25 sim_particle_r = radius
31 sim_particles_area = []
35 sim_theta_interval = 2. * np.pi / (float(sim_num_theta))
40 a = [np.cos(angle), -np.sin(angle)]
42 a = [np.sin(angle), np.cos(angle)]
48 sim_particles.append(p)
49 area = sim_theta_interval * (1. - (1. + x_one) * (1. + x_one) * 0.25)
50 sim_particles_area.append(area)
56 sim_particles.append(p)
57 sim_particles_area.append(area)
65 while continue_add ==
True:
67 val = (x_pre + x_pre_pre) * (x_pre + x_pre_pre) - 4. * area / (sim_theta_interval)
72 if continue_add ==
True:
78 print(
'counter %d\n' % (counter))
81 x_new = np.sqrt(val) - x_pre
89 sim_particles.append(p)
90 sim_particles_area.append(area)
92 area_new = sim_theta_interval * ((x_pre + x_pre_pre) * (x_pre + x_pre_pre) * 0.25 - (x_pre + x_new) * (x_pre + x_new) * 0.25)
108 sim_particles_new = []
109 sim_particles_area_new = []
110 for i
in xrange(len(sim_particles)):
117 if continue_i ==
True:
119 x = [sim_particles[i][0], sim_particles[i][1]]
120 sim_particles_new.append(x)
121 sim_particles_area_new.append(sim_particles_area[i])
124 sim_particles_nn = []
125 sim_particles_area_nn = []
126 for i
in xrange(len(sim_particles_new)):
128 x = [sim_particles_new[i][0], sim_particles_new[i][1]]
129 sim_particles_nn.append(x)
132 if i < len(sim_particles_new) - 2:
133 x_next = [sim_particles_new[i+1][0], sim_particles_new[i+1][1]]
137 x_prev = [sim_particles_new[i-1][0], sim_particles_new[i-1][1]]
142 area_new = sim_theta_interval * (1. * 1. - (1. + x[0]) * (1. + x[0]) * 0.25)
143 elif i == len(sim_particles) - 1:
144 area_new = sim_theta_interval * ((x_prev[0] + x[0]) * (x_prev[0] + x[0]) * 0.25)
146 area_new = sim_theta_interval * ((x_prev[0] + x[0]) * (x_prev[0] + x[0]) * 0.25 - (x_next[0] + x[0]) * (x_next[0] + x[0]) * 0.25)
148 sim_particles_area_nn.append(area_new)
151 sim_particles_new_new = []
152 sim_particles_area_new_new = []
153 for theta
in xrange(sim_num_theta):
154 angle = theta * sim_theta_interval
158 a = [np.cos(angle), -np.sin(angle)]
160 a = [np.sin(angle), np.cos(angle)]
163 for i
in xrange(len(sim_particles_nn)):
164 x_old = [radius * sim_particles_nn[i][0], radius * sim_particles_nn[i][1]]
165 area = radius * radius * sim_particles_area_nn[i]
167 x_new =
mult(matrix, x_old)
169 sim_particles_new_new.append(x_new)
170 sim_particles_area_new_new.append(area)
178 inpf = open(
'circle_mesh.csv',
'w')
183 for i
in xrange(len(sim_particles_new_new)):
184 inpf.write(
"%d, %Lf, %Lf, %Lf, %Lf\n" % (i, sim_particles_new_new[i][0], sim_particles_new_new[i][1], 0., sim_particles_area_new_new[i]))