File: tunnel-pack.py

package info (click to toggle)
yade 2025.2.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 33,308 kB
  • sloc: cpp: 93,298; python: 50,409; sh: 577; makefile: 162
file content (34 lines) | stat: -rw-r--r-- 1,531 bytes parent folder | download | duplicates (2)
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
# -*- encoding=utf-8 -*-
"""Simple script to create tunnel with random dense packing of spheres.
The tunnel is difference between an axis-aligned box and cylinder, or which
axis is going through the bottom wall (-z) of the box.

The tunnel hole is oriented along +y, the face is in the xz plane.

The first you run this scipt, a few minutes is neede to generate the packing. It is
saved in /tmp/triaxPackCache.sqlite and at next time it will be only loaded (fast).
"""
# set some geometry parameters: domain box size, tunnel radius, radius of particles
boxSize = Vector3(5, 8, 5)
tunnelRad = 2
rSphere = .1
# construct spatial predicate as difference of box and cylinder:
# (see examples/test/pack-predicates.py for details)
#
# https://yade-dem.org/doc/yade.pack.html?highlight=inalignedbox#yade._packPredicates.inAlignedBox
# https://yade-dem.org/doc/yade.pack.html?highlight=incylinder#yade._packPredicates.inCylinder

pred = pack.inAlignedBox((-.5 * boxSize[0], -.5 * boxSize[1], 0),
                         (.5 * boxSize[0], .5 * boxSize[1], boxSize[2])) - pack.inCylinder((-.5 * boxSize[0], 0, 0), (.5 * boxSize[0], 0, 0), tunnelRad)
# Use the predicate to generate sphere packing inside
#
# https://yade-dem.org/doc/yade.pack.html?highlight=randomdensepack#yade.pack.randomDensePack
sp = SpherePack()
sp = pack.randomDensePack(pred, radius=rSphere, rRelFuzz=.3, memoizeDb='/tmp/triaxPackCache.sqlite', spheresInCell=3000, returnSpherePack=True)
sp.toSimulation()

# to see it
from yade import qt

qt.Controller()
qt.View()