yade-dev team mailing list archive
-
yade-dev team
-
Mailing list archive
-
Message #12615
[Branch ~yade-pkg/yade/git-trunk] Rev 3841: fabricTensor() now ok for non-periodic simulations. revertSign attribute removed as well
------------------------------------------------------------
revno: 3841
committer: jduriez <jerome.duriez@xxxxxxxxxxx>
timestamp: Wed 2016-04-13 16:33:31 -0600
message:
fabricTensor() now ok for non-periodic simulations. revertSign attribute removed as well
modified:
pkg/dem/Shop.hpp
pkg/dem/Shop_02.cpp
py/FEMxDEM/simDEM.py
py/_utils.cpp
py/_utils.hpp
--
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-07-20 17:52:39 +0000
+++ pkg/dem/Shop.hpp 2016-04-13 22:33:31 +0000
@@ -133,8 +133,8 @@
static py::tuple normalShearStressTensors(bool compressionPositive=false, bool splitNormalTensor=false, Real thresholdForce=NaN);
//! Function to compute fabric tensor of periodic cell
- static void fabricTensor(Real& Fmean, Matrix3r& fabric, Matrix3r& fabricStrong, Matrix3r& fabricWeak, bool splitTensor=false, bool revertSign=false, Real thresholdForce=NaN);
- static py::tuple fabricTensor(bool splitTensor=false, bool revertSign=false, Real thresholdForce=NaN);
+ static void fabricTensor(Real& Fmean, Matrix3r& fabric, Matrix3r& fabricStrong, Matrix3r& fabricWeak, bool splitTensor=false, Real thresholdForce=NaN);
+ static py::tuple fabricTensor(bool splitTensor=false, Real thresholdForce=NaN);
//! Function to set translational and rotational velocities of all bodies to zero
static void calm(const shared_ptr<Scene>& rb=shared_ptr<Scene>(), int mask=-1);
=== modified file 'pkg/dem/Shop_02.cpp'
--- pkg/dem/Shop_02.cpp 2016-04-12 04:37:00 +0000
+++ pkg/dem/Shop_02.cpp 2016-04-13 22:33:31 +0000
@@ -225,7 +225,7 @@
// *** Normal stress tensor split into two parts according to subnetworks of strong and weak forces (or other distinction if a threshold value for the force is assigned) ***/
Real Fmean(0); Matrix3r f, fs, fw;
- fabricTensor(Fmean,f,fs,fw,false,compressionPositive,NaN);
+ fabricTensor(Fmean,f,fs,fw,false,NaN);
Matrix3r sigNStrong(Matrix3r::Zero()), sigNWeak(Matrix3r::Zero());
FOREACH(const shared_ptr<Interaction>& I, *scene->interactions){
if(!I->isReal()) continue;
@@ -257,15 +257,15 @@
/* Return the fabric tensor as according to [Satake1982]. */
/* as side-effect, set Gl1_NormShear::strongWeakThresholdForce */
-void Shop::fabricTensor(Real& Fmean, Matrix3r& fabric, Matrix3r& fabricStrong, Matrix3r& fabricWeak, bool splitTensor, bool revertSign, Real thresholdForce){
+void Shop::fabricTensor(Real& Fmean, Matrix3r& fabric, Matrix3r& fabricStrong, Matrix3r& fabricWeak, bool splitTensor, Real thresholdForce){
Scene* scene=Omega::instance().getScene().get();
- if (!scene->isPeriodic){ throw runtime_error("Can't compute fabric tensor of periodic cell in aperiodic simulation."); }
-
+
// *** Fabric tensor ***/
fabric=Matrix3r::Zero();
int count=0; // number of interactions
FOREACH(const shared_ptr<Interaction>& I, *scene->interactions){
if(!I->isReal()) continue;
+ if( !dynamic_cast<Sphere*>(Body::byId(I->getId1(),scene)->shape.get()) || !dynamic_cast<Sphere*>(Body::byId(I->getId2(),scene)->shape.get()) ) continue; // test intended to disregard boundary interactions (in non-periodic simulations)
GenericSpheresContact* geom=YADE_CAST<GenericSpheresContact*>(I->geom.get());
const Vector3r& n=geom->normal;
for(int i=0; i<3; i++) for(int j=i; j<3; j++){
@@ -285,8 +285,7 @@
GenericSpheresContact* geom=YADE_CAST<GenericSpheresContact*>(I->geom.get());
NormShearPhys* phys=YADE_CAST<NormShearPhys*>(I->phys.get());
const Vector3r& n=geom->normal;
- Real f=(revertSign?-1:1)*phys->normalForce.dot(n);
- //Real f=phys->normalForce.norm();
+ Real f=-phys->normalForce.dot(n); // will be < 0 in compression
Fmean+=f;
}
Fmean/=count;
@@ -307,10 +306,10 @@
GenericSpheresContact* geom=YADE_CAST<GenericSpheresContact*>(I->geom.get());
NormShearPhys* phys=YADE_CAST<NormShearPhys*>(I->phys.get());
const Vector3r& n=geom->normal;
- Real f=(revertSign?-1:1)*phys->normalForce.dot(n);
+ Real f=-phys->normalForce.dot(n);
// slipt the tensor according to the mean contact force or a threshold value if this is given
Real Fsplit=(!std::isnan(thresholdForce))?thresholdForce:Fmean;
- if (revertSign?(f<Fsplit):(f>Fsplit)){ // reminder: forces are compared with their sign
+ if (f<Fsplit){ // strong contact network is defined from contacts with the greatest compressive forces
for(int i=0; i<3; i++) for(int j=i; j<3; j++){
fabricStrong(i,j)+=n[i]*n[j];
}
@@ -338,9 +337,9 @@
}
}
-py::tuple Shop::fabricTensor(bool splitTensor, bool revertSign, Real thresholdForce){
+py::tuple Shop::fabricTensor(bool splitTensor, Real thresholdForce){
Real Fmean; Matrix3r fabric, fabricStrong, fabricWeak;
- fabricTensor(Fmean,fabric,fabricStrong,fabricWeak,splitTensor,revertSign,thresholdForce);
+ fabricTensor(Fmean,fabric,fabricStrong,fabricWeak,splitTensor,thresholdForce);
// returns fabric tensor or alternatively the two distinct contributions according to strong and weak subnetworks (or, if thresholdForce is specified, the distinction is made according to that value and not the mean one)
if (!splitTensor){return py::make_tuple(fabric);}
else{return py::make_tuple(fabricStrong,fabricWeak);}
=== modified file 'py/FEMxDEM/simDEM.py'
--- py/FEMxDEM/simDEM.py 2015-03-03 19:06:49 +0000
+++ py/FEMxDEM/simDEM.py 2016-04-13 22:33:31 +0000
@@ -72,12 +72,12 @@
# get contact normal based fabric tensor
def getFabric2D(scene):
Omega().stringToScene(scene)
- f = utils.fabricTensor(splitTensor=False,revertSign=False)[0]
+ f = utils.fabricTensor(splitTensor=False)[0]
return [[f[0,0],f[0,1]],[f[1,0],f[1,1]]]
def getFabric3D(scene):
Omega().stringToScene(scene)
- f = utils.fabricTensor(splitTensor=False,revertSign=False)[0]
+ f = utils.fabricTensor(splitTensor=False)[0]
return [[f[0,0],f[0,1],f[0,2]],[f[1,0],f[1,1],f[1,2]],[f[2,0],f[2,1],f[2,2]]]
""" # Used for clumped particle model only
=== modified file 'py/_utils.cpp'
--- py/_utils.cpp 2016-04-12 09:29:08 +0000
+++ py/_utils.cpp 2016-04-13 22:33:31 +0000
@@ -345,7 +345,7 @@
Real Shop__getVoxelPorosity(int resolution, Vector3r start,Vector3r end){ return Shop::getVoxelPorosity(Omega::instance().getScene(),resolution,start,end); }
//Matrix3r Shop__stressTensorOfPeriodicCell(bool smallStrains=false){return Shop::stressTensorOfPeriodicCell(smallStrains);}
-py::tuple Shop__fabricTensor(bool splitTensor, bool revertSign, Real thresholdForce){return Shop::fabricTensor(splitTensor,revertSign,thresholdForce);}
+py::tuple Shop__fabricTensor(bool splitTensor, Real thresholdForce){return Shop::fabricTensor(splitTensor,thresholdForce);}
py::tuple Shop__normalShearStressTensors(bool compressionPositive, bool splitNormalTensor, Real thresholdForce){return Shop::normalShearStressTensors(compressionPositive,splitNormalTensor,thresholdForce);}
py::list Shop__getStressLWForEachBody(){return Shop::getStressLWForEachBody();}
@@ -493,7 +493,7 @@
py::def("getViscoelasticFromSpheresInteraction",getViscoelasticFromSpheresInteraction,(py::arg("tc"),py::arg("en"),py::arg("es")),"Attention! The function is deprecated! Compute viscoelastic interaction parameters from analytical solution of a pair spheres collision problem:\n\n.. math:: k_n=\\frac{m}{t_c^2}\\left(\\pi^2+(\\ln e_n)^2\\right) \\\\ c_n=-\\frac{2m}{t_c}\\ln e_n \\\\ k_t=\\frac{2}{7}\\frac{m}{t_c^2}\\left(\\pi^2+(\\ln e_t)^2\\right) \\\\ c_t=-\\frac{2}{7}\\frac{m}{t_c}\\ln e_t \n\n\nwhere $k_n$, $c_n$ are normal elastic and viscous coefficients and $k_t$, $c_t$ shear elastic and viscous coefficients. For details see [Pournin2001]_.\n\n:param float m: sphere mass $m$\n:param float tc: collision time $t_c$\n:param float en: normal restitution coefficient $e_n$\n:param float es: tangential restitution coefficient $e_s$\n:return: dictionary with keys ``kn`` (the value of $k_n$), ``cn`` ($c_n$), ``kt`` ($k_t$), ``ct`` ($c_t$).");
py::def("stressTensorOfPeriodicCell",Shop::getStress,(py::args("volume")=0),"Deprecated, use utils.getStress instead |ydeprecated|");
py::def("normalShearStressTensors",Shop__normalShearStressTensors,(py::args("compressionPositive")=false,py::args("splitNormalTensor")=false,py::args("thresholdForce")=NaN),"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):\n\n.. math:: \\tens{\\sigma}_{ij}=\\frac{2}{V}\\sum R N \\vec{n}_i \\vec{n}_j+\\frac{2}{V}\\sum R T \\vec{n}_i\\vec{t}_j\n\nwhere $V$ is the cell volume, $R$ is \"contact radius\" (in our implementation, current distance between particle centroids), $\\vec{n}$ is the normal vector, $\\vec{t}$ is a vector perpendicular to $\\vec{n}$, $N$ and $T$ are norms of normal and shear forces.\n\n:param bool splitNormalTensor: if true the function returns normal stress tensor split into two parts according to the two subnetworks of strong an weak forces.\n\n:param Real thresholdForce: 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).");
- py::def("fabricTensor",Shop__fabricTensor,(py::args("splitTensor")=false,py::args("revertSign")=false,py::args("thresholdForce")=NaN),"Compute the fabric tensor of the periodic cell. The original paper can be found in [Satake1982]_.\n\n:param bool splitTensor: split the fabric tensor into two parts related to the strong and weak contact forces respectively.\n\n:param bool revertSign: it must be set to true if the contact law's convention takes compressive forces as positive.\n\n:param Real thresholdForce: 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.");
+ py::def("fabricTensor",Shop__fabricTensor,(py::args("splitTensor")=false,py::args("thresholdForce")=NaN),"Computes the fabric tensor $F_{ij}=\\frac{1}{n_c}\\sum_c n_i n_j$ [Satake1982]_, for all sphere-sphere interactions $c$.\n\n:param bool splitTensor: split the fabric tensor into two parts related to the strong (greatest compressive normal forces) and weak contact forces respectively.\n\n:param Real thresholdForce: if the fabric tensor is split into two parts, a threshold value can be specified otherwise the mean contact force is considered by default. Use negative signed values for compressive states. To note that this value could be set to zero if one wanted to make distinction between compressive and tensile forces.");
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)." );
=== modified file 'py/_utils.hpp'
--- py/_utils.hpp 2016-04-12 09:29:08 +0000
+++ py/_utils.hpp 2016-04-13 22:33:31 +0000
@@ -126,7 +126,7 @@
Real Shop__getVoxelPorosity(int resolution=200, Vector3r start=Vector3r(0,0,0),Vector3r end=Vector3r(0,0,0));
//Matrix3r Shop__stressTensorOfPeriodicCell(bool smallStrains=false){return Shop::stressTensorOfPeriodicCell(smallStrains);}
-py::tuple Shop__fabricTensor(bool splitTensor=false, bool revertSign=false, Real thresholdForce=NaN);
+py::tuple Shop__fabricTensor(bool splitTensor=false, Real thresholdForce=NaN);
py::tuple Shop__normalShearStressTensors(bool compressionPositive=false, bool splitNormalTensor=false, Real thresholdForce=NaN);
py::list Shop__getStressLWForEachBody();