tfix porosity calculation issues - sphere - GPU-based 3D discrete element method algorithm with optional fluid coupling
(HTM) git clone git://src.adamsgaard.dk/sphere
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) LICENSE
---
(DIR) commit e0f260ff9f6013a354742bb5dc29b2f8ae828d73
(DIR) parent 50d5be318df999c94c24af66b8ccf23b57d3d8e5
(HTM) Author: Anders Damsgaard <anders.damsgaard@geo.au.dk>
Date: Wed, 5 Nov 2014 15:42:40 +0100
fix porosity calculation issues
Diffstat:
M python/sphere.py | 37 ++++++++++++++++++-------------
M tests/porosity_tests.py | 2 +-
2 files changed, 23 insertions(+), 16 deletions(-)
---
(DIR) diff --git a/python/sphere.py b/python/sphere.py
t@@ -3627,29 +3627,36 @@ class sim:
e = (V_t - V_s)/V_s
return e
- def bulkPorosity(self):
+ def bulkPorosity(self, trim=True):
'''
- Calculates the bulk porosity in the smallest axis-parallel cube.
+ Calculates the bulk porosity of the particle assemblage.
+
+ :param trim: Trim the total volume to the smallest axis-parallel cube
+ containing all particles.
+ :type trim: bool
:returns: The bulk porosity, in [0:1]
:return type: float
'''
- min_x = numpy.min(self.x[:,0] - self.radius)
- min_y = numpy.min(self.x[:,1] - self.radius)
- min_z = numpy.min(self.x[:,2] - self.radius)
- max_x = numpy.max(self.x[:,0] + self.radius)
- max_y = numpy.max(self.x[:,1] + self.radius)
- max_z = numpy.max(self.x[:,2] + self.radius)
+ V_total = 0.0
+ if trim:
+ min_x = numpy.min(self.x[:,0] - self.radius)
+ min_y = numpy.min(self.x[:,1] - self.radius)
+ min_z = numpy.min(self.x[:,2] - self.radius)
+ max_x = numpy.max(self.x[:,0] + self.radius)
+ max_y = numpy.max(self.x[:,1] + self.radius)
+ max_z = numpy.max(self.x[:,2] + self.radius)
+ V_total = (max_x - min_x)*(max_y - min_y)*(max_z - min_z)
- #if (self.nw == 0):
- #V_total = self.L[0] * self.L[1] * self.L[2]
- #elif (self.nw == 1):
- #V_total = self.L[0] * self.L[1] * self.w_x[0]
- #if (V_total <= 0.0):
- #raise Exception("Could not determine total volume")
+ else:
+ if (self.nw == 0):
+ V_total = self.L[0] * self.L[1] * self.L[2]
+ elif (self.nw == 1):
+ V_total = self.L[0] * self.L[1] * self.w_x[0]
+ if (V_total <= 0.0):
+ raise Exception("Could not determine total volume")
- V_total = (max_x - min_x)*(max_y - min_y)*(max_z - min_z)
# Find the volume of solids
V_solid = numpy.sum(V_sphere(self.radius))
(DIR) diff --git a/tests/porosity_tests.py b/tests/porosity_tests.py
t@@ -23,7 +23,7 @@ def testPorosities(sim):
for slices in slicevals:
# Find correct value of bulk porosity
- n_bulk = sim.bulkPorosity()
+ n_bulk = sim.bulkPorosity(trim=False)
#print("Bulk: " + str(n_bulk))
porosity = sim.porosity(slices = slices)[0]