← Back to team overview

yade-dev team mailing list archive

[Branch ~yade-dev/yade/trunk] Rev 2393: 1. Add script demonstrating mass-based and size-based particle size distributions (PSD) and how t...

 

------------------------------------------------------------
revno: 2393
committer: Václav Šmilauer <eudoxos@xxxxxxxx>
branch nick: trunk
timestamp: Fri 2010-08-13 17:38:13 +0200
message:
  1. Add script demonstrating mass-based and size-based particle size distributions (PSD) and how to specify and arbitrary function for PSD when generating random loose packing with SpherePack.makeCloud
added:
  scripts/test/psd.py


--
lp:yade
https://code.launchpad.net/~yade-dev/yade/trunk

Your team Yade developers is subscribed to branch lp:yade.
To unsubscribe from this branch go to https://code.launchpad.net/~yade-dev/yade/trunk/+edit-subscription
=== added file 'scripts/test/psd.py'
--- scripts/test/psd.py	1970-01-01 00:00:00 +0000
+++ scripts/test/psd.py	2010-08-13 15:38:13 +0000
@@ -0,0 +1,32 @@
+# encoding: utf-8
+#
+# demonstrate how to generate sphere packing based on arbitrary PSD (particle size distribution)
+# show the difference between size-based and mass-based (≡ volume-based in our case) PSD
+#
+import matplotlib; matplotlib.rc('axes',grid=True)
+from yade import pack
+import pylab
+# PSD given as points of piecewise-linear function
+psdSizes,psdCumm=[.02,.04,.06,.08,.1],[0.,.1,.7,.9,1.]
+pylab.plot(psdSizes,psdCumm,label='precribed mass PSD')
+sp1=pack.SpherePack(); sp1.psdScaleExponent=2 # this exponent is somewhat empirical, see docs of SpherePack
+sp1.makeCloud((0,0,0),(1,1,1),psdSizes=psdSizes,psdCumm=psdCumm,distributeMass=True)
+pylab.plot(*sp1.psd(bins=30,mass=True),label='Mass PSD of %d random spheres'%len(sp1))
+pylab.plot(*sp1.psd(bins=30,mass=False),label='Size PSD of %d andom spheres'%len(sp1))
+pylab.legend()
+
+# uniform distribution of size (sp2) and of mass (sp3)
+sp2=pack.SpherePack(); sp2.makeCloud((0,0,0),(1,1,1),rMean=0.03,rRelFuzz=2/3.);
+sp3=pack.SpherePack(); sp3.makeCloud((0,0,0),(1,1,1),rMean=0.03,rRelFuzz=2/3.,distributeMass=True);
+pylab.figure()
+pylab.plot(*(sp2.psd(mass=True)+('g',)+sp3.psd(mass=True)+('r',)))
+pylab.legend(['Mass PSD of size-uniform distribution','Mass PSD of mass-uniform distribution'])
+
+pylab.figure()
+pylab.plot(*(sp2.psd()+('g',)+sp3.psd()+('r',)))
+pylab.legend(['Size PSD of size-uniform distribution','Size PSD of mass-uniform distribution'])
+pylab.show()
+
+pylab.show()
+
+