Class AlgorithmSphereGeneration

  • All Implemented Interfaces:
    java.awt.event.ActionListener, java.awt.event.WindowListener, java.lang.Runnable, java.util.EventListener

    public class AlgorithmSphereGeneration
    extends AlgorithmBase
    This module draws uniformly randomly positioned spheres with a specified radius. Best reference for nearest neighbor distribution for equally sized circles is: "Nearest Neighbor Assessments of Spatial Configurations of Circles rather Than Points" by Daniel Simberloff, Ecology, Vol. 60, No. 4, Aug. 1979, pp. 679-685. d = diameter lambda = mean number per unit area Dr. Daniel Simberloff writes: "In any event, you are probably correct that it would be more logical to caclulate rho for the points only in the interior, not the border region, remembering to leave out the border region when calculating area." mean nearest neighbor value = d + (exp(lambda * PI * d**2)/sqrt(lambda)*integral from t = d*sqrt(2*lambda*PI) to t = infinity of (1/sqrt(2*PI))*exp(-t**2/2)dt. The integral is simply the 1 - Gaussian probability integral. E(nearest neighbor distance squared) = d**2 + 1/(lambda * PI) variance = E(r**2) - [E(r)]**2 = d**2 + 1/(lambda * PI) - [E(r)]**2 standard error = sqrt(variance)/sqrt(N) Get percentile from Gaussian probability integral. If the measured mean is significantly greater than the analytical mean, the distribution is uniform or regular. If the measured mean is signficantly less than than the analytical mean, the distribution is clumped or aggregated. I have derived similar mathematics for Poisson distributed spheres. Consider a Poisson distribution of points in spheres of radius r. The probability that a sphere of radius r about a point contains no points, given a density of points = lambda is exp(-(4/3)*lambda*PI*(r**3)) Thus, 1 - exp(-(4/3)*lambda*PI*(r**3)) is the proportion of nearest neighbor distances dm: 4*lambda*PI*(r**2)*exp(-(4/3)*lambda*PI*(r**3)) * (1 / ( 1 - 4*lambda*PI*integral from r = 0 to r = dm of (r**2)*exp(-(4/3)*lambda*PI*(r**3))dr)) = 4*lambda*PI*(r**2)*exp(-(4/3)*lambda*PI*(r**3)) * (1/ ( 1 + integral from r = 0 to r = dm of exp(-(4/3)*lambda*PI*(r**3))d(-(4/3)*lambda*PI*(r**3)))) = 4*lambda*PI*(r**2)*exp(-(4/3)*lambda*PI*(r**3)) * (1 /(1 + exp(-(4/3)*lambda*PI*(dm**3)) - 1)) = 4*lambda*PI*exp((4/3)*lambda*PI*(dm**3))*(r**2)*exp(-(4/3)*lambda*PI*(r**3)) E(r) = 4*lambda*PI*exp((4/3)*lambda*PI*(dm**3)) * integral from r = dm to r = infinity of (r**3)*exp(-(4/3)*lambda*PI*(r**3))dr = -exp((4/3)*lambda*PI*(dm**3)) * integral from r = dm to r = infinity of rd(exp(-(4/3)*lambda*PI*(r**3))) -exp((4/3)*lambda*PI*(dm**3)) * (-dm*exp(-(4/3)*lambda*PI*(dm**3)) - intergal from r = dm to r = infinity of exp(-(4/3)*lambda*PI*(r**3))dr) = dm + exp((4/3)*lambda*PI*(dm**3))*integral from r = dm to r = infinity of exp(-(4/3)*lambda*PI*(r**3))dr E(r**2) = 4*lambda*PI*exp((4/3)*lambda*PI*(dm**3)) * integral from r = dm to r = infinity of (r**4)*exp(-(4/3)*lambda*PI*(r**3))dr = -exp((4/3)*lambda*PI*(dm**3)) * integral from r = dm to r = infinity of (r**2)*d(exp(-(4/3)*lambda*PI*(r**3))) = -exp((4/3)*lambda*PI*(dm**3) * (-(dm**2)*exp(-(4/3)*lambda*PI*(dm**3)) - integral from r = dm to r = infinity of exp(-(4/3)*lambda*PI*(r**3))d(r**2)) = dm**2 + exp((4/3)*lambda*PI*(dm**3)) * integral from r = dm to r = infinity of 2*r*exp(-(4/3)*lambda*PI*(r**3))dr Integration.MIDINF can be too slow for radius = 0. The Poisson distribution becomes inaccurate at higher densities because the assumption of the Poission distribution of rare events is violated: the mean number of points per sampling unit is not small relative to the maximum possible number of points per sampling unit. I have used the formula from "Nearest-neighbor distribution functions in many-body systems" by S. Torquato, B. Lu. and J. Rubinstein, The American Physical Society Physical Review A, Volume 41, Number 4, February 15, 1990, pp. 2059-2075. vf = volume fraction of spheres e = (1 + vf)/((1 - vf)**3) f = -0.5*vf*(3 + vf)/((1 - vf)**3) g = 0.5*vf*vf/((1 - vf)**3) mean nearest neighbor distance = diameter * (1 + integeral) integral = integral from x = 1 to x = infinity of exp{-vf[8*e*(x*x*x-1) + 12*f*(x*x - 1) + 24*g*(x - 1)]} Torquato developed more accurate equations in 1995 superseding the 1990 equations. In "Nearest-neighbor statistics for packings of hard spheres and disks" by S. Torquato, Physical Review E, Volume 51, Number 4, April, 1995, pp. 3170 - 3182: vf = volume fraction of spheres mean nearest neighbor distance = diameter * (1 + integral) integral = integral from x = 1 to x = infinity of exp{-vf[8*a0*(x*x*x - 1) + 12*a1*(x*x - 1) + 24*a2*(x-1)]} For vf / = 1 + ((2**(-1/6) * (n-1)!)/(([(4/3)*PI]**-1/3) * Gamma[(3*n + 1)/3])) * ((f/f0)**((2*n)/(2*n+1))) where is the mean nth nearest-neighbor distance, f is volume fraction, is the corresponding mean nearest-neighbor distance for a point process, and fo is the volume fraction for the close-packed structure (1.e. PI/sqrt(18) or about 0.74). = ([(4/3)*PI*Nv]**-1/3) * gamma[(3*n + 1)/3] / (n - 1)! = Kn*(Nv)**-1/3 where Nv is the number of points per unit volume.

    / = 1 + B1 * ((f/f0)**2/3) where B1 = ((2**-1/6)/K1) - 1 For spheres of varying radii the formula is modified to

    *(Nv**(1/3)) = K1*[ 1 + B1 * (f/f0)**2/3] - (1 - exp(-cv * f)) where cv is the coefficient of variation of the sphere size distribution The reference is "Nearest neighbor distances in uniform-random poly-dispersed microstructures" by A. Tewari and A. M. Gokhale, Materials Science and Engineering A 396 (2005), pp. 22-27. The equation for varying radii is good for sphere volume fractions ranging from 0.0 to 0.25.

    • Field Detail

      • numSpheres

        private int numSpheres
      • pattern

        private int pattern
      • minRadius

        private int minRadius
      • maxRadius

        private int maxRadius
      • radiusDistribution

        private int radiusDistribution
      • initialRandomSpheres

        private int initialRandomSpheres
      • minimumNearestNeighborDistance

        private double minimumNearestNeighborDistance
      • maximumNearestNeighborDistance

        private double maximumNearestNeighborDistance
      • lowestForbiddenNNDistance

        private double lowestForbiddenNNDistance
      • highestForbiddenNNDistance

        private double highestForbiddenNNDistance
      • highestRegenerationNNDistance

        private double highestRegenerationNNDistance
    • Constructor Detail

      • AlgorithmSphereGeneration

        public AlgorithmSphereGeneration()
        AlgorithmSphereGeneration - default constructor.
      • AlgorithmSphereGeneration

        public AlgorithmSphereGeneration​(ModelImage srcImage,
                                         int minRadius,
                                         int maxRadius,
                                         int numSpheres,
                                         int pattern,
                                         int radiusDistribution,
                                         int initialRandomSpheres,
                                         double minimumNearestNeighborDistance,
                                         double maximumNearestNeighborDistance,
                                         double lowestForbiddenNNDistance,
                                         double highestForbiddenNNDistance,
                                         double highestRegenerationNNDistance)
        AlgorithmRandomSphereGeneration.
        Parameters:
        srcImg - Blank source image in which spheres will be drawn
        radius - Sphere radius
        numSpheres - Number of spheres to be drawn
        pattern - RANDOM, AGGREGATED, or REGULAR
        initialRandomSpheres - Used in AGGREGATED. initialRandomSpheres are drawn randomly. The rest are drawn with nearestNeighborDistance less than or equal ot maximumNearestNeighborDistance.
        minimumNearestNeighborDistance - Used in REGULAR
        maximumNearestNeighborDistance - Used in AGGREGATED and REGULAR
        lowestForbiddenNNDistance - Used in CONSTRAINED
        highestForbiddenNNDistance - Used in CONSTRAINED
        highestRegeneerationNNDistance - Used in CONSTRAINED