예제 #1
0
 def write_neb_phonon_sd_manifests(self):
     """Make NEB phonon manifests.
     """
     neb_dict=self.input_options.get_item('neb','nebs')
     if neb_dict == None:
         return None
     nlabels=neb_dict.keys()
     
     scales = self.scaling.keys()
     scales.append("")
     for scaling_label in scales:
         if scaling_label == "":
             mySE=SE(struc_work1=self.startstr.copy())
         else:
             mySE=SE(struc_work1=self.startstr.copy(), scaling_size=self.scaling[scaling_label]["mast_size"])
         for nlabel in nlabels:
             pdict = dict(neb_dict[nlabel]["phonon"])
             for phonon_label in pdict.keys():
                 pcoordsraw = pdict[phonon_label]['phonon_center_site']
                 pthresh = pdict[phonon_label]['threshold']
                 pcrad = pdict[phonon_label]['phonon_center_radius']
                 pcoords = np.array(pcoordsraw.split(),'float')
                 if not (scaling_label == ""):
                     pcoords = mySE.get_scaled_coordinates(pcoords)
                  
                 #pindices = self.find_orig_frac_coord_in_structure_dictionary(sdict, pcoords, pthresh+pcrad, True)
                 pindices = self.find_orig_frac_coord_in_atom_indices(pcoords,"",scaling_label,True,0.001+pcrad)
                 manname=os.path.join(self.sdir,"manifest_phonon_sd_%s_%s_%s" % (nlabel, phonon_label, scaling_label))
                 self.write_manifest_file(pindices, manname) 
     return
예제 #2
0
    def write_neb_phonon_sd_manifests(self):
        """Make NEB phonon manifests.
        """
        neb_dict = self.input_options.get_item('neb', 'nebs')
        if neb_dict == None:
            return None
        nlabels = neb_dict.keys()

        scales = self.scaling.keys()
        scales.append("")
        for scaling_label in scales:
            if scaling_label == "":
                mySE = SE(struc_work1=self.startstr.copy())
            else:
                mySE = SE(
                    struc_work1=self.startstr.copy(),
                    scaling_size=self.scaling[scaling_label]["mast_size"])
            for nlabel in nlabels:
                pdict = dict(neb_dict[nlabel]["phonon"])
                for phonon_label in pdict.keys():
                    pcoordsraw = pdict[phonon_label]['phonon_center_site']
                    pthresh = pdict[phonon_label]['threshold']
                    pcrad = pdict[phonon_label]['phonon_center_radius']
                    pcoords = np.array(pcoordsraw.split(), 'float')
                    if not (scaling_label == ""):
                        pcoords = mySE.get_scaled_coordinates(pcoords)

                    #pindices = self.find_orig_frac_coord_in_structure_dictionary(sdict, pcoords, pthresh+pcrad, True)
                    pindices = self.find_orig_frac_coord_in_atom_indices(
                        pcoords, "", scaling_label, True, 0.001 + pcrad)
                    manname = os.path.join(
                        self.sdir, "manifest_phonon_sd_%s_%s_%s" %
                        (nlabel, phonon_label, scaling_label))
                    self.write_manifest_file(pindices, manname)
        return
