def testModOptsCorrectInOutFile(self):
        platoCode = "dft2"
        expModdedOptDict = {
            "blochstates": [1, 1, 1],
            "e0method": 1,
            "xtalxcmethod": -1,
            "hopxcmethod": -1,
            "xtalVnaMethod".lower(): 1,
            "hopVnaMethod".lower(): -1,
            "xtalVnlMethod".lower(): 1,
            "hopVNLMethod".lower(): -1
        }

        expModdedOptStrDict = modInp.getStrDictFromOptDict(
            expModdedOptDict, platoCode)

        testWorkFlow = tCode.CreateEosWorkFlow(
            self.structDict,
            self.modOptDicts,
            self.workFolder,
            platoCode,
            onlyCalcE0=True,
            nonE0EnergyDict=self.testE1Vals)()
        inpFilePaths = testWorkFlow._inpFilePaths
        fullInpDict = modInp.tokenizePlatoInpFile(inpFilePaths[0])

        for key in expModdedOptStrDict.keys():
            self.assertEqual(expModdedOptStrDict[key], fullInpDict[key])
def _getOutputInvSkFileNames(inpFilePath):
    tokenizedFile = {
        k.lower(): v
        for k, v in platoInp.tokenizePlatoInpFile(inpFilePath).items()
    }
    if int(tokenizedFile["format"]) != 0:
        raise ValueError(
            "Geometry format needs to be {}; but format={}".format(
                0, tokenizedFile["format"]))

    #Get the elements present
    nAtoms = tokenizedFile["natom"]
    atoms = tokenizedFile["atoms"].split("\n")
    elementsPresent = list()
    for x in atoms:
        currElement = x.split()[-1]
        if currElement not in (elementsPresent):
            elementsPresent.append(currElement)

    #Get the file names from them
    outFileNames = [
        "{}_{}_SK.csv".format(a, b)
        for a, b in itertools.product(elementsPresent, elementsPresent)
    ]

    return outFileNames
Exemple #3
0
def createInputOptionsFromCmdLineArgs(cmdArgs):
    outObj = InputOptions()
    outObj.elementComboLists = optsToParams.getAllThreeBodyElementCombos(
        cmdArgs.elementList)
    baseStrDict = {
        k.lower(): v
        for k, v in platoInp.tokenizePlatoInpFile(
            cmdArgs.templatePath).items()
    }

    outObj.geomRepStr = cmdArgs.geomRepr
    outObj.nCores = int(cmdArgs.nCores)

    dFolderPath = getDataFolderPathFromStrDict(baseStrDict)

    cutoffDict = getCutoffValuesAllElements(cmdArgs.elementList, dFolderPath)
    if cmdArgs.geomSteps is None:
        cmdArgs.geomSteps = getDefaultStepValues(cmdArgs.geomRepr)
    outObj.geomParams = getGeomParamsAllElementLists(
        outObj.elementComboLists, [float(x) for x in cmdArgs.geomSteps],
        cutoffDict, cmdArgs.geomRepr)

    outObj.twoBodyStrDict = getStrDictTwoBodyCalc(baseStrDict)
    outObj.threeBodyStrDict = getStrDictThreeBodyCalc(baseStrDict)
    outObj.startFolder = os.path.abspath(cmdArgs.startFolder)
    outObj.runJobs = cmdArgs.runCalcs

    return outObj
    def testModOptsCorrectInOutFile(self):
        inpFilePaths = self.workFlowA._inpFilePaths
        expModdedOpts = self.modOptDicts
        expModdedOpts["hcp"]["addCorrectingPPFromBdt".lower()] = str(1)
        fullInpDict = modInp.tokenizePlatoInpFile(inpFilePaths[0])

        for key in expModdedOpts["hcp"]:
            self.assertEqual(expModdedOpts["hcp"][key], fullInpDict[key])
Exemple #5
0
    def testMultiLineMod(self):
        ''' Test modPlatoInpOption works for replacing option that runs over multiple lines'''
        testInpFile = self.filePathDict["testInpFragA"]
        expectedVal = "2\n1\n2"
        testOptVal = {'Pinned': expectedVal}
        key = 'Pinned'.lower()
        tCode.modPlatoInpOptions(testInpFile, testOptVal)

        parsedOptions = tCode.tokenizePlatoInpFile(testInpFile)
        self.assertEqual(expectedVal, parsedOptions[key])
Exemple #6
0
def _grabAtomGridSpacingFromInpFile(filePath, mode, angIdx=0):
	parsedFile = platoInp.tokenizePlatoInpFile(filePath)
	gridPart = parsedFile["integralmesh"].split("\n")

	if (mode == "angular"):
		gridVal = int( gridPart[1].split()[angIdx+1] )
	elif (mode == "radial"):
		gridVal = int( gridPart[1].split()[0] )
	else:
		raise ValueError("{} is an invalid mode for _grabAtomGridSpacingFromInpFile".format(mode))
	return gridVal
Exemple #7
0
    def testOneLineMod(self):
        ''' Test modPlatoInpOption works for a simple 1 line case (RFlag). NOTE: dependent '''
        ''' on tCode.tokenizePlatoInpFile '''
        testInpFile = self.filePathDict["testInpFragA"]
        testOptVal = {'RFlag': 5}
        key = 'RFlag'.lower()
        expectedVal = "5"
        tCode.modPlatoInpOptions(testInpFile, testOptVal)

        parsedOptions = tCode.tokenizePlatoInpFile(testInpFile)
        self.assertEqual(expectedVal, parsedOptions[key])
Exemple #8
0
    def testMutliMods(self):
        ''' Test modPlatoInpOption works when replacing >1 option '''
        testInpFile = self.filePathDict["testInpFragA"]
        expectedVals = ["5", "2\n1\n2"]
        keys = ["pinned", "rflag"]
        testOptVals = {k: v for k, v in zip(keys, expectedVals)}
        tCode.modPlatoInpOptions(testInpFile, testOptVals)

        parsedOptions = tCode.tokenizePlatoInpFile(testInpFile)
        [
            self.assertEqual(expectedVals[x], parsedOptions[keys[x]])
            for x in range(len(expectedVals))
        ]
Exemple #9
0
 def testTokenizeInpFragmentA(self):
     testInpFile = self.filePathDict["testInpFragA"]
     expectedVals = {
         "rflag": "3",
         "cellrelaxmode": "0",
         "FTol".lower(): "0.0001",
         "MaxDisplacement".lower(): "0.1",
         "StressTol".lower(): "0.001",
         "Pinned".lower(): "0\n1",
         "Constrain".lower(): "0\n1 1.0 1.0 0.0",
         "ReactionCoordinate".lower(): "0"
     }
     actualVals = tCode.tokenizePlatoInpFile(testInpFile)
     self.assertEqual(expectedVals, actualVals)
def _modInvSkFlagToOn(inpFilePath):
	tokenizedFile = platoInp.tokenizePlatoInpFile(inpFilePath)
	outOptDict = {k.lower():v for k,v in tokenizedFile.items()}
	outOptDict["inversesk"] = "1"
	platoInp.writePlatoOutFileFromDict(inpFilePath,outOptDict)