def getXvsYStructsFromSkObj(parsedFileObj, xProp="distance", yProp="hVal".lower(), tbintPath=None): allBondTypes = ["sigma", "pi", "delta"] #Need to figure out all shell combinations shellIndA = parsedFileObj.getShellIndices(atomIdx=0) shellIndB = parsedFileObj.getShellIndices(atomIdx=1) #For looking at errors vs tbint we need the tbint output file if tbintPath is not None: tbintObjs = parseTbint.getIntegralsFromBdt(tbintPath) else: tbintObjs = None #Put all the info in the required structure outLists = list() for shellAIdx in range(len(shellIndA)): currListA = list() for shellBIdx in range(len(shellIndB)): currDict = dict() for bondType in allBondTypes: currDict[bondType] = getInvSKDataTwoShells( parsedFileObj, shellAIdx, shellBIdx, bondType, xProp, yProp, tbintDataObjs=tbintObjs) currListA.append(currDict) outLists.append(currListA) return outLists
def testParseKineticHoppingOverlap(self): testedInts = ["kinetic", "overlap", "hopping", "hop3B2C"] expectedInts = tData.loadExpIntsBdtFile_KineticHop3B2C_A() actualInts = tCode.getIntegralsFromBdt(self.filePathDict["bdtFileA"], inclPP=False) for key in testedInts: self.assertTrue(expectedInts[key] == actualInts[key])
def testParseWithOverallInterfaceFunct(self): expectedVals = tData.loadTestBdtFileAExpectedVals() expectedVals["nonLocPP"] = tData.loadTestBdtFileAExpectedVals_nlPPOnly( ) actualVals = tCode.getIntegralsFromBdt("Mg_Mg.bdt") #Note: Assumes order in each list (NOT DICT) is the same between expected/actual results for key in expectedVals: self.assertTrue(actualVals[key] == expectedVals[key])
def testVsKnownInput_HopPPpi(self): testShellA = 1 testShellB = 1 testSubIdx = 2 allInitInts = tCode.getIntegralsFromBdt(self.filePathDict["bdtFileA"]) fakeInts = np.array(([0.0, 2.0], [6.0, 3.0], [12.0, 5.0])) for intList in allInitInts.values(): if intList is not None: for intSet in intList: if intSet.intType == "hopping" and intSet.shellA == testShellA and intSet.shellB == testShellB and intSet.orbSubIdx == testSubIdx: intSet.integrals = fakeInts intSet.replaceIntsTbintFile( self.filePathDict["bdtFileA"]) newInts = tCode.getIntegralsFromBdt(self.filePathDict["bdtFileA"]) for key in newInts.keys(): self.assertTrue(allInitInts[key] == newInts[key])
def testCorrectlyWritesPairPot_singleFile(self): expPPCorr = self.integDicts[0]["pairpot"][0] expPPCorr.integrals[:, 1] *= -1 #Total PP is zero, so the correction must exactly cancel the initial self.testObj.writeTables() #Will always update before writing them actualPPCorr = parseTbint.getIntegralsFromBdt( self.outFileA)["PairPotCorrection0"][0] self.assertEqual(expPPCorr, actualPPCorr)
def testVsKnownInput_PairPot(self): ''' Test bdt file correctly modified for pair pot ''' allInitInts = tData.loadTestBdtFileAExpectedVals() fakePairPotInts = np.array(([0.0, 4.0], [1.0, 3.0], [2.0, 2.0])) allInitInts["pairPot"][0].integrals = fakePairPotInts allInitInts["pairPot"][0].intType = "pairPot" allInitInts["pairPot"][0].replaceIntsTbintFile( self.filePathDict["bdtFileA"]) newInts = tCode.getIntegralsFromBdt(self.filePathDict["bdtFileA"], inclPP=False) for key in allInitInts.keys(): self.assertTrue(allInitInts[key] == newInts[key])
def getAllIntInfoObjsFromIntegStrAndBdtPath(integStr: "str, e.g. hopping", bdtPath): integDict = parseTbint.getIntegralsFromBdt(bdtPath) relevantInts = integDict[integStr] modelFolder = os.path.split(bdtPath)[0] outputObjs = list() for x in relevantInts: currObj = coeffTableConv.IntegralTableInfo(modelFolder, integStr, x.atomAName, x.atomBName, x.shellA, x.shellB, x.orbSubIdx) outputObjs.append(currObj) #Need to filter out axAngMom = 1 (default in parseTbint) for atom-based integrals for x in outputObjs: if (x.shellA is None): x.axAngMom = None return outputObjs
def getTbintHoppingListStructFormat(tbintPath, intType="hopping", convToEv=False): allInts = parseTbint.getIntegralsFromBdt(tbintPath) adtPaths = parseTbint.getAdtFilePathsFromBdt(tbintPath) shellsA, shellsB = parseTbint.parseAdtFile( adtPaths[0])["numbShells"], parseTbint.parseAdtFile( adtPaths[1])["numbShells"] intTypesToConvToEv = [ "hopping", "HopXcContrib", ] if convToEv and (intType not in intTypesToConvToEv): raise AttributeError( "{} is an invalid integral type to convert to electron volts". format(intType)) #Put all the info in the required structure (TODO: extract this method somehow w/strat patt.) allBondTypes = ["sigma", "pi", "delta"] outLists = list() for shellAIdx in range(shellsA): currListA = list() for shellBIdx in range(shellsB): currDict = dict() for bondType in allBondTypes: currDict[bondType] = getTbintIntegralTableFromObjDict( allInts, shellAIdx, shellBIdx, bondType, intType=intType) if (intType in intTypesToConvToEv) and (convToEv) and ( currDict[bondType] is not None): currDict[bondType][:, 1] *= uConvs.RYD_TO_EV currListA.append(currDict) outLists.append(currListA) return outLists
def testParseBdtForm4_usingInterfaceFunct(self): expectedVals = tData.loadTestBdtFileAExpectedVals_format4() actualVals = tCode.getIntegralsFromBdt(self.bdtFile) for key in expectedVals: self.assertTrue(actualVals[key] == expectedVals[key])
def testVsExpected(self): expInts = self.loadExpectedBdtResults() actualInts = tCode.getIntegralsFromBdt(self.bdt, inclPP=False) for key in expInts: self.assertTrue(actualInts[key] == expInts[key])
def _getAllIntegDictsFromBdtPaths(allPaths): allIntegDicts = list() for currPath in allPaths: allIntegDicts.append(parseTbint.getIntegralsFromBdt(currPath)) return allIntegDicts