4from pathlib
import Path
14 Creates .csv file containing the center, radius, orientation, and zone id of each particle in two-particle setup
19 Filename of .csv file to be created
21 List containing radius of a particle
23 List containing the centers of a particle
25 Postfix .geo file with this tag
27 pp_tag_str =
'_{}'.format(str(pp_tag))
if pp_tag
is not None else ''
28 inpf = open(filename + pp_tag_str +
'.csv',
'w')
29 inpf.write(
'i, x, y, z, r, o\n')
30 for i
in range(len(radius)):
31 inpf.write(
'%d, ' % i)
33 inpf.write(
', %Lf' % radius[i])
34 o = 0.
if i == 0
else np.pi * 0.5
35 inpf.write(
', %Lf\n' % o)
38if __name__ ==
"__main__":
40 parser = argparse.ArgumentParser(description=
'Setup and run PeriDEM simulation')
41 parser.add_argument(
'--peridem_path',
44 help=
"Path to PeriDEM executable")
45 args = parser.parse_args()
46 if args.peridem_path
is None:
47 raise ValueError(
"Invalid path to PeriDEM executable")
48 if Path(args.peridem_path).is_file() ==
False:
49 raise ValueError(
"PeriDEM executable does not exist")
69 wall_rect = [0., 0., 0., 2.*R, horizon, 0.]
75 v0 = [0, -np.sqrt(2. * np.abs(g[1]) * delta), 0.]
106 R_contact_factor = 0.95
109 Kn_11 = 18. *
get_eff_k(K1, K1) / (np.pi * np.power(horizon, 5))
110 Kn_22 = 18. *
get_eff_k(K2, K2) / (np.pi * np.power(horizon, 5))
111 Kn_12 = 18. *
get_eff_k(K1, K2) / (np.pi * np.power(horizon, 5))
116 beta_n_factor = 5000.
117 damping_active =
True
121 friction_active =
False
125 centers.append([R, wall_rect[4] + (d - delta) + R, 0.])
126 print(
'top height = %Lf' % (wall_rect[4] + d + 2*R))
134 inpf = open(fpath +
'input.yaml',
'w')
137 inpf.write(
"Model:\n")
138 inpf.write(
" Dimension: 2\n")
139 inpf.write(
" Discretization_Type:\n")
140 inpf.write(
" Spatial: finite_difference\n")
141 inpf.write(
" Time: central_difference\n")
142 inpf.write(
" Final_Time: %4.6e\n" % (T))
143 inpf.write(
" Time_Steps: %d\n" % (N_steps))
146 inpf.write(
"Policy:\n")
147 inpf.write(
" Enable_PostProcessing: true\n")
153 inpf.write(
"Container:\n")
154 inpf.write(
" Geometry:\n")
155 inpf.write(
" Type: rectangle\n")
160 contain_params = [0., 0., 0., 2.*R, 4.*R, 0.]
165 inpf.write(
"Zone:\n")
166 inpf.write(
" Zones: 2\n")
169 inpf.write(
" Zone_1:\n")
171 inpf.write(
" Is_Wall: false\n")
174 inpf.write(
" Zone_2:\n")
175 inpf.write(
" Is_Wall: true\n")
176 inpf.write(
" Type: rectangle\n")
182 inpf.write(
"Particle:\n")
184 inpf.write(
" Zone_1:\n")
186 inpf.write(
" Type: circle\n")
190 p_geom = [R, center[0], center[1], center[2]]
194 inpf.write(
"Wall:\n")
195 inpf.write(
" Zone_2:\n")
196 inpf.write(
" Type: flexible\n")
197 inpf.write(
" All_Dofs_Constrained: true\n")
198 inpf.write(
" Mesh: true\n")
201 inpf.write(
"Particle_Generation:\n")
202 inpf.write(
" From_File: particle_locations.csv\n")
203 inpf.write(
" File_Data_Type: loc_rad_orient\n")
206 inpf.write(
"Mesh:\n")
209 inpf.write(
" Zone_1:\n")
210 inpf.write(
" File: p.msh \n")
213 inpf.write(
" Zone_2:\n")
214 inpf.write(
" File: w.msh \n")
218 inpf.write(
"Contact:\n")
222 inpf.write(
" Zone_11:\n")
223 inpf.write(
" Contact_Radius_Factor: %4.6e\n" % (R_contact_factor))
225 if damping_active ==
False:
226 inpf.write(
" Damping_On: false\n")
227 if friction_active ==
False:
228 inpf.write(
" Friction_On: false\n")
230 inpf.write(
" Kn: %4.6e\n" % (Kn_11))
231 inpf.write(
" Epsilon: %4.6e\n" % (beta_n_eps))
232 inpf.write(
" Friction_Coeff: %4.6e\n" % (friction_coeff))
233 inpf.write(
" Kn_Factor: 1.0\n")
234 inpf.write(
" Beta_n_Factor: %4.6e\n" % (beta_n_factor))
238 inpf.write(
" Zone_12:\n")
239 inpf.write(
" Contact_Radius_Factor: %4.6e\n" % (R_contact_factor))
241 if damping_active ==
False:
242 inpf.write(
" Damping_On: false\n")
243 if friction_active ==
False:
244 inpf.write(
" Friction_On: false\n")
246 inpf.write(
" Kn: %4.6e\n" % (Kn_12))
247 inpf.write(
" Epsilon: %4.6e\n" % (beta_n_eps))
248 inpf.write(
" Friction_Coeff: %4.6e\n" % (friction_coeff))
249 inpf.write(
" Kn_Factor: 1.0\n")
250 inpf.write(
" Beta_n_Factor: %4.6e\n" % (beta_n_factor))
253 inpf.write(
" Zone_22:\n")
254 inpf.write(
" Contact_Radius_Factor: %4.6e\n" % (R_contact_factor))
256 if damping_active ==
False:
257 inpf.write(
" Damping_On: false\n")
258 if friction_active ==
False:
259 inpf.write(
" Friction_On: false\n")
261 inpf.write(
" Kn: %4.6e\n" % (Kn_22))
262 inpf.write(
" Epsilon: %4.6e\n" % (beta_n_eps))
263 inpf.write(
" Friction_Coeff: %4.6e\n" % (friction_coeff))
264 inpf.write(
" Kn_Factor: 1.0\n")
265 inpf.write(
" Beta_n_Factor: %4.6e\n" % (beta_n_factor))
269 inpf.write(
"Neighbor:\n")
270 inpf.write(
" Update_Criteria: simple_all\n")
271 inpf.write(
" Search_Factor: 5.0\n")
275 inpf.write(
"Material:\n")
278 inpf.write(
" Zone_1:\n")
279 inpf.write(
" Type: PDState\n")
280 inpf.write(
" Horizon: %4.6e\n" % (horizon))
281 inpf.write(
" Density: %4.6e\n" % (rho1))
282 inpf.write(
" Compute_From_Classical: true\n")
283 inpf.write(
" K: %4.6e\n" % (K1))
284 inpf.write(
" G: %4.6e\n" % (G1))
285 inpf.write(
" Gc: %4.6e\n" % (Gc1))
286 inpf.write(
" Influence_Function:\n")
287 inpf.write(
" Type: 1\n")
290 inpf.write(
" Zone_2:\n")
291 inpf.write(
" Type: PDState\n")
292 inpf.write(
" Horizon: %4.6e\n" % (horizon))
293 inpf.write(
" Density: %4.6e\n" % (rho2))
294 inpf.write(
" Compute_From_Classical: true\n")
295 inpf.write(
" K: %4.6e\n" % (K2))
296 inpf.write(
" G: %4.6e\n" % (G2))
297 inpf.write(
" Gc: %4.6e\n" % (Gc2))
298 inpf.write(
" Influence_Function:\n")
299 inpf.write(
" Type: 1\n")
303 inpf.write(
"Force_BC:\n")
308 inpf.write(
" Constant_Velocity:\n")
310 inpf.write(
" Particle_List: [0]\n")
313 inpf.write(
"Displacement_BC:\n")
314 inpf.write(
" Sets: 2\n")
315 inpf.write(
" Set_1:\n")
316 inpf.write(
" Wall_List: [0]\n")
317 inpf.write(
" Direction: [1,2]\n")
318 inpf.write(
" Time_Function:\n")
319 inpf.write(
" Type: constant\n")
320 inpf.write(
" Parameters:\n")
321 inpf.write(
" - 0.0\n")
322 inpf.write(
" Spatial_Function:\n")
323 inpf.write(
" Type: constant\n")
324 inpf.write(
" Zero_Displacement: true\n")
326 inpf.write(
" Set_2:\n")
327 inpf.write(
" Particle_List: [0]\n")
328 inpf.write(
" Direction: [1]\n")
329 inpf.write(
" Time_Function:\n")
330 inpf.write(
" Type: constant\n")
331 inpf.write(
" Parameters:\n")
332 inpf.write(
" - 0.0\n")
333 inpf.write(
" Spatial_Function:\n")
334 inpf.write(
" Type: constant\n")
338 inpf.write(
"Output:\n")
340 inpf.write(
" Path: ./\n")
341 inpf.write(
" Tags:\n")
343 inpf.write(
" - Displacement\n")
344 inpf.write(
" - Velocity\n")
345 inpf.write(
" - Force\n")
346 inpf.write(
" - Force_Density\n")
347 inpf.write(
" - Damage_Z\n")
348 inpf.write(
" - Damage\n")
349 inpf.write(
" - Nodal_Volume\n")
350 inpf.write(
" - Zone_ID\n")
351 inpf.write(
" - Particle_ID\n")
352 inpf.write(
" - Fixity\n")
353 inpf.write(
" - Force_Fixity\n")
354 inpf.write(
" - Contact_Nodes\n")
355 inpf.write(
" - No_Fail_Node\n")
356 inpf.write(
" - Boundary_Node_Flag\n")
357 inpf.write(
" - Theta\n")
359 inpf.write(
" Output_Interval: %d\n" % (N_out))
360 inpf.write(
" Compress_Type: zlib\n")
361 inpf.write(
" Perform_FE_Out: false\n")
362 inpf.write(
" Perform_Out: true\n")
364 inpf.write(
" Test_Output_Interval: %d\n" % (N_out))
367 inpf.write(
" Debug: 3\n")
369 inpf.write(
" Tag_PP: 0\n")
373 inpf.write(
" Partitions: 1\n")
381 print(
'running gmsh')
382 cmd =
"gmsh p.geo -2 &> /dev/null"
383 process = subprocess.Popen(cmd.split(), stdout=subprocess.PIPE)
384 output, error = process.communicate()
386 cmd =
"gmsh w.geo -2 &> /dev/null"
387 process = subprocess.Popen(cmd.split(), stdout=subprocess.PIPE)
388 output, error = process.communicate()
391 print(
'running peridem')
392 cmd = args.peridem_path +
" -i input.yaml -nThreads 8"
393 process = subprocess.Popen(cmd.split(), stdout=subprocess.PIPE)
394 output, error = process.communicate()
particle_locations(filename, radius, centers, pp_tag=None)
generate_rectangle_gmsh_input(filename, rectangle, mesh_size, pp_tag=None)
print_dbl_list(arg, prefix="")
print_list(arg, fmt='%4.6e', delim=', ')
generate_circle_gmsh_input(filename, center, radius, mesh_size, pp_tag=None)