Example #1
0
    def initialiseParameters(self):
        # ensure parent initialisation takes place and core values are initialised
        NBB.initialiseParameters(self)

        if self.noLoadErrors == False:
            print("Critical Parameters are undefined for Cylinder Packing")
            sys.exit()
 def initialiseParameters(self):
     # ensure parent initialisation takes place and core values are initialised 
     NBB.initialiseParameters(self) 
     self.proximityScore = 0
     if self.noLoadErrors == False:            
         print("Critical Parameters are undefined for PlanePack object")
         sys.exit()        
Example #3
0
    def initialiseParameters(self):
        # ensure parent initialisation takes place and core values are initialised
        NBB.initialiseParameters(self)

        if self.noLoadErrors == False:
            print "Critical Parameters are undefined for NPackBBG object"
            sys.exit()
Example #4
0
 def initialiseParameters(self):
     # ensure parent initialisation takes place and core values are initialised 
     NBB.initialiseParameters(self) 
     
     self.compressionScaleFactor = self.getParam('compressionScaleFactor')
     
     if self.noLoadErrors == False:            
         print("Critical Parameters are undefined for constrained polymer object")
         sys.exit()
Example #5
0
 def initialiseParameters(self):
     # ensure parent initialisation takes place and core values are initialised 
     NBB.initialiseParameters(self) 
     
     # add ellipsoidal radii - sort so that c > b > a for z, y and x axes accordingly.
     # if we have to flip axes, remember and swap the vector components at the end. 
     
     
     if self.noLoadErrors == False:            
         print "Critical Parameters are undefined for Ellipsoid Pack object"
         sys.exit()        
Example #6
0
 def generateBuildingBlock(self,
                           numPoints,
                           xRadius,
                           yRadius,
                           zRadius,
                           theta1,
                           theta2,
                           phi1,
                           phi2,
                           minDist,
                           envelopeList=['None'],
                           pointsToAvoid=[],
                           visualiseEnvelope=(0, 200, 'envelope.xyz'),
                           showBlockDirector=False,
                           defaultBlockRefPoint=None):
     self.xRadius = xRadius
     self.yRadius = yRadius
     self.zRadius = zRadius
     self.theta1 = theta1 * np.pi / 180.0
     self.theta2 = theta2 * np.pi / 180.0
     self.phi1 = phi1 * np.pi / 180.0
     self.phi2 = phi2 * np.pi / 180.0
     return NBB.generateBuildingBlock(
         self,
         numPoints,
         minDist,
         envelopeList=envelopeList,
         pointsToAvoid=pointsToAvoid,
         visualiseEnvelope=visualiseEnvelope,
         showBlockDirector=showBlockDirector,
         defaultBlockRefPoint=defaultBlockRefPoint)
Example #7
0
 def generateBuildingBlock(self,
                           numPoints,
                           xRange1,
                           xRange2,
                           yRange1,
                           yRange2,
                           zRange1,
                           zRange2,
                           minDist,
                           envelopeList=['None'],
                           pointsToAvoid=[],
                           visualiseEnvelope=(0, 200),
                           showBlockDirector=False):
     self.xRange1 = xRange1
     self.xRange2 = xRange2
     self.yRange1 = yRange1
     self.yRange2 = yRange2
     self.zRange1 = zRange1
     self.zRange2 = zRange2
     return NBB.generateBuildingBlock(self,
                                      numPoints,
                                      minDist,
                                      envelopeList=envelopeList,
                                      pointsToAvoid=pointsToAvoid,
                                      visualiseEnvelope=visualiseEnvelope,
                                      showBlockDirector=False)
Example #8
0
    def checkPointInBounds(self, pos):
        # spherical coords format for pos. (r, theta, phi)
        # Return true if point is within bounds and false if it is out of bounds.

        outBounds = False

        if pos[2] <= self.phi1:
            outBounds = True
            if self.verbose == 1:
                print("phi1 violation")

        if pos[2] >= self.phi2:
            outBounds = True
            if self.verbose == 1:
                print("phi2 violation")

        if pos[1] <= self.theta1:
            outBounds = True
            if self.verbose == 1:
                print("theta1 violation")

        if pos[1] >= self.theta2:
            outBounds = True
            if self.verbose == 1:
                print("theta2 violation")

        if outBounds == True:
            inBounds = False
        else:
            inBounds = True

        if inBounds:
            inBounds = NBB.checkPointInBounds(self, pos)

        return inBounds
Example #9
0
    def generateBuildingBlock(self,
                              numPoints,
                              radius,
                              theta1,
                              theta2,
                              phi1,
                              phi2,
                              minDist,
                              envelopeList=['None'],
                              pointsToAvoid=[],
                              showBlockDirector=False,
                              visualiseEnvelope=(0, 200)):

        self.radius = radius
        self.theta1 = theta1 * np.pi / 180
        self.theta2 = theta2 * np.pi / 180

        if self.theta2 < self.theta1:
            self.theta2 = self.theta1
            self.theta1 = theta2 * np.pi / 180.0
        self.phi1 = phi1 * np.pi / 180
        self.phi2 = phi2 * np.pi / 180

        if self.phi2 < self.phi1:
            self.phi2 = self.phi1
            self.phi1 = phi2 * np.pi / 180.0

        return NBB.generateBuildingBlock(self,
                                         numPoints,
                                         minDist,
                                         envelopeList=envelopeList,
                                         pointsToAvoid=pointsToAvoid,
                                         showBlockDirector=showBlockDirector,
                                         visualiseEnvelope=(0, 200))
