tadd functions to calculate coordination numbers - sphere - GPU-based 3D discre… | |
git clone git://src.adamsgaard.dk/sphere | |
Log | |
Files | |
Refs | |
LICENSE | |
--- | |
commit 718127d5b6ce77aaade7ce88291cfbaad35dc1a0 | |
parent 5d2500342b74ad102c08fcea14092dcea82d466e | |
Author: Anders Damsgaard <[email protected]> | |
Date: Fri, 20 Feb 2015 15:50:50 +0100 | |
add functions to calculate coordination numbers | |
Diffstat: | |
M python/sphere.py | 21 +++++++++++++++++++++ | |
1 file changed, 21 insertions(+), 0 deletions(-) | |
--- | |
diff --git a/python/sphere.py b/python/sphere.py | |
t@@ -4453,6 +4453,27 @@ class sim: | |
dtype=numpy.int32) | |
self.overlaps = numpy.array(contactdata[:,2]) | |
+ def findCoordinationNumber(self): | |
+ ''' | |
+ Finds the coordination number (the average number of contacts per | |
+ particle). Requires a previous call to :func:`findOverlaps()`. Values | |
+ are stored in ``self.coordinationnumber``. | |
+ ''' | |
+ self.coordinationnumber = numpy.zeros(self.np, dtype=numpy.int) | |
+ for i in numpy.arange(self.overlaps.size): | |
+ self.coordinationnumber[self.pairs[0,i]] += 1 | |
+ self.coordinationnumber[self.pairs[1,i]] += 1 | |
+ | |
+ def findMeanCoordinationNumber(self): | |
+ ''' | |
+ Returns the coordination number (the average number of contacts per | |
+ particle). Requires a previous call to :func:`findOverlaps()` | |
+ | |
+ :returns: The mean particle coordination number | |
+ :return type: float | |
+ ''' | |
+ return numpy.mean(self.coordinationnumber) | |
+ | |
def findNormalForces(self): | |
''' | |
Finds all particle-particle overlaps (by first calling |