예제 #1
0
파일: dataset.py 프로젝트: lydiash/aBuild
    def init_enum(self,enumdicts,systemSpecies,runGetKpoints = True):
        from aBuild.enumeration import Enumerate
        from aBuild.calculators.vasp import VASP
        from aBuild.database.crystal import Crystal
        from aBuild.jobs import Job
        from random import randrange
        from aBuild.utility import chdir
        from numpy import array
        from os import remove, path

        #        from crystal import Crystal
        from os import path
        import os

        #    if not path.isdir(self.root):
        #    os.mkdir(self.root)
        print("Building database from enumerations")
        self.crystals = []
        #        configIndex = startPoint = self._starting_point
#########################my changes#########################3
        iterations = 0
########################################################
        for eDict in enumdicts:
            enumController = Enumerate(eDict)
            if enumController.nEnumStructs == 0:
                msg.warn('There are no enumerated structures for lattice type {}.  Not building any VASP folders for them.'.format(self.enumDicts[index]["name"]))
                enumController.buildInputFile()

                enumController.enumerate()
예제 #2
0
    def enumerate(self,dataset):
        from aBuild.enumeration import Enumerate

        self.dataset = dataset
        for index in range(self.nEnums):
            enumController = Enumerate(self.enumDicts[index])
            enumController.buildInputFile(False)
            enumController.enumerate(False)
예제 #3
0
    def init_enum(enumdicts, systemSpecies):
        from aBuild.enumeration import Enumerate
        from aBuild.calculators.vasp import VASP
        from aBuild.database.crystal import Crystal
        from aBuild.jobs import Job
        from random import randrange
        from aBuild.utility import chdir
        from numpy import array
        from os import remove, path

        #        from crystal import Crystal
        from os import path
        import os

        print("Building database from enumerations")
        crystals = []
        #        configIndex = startPoint = self._starting_point
        for eDict in enumdicts:
            enumController = Enumerate(eDict)
            if enumController.nEnumStructs == 0:
                msg.warn(
                    'There are no enumerated structures for lattice type {}.  Not building any VASP folders for them.'
                    .format(eDict["lattice"]))
                enumController.buildInputFile()

                enumController.enumerate()

            # Loop to generate random structures for a given lattice type
            for i in range(eDict["nconfigs"]):
                print('Adding {} structure # {} to database'.format(
                    eDict["lattice"], rStruct))
                with open('structNums', 'a+') as f:
                    f.write(eDict["name"] + ' ' + str(i) + '\n')
                enumController.generatePOSCAR(i)

                poscarpath = path.join(
                    enumController.root,
                    "poscar.{}.{}".format(eDict["name"], rStruct))
                thisCrystal = Crystal.from_poscar(
                    poscarpath, systemSpecies
                )  #title = ' '.join([self.enumDicts[index]["lattice"]," str #: {}"]).format(rStruct)
                crystals.append(thisCrystal)
                delpath = path.join(
                    enumController.root,
                    "poscar.{}.{}".format(eDict["name"], rStruct))
                remove(delpath)
        return dataset(crystals)
