5def print_bool(arg, prefix = ""):
14def print_dbl(arg, prefix = ""):
16 str = prefix +
"%4.6e\n" % (arg)
19def print_int(arg, prefix = ""):
20 str = prefix +
"%d\n" % (arg)
23def print_dbl_list(arg, prefix = ""):
27 str +=
"%4.6e" % (arg[i])
35def print_int_list(arg, prefix = ""):
39 str +=
"%d" % (arg[i])
47def does_intersect(p, r, R, particles, padding):
51 pq = np.array([p[i] - q[i]
for i
in range(3)])
52 if np.linalg.norm(pq) <= r + R + padding:
59 return 3. * K * (1. - 2. * nu)
62 return E / (2. * (1. + nu))
66 return 2. * k1 * k2 / (k1 + k2)
70 """Generate particle location data"""
73 sim_particles.append([0., R1, R1, 0., R1, 0.])
74 sim_particles.append([1., R1, 2. * R1 + R2 + offset, 0., R2, np.pi*0.5])
76 inpf = open(inp_dir +
'particle_locations_' + str(pp_tag) +
'.csv',
'w')
77 inpf.write(
"i, x, y, z, r, o\n")
78 for p
in sim_particles:
79 inpf.write(
"%d, %Lf, %Lf, %Lf, %Lf, %Lf\n" % (int(p[0]), p[1], p[2], p[3], p[4], p[5]))
86 sim_inp_dir = str(inp_dir)
100 geof = open(sim_inp_dir + filename +
'_' + str(pp_tag) +
'.geo',
'w')
101 geof.write(
"cl__1 = 1;\n")
102 geof.write(
"Mesh.MshFileVersion = 2.2;\n")
107 geof.write(
"Point(1) = {%4.6e, %4.6e, %4.6e, %4.6e};\n" % (sim_Cx, sim_Cy, sim_Cz, sim_h));
108 geof.write(
"Point(2) = {%4.6e, %4.6e, %4.6e, %4.6e};\n" % (sim_Cx + sim_radius, sim_Cy, sim_Cz, sim_h))
109 geof.write(
"Point(3) = {%4.6e, %4.6e, %4.6e, %4.6e};\n" % (sim_Cx - sim_radius, sim_Cy, sim_Cz, sim_h))
110 geof.write(
"Point(4) = {%4.6e, %4.6e, %4.6e, %4.6e};\n" % (sim_Cx, sim_Cy + sim_radius, sim_Cz, sim_h))
111 geof.write(
"Point(5) = {%4.6e, %4.6e, %4.6e, %4.6e};\n" % (sim_Cx, sim_Cy - sim_radius, sim_Cz, sim_h))
116 geof.write(
"Circle(1) = {2, 1, 4};\n")
117 geof.write(
"Circle(2) = {4, 1, 3};\n")
118 geof.write(
"Circle(3) = {3, 1, 5};\n")
119 geof.write(
"Circle(4) = {5, 1, 2};\n")
124 geof.write(
"Line Loop(1) = {2, 3, 4, 1};\n")
129 geof.write(
"Plane Surface(1) = {1};\n")
138 geof.write(
"Point{1} In Surface {1};")
146 """Generates input file for two-particle test"""
148 sim_inp_dir = str(inp_dir)
151 center = [0., 0., 0.]
158 horizon = 3. * mesh_size
159 particle_dist = 0.001
167 dt_out_n = num_steps / num_outputs
174 E1 =
get_E(K1, poisson1)
175 G1 =
get_G(E1, poisson1)
181 E2 =
get_E(K2, poisson2)
182 G2 =
get_G(E2, poisson2)
188 R_contact_factor = 0.95
195 Kn_11 = 18. *
get_eff_k(K1, K1) / (np.pi * np.power(horizon, 5))
196 Kn_22 = 18. *
get_eff_k(K2, K2) / (np.pi * np.power(horizon, 5))
197 Kn_12 = 18. *
get_eff_k(K1, K2) / (np.pi * np.power(horizon, 5))
201 damping_active =
True
202 friction_active =
False
206 gravity_active =
True
207 gravity = [0., -10., 0.]
210 free_fall_dist = particle_dist - horizon
211 free_fall_vel = [0., 0., 0.]
212 free_fall_vel[1] = -np.sqrt(2. * np.abs(gravity[1]) * free_fall_dist)
220 inpf = open(sim_inp_dir +
'input_' + str(pp_tag) +
'.yaml',
'w')
221 inpf.write(
"Model:\n")
222 inpf.write(
" Dimension: 2\n")
223 inpf.write(
" Discretization_Type:\n")
224 inpf.write(
" Spatial: finite_difference\n")
225 inpf.write(
" Time: central_difference\n")
226 inpf.write(
" Final_Time: %4.6e\n" % (final_time))
227 inpf.write(
" Time_Steps: %d\n" % (num_steps))
229 inpf.write(
"Policy:\n")
230 inpf.write(
" Enable_PostProcessing: true\n")
235 inpf.write(
"Container:\n")
236 inpf.write(
" Geometry:\n")
237 inpf.write(
" Type: rectangle\n")
238 contain_params = [0., 0., 0., 2.*R1, 2.*R1 + 2.*R2 + particle_dist, 0.]
240 contain_params[3] = 2.*R2
246 inpf.write(
"Zone:\n")
247 inpf.write(
" Zones: 2\n")
250 inpf.write(
" Zone_1:\n")
251 inpf.write(
" Is_Wall: false\n")
254 inpf.write(
" Zone_2:\n")
255 inpf.write(
" Is_Wall: false\n")
260 inpf.write(
"Particle:\n")
261 inpf.write(
" Test_Name: two_particle\n")
262 inpf.write(
" Zone_1:\n")
263 inpf.write(
" Type: circle\n")
264 p1_geom = [R1, center[0], center[1], center[2]]
266 inpf.write(
" Zone_2:\n")
267 inpf.write(
" Type: circle\n")
268 p2_geom = [R2, center[0], center[1], center[2]]
274 inpf.write(
"Particle_Generation:\n")
275 inpf.write(
" From_File: particle_locations_" + str(pp_tag) +
".csv\n")
276 inpf.write(
" File_Data_Type: loc_rad_orient\n")
281 inpf.write(
"Mesh:\n")
284 inpf.write(
" Zone_1:\n")
285 inpf.write(
" File: mesh_cir_1_" + str(pp_tag) +
".msh \n")
288 inpf.write(
" Zone_2:\n")
289 inpf.write(
" File: mesh_cir_2_" + str(pp_tag) +
".msh \n")
294 inpf.write(
"Contact:\n")
297 inpf.write(
" Zone_11:\n")
298 inpf.write(
" Contact_Radius_Factor: %4.6e\n" % (R_contact_factor))
300 if damping_active ==
False:
301 inpf.write(
" Damping_On: false\n")
302 if friction_active ==
False:
303 inpf.write(
" Friction_On: false\n")
305 inpf.write(
" Kn: %4.6e\n" % (Kn_11))
306 inpf.write(
" Epsilon: %4.6e\n" % (beta_n_eps))
307 inpf.write(
" Friction_Coeff: %4.6e\n" % (friction_coeff))
308 inpf.write(
" Kn_Factor: 1.0\n")
309 inpf.write(
" Beta_n_Factor: %4.6e\n" % (beta_n_factor))
312 inpf.write(
" Zone_12:\n")
313 inpf.write(
" Contact_Radius_Factor: %4.6e\n" % (R_contact_factor))
315 if damping_active ==
False:
316 inpf.write(
" Damping_On: false\n")
317 if friction_active ==
False:
318 inpf.write(
" Friction_On: false\n")
320 inpf.write(
" Kn: %4.6e\n" % (Kn_12))
321 inpf.write(
" Epsilon: %4.6e\n" % (beta_n_eps))
322 inpf.write(
" Friction_Coeff: %4.6e\n" % (friction_coeff))
323 inpf.write(
" Kn_Factor: 1.0\n")
324 inpf.write(
" Beta_n_Factor: %4.6e\n" % (beta_n_factor))
327 inpf.write(
" Zone_22:\n")
328 inpf.write(
" Contact_Radius_Factor: %4.6e\n" % (R_contact_factor))
330 if damping_active ==
False:
331 inpf.write(
" Damping_On: false\n")
332 if friction_active ==
False:
333 inpf.write(
" Friction_On: false\n")
335 inpf.write(
" Kn: %4.6e\n" % (Kn_22))
336 inpf.write(
" Epsilon: %4.6e\n" % (beta_n_eps))
337 inpf.write(
" Friction_Coeff: %4.6e\n" % (friction_coeff))
338 inpf.write(
" Kn_Factor: 1.0\n")
339 inpf.write(
" Beta_n_Factor: %4.6e\n" % (beta_n_factor))
344 inpf.write(
"Neighbor:\n")
345 inpf.write(
" Update_Criteria: simple_all\n")
346 inpf.write(
" Search_Factor: 5.0\n")
351 inpf.write(
"Material:\n")
354 inpf.write(
" Zone_1:\n")
355 inpf.write(
" Type: PDState\n")
356 inpf.write(
" Horizon: %4.6e\n" % (horizon))
357 inpf.write(
" Density: %4.6e\n" % (rho1))
358 inpf.write(
" Compute_From_Classical: true\n")
359 inpf.write(
" K: %4.6e\n" % (K1))
360 inpf.write(
" G: %4.6e\n" % (G1))
361 inpf.write(
" Gc: %4.6e\n" % (Gc1))
362 inpf.write(
" Influence_Function:\n")
363 inpf.write(
" Type: 1\n")
366 inpf.write(
" Zone_2:\n")
367 inpf.write(
" Type: PDState\n")
368 inpf.write(
" Horizon: %4.6e\n" % (horizon))
369 inpf.write(
" Density: %4.6e\n" % (rho2))
370 inpf.write(
" Compute_From_Classical: true\n")
371 inpf.write(
" K: %4.6e\n" % (K2))
372 inpf.write(
" G: %4.6e\n" % (G2))
373 inpf.write(
" Gc: %4.6e\n" % (Gc2))
374 inpf.write(
" Influence_Function:\n")
375 inpf.write(
" Type: 1\n")
380 if gravity_active ==
True:
381 inpf.write(
"Force_BC:\n")
388 inpf.write(
" Constant_Velocity:\n")
390 inpf.write(
" Particle_List: [1]\n")
395 inpf.write(
"Displacement_BC:\n")
396 inpf.write(
" Sets: 1\n")
398 inpf.write(
" Set_1:\n")
399 inpf.write(
" Particle_List: [0]\n")
400 inpf.write(
" Direction: [1,2]\n")
401 inpf.write(
" Time_Function:\n")
402 inpf.write(
" Type: constant\n")
403 inpf.write(
" Parameters:\n")
404 inpf.write(
" - 0.0\n")
405 inpf.write(
" Spatial_Function:\n")
406 inpf.write(
" Type: constant\n")
407 inpf.write(
" Zero_Displacement: true\n")
412 inpf.write(
"Output:\n")
413 inpf.write(
" Path: ../out/\n")
414 inpf.write(
" Tags:\n")
415 inpf.write(
" - Displacement\n")
416 inpf.write(
" - Velocity\n")
417 inpf.write(
" - Force\n")
418 inpf.write(
" - Force_Density\n")
419 inpf.write(
" - Damage_Z\n")
420 inpf.write(
" - Damage\n")
421 inpf.write(
" - Nodal_Volume\n")
422 inpf.write(
" - Zone_ID\n")
423 inpf.write(
" - Particle_ID\n")
424 inpf.write(
" - Fixity\n")
425 inpf.write(
" - Force_Fixity\n")
426 inpf.write(
" - Contact_Nodes\n")
427 inpf.write(
" - No_Fail_Node\n")
428 inpf.write(
" - Boundary_Node_Flag\n")
429 inpf.write(
" - Theta\n")
430 inpf.write(
" Output_Interval: %d\n" % (dt_out_n))
431 inpf.write(
" Compress_Type: zlib\n")
432 inpf.write(
" Perform_FE_Out: false\n")
434 inpf.write(
" Perform_Out: true\n")
436 inpf.write(
" Perform_Out: false\n")
437 inpf.write(
" Test_Output_Interval: %d\n" % (dt_out_n))
439 inpf.write(
" Debug: 1\n")
440 inpf.write(
" Tag_PP: %d\n" %(int(pp_tag)))
444 inpf.write(
" Partitions: 1\n")
463 pp_tag = int(sys.argv[1])
generate_particle_gmsh_input(inp_dir, filename, center, radius, mesh_size, pp_tag)
create_input_file(inp_dir, pp_tag)
particle_locations(inp_dir, pp_tag, center, padding, max_y, mesh_size, R1, R2, id_choices1, id_choices2, Nmax, R_in, bar_rect, z_coord, add_orient=True)
print_dbl_list(arg, prefix="")