コード例 #1
0
 def testOctaInExpectedPositionCoverAlessThanPerfect(self):
     self.site = "octahedral"
     expOutCell = copy.deepcopy(self.testCellA)
     expCartCoords = expOutCell.cartCoords
     expNewCoord = self._getCoordForOctaInter()
     expCartCoords.append(expNewCoord)
     expOutCell.cartCoords = expCartCoords
     tCode.addSingleInterToHcpBulkGeom(self.testCellA,
                                       self.site,
                                       ele=self.ele,
                                       strat="utest")
     self.assertEqual(expOutCell, self.testCellA)
コード例 #2
0
 def testCrowdionInExpectedPositionCoverALessThanPerfect(self):
     self.site = "crowdion"
     expOutCell = copy.deepcopy(self.testCellA)
     expCartCoords = expOutCell.cartCoords
     expNewCoord = [0.5 * x for x in expCartCoords[1][:3]] + [self.ele]
     expCartCoords.append(expNewCoord)
     expOutCell.cartCoords = expCartCoords
     tCode.addSingleInterToHcpBulkGeom(self.testCellA,
                                       self.site,
                                       ele=self.ele,
                                       strat="utest")
     self.assertEqual(expOutCell, self.testCellA)
コード例 #3
0
 def testBasalCrowdionInExpectedPositionCoverAlessThanPerfect(self):
     self.site = "basal_crowdion"
     expOutCell = copy.deepcopy(self.testCellA)
     expCartCoords = expOutCell.cartCoords
     expNewCoord = [0.5 * self.lattParams[0], 0, 0] + [self.ele]
     expCartCoords.append(expNewCoord)
     expOutCell.cartCoords = expCartCoords
     tCode.addSingleInterToHcpBulkGeom(self.testCellA,
                                       self.site,
                                       ele=self.ele,
                                       strat="utest")
     self.assertEqual(expOutCell, self.testCellA)
コード例 #4
0
 def testTetraBasalInExpectedPositionCoverALessThanPerfect(self):
     self.site = "basal_tetrahedral"
     expOutCell = copy.deepcopy(self.testCellA)
     expCartCoords = expOutCell.cartCoords
     expNewCoord = expCartCoords[0][:2] + [
         expCartCoords[0][2] + 0.5 * self.lattParams[-1]
     ] + ["X"]
     expCartCoords.append(expNewCoord)
     expOutCell.cartCoords = expCartCoords
     tCode.addSingleInterToHcpBulkGeom(self.testCellA,
                                       self.site,
                                       ele="X",
                                       strat="utest")
     self.assertEqual(expOutCell, self.testCellA)
コード例 #5
0
 def testTetraInExpectedPositionA(self):
     nearestNebOutOfPlaneDist = tCode._getNearestNebDistanceOutOfZPlane(
         self.testCellA, 0)
     nearestNebCartCoords = self.testCellA.cartCoords[1][:3]
     angle = math.degrees(
         math.acos(0.7924058156930613))  #Calculated "by hand"
     expZDisplace = (0.5 * nearestNebOutOfPlaneDist) / math.cos(
         math.radians(angle))
     expOutCell = copy.deepcopy(self.testCellA)
     expCartCoords = expOutCell.cartCoords
     expNewCoord = [
         expCartCoords[0][0], expCartCoords[0][1],
         expCartCoords[0][2] + expZDisplace
     ]
     expCartCoords.append(expNewCoord + ["X"])
     expOutCell.cartCoords = expCartCoords
     tCode.addSingleInterToHcpBulkGeom(self.testCellA,
                                       self.site,
                                       ele="X",
                                       strat="utest")
     self.assertEqual(expOutCell, self.testCellA)
コード例 #6
0
 def testTetraInExpectedPositionWithCOverAGreaterThanPerfect(self):
     self.lattParams[-1] = self.lattParams[0] * 2
     self.createTestObjs()
     #Largely C+P from above
     nearestNebOutOfPlaneDist = tCode._getNearestNebDistanceOutOfZPlane(
         self.testCellA, 0)
     angle = 30
     expZDisplace = (0.5 * nearestNebOutOfPlaneDist) / math.cos(
         math.radians(angle))
     expOutCell = copy.deepcopy(self.testCellA)
     expCartCoords = expOutCell.cartCoords
     expNewCoord = [
         expCartCoords[0][0], expCartCoords[0][1],
         expCartCoords[0][2] + expZDisplace
     ]
     expCartCoords.append(expNewCoord + ["X"])
     expOutCell.cartCoords = expCartCoords
     tCode.addSingleInterToHcpBulkGeom(self.testCellA,
                                       self.site,
                                       ele="X",
                                       strat="utest")
     self.assertEqual(expOutCell, self.testCellA)
コード例 #7
0
    def testBasalSplitInExpectedPositionCoverALessThanPerfect(self):
        self.site = "basal_split"
        #Need at least TWO atoms in-plane in the regular (non periodic) cell
        self.fractPositions = [
            [0.0, 0.0, 0.0],
            [0.16666666666666677, 0.6666666666666664, 0.4999999999999999],
            [0.5, 0.0, 0.0],
            [0.6666666666666666, 0.6666666666666664, 0.4999999999999999]
        ]
        self.createTestObjs()

        expOutCell = copy.deepcopy(self.testCellA)
        expCartCoords = expOutCell.cartCoords
        displacement = (2 / 3) * 0.5 * 0.5 * self.lattParams[0]
        newCoordPos = copy.deepcopy(expCartCoords[0])
        newCoordPos[0] += displacement
        expCartCoords[0][0] -= displacement
        expCartCoords.append(newCoordPos)
        expOutCell.cartCoords = expCartCoords
        tCode.addSingleInterToHcpBulkGeom(self.testCellA,
                                          self.site,
                                          ele=self.ele,
                                          strat="utest")
        self.assertEqual(self.testCellA, expOutCell)
コード例 #8
0
 def testRaisesForIncorrectSite(self):
     with self.assertRaises(ValueError):
         tCode.addSingleInterToHcpBulkGeom(self.testCellA, "fake_site")
コード例 #9
0
 def testRaisesForIncorrectLatticeAngles(self):
     self.lattAngles[2] = 50
     self.createTestObjs()
     with self.assertRaises(ValueError):
         tCode.addSingleInterToHcpBulkGeom(self.testCellA, self.site)