Heap of functions that don’t (yet) fit anywhere else.
Devs: please DO NOT ADD more functions here, it is getting too crowded!
Compute the normal damping rate as a function of the normal coefficient of restitution . For
damping rate equals
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 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)
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.
Setup the reader class, read data into memory.
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).
Return dimensions of the axis-aligned bounding box, optionally with relative part cutoff cut away.
Return 2d bounding box for a sequence of 2-tuples.
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.
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.
With skipFree, particles not contributing to stable state of the packing are skipped, following equation (8) given in [Thornton2000]:
Parameters: |
|
---|
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.
Create and chain a MinkCylinder with given parameters. This shape is the Minkowski sum of line and sphere.
Parameters: |
|
---|
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. |
---|
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:
FrictMat(density=1e3,young=1e7,poisson=.3,frictionAngle=.5,label=’defaultMat’)
Cast given object to class deriving from the same yade root class and copy all parameters from given object. Obj should be up in the inheritance tree, otherwise some attributes may not be defined in the new class.
Create facet with given parameters.
Parameters : | |
---|---|
Parameters: |
|
See utils.sphere‘s documentation for meaning of other parameters.
Create arbitrarily-aligned box composed of facets, with given center, extents and orientation. If any of the box dimensions is zero, corresponding facets will not be created. The facets are oriented outwards from the box.
Parameters : |
|
---|---|
Returns : | list of facets forming the box. |
Create arbitrarily-aligned cylinder composed of facets, with given center, radius, height and orientation. Return List of facets forming the cylinder;
Parameters: |
|
---|
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
Load variables from saveVars, which are saved inside the simulation. If mark==None, all save variables are loaded. Otherwise only those with the mark passed.
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: |
|
---|
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.
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.
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). |
---|
Plot histogram with number of interactions per body, optionally cutting away cutoff relative axis-aligned box from specimen margin.
Return random Vector3 with each component in interval 0…1 (uniform distribution)
Assign random colors to Shape::color.
If onlyDynamic is true, only dynamic bodies will have the color changed.
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:
All parameters (default as well as settable) are saved using utils.saveVars('table').
Parameters : |
|
---|---|
Returns: | number of assigned parameters. |
Replaces collider (Collider) engine with the engine supplied. Raises error if no collider is in engines.
Tell whether we are running inside the batch or separately.
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:
>>> from yade import utils
>>> utils.saveVars('mark',a=1,b=2,c=3)
>>> from yade.params.mark 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
>>> utils.loadVars('mark')
and they will be defined in the yade.params.mark module
m*==True, variables will be loaded immediately after saving. That effectively makes **kw available in builtin namespace.
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: |
|
---|---|
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)
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
Get some data about the current packing useful for uniaxial test:
Parameters : |
|
---|---|
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).
Return memory usage data from Linux’s /proc/[pid]/status, line VmData.
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).
Return ready-made wall body.
Parameters : | |
---|---|
Parameters: |
|
See utils.sphere‘s documentation for meaning of other parameters.
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.
Get timestep accoring to the velocity of P-Wave propagation; computed from sphere radii, rigidities and masses.
Return coordinates of box enclosing all bodies
Parameters: |
|
---|---|
Returns: | (lower corner, upper corner) as (Vector3,Vector3) |
Compute area of convex hull when when taking (swept) spheres crossing the plane at coord, perpendicular to axis.
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.
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 return false under normal circumstances.
This function will very likely behave incorrectly for periodic simulations (though it could be extended it to handle it farily easily).
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.
This function is currently broken and should not be used.
Find all interactions deriving from NormShearPhys that cross given plane and sum forces (both normal and shear) on them.
Parameters: |
|
---|
Compute the total volume of spheres in the simulation (might crash for now if dynamic bodies are not spheres)
Get viscoelastic interaction parameters from analytical solution of a pair spheres collision problem.
Parameters : |
---|
`m` : float sphere mass `tc` : float collision time `en` : float normal restitution coefficient `es` : float tangential restitution coefficient.
Returns: |
---|
dict with keys:
kn : float normal elastic coefficient computed as:
cn : float normal viscous coefficient computed as:
kt : float tangential elastic coefficient computed as:
ct : float tangential viscous coefficient computed as:
For details see [Pournin2001].
Return center of inscribed circle for triangle given by its vertices v1, v2, v3.
Compute overall kinetic energy of the simulation as
No transformation of inertia tensor (in local frame) is done, although it is multiplied by angular velocity
(in global frame); the value will not be accurate for aspherical particles.
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.
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.
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.
Compute packing porosity where
is overall volume and
is volume of spheres.:param float volume: overall volume which must be specified for aperiodic simulations. For periodic simulations, current volume of the Cell is used.
Return True/False whether the point p is within box given by its min and max corners
Set reference positions and orientations of all bodies equal to their current positions and orientations.
Compute overall (macroscopic) stress of periodic cell using equation published in [Kuhl2001]:
where is volume of the cell,
length of interaction
,
normal force and
shear force. Sumed are values over all interactions
.
and
are projection tensors (see the original publication for more details):
where is unit vector oriented along the interaction (normal) and
is Kronecker’s delta. As
and
are perpendicular (therfore
) we can write
Parameters: | smallStrains (bool) – if false (large strains), real values of volume and interaction lengths are computed. If true, only refLength of interactions and initial volume are computed (can save some time). |
---|---|
Returns: | macroscopic stress tensor as Matrix3 |
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.
Return summary force on bodies with given ids, projected on the direction vector.
Sum forces and torques on bodies given in ids with respect to axis specified by a point axisPt and its direction axis.
Return summed forces on all interactions and average isotropic stiffness, as tuple (Vector3,float)
Compute the ratio of mean (or maximum, if useMaxForce) summary force on bodies and maximum 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.
Set Shape::wire on all bodies to True, rendering them with wireframe only.
Set Shape::wire to True on non-spherical bodies (Facets, Walls).
Set Shape::wire on all bodies to False, rendering them as solids.