Creating packings and filling volumes defined by boundary representation or constructive solid geometry.
For examples, see
Append spheres directly to the simulation. In addition calling O.bodies.append, this method also appropriately sets periodic cell information of the simulation.
>>> from yade import pack; from math import *
>>> sp=pack.SpherePack()
Create random periodic packing with 20 spheres:
>>> sp.makeCloud((0,0,0),(5,5,5),rMean=.5,rRelFuzz=.5,periodic=True,num=20)
20
Virgin simulation is aperiodic:
>>> O.reset()
>>> O.periodic
False
Add generated packing to the simulation, rotated by 45° along +z
>>> sp.toSimulation(rot=Quaternion((0,0,1),pi/4),color=(0,0,1))
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]
Periodic properties are transferred to the simulation correctly, including rotation (this could be avoided by explicitly passing “hSize=O.cell.hSize” as an argument):
>>> O.periodic
True
>>> O.cell.refSize
Vector3(5,5,5)
Using given SpherePack instance, return spheres that satisfy predicate. It returns either a pack.SpherePack (if returnSpherePack) or a list. The packing will be recentered to match the predicate and warning is given if the predicate is larger than the packing.
Construct facets from given GTS surface. **kw is passed to utils.facet.
Return (Vector3 center, Vector3 halfSize, Quaternion orientation) describing bestfit oriented bounding box (OBB) for the given surface. See cloudBestFitOBB for details.
Definition of the particles for a hexagonal wire net in the xyplane for the WireMatPM.
Parameters: 


Returns:  set of spheres which defines the net (net) and exact dimensions of the net (lx,ly). 
Note
This packing works for the WireMatPM only. The particles at the corner are always generated first. For examples on how to use this packing see examples/WireMatPM. In order to create the proper interactions for the net the interaction radius has to be adapted in the simulation.
This class was reimplemented in c++, but should stay here to serve as reference for implementing Predicates in pure python code. C++ allows us to play dirty tricks in GTS which are not accessible through pygts itself; the performance penalty of pygts comes from fact that if constructs and destructs bb tree for the surface at every invocation of gts.Point().is_inside(). That is cached in the c++ code, provided that the surface is not manipulated with during lifetime of the object (user’s responsibility).
—
Predicate for GTS surfaces. Constructed using an already existing surfaces, which must be closed.
import gts surf=gts.read(open(‘horse.gts’)) inGtsSurface(surf)
Note
Padding is optionally supported by testing 6 points along the axes in the pad distance. This must be enabled in the ctor by saying doSlowPad=True. If it is not enabled and pad is not zero, warning is issued.
Predicate returning True any points, with infinite bounding box.
Predicate returning True for any points, with infinite bounding box.
Generator of random dense packing with given geometry properties, using TriaxialTest (aperiodic) or PeriIsoCompressor (periodic). The periodicity depens on whether the spheresInCell parameter is given.
O.switchScene() magic is used to have clean simulation for TriaxialTest without deleting the original simulation. This function therefore should never run in parallel with some code accessing your simulation.
Parameters: 


Returns:  SpherePack object with spheres, filtered by the predicate. 
Generate periodic dense packing.
A cell of initSize is stuffed with as many spheres as possible, then we run periodic compression with PeriIsoCompressor, just like with randomDensePack.
Parameters: 


Returns:  SpherePack object, which also contains periodicity information. 
Return set of spheres in regular hexagonal grid, clipped inside solid given by predicate. Created spheres will have given radius and will be separated by gap space.
Return set of spheres in regular orthogonal grid, clipped inside solid given by predicate. Created spheres will have given radius and will be separated by gap space.
Revolution surface given sequences of 2d points and sequence of corresponding angles, returning sequences of 3d points representing meridian sections of the revolution surface. The 2d sections are turned around zaxis, but they can be transformed using the origin and orientation arguments to give arbitrary orientation.
Create swept suface (as GTS triangulation) given samelength sequences of points (as 3tuples).
If threshold is given (>0), then
Note
capStart and capEnd make the most naive polygon triangulation (diagonals) and will perhaps fail for nonconvex sections.
Warning
the algorithm connects points sequentially; if two polylines are mutually rotated or have inverse sense, the algorithm will not detect it and connect them regardless in their given order.
Creation, manipulation, IO for generic sphere packings.
Set of spheres represented as centers and radii. This class is returned by pack.randomDensePack, pack.randomPeriPack and others. The object supports iteration over spheres, as in
>>> sp=SpherePack()
>>> for center,radius in sp: print center,radius
>>> for sphere in sp: print sphere[0],sphere[1] ## same, but without unpacking the tuple automatically
>>> for i in range(0,len(sp)): print sp[i][0], sp[i][1] ## same, but accessing spheres by index
Special constructors
Construct from list of [(c1,r1),(c2,r2),…]. To convert two samelength lists of centers and radii, construct with zip(centers,radii).
Empty constructor, optionally taking list [ ((cx,cy,cz),r), … ] for initial data.
Get axisaligned bounding box coordinates, as 2 3tuples.
Add single sphere to packing, given center as 3tuple and radius
A factor between 0 and 1, uniformly applied on all sizes of of the PSD.
Repeat the packing (if periodic) so that the results has dim() >= given size. The packing retains periodicity, but changes cellSize. Raises exception for nonperiodic packing.
Repeat the packing given number of times in each dimension. Periodicity is retained, cellSize changes. Raises exception for nonperiodic packing.
Size of periodic cell; is Vector3(0,0,0) if not periodic. (Change this property only if you know what you’re doing).
Return coordinates of the bounding box center.
Return dimensions of the packing in terms of aabb(), as a 3tuple.
Make packing from given list, same format as for constructor. Discards current data.
Make packing corresponding to the current simulation. Discards current data.
Return lists of sphere ids sorted by clumps they belong to. The return value is (standalones,[clump1,clump2,…]), where each item is list of id’s of spheres.
Whether this object contains clumps.
was the packing generated in periodic boundaries?
Load packing from external text file (current data will be discarded).
Create random very loose packing enclosed in a parallelepiped (also works in 2D if minCorner[k]=maxCorner[k] for one coordinate). The resulting packing conforms in fact a gaslike state (see Cloud denomination) with no contacts between particles. Usually used as a first step for packing generation, before subsequent mechanical loading that will confer a solidlike nature to the packing. Sphere radius distribution can be specified using one of the following ways:
By default (with distributeMass==False), the distribution is applied to particle radii. The usual sense of “particle size distribution” is the distribution of mass fraction (rather than particle count); this can be achieved with distributeMass=True.
If num is defined, then sizes generation is deterministic, giving the best fit of target distribution. It enables spheres placement in descending size order, thus giving lower porosity than the random generation.
Parameters: 


