Packing Class
- class Packing(n, dim=2, radius=0, rfac=0.8, params={'central': 0.0005, 'contact': 0.1, 'drag': 0.05}, seed=12)
Bases:
objectClass to model a contact network of bidisperse spheres.
- Parameters:
n (int) – The number of spheres.
dim (int) – The dimensionality of the system. Valid options are 2 and 3.
radius (float, optional) – The radius of the larger spheres. If 0 (default), a good choice is computed automatically.
rfac (float, optional) – Factor by which the smaller sphere radius is scaled relative to large spheres.
params (dict, optional) –
Specifies system parameters. Required keywords are :
’central’: strength of the force pulling spheres toward origin
’drag’: coefficient of isotropic drag
’contact’: strength of contact repulsion
seed (int, optional) – A random seed used for initializing the positions of the spheres, and assigning which are large or small.
- Variables:
n (int) – The number of spheres.
dim (int) – The dimensionality of the system.
pts (ndarray) – (x,y) coordinates for each sphere.
labels (ndarray) – Array of sphere labels (0=large, 1=small).
radii (list) – List of sphere radii, indexed by sphere type (0=large, 1=small).
traj (ndarray) – The simulated trajectory of the network produced after a call to the generate() routine.
t_eval (ndarray) – The corresponding time at each simulated frame.
graph (networkx.graph) – Graph specifying the nodes and edges in the final contact network.
- animate(spheres=True, edges=True, figsize=(5, 5), skip=1)
Animate the system after a simulation.
- Parameters:
- Returns:
The resulting animation. In a jupyter notebook, the animation may be visualized with the import from IPython.display import HTML, and running HTML(ani.to_html5_video()).
- Return type:
matplotlib.animation.FuncAnimation
- coordination()
Compute the coordination information of the network.
- Returns:
nc (int) – The number of nodes forming a connected network.
Ziso (float) – The required average coordination for isostaticity.
Z (float) – The average coordination of the network.
dZ (float) – The excess coordination, defined as Z - Ziso.
- generate(duration=1000.0, frames=200)
Run a packing simulation.
Generates a graph of the resulting contact network at the end.
- initialize()
Initialize the sphere positions and radii.
- plot(spheres=True, edges=True, figsize=(5, 5), filename=None)
Plot the network, optionally specifying whether to include spheres and edges.
- rotate(spheres=True, edges=True, figsize=(5, 5), skip=1)
Animate camera and light rotation about a static scene.