Example #1
0
 def __init__(self,input):
     #import structure from PYMATGEN
     self.key = input.APIKEY # Import API key from input
     self.MaterialID = input.MATERIALID # Set class variable MaterialID from input
     self.cutoff = input.ECUT
     self.Ecut = input.ECUT #Class variable; in Ryberg, transfer from input file
     self.kpts = input.KMESH ### KPTS from input file for a generator, class variable
     #self.pseudodir = "ABINIT/ABINITPP/ATOMICDATA/" # Set the directory for pseudopotentials
     self.EMAIL = input.Email #Class variable; set email for SLURM from input file
     self.NCORE = input.ncore #Class Variable; number of cores, taken from input file
     self.SOC = input.SOC
     self.nbnd = input.NUMBANDS
     self.lspinorb = '.FALSE.'
     if input.SOC:
         self.noncolin = '.TRUE.'
         self.lspinorb = '.TRUE.'
     selectconventional = input.conventional_cell
     selectrelax = input.Relax
     with matproj.MPRester(self.key) as m:
         struct = m.get_structure_by_material_id(self.MaterialID,final=selectrelax,conventional_unit_cell=selectconventional) # GET STRUCT FROM MATERIALS PROJECT
         self.struct = m.get_structure_by_material_id(self.MaterialID,final=selectrelax,conventional_unit_cell=selectconventional) # GET STRUCT FROM MATERIALS PROJECT
     C = Composition(str(struct.formula))
     self.seedname = str(input.seedname) # set class variable SEEDNAME from input file
     self.SEEDDIR = "OUTPUT/" + 'S-' + self.seedname + '/'  #set the seed directory
     # MAKE DIRECTORIES
     if not os.path.exists(self.SEEDDIR):
         os.makedirs(self.SEEDDIR)
     if not os.path.exists(self.SEEDDIR + "WT"):
         os.makedirs(self.SEEDDIR + "WT")
     ##### Set variables
     self.UNIQUE_ATOMS = np.unique(struct.species)
     self.cord = struct.frac_coords
     self.ntypat = np.unique(struct.atomic_numbers).size
     self.natom = np.array(struct.atomic_numbers).size
     self.numlist = np.array(struct.atomic_numbers)[::1]
     self.atomnum = np.unique(struct.atomic_numbers)[::1]
     self.typat = ""
     for x in struct.atomic_numbers:
         for at in self.atomnum:
             if at == x:
                     self.typat += ''.join(map(str,np.where(self.atomnum == at)
                         [0] + 1)) + " "
     # SOC CASE
     num_bands = input.NUMBANDS
     # for x in struct.species:
     #     PP = gb.glob(self.pseudodir + str(x) + ".*") 
     #     readpp = minidom.parse(''.join(map(str,PP)))
     #     items = readpp.getElementsByTagName('atom')
     #     num_bands += float(items[0].attributes['valence'].value)
     num_wann = num_bands - (num_bands%2) # FORCE EVEN
     self.wan = num_wann
     if self.SOC:
         self.WTwan = self.wan/2
     else:
         self.WTwan = self.wan
Example #2
0
import pandas as pd

from pymatgen.ext import matproj
from pymatgen.core import periodic_table

import util

