yade-dev team mailing list archive
-
yade-dev team
-
Mailing list archive
-
Message #12071
[Branch ~yade-pkg/yade/git-trunk] Rev 3669: Add a function in shop to evaluate average depth profiles
------------------------------------------------------------
revno: 3669
committer: Raphael Maurin <raph_maurin@xxxxxxxxxxx>
timestamp: Thu 2015-06-04 18:50:18 +0200
message:
Add a function in shop to evaluate average depth profiles
of particle velocity (x,y,z components), and solid volume fraction.
modified:
pkg/dem/Shop.hpp
pkg/dem/Shop_02.cpp
py/_utils.cpp
--
lp:yade
https://code.launchpad.net/~yade-pkg/yade/git-trunk
Your team Yade developers is subscribed to branch lp:yade.
To unsubscribe from this branch go to https://code.launchpad.net/~yade-pkg/yade/git-trunk/+edit-subscription
=== modified file 'pkg/dem/Shop.hpp'
--- pkg/dem/Shop.hpp 2015-06-02 08:51:06 +0000
+++ pkg/dem/Shop.hpp 2015-06-04 16:50:18 +0000
@@ -122,8 +122,12 @@
static Matrix3r getCapillaryStress(Real volume=0, bool mindlin=false);
static Matrix3r stressTensorOfPeriodicCell() { LOG_WARN("Shop::stressTensorOfPeriodicCelli is DEPRECATED: use getStress instead"); return Shop::getStress(); }
+ //! Compute the stress tensor in each defined cell, return a stress tensor depth profile
static py::tuple getStressProfile(Real volume, int nCell, Real dz, Real zRef, vector<Real> vPartAverageX, vector<Real> vPartAverageY, vector<Real> vPartAverageZ);
+ //! Compute average depth profile of particle velocity (x,y,z) and solid volume fraction
+ static py::tuple getDepthProfiles(Real vCell, int nCell, Real dz, Real zRef);
+
//! Compute overall ("macroscopic") stress of periodic cell, returning 2 tensors
//! (contribution of normal and shear forces)
static py::tuple normalShearStressTensors(bool compressionPositive=false, bool splitNormalTensor=false, Real thresholdForce=NaN);
=== modified file 'pkg/dem/Shop_02.cpp'
--- pkg/dem/Shop_02.cpp 2015-06-02 08:51:06 +0000
+++ pkg/dem/Shop_02.cpp 2015-06-04 16:50:18 +0000
@@ -480,6 +480,70 @@
}
+py::tuple Shop::getDepthProfiles(Real vCell, int nCell, Real dz, Real zRef){
+ //Initialization
+ int minZ;
+ int maxZ;
+ int numLayer;
+ Real deltaCenter;
+ Real zInf;
+ Real zSup;
+ Real volPart;
+
+ vector<Real> velAverageX(nCell,0.0);
+ vector<Real> velAverageY(nCell,0.0);
+ vector<Real> velAverageZ(nCell,0.0);
+ vector<Real> phiAverage(nCell,0.0);
+
+ //Loop over the particles
+ FOREACH(const shared_ptr<Body>& b, *Omega::instance().getScene()->bodies){
+ shared_ptr<Sphere> s=YADE_PTR_DYN_CAST<Sphere>(b->shape); if(!s) continue;
+ const Real zPos = b->state->pos[2]-zRef;
+ int Np = floor(zPos/dz); //Define the layer number with 0 corresponding to zRef. Let the z position wrt to zero, that way all z altitude are positive. (otherwise problem with volPart evaluation)
+
+ minZ= floor((zPos-s->radius)/dz);
+ maxZ= floor((zPos+s->radius)/dz);
+ deltaCenter = zPos - Np*dz;
+
+ // Loop over the cell in which the particle is contained
+ numLayer = minZ;
+ while (numLayer<=maxZ){
+ if ((numLayer>=0)&&(numLayer<nCell)){ //average under zRef does not interest us, avoid also negative values not compatible with the evaluation of volPart
+ zInf=(numLayer-Np-1)*dz + deltaCenter;
+ zSup=(numLayer-Np)*dz + deltaCenter;
+ if (zInf<-s->radius) zInf = -s->radius;
+ if (zSup>s->radius) zSup = s->radius;
+
+ //Analytical formulation of the volume of a slice of sphere
+ volPart = Mathr::PI*pow(s->radius,2)*(zSup - zInf +(pow(zInf,3)-pow(zSup,3))/(3*pow(s->radius,2)));
+
+ phiAverage[numLayer]+=volPart;
+ velAverageX[numLayer]+=volPart*b->state->vel[0];
+ velAverageY[numLayer]+=volPart*b->state->vel[1];
+ velAverageZ[numLayer]+=volPart*b->state->vel[2];
+ }
+ numLayer+=1;
+ }
+ }
+ //Normalized the weighted velocity by the volume of particles contained inside the cell
+ for(int n=0;n<nCell;n++){
+ if (phiAverage[n]!=0){
+ velAverageX[n]/=phiAverage[n];
+ velAverageY[n]/=phiAverage[n];
+ velAverageZ[n]/=phiAverage[n];
+ //Normalize the concentration after
+ phiAverage[n]/=vCell;
+ }
+ else {
+ velAverageX[n] = 0.0;
+ velAverageY[n] = 0.0;
+ velAverageZ[n] = 0.0;
+ }
+ }
+ return py::make_tuple(phiAverage,velAverageX,velAverageY,velAverageZ);
+}
+
+
Matrix3r Shop::getCapillaryStress(Real volume, bool mindlin){
Scene* scene=Omega::instance().getScene().get();
=== modified file 'py/_utils.cpp'
--- py/_utils.cpp 2015-05-19 19:03:44 +0000
+++ py/_utils.cpp 2015-06-04 16:50:18 +0000
@@ -459,6 +459,7 @@
py::def("bodyStressTensors",Shop__getStressLWForEachBody,"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).\n\nProof: \n\nFirst, we remark the identity: $\\sigma_{ij}=\\delta_{ik}\\sigma_{kj}=x_{i,k}\\sigma_{kj}=(x_{i}\\sigma_{kj})_{,k}-x_{i}\\sigma_{kj,k}$.\n\nAt equilibrium, the divergence of stress is null: $\\sigma_{kj,k}=\\vec{0}$. Consequently, after divergence theorem: $\\frac{1}{V}\\int_V \\sigma_{ij}dV = \\frac{1}{V}\\int_V (x_{i}\\sigma_{kj})_{,k}dV = \\frac{1}{V}\\int_{\\partial V}x_i\\sigma_{kj}n_kdS = \\frac{1}{V}\\sum_bx_i^bf_j^b$.\n\nThe 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 $x_i$ in the deformed configuration.\n\nA 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 $n$, the relation reads: $\\sigma_{ij}^{equ.}=(1-n)\\sigma_{ij}^{solid}$.\n\nThis 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 :yref:`TesselationWrapper` (see e.g. [Catalano2014a]_)");
py::def("getStress",Shop::getStress,(py::args("volume")=0),"Compute and return Love-Weber stress tensor:\n\n $\\sigma_{ij}=\\frac{1}{V}\\sum_b f_i^b l_j^b$, where the sum is over all interactions, with $f$ the contact force and $l$ the branch vector (joining centers of the bodies). Stress is negativ for repulsive contact forces, i.e. compression. $V$ 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.");
py::def("getStressProfile",Shop::getStressProfile,(py::args("volume"),py::args("nCell"),py::args("dz"),py::args("zRef"),py::args("vPartAverageX"),py::args("vPartAverageY"),py::args("vPartAverageZ")),"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: \n\n $\\sigma_{ij}^z= \\frac{1}{V}\\sum_c f_i^c l_j^{c,z} - \\frac{1}{V}\\sum_p m^p u'^p_i u'^p_j$,\n\n 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.\n 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)." );
+ py::def("getDepthProfiles",Shop::getDepthProfiles,(py::args("volume"),py::args("nCell"),py::args("dz"),py::args("zRef")),"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: \n\n $<v_k>^z= \\sum_p V^p v_k^p/\\sum_p V^p$,\n\n where the sum is made over the particles contained in the cell, $v_k^p$ is the k component of the velocity associated to particle p, and $V^p$ 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: \n\n $<\\phi>^z= \\frac{1}{V_{cell}}\\sum_p V^p$, where $V_{cell}$ is the volume of the cell considered, and $V^p$ is the volume of particle p contained in cell z.\n 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)." );
py::def("getCapillaryStress",Shop::getCapillaryStress,(py::args("volume")=0,py::args("mindlin")=false),"Compute and return Love-Weber capillary stress tensor:\n\n $\\sigma^{cap}_{ij}=\\frac{1}{V}\\sum_b l_i^b f^{cap,b}_j$, where the sum is over all interactions, with $l$ the branch vector (joining centers of the bodies) and $f^{cap}$ is the capillary force. $V$ 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.");
py::def("getBodyIdsContacts",Shop__getBodyIdsContacts,(py::args("bodyID")=0),"Get a list of body-ids, which contacts the given body.");
py::def("maxOverlapRatio",maxOverlapRatio,"Return maximum overlap ration in interactions (with :yref:`ScGeom`) of two :yref:`spheres<Sphere>`. The ratio is computed as $\\frac{u_N}{2(r_1 r_2)/r_1+r_2}$, where $u_N$ is the current overlap distance and $r_1$, $r_2$ are radii of the two spheres in contact.");