Example #10
0
    def generateBuildingBlock(self,
                              numPoints,
                              minDist,
                              graph,
                              points,
                              params,
                              packType,
                              epsilon,
                              envelopeList=['None'],
                              pointsToAvoid=[],
                              visualiseEnvelope=(0, 200, 'envelope.xyz'),
                              showBlockDirector=False):
        self.graph = graph
        self.points = points
        self.params = params
        self.packType = packType  # inside, outside or surface
        self.epsilon = epsilon  # tolerance on equality between two real values.
        self.xMin, self.xMax, self.yMin, self.yMax, self.zMin, self.zMax = self.boundingRegion(
        )
        BuildingBlock = NBB.generateBuildingBlock(
            self,
            numPoints,
            minDist,
            envelopeList=envelopeList,
            pointsToAvoid=pointsToAvoid,
            visualiseEnvelope=visualiseEnvelope,
            showBlockDirector=showBlockDirector)
        directorStatus = self.computeDirectors()

        # extract and normalise the directors
        directors = [
            dirn[1] / np.linalg.norm(dirn[1]) for dirn in directorStatus
        ]
        return BuildingBlock, directors
Example #11
0
 def generateBuildingBlock(self,
                           numPoints,
                           xSize,
                           ySize,
                           zSize,
                           thetaDir1,
                           thetaDir2,
                           phiDir1,
                           phiDir2,
                           minDist,
                           pLength,
                           numSpheresPerParticle,
                           envelopeList=['None'],
                           pointsToAvoid=[],
                           visualiseEnvelope=(0, 200, 'envelope.xyz'),
                           showBlockDirector=False):
     self.xSize = xSize
     self.ySize = ySize
     self.zSize = zSize
     self.thetaDir1 = thetaDir1 * np.pi / 180.0
     self.thetaDir2 = thetaDir2 * np.pi / 180.0
     self.phiDir1 = phiDir1 * np.pi / 180.0
     self.phiDir2 = phiDir2 * np.pi / 180.0
     self.minDist = minDist
     self.pLength = pLength
     self.numSpheresPerParticle = numSpheresPerParticle
     return NBB.generateBuildingBlock(self,
                                      numPoints,
                                      minDist,
                                      envelopeList=envelopeList,
                                      pointsToAvoid=pointsToAvoid,
                                      visualiseEnvelope=visualiseEnvelope,
                                      showBlockDirector=showBlockDirector)
 def generateBuildingBlock(self, numPoints, xRange1, xRange2, yRange1, yRange2, zRange1, zRange2, minDist, r0, proximityT, seedLength, envelopeList=['None'], pointsToAvoid=[], visualiseEnvelope=(0,200), showBlockDirector=False):
     self.xRange1 = xRange1 
     self.xRange2 = xRange2
     self.yRange1 = yRange1
     self.yRange2 = yRange2
     self.zRange1 = zRange1
     self.zRange2 = zRange2
     self.r0 = r0
     self.proximityScore = 0
     self.lenListForProximityScore = 0
     self.ProximityT = proximityT
     self.seedLength = seedLength
     return NBB.generateBuildingBlock(self, numPoints, minDist, envelopeList=envelopeList, pointsToAvoid=pointsToAvoid, visualiseEnvelope=visualiseEnvelope, showBlockDirector=False)