if __name__ == '__main__':
    # path
    output_filepath = './query_result.csv'

    elementgroup_dict = util.element_of_interest()

    # open restful interface
    with matproj.MPRester(api_key='9bASScRXuQNDSebS') as m:
        # build criteria
        criteria = {
            'elements': {
                '$in': elementgroup_dict['transition_metal'],
                '$in': elementgroup_dict['chalcogen'],
                '$nin': elementgroup_dict['others'],
            },
            'nelements': {
                '$in': [2, 3]
            },
        }
        properties = ['material_id', 'pretty_formula', 'spacegroup', 'nsites']
        result = m.query(criteria=criteria, properties=properties)

    record = [{
        'material_id': row['material_id'],
Example #3
0
 def __init__(self, input):
     #self.CIFDIR = "cifdir/"
     self.key = input.APIKEY  # Import API key from input
     self.MaterialID = input.MATERIALID  # Set class variable MaterialID from input
     self.seedname = str(
         input.seedname)  # set class variable SEEDNAME from input file
     self.Ecut = input.ECUT  #Class variable; in Ryberg, transfer from input file
     self.kpts = input.KMESH  ### KPTS from input file for a generator, class variable
     self.SEEDDIR = "OUTPUT/" + 'Abi-' + self.seedname + '/'  #set the seed directory
     self.pseudodir = "Pseudopotentials/ABINIT/ATOMICDATA/"  # Set the directory for pseudopotentials
     self.EMAIL = input.Email  #Class variable; set email for SLURM from input file
     self.NCORE = input.ncore  #Class Variable; number of cores, taken from input file
     self.SOC = input.SOC
     selectconventional = input.conventional_cell
     selectrelax = input.Relax
     # MAKE DIRECTORIES
     if not os.path.exists(self.SEEDDIR):
         os.makedirs(self.SEEDDIR)
     if not os.path.exists(self.SEEDDIR + "PP"):
         os.makedirs(self.SEEDDIR + "PP")
     if not os.path.exists(self.SEEDDIR + "WT"):
         os.makedirs(self.SEEDDIR + "WT")
     #import structure from PYMATGEN
     with matproj.MPRester(self.key) as m:
         struct = m.get_structure_by_material_id(
             self.MaterialID,
             final=selectrelax,
             conventional_unit_cell=selectconventional
         )  # GET STRUCT FROM MATERIALS PROJECT
         self.struct = m.get_structure_by_material_id(
             self.MaterialID,
             final=selectrelax,
             conventional_unit_cell=selectconventional
         )  # GET STRUCT FROM MATERIALS PROJECT
     C = Composition(str(struct.formula))
     ########## MAKE A CIF FILE ###
     # cif = CifWriter(struct) # Start generator
     # cif.write_file(self.CIFDIR + self.seedname + ".cif") #write cif file to directory
     # ciffile = self.CIFDIR + self.seedname + ".cif" # define ciffile
     # cif = open(ciffile) # open cif file
     # parser = CifParser(ciffile) #Start Parser
     self.lattice = struct.lattice
     self.a = self.lattice.a
     self.b = self.lattice.b
     self.c = self.lattice.c
     self.alpha = self.lattice.alpha
     self.beta = self.lattice.beta
     self.gamma = self.lattice.gamma
     self.UNIQUE_ATOMS = np.unique(struct.species)
     self.cord = struct.frac_coords
     self.ntypat = np.unique(struct.atomic_numbers).size
     self.natom = np.array(struct.atomic_numbers).size
     self.atomnum = np.unique(struct.atomic_numbers)[::1]
     # It has to be done this way, otherwise format would be off
     self.typat = ""
     for x in struct.atomic_numbers:
         for at in self.atomnum:
             if at == x:
                 self.typat += ''.join(
                     map(str,
                         np.where(self.atomnum == at)[0] + 1)) + " "
     # SOC CASE
     num_bands = 0
     for x in struct.species:
         PP = gb.glob(self.pseudodir + str(x) + ".*")
         readpp = minidom.parse(''.join(map(str, PP)))
         items = readpp.getElementsByTagName('atom')
         num_bands += float(items[0].attributes['valence'].value)
     num_wann = num_bands - (num_bands % 2)  # FORCE EVEN
     self.wan = num_wann
     self.WTwan = num_wann
     if self.SOC:
         self.WTwan = self.wan / 2
Example #4
0
    def __init__(self):
        self.CIFDIR = "cifdir/"
        self.key = input.APIKEY  # Import API key from input
        self.MaterialID = input.MATERIALID  # Set class variable MaterialID from input
        self.seedname = str(
            input.SEEDNAME)  # set class variable SEEDNAME from input file
        self.Ecut = input.ECUT  #Class variable; in Ryberg, transfer from input file
        self.kpts = input.KMESH  ### KPTS from input file for a generator, class variable
        self.SEEDDIR = "OUTPUT/" + 'STA-' + self.seedname + '/'  #set the seed directory
        #self.pseudodir = "ABINIT/ABINITPP/ATOMICDATA/" # Set the directory for pseudopotentials
        self.EMAIL = input.EMAIL  #Class variable; set email for SLURM from input file
        self.NCORE = input.ncore  #Class Variable; number of cores, taken from input file
        self.SOC = input.SOC
        self.nbnd = input.NUMBANDS

        # MAKE DIRECTORIES
        if not os.path.exists(self.SEEDDIR):
            os.makedirs(self.SEEDDIR)
        if not os.path.exists(self.SEEDDIR + "WT"):
            os.makedirs(self.SEEDDIR + "WT")
        #import structure from PYMATGEN
        with matproj.MPRester(self.key) as m:
            struct = m.get_structure_by_material_id(
                self.MaterialID, final=True, conventional_unit_cell=False
            )  # GET STRUCT FROM MATERIALS PROJECT
            self.struct = m.get_structure_by_material_id(
                self.MaterialID, final=True, conventional_unit_cell=False
            )  # GET STRUCT FROM MATERIALS PROJECT
        C = Composition(str(struct.formula))
        ########## MAKE A CIF FILE ###
        cif = CifWriter(struct)  # Start generator
        cif.write_file(self.CIFDIR + self.seedname +
                       ".cif")  #write cif file to directory
        ciffile = self.CIFDIR + self.seedname + ".cif"  # define ciffile
        cif = open(ciffile)  # open cif file
        parser = CifParser(ciffile)  #Start Parser
        ####### PARSE VARIABLES FROM CIF ##########
        chk_a = "_cell_length_a"
        chk_b = "_cell_length_b"
        chk_c = "_cell_length_c"
        chk_alpha = "_cell_angle_alpha"
        chk_beta = "_cell_angle_beta"
        chk_gamma = "_cell_angle_gamma"
        chk_name = "_chemical_formula_structural"
        for x in cif:
            if chk_a in x:
                self.a = x.replace(chk_a, '').replace('\n', '')
            if chk_b in x:
                self.b = x.replace(chk_b, '').replace('\n', '')
            if chk_c in x:
                self.c = x.replace(chk_c, '').replace('\n', '')
            if chk_alpha in x:
                self.alpha = x.replace(chk_alpha, '').replace('\n', '')
            if chk_beta in x:
                self.beta = x.replace(chk_beta, '').replace('\n', '')
            if chk_gamma in x:
                self.gamma = x.replace(chk_gamma, '').replace('\n', '')
            #if chk_name in x:
            #    seedname = x.replace(chk_name, '')
            #    seedname = seedname.replace('\n', '').translate(
            #    {ord(i): None for i in ' '})
        self.UNIQUE_ATOMS = np.unique(struct.species)
        self.cord = struct.frac_coords
        self.ntypat = np.unique(struct.atomic_numbers).size
        self.natom = np.array(struct.atomic_numbers).size
        self.numlist = np.array(struct.atomic_numbers)[::1]
        self.atomnum = np.unique(struct.atomic_numbers)[::1]
        self.typat = ""
        for x in struct.atomic_numbers:
            for at in self.atomnum:
                if at == x:
                    self.typat += ''.join(
                        map(str,
                            np.where(self.atomnum == at)[0] + 1)) + " "
        # SOC CASE
        num_bands = input.NUMBANDS
        # for x in struct.species:
        #     PP = gb.glob(self.pseudodir + str(x) + ".*")
        #     readpp = minidom.parse(''.join(map(str,PP)))
        #     items = readpp.getElementsByTagName('atom')
        #     num_bands += float(items[0].attributes['valence'].value)
        num_wann = num_bands - (num_bands % 2)  # FORCE EVEN
        self.wan = num_wann
        if self.SOC:
            self.WTwan = self.wan / 2