예제 #4
0
파일: dataset.py 프로젝트: to275/aBuild
    def init_enum(self, enumdicts, systemSpecies, runGetKpoints=True):
        from aBuild.enumeration import Enumerate
        from aBuild.calculators.vasp import VASP
        from aBuild.database.crystal import Crystal
        from aBuild.jobs import Job
        from random import randrange
        from aBuild.utility import chdir

        #        from crystal import Crystal
        from os import path
        import os

        #    if not path.isdir(self.root):
        #    os.mkdir(self.root)
        print("Building database from enumerations")
        self.crystals = []
        #        configIndex = startPoint = self._starting_point
        for eDict in enumdicts:
            enumController = Enumerate(eDict)
            if enumController.nEnumStructs == 0:
                msg.warn(
                    'There are no enumerated structures for lattice type {}.  Not building any VASP folders for them.'
                    .format(self.enumDicts[index]["lattice"]))
                enumController.buildInputFile()

                enumController.enumerate()

            # Loop to generate random structures for a given lattice type
            for i in range(eDict["nconfigs"]):
                rStruct = randrange(1, enumController.nEnumStructs)
                print('Adding {} structure # {} to database'.format(
                    eDict["lattice"], rStruct))
                with open('structNums', 'a+') as f:
                    f.write(eDict["lattice"] + ' ' + str(rStruct) + '\n')
                    #print("Building VASP folder for {} structure #: {}".format(eDict["lattice"],rStruct))
                enumController.generatePOSCAR(rStruct)

                poscarpath = path.join(
                    enumController.root,
                    "poscar.{}.{}".format(eDict["lattice"], rStruct))
                thisCrystal = Crystal(
                    poscarpath, systemSpecies=systemSpecies
                )  #title = ' '.join([self.enumDicts[index]["lattice"]," str #: {}"]).format(rStruct)
                self.crystals.append(thisCrystal)
예제 #5
0
    def init_enum(self, enumdicts, systemSpecies, runGetKpoints=True):
        from aBuild.enumeration import Enumerate
        from aBuild.calculators.vasp import VASP
        from aBuild.database.crystal import Crystal
        from aBuild.jobs import Job
        from random import randrange
        from aBuild.utility import chdir
        from numpy import array
        from os import remove, path

        #        from crystal import Crystal
        from os import path
        import os

        #    if not path.isdir(self.root):
        #    os.mkdir(self.root)
        print("Building database from enumerations")
        self.crystals = []
        #        configIndex = startPoint = self._starting_point
        for eDict in enumdicts:
            enumController = Enumerate(eDict)
            if enumController.nEnumStructs == 0:
                msg.warn(
                    'There are no enumerated structures for lattice type {}.  Not building any VASP folders for them.'
                    .format(self.enumDicts[index]["lattice"]))
                enumController.buildInputFile()

                enumController.enumerate()

            # Loop to generate random structures for a given lattice type
            for i in range(eDict["nconfigs"]):
                rStruct = 16254  #randrange(1,enumController.nEnumStructs)
                print('Adding {} structure # {} to database'.format(
                    eDict["lattice"], rStruct))
                with open('structNums', 'a+') as f:
                    f.write(eDict["name"] + ' ' + str(rStruct) + '\n')
                    #print("Building VASP folder for {} structure #: {}".format(eDict["lattice"],rStruct))
                enumController.generatePOSCAR(rStruct)

                poscarpath = path.join(
                    enumController.root,
                    "poscar.{}.{}".format(eDict["name"], rStruct))
                thisCrystal = Crystal(
                    poscarpath, systemSpecies=systemSpecies
                )  #title = ' '.join([self.enumDicts[index]["lattice"]," str #: {}"]).format(rStruct)
                if self.restrictions is None:
                    self.crystals.append(thisCrystal)
                elif thisCrystal.getAFMPlanes([1, 0, 0]):
                    print('parent is AFM compatible')
                    self.crystals.append(thisCrystal)
                    import sys
                    sys.exit()
                else:
                    superCrystal = thisCrystal.superPeriodics(2)
                    if superCrystal != []:
                        print('super periodic structures is AFM compatible')
                        print(superCrystal.minDist, 'minDist')
                        print(superCrystal.basis, ' basis')
                        print(array(superCrystal.Bv_direct), 'direct')
                        print(array(superCrystal.Bv_cartesian), 'cartesian')
                        self.crystals.append(superCrystal)
                        import sys
                        sys.exit()
                    else:
                        print("Can't find an AFM compatible structure")
                        import sys
                        sys.exit()
#                self.crystals.append(thisCrystal)
                delpath = path.join(
                    enumController.root,
                    "poscar.{}.{}".format(eDict["name"], rStruct))
                remove(delpath)