def testToAndFromDictConsistent(self):
		#Setup in effect
		testAtomIdx = 2
		testConstraintA = tCode.AtomicCartesianConstraint(testAtomIdx, fixY=True)
		testConstraintB = tCode.AtomicCartesianConstraint(testAtomIdx, fixZ=True)
		self.atomicCartConstraints.append(testConstraintA)
		self.atomicCartConstraints.append(testConstraintB)
		self.createTestObjs()

		#
		expObj = self.testObjA
		inpDict = expObj.toDict()
		actObj = tCode.AtomicPositionConstraints.fromDict(inpDict)
 def testReturnsExpectedStrForMultipleAtomConstraints(self):
     atomIdxAFixed, atomIdxBFixed = 1, 2
     atomConstraintA = geomConstraints.AtomicCartesianConstraint(
         atomIdxAFixed, fixY=True)
     atomConstraintB = geomConstraints.AtomicCartesianConstraint(
         atomIdxBFixed, fixY=True, fixZ=True)
     self.atomicConstraintObjs.append(atomConstraintA)
     self.atomicConstraintObjs.append(atomConstraintB)
     self.createTestObjs()
     expStr = "1 Y 1 0.0 1.0 0.0\n" + "2 X 2 0.0 1.0 0.0\n" + "3 X 2 0.0 0.0 1.0"
     actStr = tCode.getIonicConstraintsStrFromAtomicPosConstraintObj(
         self.geoConstraints.atomicPositionConstraints, self.eleList)
     self.assertEqual(expStr, actStr)
 def _getAllExpectedAtomicGeomConstraints(self):
     outConstraints = list()
     for idx, unused in enumerate(self.fractPositions):
         currConstraint = geomConstrHelp.AtomicCartesianConstraint(
             idx, fixX=True)
         outConstraints.append(currConstraint)
     return outConstraints
	def createTestObjs(self):
		#cart constraints
		cartConstraints = list()
		for idx in self.atomIndicesToFixX:
			currConstraint = tCode.AtomicCartesianConstraint(idx, fixX=True)
			cartConstraints.append( currConstraint )

		#
		self.testObjA = tCode.GeomConstraints.initWithNoConstraints()
		self.testObjA.cellConstraints.anglesToFix = self.cellAnglesToFix
		self.testObjA.atomicPositionConstraints.atomicCartConstraints = cartConstraints
예제 #5
0
 def createTestObjs(self):
     self.geomConstrA = geomConstr.GeomConstraints.initWithNoConstraints()
     atomicCartConstr = list()
     for idx, comps in it.zip_longest(self.atomsToFix,
                                      self.componentsToFix):
         fixX = True if "X" in comps else False
         fixY = True if "Y" in comps else False
         fixZ = True if "Z" in comps else False
         currConstr = geomConstr.AtomicCartesianConstraint(idx,
                                                           fixX=fixX,
                                                           fixY=fixY,
                                                           fixZ=fixZ)
         atomicCartConstr.append(currConstr)
     self.geomConstrA.atomicPositionConstraints.atomicCartConstraints = atomicCartConstr
    def testReturnsExpectedForSingleAtomCoordFixed(self):
        atomIdxFixed = 1  #Note indexing starts at zero
        atomConstraint = geomConstraints.AtomicCartesianConstraint(
            atomIdxFixed, fixX=True)
        self.atomicConstraintObjs.append(atomConstraint)
        self.createTestObjs()

        expCastepAtomIdx = 1  #Because its the first "Y" element
        expConstraintNumber = 1  #Simply means first constraint applied
        expStr = "{} {} {} 1.0 0.0 0.0".format(1, self.eleList[atomIdxFixed],
                                               expCastepAtomIdx)
        actStr = tCode.getIonicConstraintsStrFromAtomicPosConstraintObj(
            self.geoConstraints.atomicPositionConstraints, self.eleList)
        self.assertEqual(expStr, actStr)
	def createTestObjs(self):
		kwargDict = {"fixX":self.fixX, "fixY":self.fixY, "fixZ":self.fixZ}
		self.testObjA = tCode.AtomicCartesianConstraint(self.atomIdx, **kwargDict)
	def testTwoCompareUnequal_differentAtomicConstraintObjs(self):
		atomicConstrA = tCode.AtomicCartesianConstraint(1,fixY=True)
		atomicConstrB = tCode.AtomicCartesianConstraint(1,fixZ=True)
		objA = tCode.AtomicPositionConstraints(atomicCartConstraints = [atomicConstrA])
		objB = tCode.AtomicPositionConstraints(atomicCartConstraints = [atomicConstrB])
		self.assertNotEqual(objA,objB)
	def testTwoCompareEqual_oneWithBlankCartConstraints(self):
		atomicConstrA = tCode.AtomicCartesianConstraint(1) #not really a constraint
		objA = tCode.AtomicPositionConstraints.initWithNoConstraints()
		objB = tCode.AtomicPositionConstraints(atomicCartConstraints=[atomicConstrA])
		self.assertEqual(objA,objB)
	def testTwoUnequalObjsCompareUnequal_diffNumberOfConstraints(self):
		atomicConstrA = tCode.AtomicCartesianConstraint(1,fixX=True)
		objA = tCode.AtomicPositionConstraints.initWithNoConstraints()
		objB = tCode.AtomicPositionConstraints(atomicCartConstraints=[atomicConstrA])
		self.assertNotEqual(objA, objB)
	def testConstraintsPresentTrueIfBlankConstraintPassed(self):
		testAtomIdx = 3
		blankConstraint = tCode.AtomicCartesianConstraint(testAtomIdx)
		self.atomicCartConstraints.append(blankConstraint)
		self.createTestObjs()
		self.assertFalse(self.testObjA.constraintsPresent)
	def testConstraintsPresentTrueIfOnePassed(self):
		testAtomIdx = 2
		testConstraint = tCode.AtomicCartesianConstraint(testAtomIdx, fixY=True)
		self.atomicCartConstraints.append(testConstraint)
		self.createTestObjs()
		self.assertTrue(self.testObjA.constraintsPresent)