Porosity of a particles inside the container

Asked by Lassakorn Eawsakul

Hi everyone I'm very new to this program and I have a problem for adding porosity calculation function into my code I'm trying to let the cloud of spheres particles fall down in to a cylinder by gravity and find the void ration inside the container, do you guys have any idea what should i do to my code
##################################
# gravity deposition in box, showing how to plot and save history of data,
# and how to control the simulation while it is running by calling
# python functions from within the simulation loop

# import yade modules that we will use below
from yade import pack, plot

# create cylinder box from facets
O.bodies.append(yade.geom.facetCylinder((0,0,0),radius=5.08,height=5.08,segmentsNumber=40,wallMask=6))

# create empty sphere packing
# sphere packing is not equivalent to particles in simulation, it contains only the pure geometry
sp = pack.SpherePack()
# generate randomly spheres with uniform radius distribution
sp.makeCloud((-8, -8, 8, (8, 8, 20), rMean=0.9, rRelFuzz=0)
# add the sphere pack to the simulation
sp.toSimulation()

O.engines = [
        ForceResetter(),
        InsertionSortCollider([Bo1_Sphere_Aabb(), Bo1_Facet_Aabb()]),
        InteractionLoop(
                # handle sphere+sphere and facet+sphere collisions
                [Ig2_Sphere_Sphere_ScGeom(), Ig2_Facet_Sphere_ScGeom()],
                [Ip2_FrictMat_FrictMat_FrictPhys()],
                [Law2_ScGeom_FrictPhys_CundallStrack()]
        ),
        NewtonIntegrator(gravity=(0, 0, -9.81), damping=0.4),
        # call the checkUnbalanced function (defined below) every 2 seconds
        PyRunner(command='checkUnbalanced()', realPeriod=2),
        # call the addPlotData function every 200 steps
        PyRunner(command='addPlotData()', iterPeriod=100)
]
O.dt = .5 * PWaveTimeStep()

# enable energy tracking; any simulation parts supporting it
# can create and update arbitrary energy types, which can be
# accessed as O.energy['energyName'] subsequently
O.trackEnergy = True

# if the unbalanced forces goes below .05, the packing
# is considered stabilized, therefore we stop collected
# data history and stop
def checkUnbalanced():
 if unbalancedForce() < .05:
  O.pause()
  plot.saveDataTxt('bbb.txt.bz2')
  # plot.saveGnuplot('bbb') is also possible

# collect history of data which will be plotted
def addPlotData():
 # each item is given a names, by which it can be the unsed in plot.plots
 # the **O.energy converts dictionary-like O.energy to plot.addData arguments
 plot.addData(i=O.iter, unbalanced=unbalancedForce(), **O.energy)

# define how to plot data: 'i' (step number) on the x-axis, unbalanced force
# on the left y-axis, all energies on the right y-axis
# (O.energy.keys is function which will be called to get all defined energies)
# None separates left and right y-axis
plot.plots = {'i': ('unbalanced', None, O.energy.keys)}

# show the plot on the screen, and update while the simulation runs
plot.plot()

O.saveTmp()

Question information

Language:
English Edit question
Status:
Answered
For:
Yade Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Vasileios Angelidakis (vsangelidakis) said :
#1

Hi Lassakorn,

> I'm very new to this program
Welcome :)

You can calculate the volume of all the spheres in your model using: Vs=getSpheresVolume()
Calculate the volume of your cylinder as: Vtot=height*(pi*radius**2)
and then calculate porosity as: n=(Vtot-Vs)/Vtot

If not the whole container is not filled, you might want to adjust "height" to your filling height, to get a more meaningful measurement.

Hope this helps, Vasileios

PS: There is a built-in function porosity(), but it only works considering the bounding box of all the spheres in your model, and not a cylinder.

Can you help with this problem?

Provide an answer of your own, or ask Lassakorn Eawsakul for more information if necessary.

To post a message you must log in.