yade.utils module¶
Heap of functions that don’t (yet) fit anywhere else.
Devs: please DO NOT ADD more functions here, it is getting too crowded!
-
yade.utils.
NormalRestitution2DampingRate
(en)[source]¶ Compute the normal damping rate as a function of the normal coefficient of restitution
. For
damping rate equals
-
yade.utils.
SpherePWaveTimeStep
(radius, density, young)[source]¶ Compute P-wave critical timestep for a single (presumably representative) sphere, using formula for P-Wave propagation speed
. If you want to compute minimum critical timestep for all spheres in the simulation, use utils.PWaveTimeStep instead.
>>> SpherePWaveTimeStep(1e-3,2400,30e9) 2.8284271247461903e-07
-
class
yade.utils.
TableParamReader
[source]¶ Class for reading simulation parameters from text file.
Each parameter is represented by one column, each parameter set by one line. Colums are separated by blanks (no quoting).
First non-empty line contains column titles (without quotes). You may use special column named ‘description’ to describe this parameter set; if such colum is absent, description will be built by concatenating column names and corresponding values (
param1=34,param2=12.22,param4=foo
)- from columns ending in
!
(the!
is not included in the column name) - from all columns, if no columns end in
!
.
Empty lines within the file are ignored (although counted);
#
starts comment till the end of line. Number of blank-separated columns must be the same for all non-empty lines.A special value
=
can be used instead of parameter value; value from the previous non-empty line will be used instead (works recursively).This class is used by utils.readParamsFromTable.
-
paramDict
()[source]¶ Return dictionary containing data from file given to constructor. Keys are line numbers (which might be non-contiguous and refer to real line numbers that one can see in text editors), values are dictionaries mapping parameter names to their values given in the file. The special value ‘=’ has already been interpreted,
!
(bangs) (if any) were already removed from column titles,description
column has already been added (if absent).
- from columns ending in
-
class
yade.utils.
UnstructuredGrid
[source]¶ EXPERIMENTAL. Class representing triangulated FEM-like unstructured grid. It is used for transfereing data from ad to YADE and external FEM program. The main purpose of this class is to store information about individual grid vertices/nodes coords (since facets stores only coordinates of vertices in local coords) and to avaluate and/or apply nodal forces from contact forces (from actual contact force and contact point the force is distributed to nodes using linear approximation).
TODO rewrite to C++ TODO better docs
Parameters: -
getForcesOfNodes
()[source]¶ Computes forces for each vertex/node. The nodal force is computed from contact force and contact point using linear approximation
-
setPositionsOfNodes
()[source]¶ Sets new position of nodes and also updates all elements in the simulation
:param [Vector3] newPoss: list of new positions
-
setup
()[source]¶ Sets new information to receiver
:param dict vertices: see constructor for explanation :param dict connectivityTable: see constructor for explanation :param bool toSimulation: if new information should be inserted to Yade simulation (create new bodies or not) :param [[int]]|None bodies: list of list of bodies indices to be appended as clumps (thus no contact detection is done within one body)
-
-
yade.utils.
aabbDim
(cutoff=0.0, centers=False)[source]¶ Return dimensions of the axis-aligned bounding box, optionally with relative part cutoff cut away.
-
yade.utils.
aabbWalls
(extrema=None, thickness=0, oversizeFactor=1.5, **kw)[source]¶ Return 6 boxes that will wrap existing packing as walls from all sides; extrema are extremal points of the Aabb of the packing (will be calculated if not specified) thickness is wall thickness (will be 1/10 of the X-dimension if not specified) Walls will be enlarged in their plane by oversizeFactor. returns list of 6 wall Bodies enclosing the packing, in the order minX,maxX,minY,maxY,minZ,maxZ.
-
yade.utils.
avgNumInteractions
(cutoff=0.0, skipFree=False, considerClumps=False)[source]¶ Return average numer of interactions per particle, also known as coordination number
. This number is defined as
where
is number of contacts and
is number of particles. When clumps are present, number of particles is the sum of standalone spheres plus the sum of clumps. Clumps are considered in the calculation if cutoff != 0 or skipFree = True. If cutoff=0 (default) and skipFree=False (default) one needs to set considerClumps=True to consider clumps in the calculation.
With skipFree, particles not contributing to stable state of the packing are skipped, following equation (8) given in [Thornton2000]:
Parameters: - cutoff – cut some relative part of the sample’s bounding box away.
- skipFree – see above.
- considerClumps – also consider clumps if cutoff=0 and skipFree=False; for further explanation see above.
-
yade.utils.
box
(center, extents, orientation=Quaternion((1, 0, 0), 0), dynamic=None, fixed=False, wire=False, color=None, highlight=False, material=-1, mask=1)[source]¶ Create box (cuboid) with given parameters.
Parameters: extents (Vector3) – half-sizes along x,y,z axes See utils.sphere‘s documentation for meaning of other parameters.
-
yade.utils.
chainedCylinder
(begin=Vector3(0, 0, 0), end=Vector3(1, 0, 0), radius=0.2, dynamic=None, fixed=False, wire=False, color=None, highlight=False, material=-1, mask=1)[source]¶ Create and connect a chainedCylinder with given parameters. The shape generated by repeted calls of this function is the Minkowski sum of polyline and sphere.
Parameters: - radius (Real) – radius of sphere in the Minkowski sum.
- begin (Vector3) – first point positioning the line in the Minkowski sum
- last (Vector3) – last point positioning the line in the Minkowski sum
In order to build a correct chain, last point of element of rank N must correspond to first point of element of rank N+1 in the same chain (with some tolerance, since bounding boxes will be used to create connections.
Returns: Body object with the ChainedCylinder shape.
-
class
yade.utils.
clumpTemplate
[source]¶ Create a clump template by a list of relative radii and a list of relative positions. Both lists must have the same length.
Parameters: - relRadii ([float,float,...]) – list of relative radii (minimum length = 2)
- relPositions ([Vector3,Vector3,...]) – list of relative positions (minimum length = 2)
-
yade.utils.
defaultMaterial
()[source]¶ Return default material, when creating bodies with utils.sphere and friends, material is unspecified and there is no shared material defined yet. By default, this function returns:
.. code-block:: python
FrictMat(density=1e3,young=1e7,poisson=.3,frictionAngle=.5,label=’defaultMat’)
-
yade.utils.
facet
(vertices, dynamic=None, fixed=True, wire=True, color=None, highlight=False, noBound=False, material=-1, mask=1, chain=-1)[source]¶ Create facet with given parameters.
Parameters: - vertices ([Vector3,Vector3,Vector3]) – coordinates of vertices in the global coordinate system.
- wire (bool) – if
True
, facets are shown as skeleton; otherwise facets are filled - noBound (bool) – set Body.bounded
- color (Vector3-or-None) – color of the facet; random color will be assigned if
None
.
See utils.sphere‘s documentation for meaning of other parameters.
-
yade.utils.
fractionalBox
(fraction=1.0, minMax=None)[source]¶ retrurn (min,max) that is the original minMax box (or aabb of the whole simulation if not specified) linearly scaled around its center to the fraction factor
-
yade.utils.
gridConnection
(id1, id2, radius, wire=False, color=None, highlight=False, material=-1, mask=1, cellDist=None)[source]¶
-
yade.utils.
gridNode
(center, radius, dynamic=None, fixed=False, wire=False, color=None, highlight=False, material=-1)[source]¶
-
yade.utils.
loadVars
(mark=None)[source]¶ Load variables from utils.saveVars, which are saved inside the simulation. If
mark==None
, all save variables are loaded. Otherwise only those with the mark passed.
-
yade.utils.
makeVideo
(frameSpec, out, renameNotOverwrite=True, fps=24, kbps=6000, bps=None)[source]¶ Create a video from external image files using mencoder. Two-pass encoding using the default mencoder codec (mpeg4) is performed, running multi-threaded with number of threads equal to number of OpenMP threads allocated for Yade.
Parameters: - frameSpec – wildcard | sequence of filenames. If list or tuple, filenames to be encoded in given order; otherwise wildcard understood by mencoder’s mf:// URI option (shell wildcards such as
/tmp/snap-*.png
or and printf-style pattern like/tmp/snap-%05d.png
) - out (str) – file to save video into
- renameNotOverwrite (bool) – if True, existing same-named video file will have -number appended; will be overwritten otherwise.
- fps (int) – Frames per second (
-mf fps=…
) - kbps (int) – Bitrate (
-lavcopts vbitrate=…
) in kb/s
- frameSpec – wildcard | sequence of filenames. If list or tuple, filenames to be encoded in given order; otherwise wildcard understood by mencoder’s mf:// URI option (shell wildcards such as
-
yade.utils.
perpendicularArea
(axis)[source]¶ Return area perpendicular to given axis (0=x,1=y,2=z) generated by bodies for which the function consider returns True (defaults to returning True always) and which is of the type Sphere.
-
yade.utils.
plotDirections
(aabb=(), mask=0, bins=20, numHist=True, noShow=False, sphSph=False)[source]¶ Plot 3 histograms for distribution of interaction directions, in yz,xz and xy planes and (optional but default) histogram of number of interactions per body. If sphSph only sphere-sphere interactions are considered for the 3 directions histograms.
Returns: If noShow is False
, displays the figure and returns nothing. If noShow, the figure object is returned without being displayed (works the same way as plot.plot).
-
yade.utils.
plotNumInteractionsHistogram
(cutoff=0.0)[source]¶ Plot histogram with number of interactions per body, optionally cutting away cutoff relative axis-aligned box from specimen margin.
-
yade.utils.
polyhedron
(vertices, dynamic=True, fixed=False, wire=True, color=None, highlight=False, noBound=False, material=-1, mask=1, chain=-1)[source]¶ Create polyhedron with given parameters.
Parameters: vertices ([[Vector3]]) – coordinates of vertices in the global coordinate system. See utils.sphere‘s documentation for meaning of other parameters.
-
yade.utils.
psd
(bins=5, mass=True, mask=-1)[source]¶ Calculates particle size distribution.
Parameters: - bins (int) – number of bins
- mass (bool) – if true, the mass-PSD will be calculated
- mask (int) – Body.mask for the body
Returns: - binsSizes: list of bin’s sizes
- binsProc: how much material (in percents) are in the bin, cumulative
- binsSumCum: how much material (in units) are in the bin, cumulative
binsSizes, binsProc, binsSumCum
-
yade.utils.
randomColor
()[source]¶ Return random Vector3 with each component in interval 0…1 (uniform distribution)
-
yade.utils.
randomizeColors
(onlyDynamic=False)[source]¶ Assign random colors to Shape::color.
If onlyDynamic is true, only dynamic bodies will have the color changed.
-
yade.utils.
readParamsFromTable
(tableFileLine=None, noTableOk=True, unknownOk=False, **kw)[source]¶ Read parameters from a file and assign them to __builtin__ variables.
The format of the file is as follows (commens starting with # and empty lines allowed):
# commented lines allowed anywhere name1 name2 … # first non-blank line are column headings # empty line is OK, with or without comment val1 val2 … # 1st parameter set val2 val2 … # 2nd …
Assigned tags (the
description
column is synthesized if absent,see utils.TableParamReader);O.tags[‘description’]=… # assigns the description column; might be synthesized O.tags[‘params’]=”name1=val1,name2=val2,…” # all explicitly assigned parameters O.tags[‘defaultParams’]=”unassignedName1=defaultValue1,…” # parameters that were left at their defaults O.tags[‘d.id’]=O.tags[‘id’]+’.’+O.tags[‘description’] O.tags[‘id.d’]=O.tags[‘description’]+’.’+O.tags[‘id’]All parameters (default as well as settable) are saved using utils.saveVars
('table')
.Parameters: - tableFile – text file (with one value per blank-separated columns)
- tableLine (int) – number of line where to get the values from
- noTableOk (bool) – if False, raise exception if the file cannot be open; use default values otherwise
- unknownOk (bool) – do not raise exception if unknown column name is found in the file, and assign it as well
Returns: number of assigned parameters
-
yade.utils.
replaceCollider
(colliderEngine)[source]¶ Replaces collider (Collider) engine with the engine supplied. Raises error if no collider is in engines.
-
yade.utils.
saveVars
(mark='', loadNow=True, **kw)[source]¶ Save passed variables into the simulation so that it can be recovered when the simulation is loaded again.
For example, variables a, b and c are defined. To save them, use:
>>> saveVars('something',a=1,b=2,c=3) >>> from yade.params.something import * >>> a,b,c (1, 2, 3)
those variables will be save in the .xml file, when the simulation itself is saved. To recover those variables once the .xml is loaded again, use ``loadVars(‘something’)``and they will be defined in the yade.params.mark module. The loadNow parameter calls utils.loadVars after saving automatically. If ‘something’ already exists, given variables will be inserted.
-
yade.utils.
sphere
(center, radius, dynamic=None, fixed=False, wire=False, color=None, highlight=False, material=-1, mask=1)[source]¶ Create sphere with given parameters; mass and inertia computed automatically.
Last assigned material is used by default (material = -1), and utils.defaultMaterial() will be used if no material is defined at all.
Parameters: - center (Vector3) – center
- radius (float) – radius
- dynamic (float) – deprecated, see “fixed”
- fixed (float) – generate the body with all DOFs blocked?
- material –
- specify Body.material; different types are accepted:
- int: O.materials[material] will be used; as a special case, if material==-1 and there is no shared materials defined, utils.defaultMaterial() will be assigned to O.materials[0]
- string: label of an existing material that will be used
- Material instance: this instance will be used
- callable: will be called without arguments; returned Material value will be used (Material factory object, if you like)
- mask (int) – Body.mask for the body
- wire – display as wire sphere?
- highlight – highlight this body in the viewer?
- Vector3-or-None – body’s color, as normalized RGB; random color will be assigned if
None
.
Returns: A Body instance with desired characteristics.
Creating default shared material if none exists neither is given:
>>> O.reset() >>> from yade import utils >>> len(O.materials) 0 >>> s0=utils.sphere([2,0,0],1) >>> len(O.materials) 1
Instance of material can be given:
>>> s1=utils.sphere([0,0,0],1,wire=False,color=(0,1,0),material=ElastMat(young=30e9,density=2e3)) >>> s1.shape.wire False >>> s1.shape.color Vector3(0,1,0) >>> s1.mat.density 2000.0
Material can be given by label:
>>> O.materials.append(FrictMat(young=10e9,poisson=.11,label='myMaterial')) 1 >>> s2=utils.sphere([0,0,2],1,material='myMaterial') >>> s2.mat.label 'myMaterial' >>> s2.mat.poisson 0.11
Finally, material can be a callable object (taking no arguments), which returns a Material instance. Use this if you don’t call this function directly (for instance, through yade.pack.randomDensePack), passing only 1 material parameter, but you don’t want material to be shared.
For instance, randomized material properties can be created like this:
>>> import random >>> def matFactory(): return ElastMat(young=1e10*random.random(),density=1e3+1e3*random.random()) ... >>> s3=utils.sphere([0,2,0],1,material=matFactory) >>> s4=utils.sphere([1,2,0],1,material=matFactory)
-
yade.utils.
tetra
(vertices, strictCheck=True, dynamic=True, fixed=False, wire=True, color=None, highlight=False, noBound=False, material=-1, mask=1, chain=-1)[source]¶ Create tetrahedron with given parameters.
Parameters: - vertices ([Vector3,Vector3,Vector3,Vector3]) – coordinates of vertices in the global coordinate system.
- strictCheck (bool) – checks vertices order, raise RuntimeError for negative volume
See utils.sphere‘s documentation for meaning of other parameters.
-
yade.utils.
tetraPoly
(vertices, dynamic=True, fixed=False, wire=True, color=None, highlight=False, noBound=False, material=-1, mask=1, chain=-1)[source]¶ Create tetrahedron (actually simple Polyhedra) with given parameters.
Parameters: vertices ([Vector3,Vector3,Vector3,Vector3]) – coordinates of vertices in the global coordinate system. See utils.sphere‘s documentation for meaning of other parameters.
-
yade.utils.
trackPerfomance
(updateTime=5)[source]¶ Track perfomance of a simulation. (Experimental) Will create new thread to produce some plots. Useful for track perfomance of long run simulations (in bath mode for example).
-
yade.utils.
typedEngine
(name)[source]¶ Return first engine from current O.engines, identified by its type (as string). For example:
>>> from yade import utils >>> O.engines=[InsertionSortCollider(),NewtonIntegrator(),GravityEngine()] >>> utils.typedEngine("NewtonIntegrator") == O.engines[1] True
-
yade.utils.
uniaxialTestFeatures
(filename=None, areaSections=10, axis=-1, distFactor=2.2, **kw)[source]¶ Get some data about the current packing useful for uniaxial test:
- Find the dimensions that is the longest (uniaxial loading axis)
- Find the minimum cross-section area of the specimen by examining several (areaSections) sections perpendicular to axis, computing area of the convex hull for each one. This will work also for non-prismatic specimen.
- Find the bodies that are on the negative/positive boundary, to which the straining condition should be applied.
Parameters: - filename – if given, spheres will be loaded from this file (ASCII format); if not, current simulation will be used.
- areaSection (float) – number of section that will be used to estimate cross-section
- axis (∈{0,1,2}) – if given, force strained axis, rather than computing it from predominant length
Returns: dictionary with keys
negIds
,posIds
,axis
,area
.Warning
The function utils.approxSectionArea uses convex hull algorithm to find the area, but the implementation is reported to be buggy (bot works in some cases). Always check this number, or fix the convex hull algorithm (it is documented in the source, see py/_utils.cpp).
-
yade.utils.
voxelPorosityTriaxial
(triax, resolution=200, offset=0)[source]¶ Calculate the porosity of a sample, given the TriaxialCompressionEngine.
A function utils.voxelPorosity is invoked, with the volume of a box enclosed by TriaxialCompressionEngine walls. The additional parameter offset allows using a smaller volume inside the box, where each side of the volume is at offset distance from the walls. By this way it is possible to find a more precise porosity of the sample, since at walls’ contact the porosity is usually reduced.
A recommended value of offset is bigger or equal to the average radius of spheres inside.
The value of resolution depends on size of spheres used. It can be calibrated by invoking voxelPorosityTriaxial with offset=0 and comparing the result with TriaxialCompressionEngine.porosity. After calibration, the offset can be set to radius, or a bigger value, to get the result.
Parameters: - triax – the TriaxialCompressionEngine handle
- resolution – voxel grid resolution
- offset – offset distance
Returns: the porosity of the sample inside given volume
Example invocation:
from yade import utils rAvg=0.03 TriaxialTest(numberOfGrains=200,radiusMean=rAvg).load() O.dt=-1 O.run(1000) O.engines[4].porosity 0.44007807740143889 utils.voxelPorosityTriaxial(O.engines[4],200,0) 0.44055412500000002 utils.voxelPorosityTriaxial(O.engines[4],200,rAvg) 0.36798199999999998
-
yade.utils.
waitIfBatch
()[source]¶ Block the simulation if running inside a batch. Typically used at the end of script so that it does not finish prematurely in batch mode (the execution would be ended in such a case).
-
yade.utils.
wall
(position, axis, sense=0, color=None, material=-1, mask=1)[source]¶ Return ready-made wall body.
Parameters: - position (float-or-Vector3) – center of the wall. If float, it is the position along given axis, the other 2 components being zero
- axis (∈{0,1,2}) – orientation of the wall normal (0,1,2) for x,y,z (sc. planes yz, xz, xy)
- sense (∈{-1,0,1}) – sense in which to interact (0: both, -1: negative, +1: positive; see Wall)
See utils.sphere‘s documentation for meaning of other parameters.
-
yade.utils.
xMirror
(half)[source]¶ Mirror a sequence of 2d points around the x axis (changing sign on the y coord). The sequence should start up and then it will wrap from y downwards (or vice versa). If the last point’s x coord is zero, it will not be duplicated.
-
yade._utils.
PWaveTimeStep
() → float¶ Get timestep accoring to the velocity of P-Wave propagation; computed from sphere radii, rigidities and masses.
-
yade._utils.
RayleighWaveTimeStep
() → float¶ Determination of time step according to Rayleigh wave speed of force propagation.
-
yade._utils.
TetrahedronCentralInertiaTensor
((object)arg1) → Matrix3¶ TODO
-
yade._utils.
TetrahedronInertiaTensor
((object)arg1) → Matrix3¶ TODO
-
yade._utils.
TetrahedronSignedVolume
((object)arg1) → float¶ TODO
-
yade._utils.
TetrahedronVolume
((object)arg1) → float¶ TODO
-
yade._utils.
TetrahedronWithLocalAxesPrincipal
((Body)arg1) → Quaternion¶ TODO
-
yade._utils.
aabbExtrema
([(float)cutoff=0.0[, (bool)centers=False]]) → tuple¶ Return coordinates of box enclosing all bodies
Parameters: - centers (bool) – do not take sphere radii in account, only their centroids
- cutoff (float∈〈0…1〉) – relative dimension by which the box will be cut away at its boundaries.
Returns: (lower corner, upper corner) as (Vector3,Vector3)
-
yade._utils.
angularMomentum
([(Vector3)origin=Vector3(0, 0, 0)]) → Vector3¶ TODO
-
yade._utils.
approxSectionArea
((float)arg1, (int)arg2) → float¶ Compute area of convex hull when when taking (swept) spheres crossing the plane at coord, perpendicular to axis.
-
yade._utils.
bodyNumInteractionsHistogram
((tuple)aabb) → tuple¶
-
yade._utils.
bodyStressTensors
() → list¶ Compute and return a table with per-particle stress tensors. Each tensor represents the average stress in one particle, obtained from the contour integral of applied load as detailed below. This definition is considering each sphere as a continuum. It can be considered exact in the context of spheres at static equilibrium, interacting at contact points with negligible volume changes of the solid phase (this last assumption is not restricting possible deformations and volume changes at the packing scale).
Proof:
First, we remark the identity:
.
At equilibrium, the divergence of stress is null:
. Consequently, after divergence theorem:
.
The last equality is implicitely based on the representation of external loads as Dirac distributions whose zeros are the so-called contact points: 0-sized surfaces on which the contact forces are applied, located at
in the deformed configuration.
A weighted average of per-body stresses will give the average stress inside the solid phase. There is a simple relation between the stress inside the solid phase and the stress in an equivalent continuum in the absence of fluid pressure. For porosity
, the relation reads:
.
This last relation may not be very useful if porosity is not homogeneous. If it happens, one can define the equivalent bulk stress a the particles scale by assigning a volume to each particle. This volume can be obtained from TesselationWrapper (see e.g. [Catalano2014a])
-
yade._utils.
calm
([(int)mask=-1]) → None¶ Set translational and rotational velocities of bodies to zero. Applied to all bodies by default. To calm only some bodies, use mask parameter, it will calm only bodies with groupMask compatible to given value
-
yade._utils.
coordsAndDisplacements
((int)axis[, (tuple)Aabb=()]) → tuple¶ Return tuple of 2 same-length lists for coordinates and displacements (coordinate minus reference coordinate) along given axis (1st arg); if the Aabb=((x_min,y_min,z_min),(x_max,y_max,z_max)) box is given, only bodies within this box will be considered.
-
yade._utils.
createInteraction
((int)id1, (int)id2) → Interaction¶ Create interaction between given bodies by hand.
Current engines are searched for IGeomDispatcher and IPhysDispatcher (might be both hidden in InteractionLoop). Geometry is created using
force
parameter of the geometry dispatcher, wherefore the interaction will exist even if bodies do not spatially overlap and the functor would returnfalse
under normal circumstances.Warning
This function will very likely behave incorrectly for periodic simulations (though it could be extended it to handle it farily easily).
-
yade._utils.
fabricTensor
([(bool)splitTensor=False[, (bool)revertSign=False[, (float)thresholdForce=nan]]]) → tuple¶ Compute the fabric tensor of the periodic cell. The original paper can be found in [Satake1982].
Parameters: - splitTensor (bool) – split the fabric tensor into two parts related to the strong and weak contact forces respectively.
- revertSign (bool) – it must be set to true if the contact law’s convention takes compressive forces as positive.
- thresholdForce (Real) – if the fabric tensor is split into two parts, a threshold value can be specified otherwise the mean contact force is considered by default. It is worth to note that this value has a sign and the user needs to set it according to the convention adopted for the contact law. To note that this value could be set to zero if one wanted to make distinction between compressive and tensile forces.
-
yade._utils.
flipCell
([(Matrix3)flip=Matrix3(0, 0, 0, 0, 0, 0, 0, 0, 0)]) → Matrix3¶ Flip periodic cell so that angles between
axes and transformed axes are as small as possible. This function relies on the fact that periodic cell defines by repetition or its corners regular grid of points in
; however, all cells generating identical grid are equivalent and can be flipped one over another. This necessiatates adjustment of Interaction.cellDist for interactions that cross boundary and didn’t before (or vice versa), and re-initialization of collider. The flip argument can be used to specify desired flip: integers, each column for one axis; if zero matrix, best fit (minimizing the angles) is computed automatically.
In c++, this function is accessible as
Shop::flipCell
.Warning
This function is currently broken and should not be used.
-
yade._utils.
forcesOnCoordPlane
((float)arg1, (int)arg2) → Vector3¶
-
yade._utils.
forcesOnPlane
((Vector3)planePt, (Vector3)normal) → Vector3¶ Find all interactions deriving from NormShearPhys that cross given plane and sum forces (both normal and shear) on them.
Parameters: - planePt (Vector3) – a point on the plane
- normal (Vector3) – plane normal (will be normalized).
-
yade._utils.
getBodyIdsContacts
([(int)bodyID=0]) → list¶ Get a list of body-ids, which contacts the given body.
-
yade._utils.
getCapillaryStress
([(float)volume=0[, (bool)mindlin=False]]) → Matrix3¶ Compute and return Love-Weber capillary stress tensor:
, where the sum is over all interactions, with
the branch vector (joining centers of the bodies) and
is the capillary force.
can be passed to the function. If it is not, it will be equal to one in non-periodic cases, or equal to the volume of the cell in periodic cases. Only the CapillaryPhys interaction type is supported presently. Using this function with physics MindlinCapillaryPhys needs to pass True as second argument.
-
yade._utils.
getDepthProfiles
((float)volume, (int)nCell, (float)dz, (float)zRef, (bool)activateCond, (float)radiusPy) → tuple¶ Compute and return the particle velocity and solid volume fraction (porosity) depth profile. For each defined cell z, the k component of the average particle velocity reads:
,
where the sum is made over the particles contained in the cell,
is the k component of the velocity associated to particle p, and
is the part of the volume of the particle p contained inside the cell. This definition allows to smooth the averaging, and is equivalent to taking into account the center of the particles only when there is a lot of particles in each cell. As for the solid volume fraction, it is evaluated in the same way: for each defined cell z, it reads:
, where
is the volume of the cell considered, and
is the volume of particle p contained in cell z. This function gives depth profiles of average velocity and solid volume fraction, returning the average quantities in each cell of height dz, from the reference horizontal plane at elevation zRef (input parameter) until the plane of elevation zRef+nCell*dz (input parameters). If the argument activateCond is set to true, do the average only on particles of radius equal to radiusPy (input parameter)
-
yade._utils.
getSpheresMass
([(int)mask=-1]) → float¶ Compute the total mass of spheres in the simulation (might crash for now if dynamic bodies are not spheres), mask parameter is considered
-
yade._utils.
getSpheresVolume
([(int)mask=-1]) → float¶ Compute the total volume of spheres in the simulation (might crash for now if dynamic bodies are not spheres), mask parameter is considered
-
yade._utils.
getSpheresVolume2D
([(int)mask=-1]) → float¶ Compute the total volume of discs in the simulation (might crash for now if dynamic bodies are not discs), mask parameter is considered
-
yade._utils.
getStress
([(float)volume=0]) → Matrix3¶ Compute and return Love-Weber stress tensor:
, where the sum is over all interactions, with
the contact force and
the branch vector (joining centers of the bodies). Stress is negativ for repulsive contact forces, i.e. compression.
can be passed to the function. If it is not, it will be equal to the volume of the cell in periodic cases, or to the one deduced from utils.aabbDim() in non-periodic cases.
-
yade._utils.
getStressAndTangent
([(float)volume=0[, (bool)symmetry=True]]) → tuple¶ Compute overall stress of periodic cell using the same equation as function getStress. In addition, the tangent operator is calculated using the equation published in [Kruyt and Rothenburg1998]_:
Parameters: - volume (float) – same as in function getStress
- symmetry (bool) – make the tensors symmetric.
Returns: macroscopic stress tensor and tangent operator as py::tuple
-
yade._utils.
getStressProfile
((float)volume, (int)nCell, (float)dz, (float)zRef, (object)vPartAverageX, (object)vPartAverageY, (object)vPartAverageZ) → tuple¶ Compute and return the stress tensor depth profile, including the contribution from Love-Weber stress tensor and the dynamic stress tensor taking into account the effect of particles inertia. For each defined cell z, the stress tensor reads:
,
where the first sum is made over the contacts which are contained or cross the cell z, f^c is the contact force from particle 1 to particle 2, and l^{c,z} is the part of the branch vector from particle 2 to particle 1, contained in the cell. The second sum is made over the particles, and u’^p is the velocity fluctuations of the particle p with respect to the spatial averaged particle velocity at this point (given as input parameters). The expression of the stress tensor is the same as the one given in getStress plus the inertial contribution. Apart from that, the main difference with getStress stands in the fact that it gives a depth profile of stress tensor, i.e. from the reference horizontal plane at elevation zRef (input parameter) until the plane of elevation zRef+nCell*dz (input parameters), it is computing the stress tensor for each cell of height dz. For the love-Weber stress contribution, the branch vector taken into account in the calculations is only the part of the branch vector contained in the cell considered. To validate the formulation, it has been checked that activating only the Love-Weber stress tensor, and suming all the contributions at the different altitude, we recover the same stress tensor as when using getStress. For my own use, I have troubles with strong overlap between fixed object, so that I made a condition to exclude the contribution to the stress tensor of the fixed objects, this can be desactivated easily if needed (and should be desactivated for the comparison with getStress).
-
yade._utils.
getViscoelasticFromSpheresInteraction
((float)tc, (float)en, (float)es) → dict¶ Attention! The function is deprecated! Compute viscoelastic interaction parameters from analytical solution of a pair spheres collision problem:
where
,
are normal elastic and viscous coefficients and
,
shear elastic and viscous coefficients. For details see [Pournin2001].
Parameters: - m (float) – sphere mass
- tc (float) – collision time
- en (float) – normal restitution coefficient
- es (float) – tangential restitution coefficient
Returns: dictionary with keys
kn
(the value of),
cn
(),
kt
(),
ct
().
- m (float) – sphere mass
-
yade._utils.
growParticle
((int)bodyID, (float)multiplier[, (bool)updateMass=True]) → None¶ Change the size of a single sphere (to be implemented: single clump). If updateMass=True, then the mass is updated.
-
yade._utils.
growParticles
((float)multiplier[, (bool)updateMass=True[, (bool)dynamicOnly=True]]) → None¶ Change the size of spheres and sphere clumps by the multiplier. If updateMass=True, then the mass and inertia are updated. dynamicOnly=True will select dynamic bodies.
-
yade._utils.
inscribedCircleCenter
((Vector3)v1, (Vector3)v2, (Vector3)v3) → Vector3¶ Return center of inscribed circle for triangle given by its vertices v1, v2, v3.
-
yade._utils.
interactionAnglesHistogram
((int)axis, (int)mask, (int)bins, (tuple)aabb, (bool)sphSph, (float)minProjLen) → tuple¶
-
yade._utils.
intrsOfEachBody
() → list¶ returns list of lists of interactions of each body
-
yade._utils.
kineticEnergy
([(bool)findMaxId=False]) → object¶ Compute overall kinetic energy of the simulation as
For aspherical bodies, the inertia tensor
is transformed to global frame, before multiplied by
, therefore the value should be accurate.
-
yade._utils.
maxOverlapRatio
() → float¶ Return maximum overlap ration in interactions (with ScGeom) of two spheres. The ratio is computed as
, where
is the current overlap distance and
,
are radii of the two spheres in contact.
-
yade._utils.
momentum
() → Vector3¶ TODO
-
yade._utils.
negPosExtremeIds
((int)axis, (float)distFactor) → tuple¶ Return list of ids for spheres (only) that are on extremal ends of the specimen along given axis; distFactor multiplies their radius so that sphere that do not touch the boundary coordinate can also be returned.
-
yade._utils.
normalShearStressTensors
([(bool)compressionPositive=False[, (bool)splitNormalTensor=False[, (float)thresholdForce=nan]]]) → tuple¶ Compute overall stress tensor of the periodic cell decomposed in 2 parts, one contributed by normal forces, the other by shear forces. The formulation can be found in [Thornton2000], eq. (3):
where
is the cell volume,
is “contact radius” (in our implementation, current distance between particle centroids),
is the normal vector,
is a vector perpendicular to
,
and
are norms of normal and shear forces.
Parameters: - splitNormalTensor (bool) – if true the function returns normal stress tensor split into two parts according to the two subnetworks of strong an weak forces.
- thresholdForce (Real) – threshold value according to which the normal stress tensor can be split (e.g. a zero value would make distinction between tensile and compressive forces).
-
yade._utils.
numIntrsOfEachBody
() → list¶ returns list of number of interactions of each body
-
yade._utils.
pointInsidePolygon
((tuple)arg1, (object)arg2) → bool¶
-
yade._utils.
porosity
([(float)volume=-1]) → float¶ Compute packing porosity
where
is overall volume and
is volume of spheres.
Parameters: volume (float) – overall volume . For periodic simulations, current volume of the Cell is used. For aperiodic simulations, the value deduced from utils.aabbDim() is used. For compatibility reasons, positive values passed by the user are also accepted in this case.
-
yade._utils.
ptInAABB
((Vector3)arg1, (Vector3)arg2, (Vector3)arg3) → bool¶ Return True/False whether the point p is within box given by its min and max corners
-
yade._utils.
scalarOnColorScale
((float)arg1, (float)arg2, (float)arg3) → Vector3¶
-
yade._utils.
setContactFriction
((float)angleRad) → None¶ Modify the friction angle (in radians) inside the material classes and existing contacts. The friction for non-dynamic bodies is not modified.
-
yade._utils.
setNewVerticesOfFacet
((Body)b, (Vector3)v1, (Vector3)v2, (Vector3)v3) → None¶ Sets new vertices (in global coordinates) to given facet.
-
yade._utils.
setRefSe3
() → None¶ Set reference positions and orientations of all bodies equal to their current positions and orientations.
-
yade._utils.
shiftBodies
((list)ids, (Vector3)shift) → float¶ Shifts bodies listed in ids without updating their velocities.
-
yade._utils.
spiralProject
((Vector3)pt, (float)dH_dTheta[, (int)axis=2[, (float)periodStart=nan[, (float)theta0=0]]]) → tuple¶
-
yade._utils.
sumFacetNormalForces
((object)ids[, (int)axis=-1]) → float¶ Sum force magnitudes on given bodies (must have shape of the Facet type), considering only part of forces perpendicular to each facet’s face; if axis has positive value, then the specified axis (0=x, 1=y, 2=z) will be used instead of facet’s normals.
-
yade._utils.
sumForces
((list)ids, (Vector3)direction) → float¶ Return summary force on bodies with given ids, projected on the direction vector.
-
yade._utils.
sumTorques
((list)ids, (Vector3)axis, (Vector3)axisPt) → float¶ Sum forces and torques on bodies given in ids with respect to axis specified by a point axisPt and its direction axis.
-
yade._utils.
totalForceInVolume
() → tuple¶ Return summed forces on all interactions and average isotropic stiffness, as tuple (Vector3,float)
-
yade._utils.
unbalancedForce
([(bool)useMaxForce=False]) → float¶ Compute the ratio of mean (or maximum, if useMaxForce) summary force on bodies and mean force magnitude on interactions. For perfectly static equilibrium, summary force on all bodies is zero (since forces from interactions cancel out and induce no acceleration of particles); this ratio will tend to zero as simulation stabilizes, though zero is never reached because of finite precision computation. Sufficiently small value can be e.g. 1e-2 or smaller, depending on how much equilibrium it should be.
-
yade._utils.
voidratio2D
([(float)zlen=1]) → float¶ Compute 2D packing void ratio
where
is overall volume and
is volume of disks.
Parameters: zlen (float) – length in the third direction.
-
yade._utils.
voxelPorosity
([(int)resolution=200[, (Vector3)start=Vector3(0, 0, 0)[, (Vector3)end=Vector3(0, 0, 0)]]]) → float¶ Compute packing porosity
where
is a specified volume (from start to end) and
is volume of voxels that fall inside any sphere. The calculation method is to divide whole volume into a dense grid of voxels (at given resolution), and count the voxels that fall inside any of the spheres. This method allows one to calculate porosity in any given sub-volume of a whole sample. It is properly excluding part of a sphere that does not fall inside a specified volume.
Parameters: - resolution (int) – voxel grid resolution, values bigger than resolution=1600 require a 64 bit operating system, because more than 4GB of RAM is used, a resolution=800 will use 500MB of RAM.
- start (Vector3) – start corner of the volume.
- end (Vector3) – end corner of the volume.
-
yade._utils.
wireAll
() → None¶ Set Shape::wire on all bodies to True, rendering them with wireframe only.
-
yade._utils.
wireNoSpheres
() → None¶ Set Shape::wire to True on non-spherical bodies (Facets, Walls).
-
yade._utils.
wireNone
() → None¶ Set Shape::wire on all bodies to False, rendering them as solids.