NetDEM v1.0
Loading...
Searching...
No Matches
single_irregular_bp_dem.py

This is an example of how to use the netdem library.

1import netdem
2import math
3
4# simulation settings
6sim.domain_manager.SetBound(-16, -16, -16, 16, 16, 16)
7sim.domain_manager.SetCellSpacing(0.6, 0.6, 0.6)
8
9cnt_model = netdem.LinearSpring(2.0e6, 1.0e6, 0.5, 0.3)
10cnt_model_ptr = sim.scene.InsertContactModel(cnt_model)
11sim.scene.SetNumberOfMaterials(1)
12sim.scene.SetCollisionModel(0, 0, cnt_model_ptr)
13
14# create a particle and two walls
15stl_model = netdem.STLModel()
16stl_model.InitFromSTL("data/particle_template.stl")
17stl_model.Decimate(200)
18stl_model.Standardize()
19stl_model.SetSize(1.0)
20
21bond_model = netdem.ParallelBond(2.0e6, 1.0e6, 1.0e6, 1.0e6, 0.3)
22bond_model.label = "bond_model"
23bond_model_ptr = sim.scene.InsertContactModel(bond_model)
24
25bonded_spheres = netdem.BondedSpheres()
26bonded_spheres.SetBondModel(bond_model_ptr)
27bonded_spheres.InitFromSTL(stl_model, 0.1)
28sim.scene.InsertParticle(bonded_spheres)
29
30plane_1 = netdem.Plane(0, 0, 0.39, 0, 0, -1)
31plane_2 = netdem.Plane(0, 0, -0.44, 0, 0, 1)
32
33plane_1_ptr = sim.scene.InsertShape(plane_1)
34plane_2_ptr = sim.scene.InsertShape(plane_2)
35
36w_1 = netdem.Wall(plane_1_ptr)
37w_2 = netdem.Wall(plane_2_ptr)
38
39sim.scene.InsertWall(w_1)
40sim.scene.InsertWall(w_2)
41
42# gravity
43grav = netdem.Gravity()
44grav.Init(sim)
45sim.modifier_manager.Insert(grav)
46sim.modifier_manager.Enable(grav.label)
47sim.scene.gravity_coef = [0, 0, -9.81e-3]
48
49# save results
50data_dumper = netdem.DataDumper()
51data_dumper.Init(sim)
52data_dumper.SetRootPath("tmp/out/")
53data_dumper.SetSaveByCycles(100)
54data_dumper.SaveShapeInfoAsSTL()
55data_dumper.dump_shape_info = True
56data_dumper.dump_wall_info = True
57data_dumper.dump_contact_info = True
58sim.modifier_manager.Insert(data_dumper)
59sim.modifier_manager.Enable(data_dumper.label)
60
61# add deformation drived loading for top wall
62disp_control = netdem.WallMotionControl()
63disp_control.Init(sim)
64disp_control.SetWall([0])
65disp_control.SetVelocity(0, 0, -0.1)
66sim.modifier_manager.Insert(disp_control)
67sim.modifier_manager.Enable(disp_control.label)
68
69# run the simulation
70sim.dem_solver.timestep = 1.0e-4
71sim.Run(2.0)
A class representing a sphere bonded to other spheres through contact pairs.
Definition bonded_spheres.hpp:18
A class used to dump particle data into vtk files. This is a post-modifier, which will be executed at...
Definition data_dumper.hpp:12
A class used to apply gravity to particles in a DEM simulation.
Definition gravity.hpp:10
Contact model that uses linear spring elements to evaluate contact forces and moments.
Definition model_linear_spring.hpp:16
Contact model that evaluates forces and moments between two particles using parallel bond models.
Definition model_parallel_bond.hpp:15
A class for representing a plane with a center point and normal vector.
Definition shape_plane.hpp:22
Class for working with STL models.
Definition stl_model.hpp:17
Class for managing a DEM simulation.
Definition simulation.hpp:21
A class representing a wall object in a physics simulation.
Definition wall.hpp:32
A class used to control the displacement of walls in a DEM simulation.
Definition wall_motion_control.hpp:16