예제 #3
0
 def write_neb_endpoint_manifests(self):
     """Make NEB endpoint manifests.
     """
     neb_dict=self.input_options.get_item('neb','nebs')
     if neb_dict == None:
         return None
     nlabels=neb_dict.keys()
     
     scales = self.scaling.keys()
     scales.append("")
     for scaling_label in scales:
         if scaling_label == "":
             mySE=SE(struc_work1=self.startstr.copy())
         else:
             mySE=SE(struc_work1=self.startstr.copy(), scaling_size=self.scaling[scaling_label]["mast_size"])
         for nlabel in nlabels:
             def1 = nlabel.split("-")[0].strip()
             def2 = nlabel.split("-")[1].strip()
             manname1=os.path.join(self.sdir,"manifest_%s_%s_%s" % (scaling_label, def1, nlabel))
             manname2=os.path.join(self.sdir,"manifest_%s_%s_%s" % (scaling_label, def2, nlabel))
             mlist1raw=list(self.read_manifest_file("%s/manifest_%s_%s_" % (self.sdir, scaling_label, def1)))
             mlist2raw=list(self.read_manifest_file("%s/manifest_%s_%s_" % (self.sdir, scaling_label, def2)))
             mlist1=list()
             mlist2=list()
             for mitem in mlist1raw: #clean up leftover semicolons from defect manifests
                 if ";" in mitem:
                     mlist1.append(mitem.split(";")[0])
                 else:
                     mlist1.append(mitem)
             for mitem in mlist2raw: #clean up leftover semicolons from defect manifests
                 if ";" in mitem:
                     mlist2.append(mitem.split(";")[0])
                 else:
                     mlist2.append(mitem)
             maddtoend1=list()
             maddtoend2=list()
             nlines=list(neb_dict[nlabel]["lines"])
             for nline in nlines:
                 ncoord1 = np.array(nline[1].split(), 'float')
                 ncoord2 = np.array(nline[2].split(), 'float')
                 if not (scaling_label == ""):
                     ncoord1 = mySE.get_scaled_coordinates(ncoord1)
                     ncoord2 = mySE.get_scaled_coordinates(ncoord2)
                 nelem = nline[0]
                 nidx1 = self.find_orig_frac_coord_in_atom_indices(ncoord1, nelem, scaling_label, False, 0.001)
                 nidx2 = self.find_orig_frac_coord_in_atom_indices(ncoord2, nelem, scaling_label, False, 0.001)
                 try:
                     mlist1.remove(nidx1)
                 except ValueError:
                     raise MASTError(self.__class__.__name__, "For neb %s, cannot remove atom index %s from mlist1: %s" % (nlabel, nidx1, mlist1))
                 maddtoend1.append(nidx1) #resort matches to the bottom
                 try:
                     mlist2.remove(nidx2)
                 except ValueError:
                     raise MASTError(self.__class__.__name__, "For neb %s, cannot remove atom index %s from mlist2: %s" % (nlabel, nidx2, mlist2))
                 maddtoend2.append(nidx2)
             if not (mlist1==mlist2):
                 raise MASTError("NEB %s truncated manifests do not match: %s, %s" % (nlabel, mlist1, mlist2))
             mlist1.extend(maddtoend1)
             mlist2.extend(maddtoend2)
             self.write_manifest_file(mlist1, manname1)
             self.write_manifest_file(mlist2, manname2)
     return
예제 #4
0
 def write_defected_atom_indices(self):
     """Write any additional defect atom indices and make manifests.
     """
     defect_dict=self.input_options.get_item('defects','defects')
     if defect_dict == None:
         return None
     dlabels=defect_dict.keys()
     
     scales = self.scaling.keys()
     scales.append("")
     for scaling_label in scales:
         alist=list(self.read_manifest_file("%s/manifest_%s__" % (self.sdir, scaling_label)))
         if scaling_label == "":
             mySE=SE(struc_work1=self.startstr.copy())
         else:
             mySE=SE(struc_work1=self.startstr.copy(), scaling_size=self.scaling[scaling_label]["mast_size"])
         for dlabel in dlabels:
             dlist = list(alist)
             manname=os.path.join(self.sdir,"manifest_%s_%s_" % (scaling_label, dlabel))
             dsubkeys=defect_dict[dlabel].keys()
             for dsubkey in dsubkeys:
                 if "subdefect_" in dsubkey:
                     dtype=defect_dict[dlabel][dsubkey]['type']
                     dcoords=defect_dict[dlabel][dsubkey]['coordinates']
                     delement=defect_dict[dlabel][dsubkey]['symbol']
                     if not (scaling_label == ""):
                         dcoords = mySE.get_scaled_coordinates(dcoords)
                     if dtype == "interstitial":
                         didx=self.find_orig_frac_coord_in_atom_indices(dcoords, delement, scaling_label, False, 0.001)
                         if didx == None:
                             akey=self.get_new_key()
                             aname="atom_index_%s" % akey
                             aname = os.path.join(self.sdir, aname)
                             ameta = Metadata(metafile=aname)
                             ameta.write_data("atom_index",akey)
                             ameta.write_data("original_frac_coords", dcoords)
                             ameta.write_data("element", delement)
                             ameta.write_data("scaling_label", scaling_label)
                             dlist.append("%s;int" % akey) #interstitial label
                         else:
                             dlist.append("%s;int" % didx)
                     elif dtype == "vacancy":
                         didx=self.find_orig_frac_coord_in_atom_indices(dcoords, delement, scaling_label, False, 0.001)
                         try:
                             dlist.remove(didx)
                         except ValueError:
                             raise MASTError(self.__class__.__name__, "For defect %s, cannot remove atom index %s from list: %s" % (dlabel, didx, dlist))
                     elif dtype in ["substitution","antisite"]:
                         didxlist=self.find_orig_frac_coord_in_atom_indices(dcoords, "", scaling_label, True, 0.001) #leave element empty; just search coords
                         idxtorepl=list()
                         for didx in didxlist:
                             dmeta = Metadata(metafile="%s/atom_index_%s" % (self.sdir, didx))
                             dmetaelem = dmeta.read_data("element")
                             if not (delement == dmetaelem):
                                 if didx in dlist:
                                     dlist.remove(didx)
                                     idxtorepl.append(didx)
                         if len(idxtorepl) > 1:
                             raise MASTError(self.__class__.__name__, "Interstitial %s is attempting to replace more than one atom: %s" % (dlabel, idxtorepl))
                         didxsub=self.find_orig_frac_coord_in_atom_indices(dcoords, delement, scaling_label, False, 0.001) #leave element empty; just search coords
                         if didxsub == None:
                             akey=self.get_new_key()
                             aname="atom_index_%s" % akey
                             aname = os.path.join(self.sdir, aname)
                             ameta = Metadata(metafile=aname)
                             ameta.write_data("atom_index",akey)
                             ameta.write_data("original_frac_coords", dcoords)
                             ameta.write_data("element", delement) #sub element here
                             ameta.write_data("scaling_label", scaling_label)
                             dlist.append("%s;%s" % (akey, idxtorepl[0]))
                         else:
                             dlist.append("%s;%s" % (didxsub, idxtorepl[0]))
             self.write_manifest_file(dlist, manname)
     return 