Returns:  number of created spheres, which can be lower than num depending on the method used. 
Create random loose packing of clumps within box given by minCorner and maxCorner. Clumps are selected with equal probability. At most num clumps will be positioned if num is positive; otherwise, as many clumps as possible will be put in space, until maximum number of attempts to place a new clump randomly is attained.
Parameters:  seed – number used to initialize the random number generator. 

Return particle size distribution of the packing.
Parameters: 


Returns:  tuple of (cumm,edges), where cumm are cummulative fractions for respective diameters and edges are those diameter values. Dimension of both arrays is equal to bins+1. 
Relative packing density, measured as sum of spheres’ volumes / aabb volume. (Sphere overlaps are ignored.)
Rotate all spheres around packing center (in terms of aabb()), given axis and angle of the rotation.
Save packing to external text file (will be overwritten).
Scale the packing around its center (in terms of aabb()) by given factor (may be negative).
Return packing data as python list.
this method also appropriately sets periodic cell information of the simulation.
>>> from yade import pack; from math import *
>>> sp=pack.SpherePack()
Create random periodic packing with 20 spheres:
>>> sp.makeCloud((0,0,0),(5,5,5),rMean=.5,rRelFuzz=.5,periodic=True,num=20)
20
Virgin simulation is aperiodic:
>>> O.reset()
>>> O.periodic
False
Add generated packing to the simulation, rotated by 45° along +z
>>> sp.toSimulation(rot=Quaternion((0,0,1),pi/4),color=(0,0,1))
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]
Periodic properties are transferred to the simulation correctly, including rotation (this could be avoided by explicitly passing “hSize=O.cell.hSize” as an argument):
>>> O.periodic
True
>>> O.cell.refSize
Vector3(5,5,5)
Translate all spheres by given vector.
Spatial predicates for volumes (defined analytically or by triangulation).
aabb( (Predicate)arg1) → None
Boolean operation on 2 predicates (abstract class)
Raises an exception This class cannot be instantiated from Python
aabb( (Predicate)arg1) → None
Difference (conjunction with negative predicate) of 2 predicates. A point has to be inside the first and outside the second predicate. Can be constructed using the  operator on predicates: pred1  pred2.
aabb( (Predicate)arg1) → None
Intersection (conjunction) of 2 predicates. A point has to be inside both predicates. Can be constructed using the & operator on predicates: pred1 & pred2.
aabb( (Predicate)arg1) → None
SymmetricDifference (exclusive disjunction) of 2 predicates. A point has to be in exactly one predicate of the two. Can be constructed using the ^ operator on predicates: pred1 ^ pred2.
aabb( (Predicate)arg1) → None
Union (nonexclusive disjunction) of 2 predicates. A point has to be inside any of the two predicates to be inside. Can be constructed using the  operator on predicates: pred1  pred2.
aabb( (Predicate)arg1) → None
Axisaligned box predicate
Ctor taking minumum and maximum points of the box (as 3tuples).
aabb( (Predicate)arg1) → None
Cylinder predicate
Ctor taking centers of the lateral walls (as 3tuples) and radius.
aabb( (Predicate)arg1) → None
Ellipsoid predicate
Ctor taking center of the ellipsoid (3tuple) and its 3 radii (3tuple).
aabb( (Predicate)arg1) → None
GTS surface predicate
Ctor taking a gts.Surface() instance, which must not be modified during instance lifetime. The optional noPad can disable padding (if set to True), which speeds up calls several times. Note: padding checks inclusion of 6 points along + cardinal directions in the pad distance from given point, which is not exact.
aabb( (Predicate)arg1) → None
The associated gts.Surface object.
Hyperboloid predicate
Ctor taking centers of the lateral walls (as 3tuples), radius at bases and skirt (middle radius).
aabb( (Predicate)arg1) → None
Parallelepiped predicate
Ctor taking four points: o (for origin) and then a, b, c which define endpoints of 3 respective edges from o.
aabb( (Predicate)arg1) → None
Sphere predicate.
Ctor taking center (as a 3tuple) and radius
aabb( (Predicate)arg1) → None
Outside of infinite, rectangleshaped notch predicate
Ctor taking point in the symmetry plane, vector pointing along the edge, plane normal and aperture size. The side inside the notch is edge×normal. Normal is made perpendicular to the edge. All vectors are normalized at construction time.
aabb( (Predicate)arg1) → None
Computation of oriented bounding box for cloud of points.
Return (Vector3 center, Vector3 halfSize, Quaternion orientation) of bestfit oriented boundingbox for given tuple of points (uses bruteforce velome minimization, do not use for very large clouds).