Compaction problem

This is a sample script that simulates the compaction of a powder using a constant velocity mesh (2D wall). The input script and mesh files are found here.

Stage 1: data structure creation

First, a python dictionary (params) defining the simulation parameters is created as shown below:

In [ ]:
from pygran import simulation
from pygran.params import organic

# Create a dictionary of physical parameters
params = {

	# Define the system
	'boundary': ('p','p','p'), # periodic BCs
	'box':  (-0.001, 0.001, -0.001, 0.001, 0, 0.004), # simulation box size

	# Define component(s)
	'species': ({'material': organic, 'radius': ('constant', 2e-4)}, ),

	# Timestep
	'dt': 1e-6,

	# Apply gravitional force in the negative direction along the z-axis
	'gravity': (9.81, 0, 0, -1),

	# Number of simulation steps (non-pygran variable)
	'nsteps': 2.5e4,

	# Import surface mesh
	'mesh': {
		'wallZ': {'file': 'mesh/square.stl', 'mtype': 'mesh/surface/stress', 'material': organic, \
			'args': {'scale':1e-3, 'move': (0, 0, 1e-3)}}
		},
}

Stage 2: simulation

The params dictionary is then used to create a DEM class and run the simulation. By default, the unit system used is S.I.

In [ ]:
# Create an instance of the DEM class
sim = simulation.DEM(**params)

# Setup a primitive wall along the xoy plane at z=0 of material properties defined in species 1
sim.setupWall(species=1, wtype='primitive', plane = 'zplane', peq = 0.0)

# Insert 200 particles periodically (every 8333 steps)
insert = sim.insert(species=1, value=200, freq=params['nsteps']/3)
sim.run(params['nsteps'], params['dt'])
sim.remove(insert)

# Move wall at constant speed (0.03 m/s) in the negative z direction
moveZ = sim.moveMesh(name='wallZ', linear=(0, 0, -0.03))
sim.run(params['nsteps'] * 2, params['dt'])
sim.remove(moveZ)

# Relax the system (move wall upwards) at constant speed of 0.01 m/s in the positive z direction
moveZ = sim.moveMesh(name='wallZ', linear=(0, 0, 0.01))
sim.run(params['nsteps'] * 2, params['dt'])

Output

In [1]:
# Play video
video = io.open('movie/compaction.mp4', 'r+b').read()
Out[1]: