File: cylindrical_packing.py

package info (click to toggle)
yade 2026.1.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 34,448 kB
  • sloc: cpp: 97,645; python: 52,173; sh: 677; makefile: 162
file content (80 lines) | stat: -rw-r--r-- 3,270 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# -*- encoding=utf-8 -*-
# 2022 © Vasileios Angelidakis <vasileios.angelidakis@ncl.ac.uk>

# Gravity deposition of regular polyhedra (Platonic solids) in a cylindrical packing, using the Potential Blocks

from yade import pack
from potential_utils import *
import math, os, errno
from numpy import array

# ------------------------------------------------------------------------------------------------------------------------------------------ #
# Material Parameters
m = O.materials.append(FrictMat(young=-1, poisson=-1, frictionAngle=atan(0.5), density=2000, label='frictMat'))

Kn = 1e8  #Pa/m
Ks = Kn * 2 / 3  #Pa/m

# ------------------------------------------------------------------------------------------------------------------------------------------ #
# Engines
O.engines = [
        ForceResetter(),
        InsertionSortCollider([PotentialBlock2AABB()], verletDist=0.01, avoidSelfInteractionMask=2),
        InteractionLoop(
                [Ig2_PB_PB_ScGeom(twoDimension=False, unitWidth2D=1.0, calContactArea=True)],
                [Ip2_FrictMat_FrictMat_KnKsPBPhys(kn_i=Kn, ks_i=Ks, Knormal=Kn, Kshear=Ks, useFaceProperties=False, viscousDamping=0.2)],
                [Law2_SCG_KnKsPBPhys_KnKsPBLaw(label='law', neverErase=False, allowViscousAttraction=False)]
        ),
        NewtonIntegrator(damping=0.0, exactAsphericalRot=True, gravity=[0, 0, -9.81], label='newton'),
]

# ------------------------------------------------------------------------------------------------------------------------------------------ #
# Create cylindrical packing of non-intersecting platonic solids with the same circumradius
rc = 0.05
radius = 0.5  #radius of the cylinder
height = 1.0  #height  of the cylinder

sp = pack.SpherePack()
mn = -Vector3(radius, radius, 0)
mx = Vector3(radius, radius, height)
sp.makeCloud(mn, mx, rc, 0, 200, False)

cyl = pack.inCylinder((0, 0, 0), (0, 0, 0.999 * height), 0.999 * radius)  # Create predicate inCylinder((bottomPoint,topPoint),radius)
sp = pack.filterSpherePack(cyl, sp, True)  # Filter initial cloud to retain only the bodies inside the predicate

r = 0.3 * rc
for s in sp:
	pb = platonic_solid(
	        material=m, numFaces=random.choice([4, 6, 8, 12]), rc=rc, r=r, R=0.0, center=s[0], mask=1, isBoundary=False, fixed=False
	)  # FIXME: Icosahedra are excluded for now
	pb.state.ori = Quaternion((random.random(), random.random(), random.random()), random.random())  #s[2]
	O.bodies.append(pb)

plates = cylindricalPlates(
        material=m, radius=0.5, height=1.0, thickness=0.05, numFaces=12, r=0.005, R=0.0, mask=3, isBoundary=False, fixed=True, lid=[False, True]
)
O.bodies.append(plates)

# ------------------------------------------------------------------------------------------------------------------------------------------ #
# Visualisation
try:
	from yade import qt
	qt.Controller()
	v = qt.View()
	v.ortho = True
	v.sceneRadius = 20

	v.eyePosition = Vector3(0, -2, 0.5)
	v.viewDir = Vector3(0, 1, 0)
	v.upVector = Vector3(0, 0, 1)

	rndr = yade.qt.Renderer()
except:
	pass

# ------------------------------------------------------------------------------------------------------------------------------------------ #
# Timestep
O.dt = 2 * sqrt(O.bodies[0].state.mass / Kn)

O.saveTmp()
O.run()