Example #13
0
    def checkPointInBounds(self, pos):
        # cylindrical coords format for pos. Return true if point is within bounds and false if it is out of bounds.

        # assume point is inBounds and test for outBoundness
        outBounds = False

        if pos[2] < self.z1:
            outBounds = True
            if self.verbose == 1:
                print("z1 violation")

        if pos[2] > self.z2:
            outBounds = True
            if self.verbose == 1:
                print("z2 violation")

        if pos[1] < self.phi1:
            outBounds = True
            if self.verbose == 1:
                print("phi1 violation")

        if pos[1] > self.phi2:
            outBounds = True
            if self.verbose == 1:
                print("phi2 violation")

        if (pos[0] < self.radiusX) and (pos[0] < self.radiusY):
            outBounds = True
            if self.verbose == 1:
                print("radius inner violation")

        if (pos[0] > self.radiusX) and (pos[0] > self.radiusY):
            outBounds = True
            if self.verbose == 1:
                print("radius outer violation")

        if outBounds == True:
            inBounds = False
        else:
            inBounds = True

        if inBounds:
            inBounds = NBB.checkPointInBounds(self, pos)

        return inBounds
 def generateBuildingBlock(self,
                           numPoints,
                           xRadius,
                           yRadius,
                           zRadius,
                           theta1,
                           theta2,
                           phi1,
                           phi2,
                           thetaDir1,
                           thetaDir2,
                           phiDir1,
                           phiDir2,
                           minDist,
                           pLength,
                           numSpheresPerParticle,
                           envelopeList=['None'],
                           pointsToAvoid=[],
                           visualiseEnvelope=(0, 200, 'envelope.xyz'),
                           showBlockDirector=False):
     self.xRadius = xRadius
     self.yRadius = yRadius
     self.zRadius = zRadius
     self.theta1 = theta1 * np.pi / 180.0
     self.theta2 = theta2 * np.pi / 180.0
     self.phi1 = phi1 * np.pi / 180.0
     self.phi2 = phi2 * np.pi / 180.0
     self.thetaDir1 = thetaDir1 * np.pi / 180.0
     self.thetaDir2 = thetaDir2 * np.pi / 180.0
     self.phiDir1 = phiDir1 * np.pi / 180.0
     self.phiDir2 = phiDir2 * np.pi / 180.0
     self.minDist = minDist
     self.pLength = pLength
     self.numSpheresPerParticle = numSpheresPerParticle
     return NBB.generateBuildingBlock(self,
                                      numPoints,
                                      minDist,
                                      envelopeList=envelopeList,
                                      pointsToAvoid=pointsToAvoid,
                                      visualiseEnvelope=visualiseEnvelope,
                                      showBlockDirector=showBlockDirector)
Example #15
0
    def generateNConstrainedRandomPoints(self):
        # compute some derived quantities
        self.maxLength = (self.numPoints-1) * self.bondLength
        self.distAToB= np.linalg.norm(self.pointB - self.pointA)
        self.polymerCompression= self.compressionScaleFactor * self.distAToB/self.maxLength

        # perform an initial sanity check on the given starting points
        if (not self.checkPointInSphereRange(self.pointA)):
            print ("Invalid starting point: pointA is not inside spherical constraints.")
            sys.exit()
        
        if (not self.checkPointInSphereRange(self.pointB)):
            print ("Invalid starting point: pointB is not inside spherical constraints.")
            sys.exit()        
        
        # calculate the maximum allowed distance that the two end points can be apart
        maxDistance = self.polymerCompression * (self.numPoints - 1) * self.bondLength
        if np.linalg.norm(self.pointA - self.pointB) > maxDistance:
            print ("Invalid starting point: Point A and B are too far apart for given number of points, and bondLength.")
            sys.exit()        

        return NBB.generateNConstrainedRandomPoints(self)
Example #16
0
    def generateBuildingBlock(self,
                              numPoints,
                              rx,
                              ry,
                              z1,
                              z2,
                              phi1,
                              phi2,
                              minDist,
                              envelopeList=['None'],
                              pointsToAvoid=[],
                              visualiseEnvelope=(0, 200),
                              showBlockDirector=False):

        self.radiusX = rx
        self.radiusY = ry

        # process the zs
        self.z1 = min(z1, z2)
        self.z2 = max(z1, z2)

        # compute the length of the cylinder
        self.zLength = abs(self.z2 - self.z1)

        self.phi1 = phi1 * np.pi / 180
        self.phi2 = phi2 * np.pi / 180
        if self.phi2 < self.phi1:
            self.phi2 = self.phi1
            self.phi1 = phi2 * np.pi / 180.0

        return NBB.generateBuildingBlock(self,
                                         numPoints,
                                         minDist,
                                         envelopeList=envelopeList,
                                         pointsToAvoid=pointsToAvoid,
                                         visualiseEnvelope=visualiseEnvelope,
                                         showBlockDirector=showBlockDirector)
Example #17
0
    def generateBuildingBlock( self, 
                               numPoints, 
                               pointA,
                               pointB, 
                               alpha1, 
                               alpha2,
                               beta1,
                               beta2, 
                               minDist,
                               bondLength,
                               innerSphereR,
                               outerSphereR,
                               spherePos):

        self.originalNumPoints = numPoints
        self.pointA = pointA
        self.pointB = pointB
        self.bondLength = bondLength
        
        # use these ranges for the dihedral and bond angles to find an intial chain between
        # the end points. We will apply the bonds and dihedrals constraints once we have a starting chain.
        self.alpha1 = alpha1 * np.pi/180
        self.alpha2 = alpha2 * np.pi/180
        self.beta1 = beta1 * np.pi/180
        self.beta2 = beta2 * np.pi/180
        if self.alpha2 < self.alpha1:
            self.alpha2 = self.alpha1
            self.alpha1 =  alpha2 * np.pi/180.0
        if self.beta2 < self.beta1:
            self.beta2 = self.beta1
            self.beta1 = beta2 * np.pi/180.0

        self.bannedSphereCentre = spherePos
        self.bannedSphereRadiusInner = innerSphereR 
        self.bannedSphereRadiusOuter = outerSphereR

        return NBB.generateBuildingBlock(self, numPoints, minDist)
Example #18
0
 def __init__(self, filename):
     NBB.__init__(self, filename)