예제 #5
0
    def write_neb_endpoint_manifests(self):
        """Make NEB endpoint manifests.
        """
        neb_dict = self.input_options.get_item('neb', 'nebs')
        if neb_dict == None:
            return None
        nlabels = neb_dict.keys()

        scales = self.scaling.keys()
        scales.append("")
        for scaling_label in scales:
            if scaling_label == "":
                mySE = SE(struc_work1=self.startstr.copy())
            else:
                mySE = SE(
                    struc_work1=self.startstr.copy(),
                    scaling_size=self.scaling[scaling_label]["mast_size"])
            for nlabel in nlabels:
                def1 = nlabel.split("-")[0].strip()
                def2 = nlabel.split("-")[1].strip()
                manname1 = os.path.join(
                    self.sdir,
                    "manifest_%s_%s_%s" % (scaling_label, def1, nlabel))
                manname2 = os.path.join(
                    self.sdir,
                    "manifest_%s_%s_%s" % (scaling_label, def2, nlabel))
                mlist1raw = list(
                    self.read_manifest_file("%s/manifest_%s_%s_" %
                                            (self.sdir, scaling_label, def1)))
                mlist2raw = list(
                    self.read_manifest_file("%s/manifest_%s_%s_" %
                                            (self.sdir, scaling_label, def2)))
                mlist1 = list()
                mlist2 = list()
                for mitem in mlist1raw:  #clean up leftover semicolons from defect manifests
                    if ";" in mitem:
                        mlist1.append(mitem.split(";")[0])
                    else:
                        mlist1.append(mitem)
                for mitem in mlist2raw:  #clean up leftover semicolons from defect manifests
                    if ";" in mitem:
                        mlist2.append(mitem.split(";")[0])
                    else:
                        mlist2.append(mitem)
                maddtoend1 = list()
                maddtoend2 = list()
                nlines = list(neb_dict[nlabel]["lines"])
                for nline in nlines:
                    ncoord1 = np.array(nline[1].split(), 'float')
                    ncoord2 = np.array(nline[2].split(), 'float')
                    if not (scaling_label == ""):
                        ncoord1 = mySE.get_scaled_coordinates(ncoord1)
                        ncoord2 = mySE.get_scaled_coordinates(ncoord2)
                    nelem = nline[0]
                    nidx1 = self.find_orig_frac_coord_in_atom_indices(
                        ncoord1, nelem, scaling_label, False, 0.001)
                    nidx2 = self.find_orig_frac_coord_in_atom_indices(
                        ncoord2, nelem, scaling_label, False, 0.001)
                    try:
                        mlist1.remove(nidx1)
                    except ValueError:
                        raise MASTError(
                            self.__class__.__name__,
                            "For neb %s, cannot remove atom index %s from mlist1: %s"
                            % (nlabel, nidx1, mlist1))
                    maddtoend1.append(nidx1)  #resort matches to the bottom
                    try:
                        mlist2.remove(nidx2)
                    except ValueError:
                        raise MASTError(
                            self.__class__.__name__,
                            "For neb %s, cannot remove atom index %s from mlist2: %s"
                            % (nlabel, nidx2, mlist2))
                    maddtoend2.append(nidx2)
                if not (mlist1 == mlist2):
                    raise MASTError(
                        "NEB %s truncated manifests do not match: %s, %s" %
                        (nlabel, mlist1, mlist2))
                mlist1.extend(maddtoend1)
                mlist2.extend(maddtoend2)
                self.write_manifest_file(mlist1, manname1)
                self.write_manifest_file(mlist2, manname2)
        return
