22 """Generates discretization of circle so that area of all nodes are same"""
25 sim_particle_r = radius
31 sim_particles_area = []
34 sim_num_theta = num_theta
35 sim_theta_interval = 2. * np.pi / (float(sim_num_theta))
39 for i
in xrange(num_r_points+1):
41 x = [radius - i * radius / (float(num_r_points)), 0.]
43 sim_particles.append(x)
46 if i < num_r_points - 1:
47 x_next = [radius - (i+1.) * radius / (float(num_r_points)), 0.]
51 x_prev = [radius - (i-1.) * radius / (float(num_r_points)), 0.]
56 area_new = sim_theta_interval * (1. - (x[0] + x_next[0]) * (x[0] + x_next[0]) * 0.25)
57 elif i == num_r_points:
58 area_new = np.pi * ((x_prev[0] + x[0]) * (x_prev[0] + x[0]) * 0.25)
60 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)
62 sim_particles_area.append(area_new)
66 sim_particles_new = []
67 sim_particles_area_new = []
68 for theta
in xrange(sim_num_theta):
69 angle = theta * sim_theta_interval
73 a = [np.cos(angle), -np.sin(angle)]
75 a = [np.sin(angle), np.cos(angle)]
78 for i
in xrange(len(sim_particles)):
80 x_old = [sim_particles[i][0], sim_particles[i][1]]
81 area = sim_particles_area[i]
83 x_new =
mult(matrix, x_old)
86 if i == len(sim_particles) - 1
and theta > 0:
89 if continue_i ==
True:
90 sim_particles_new.append(x_new)
91 sim_particles_area_new.append(area)
95 inpf = open(
'circle_mesh.csv',
'w')
98 inpf.write(
"id, x, y, volume\n")
100 for i
in xrange(len(sim_particles_new)):
101 inpf.write(
"%d, %Lf, %Lf,%Lf\n" % (i, sim_particles_new[i][0], sim_particles_new[i][1], sim_particles_area_new[i]))