def testWriteGauFile_gauR0(self): fileData = tCode.parseGauFile(self.filePathGauR0_A) fileHeader = tCode.getHeaderStrFromGauFile(self.filePathGauR0_A) outFilePath = self.outFilePath tCode.writeGauFile( outFilePath, fileData, fileHeader ) writtenData = tCode.parseGauFile(outFilePath) for key in fileData: self.assertEqual( fileData[key], writtenData[key] )
def testR0FitParams_OrbsA(self): expectedOrbAVals = [(0.2256533391134165345 , 37.734285273902244739), #(exponent,coefficient) (0.27166909389199239699 , -225.58343293227176218), (0.32706848862095144748 , 654.62927000596084781), (0.39376505702677788712 , -1200.7690751643528984), (0.47406254509279360798 , 1526.929211213746612)] expectedOrbBVals = [(0.2256533391134165345 , 17.814973037417860979), #(exponent,coefficient) (0.270830897196620346 , -104.93193089850436195), (0.32505335469226059875, 301.52446638262307488), (0.39013157099274675677, -548.60645017933700274), (0.46823895366151246922, 691.88850762815638973)] parsedFile = tCode.parseGauFile(self.filePathGauR0_A) actualOrbAVals = parsedFile["orbitals"][0] actualOrbBVals = parsedFile["orbitals"][1] allExpectedOrbs = [expectedOrbAVals, expectedOrbBVals] allActualOrbs = parsedFile["orbitals"] for expectedOrbVals,actualOrbVals in itertools.zip_longest(allExpectedOrbs,allActualOrbs): for primIdx,expPrimVals in enumerate(expectedOrbVals): expExponent, expCoeff = expPrimVals[0], expPrimVals[1] actExponent, actCoeff = actualOrbVals.exponents[primIdx],actualOrbVals.r0Coeffs[primIdx] self.assertAlmostEqual( expExponent, actExponent ) self.assertAlmostEqual( expCoeff, actCoeff )
def getFieldDatafromGauFile(gauFile, field, fieldIdx=0): parsedGau = parseGau.parseGauFile(gauFile) dataSection = parsedGau[field.lower()] #orbitals/nl-pp are lists while density/potential are single objs. try: fieldData = dataSection[fieldIdx] except TypeError: fieldData = dataSection return fieldData
def testR0Density(self): expectedDensity = [ (0.24977446411892198497, 0.18906107877553832153), (0.29973495506030567448, -0.27126779867644273958), (0.38482187439714704569, 0.17122695197285703328), (0.65934295531661524237, -0.18788457858635970732), (0.88972219525501938797, 0.16118101005396684444) ] actualDensity = tCode.parseGauFile(self.filePathGauR0_A)["density"] for idx,exp in enumerate(expectedDensity): self.assertAlmostEqual( exp[0], actualDensity.exponents[idx] ) self.assertAlmostEqual( exp[1], actualDensity.r0Coeffs[idx] )
def testVsKnownValsA(self): expectedElement = "Mg" expectedShellLVals = [0,1] expectedShellNVals = [3,3] parsedFile = tCode.parseGauFile(self.filePathGauR0_A) actualElement = parsedFile["element"] actualShellLVals = parsedFile["shellAngMoms".lower()] actualShellNVals = parsedFile["shellNVals".lower()] self.assertEqual( expectedElement, actualElement ) [self.assertEqual(exp,act) for exp,act in itertools.zip_longest(expectedShellLVals, actualShellLVals)] [self.assertEqual(exp,act) for exp,act in itertools.zip_longest(expectedShellNVals, actualShellNVals)]
def testParseNlPP(self): expNlPP = list() expExponentsA = [1.4174540372986133008] expCoeffsA = [ [-0.2826563852303170532], [-1.595515250025759002] ] expExponentsB = [1.4174540055315427711] expCoeffsB = [ [-2.4343440773146363121], [0.92424384058112241114] ] expExponentsC = [0.99985718149534019705] expCoeffsC = [[1.8374666607470948598]] expNlA = tCode.GauPolyBasis( expExponentsA, expCoeffsA ) expNlB = tCode.GauPolyBasis ( expExponentsB, expCoeffsB ) expNlC = tCode.GauPolyBasis ( expExponentsC, expCoeffsC ) expNlAll = [expNlA, expNlB, expNlC] actNlAll = tCode.parseGauFile(self.filePathGauR1_A)["nlpp"] for exp,act in itertools.zip_longest( expNlAll, actNlAll ): self.assertTrue( exp==act )
def testR1FitParams_DenAndNeutAtom(self): expDenExp = (0.25977874512795540163, 1.189557405762461384) expDenCoeffs_R0 = (0.02679475556046136131, -0.026859074525597253363) expDenCoeffs_R1 = (0.0046827657367609657954, -0.027478265238950479177) expNeutAtomExp = (0.34263537115218700713, 1.3551837469820726678) expNeutAtomCoeffs_R0 = (-2.0638099246154166799, -7.4099430193128172917) expNeutAtomCoeffs_R1 = (0.029208685956966910086, 0.20618555433380203468) expDenObj = tCode.GauPolyBasis( expDenExp, [expDenCoeffs_R0, expDenCoeffs_R1] ) expNaObj = tCode.GauPolyBasis( expNeutAtomExp, [expNeutAtomCoeffs_R0, expNeutAtomCoeffs_R1] ) parsedFile = tCode.parseGauFile(self.filePathGauR1_A) actualDensity = parsedFile["density"] actualNeutAtom = parsedFile["neutAtom".lower()] self.assertTrue( actualDensity==expDenObj ) self.assertTrue( actualNeutAtom==expNaObj )
def testR0FileWeightFuncts(self): expectedWeightAVals = [(0.2256533391134165345, 37.734285273902244739), #(exponent,coefficient) (0.27166909389199239699, -225.58343293227176218)] expectedWeightBVals = [(0.65934295531661524237, -0.18788457858635970732), #(exponent,coefficient) (0.88972219525501938797, 0.16118101005396684444)] allExpectedVals = [expectedWeightAVals, expectedWeightBVals] parsedFile = tCode.parseGauFile(self.inpFile) allActualVals = parsedFile["weightfuncts"] for expVals,actVals in itertools.zip_longest(allExpectedVals,allActualVals): for primIdx,expPrimVals in enumerate(expVals): expExponent, expCoeff = expPrimVals[0], expPrimVals[1] actExponent, actCoeff = actVals.exponents[primIdx],actVals.r0Coeffs[primIdx] self.assertAlmostEqual( expExponent, actExponent ) self.assertAlmostEqual( expCoeff, actCoeff )