예제 #6
0
    def write_defected_atom_indices(self):
        """Write any additional defect atom indices and make manifests.
        """
        defect_dict = self.input_options.get_item('defects', 'defects')
        if defect_dict == None:
            return None
        dlabels = defect_dict.keys()

        scales = self.scaling.keys()
        scales.append("")
        for scaling_label in scales:
            alist = list(
                self.read_manifest_file("%s/manifest_%s__" %
                                        (self.sdir, scaling_label)))
            if scaling_label == "":
                mySE = SE(struc_work1=self.startstr.copy())
            else:
                mySE = SE(
                    struc_work1=self.startstr.copy(),
                    scaling_size=self.scaling[scaling_label]["mast_size"])
            for dlabel in dlabels:
                dlist = list(alist)
                manname = os.path.join(
                    self.sdir, "manifest_%s_%s_" % (scaling_label, dlabel))
                dsubkeys = defect_dict[dlabel].keys()
                for dsubkey in dsubkeys:
                    if "subdefect_" in dsubkey:
                        dtype = defect_dict[dlabel][dsubkey]['type']
                        dcoords = defect_dict[dlabel][dsubkey]['coordinates']
                        delement = defect_dict[dlabel][dsubkey]['symbol']
                        if not (scaling_label == ""):
                            dcoords = mySE.get_scaled_coordinates(dcoords)
                        if dtype == "interstitial":
                            didx = self.find_orig_frac_coord_in_atom_indices(
                                dcoords, delement, scaling_label, False, 0.001)
                            if didx == None:
                                akey = self.get_new_key()
                                aname = "atom_index_%s" % akey
                                aname = os.path.join(self.sdir, aname)
                                ameta = Metadata(metafile=aname)
                                ameta.write_data("atom_index", akey)
                                ameta.write_data("original_frac_coords",
                                                 dcoords)
                                ameta.write_data("element", delement)
                                ameta.write_data("scaling_label",
                                                 scaling_label)
                                dlist.append("%s;int" %
                                             akey)  #interstitial label
                            else:
                                dlist.append("%s;int" % didx)
                        elif dtype == "vacancy":
                            didx = self.find_orig_frac_coord_in_atom_indices(
                                dcoords, delement, scaling_label, False, 0.001)
                            try:
                                dlist.remove(didx)
                            except ValueError:
                                raise MASTError(
                                    self.__class__.__name__,
                                    "For defect %s, cannot remove atom index %s from list: %s"
                                    % (dlabel, didx, dlist))
                        elif dtype in ["substitution", "antisite"]:
                            didxlist = self.find_orig_frac_coord_in_atom_indices(
                                dcoords, "", scaling_label, True, 0.001
                            )  #leave element empty; just search coords
                            idxtorepl = list()
                            for didx in didxlist:
                                dmeta = Metadata(metafile="%s/atom_index_%s" %
                                                 (self.sdir, didx))
                                dmetaelem = dmeta.read_data("element")
                                if not (delement == dmetaelem):
                                    if didx in dlist:
                                        dlist.remove(didx)
                                        idxtorepl.append(didx)
                            if len(idxtorepl) > 1:
                                raise MASTError(
                                    self.__class__.__name__,
                                    "Interstitial %s is attempting to replace more than one atom: %s"
                                    % (dlabel, idxtorepl))
                            didxsub = self.find_orig_frac_coord_in_atom_indices(
                                dcoords, delement, scaling_label, False, 0.001
                            )  #leave element empty; just search coords
                            if didxsub == None:
                                akey = self.get_new_key()
                                aname = "atom_index_%s" % akey
                                aname = os.path.join(self.sdir, aname)
                                ameta = Metadata(metafile=aname)
                                ameta.write_data("atom_index", akey)
                                ameta.write_data("original_frac_coords",
                                                 dcoords)
                                ameta.write_data("element",
                                                 delement)  #sub element here
                                ameta.write_data("scaling_label",
                                                 scaling_label)
                                dlist.append("%s;%s" % (akey, idxtorepl[0]))
                            else:
                                dlist.append("%s;%s" % (didxsub, idxtorepl[0]))
                self.write_manifest_file(dlist, manname)
        return