Esempio n. 1
0
def compare_old_and_new_change_status_files():
    """Compare old and new status files from $MAST_CONTROL
        and $MAST_SCRATCH.
        Write an indication whether the status files have changed,
        not changed. Use "archived" if a recipe has been archived or is
        missing from SCRATCH for some other reason.
    """
    rdict = dict()
    mastcontrol = dirutil.get_mast_control_path()
    mastscratch = dirutil.get_mast_scratch_path()
    recipedirs = dirutil.immediate_subdirs(
        os.path.join(mastcontrol, "changestatusfiles"))
    for recipedir in recipedirs:
        mystatus = "unknown"
        rdict[recipedir] = dict()
        changelist = list()
        if not os.path.exists(os.path.join(mastscratch, recipedir)):
            mystatus = "archived"
        else:
            ingreddirs = dirutil.immediate_subdirs(
                os.path.join(mastcontrol, "changestatusfiles", recipedir))
            for ingreddir in ingreddirs:
                scratchstatusfile = MASTFile(
                    os.path.join(mastscratch, recipedir, ingreddir,
                                 "change_status.txt"))
                controlstatusfile = MASTFile(
                    os.path.join(mastcontrol, "changestatusfiles", recipedir,
                                 ingreddir, "change_status.txt"))
                if scratchstatusfile.data == controlstatusfile.data:
                    mystatus = "unchanged"
                else:
                    mystatus = "changed"
                    rdict[recipedir][ingreddir] = "send"
            rdict[recipedir]["MAIN"] = mystatus
    return rdict
Esempio n. 2
0
def get_new_change_status_files():
    """Compare old and new status files from $MAST_CONTROL
        and $MAST_SCRATCH.
        Write an indication whether the status files have changed,
        not changed. Use "archived" if a recipe has been archived or is
        missing from SCRATCH for some other reason.
    """
    rdict = dict()
    mastcontrol = dirutil.get_mast_control_path()
    mastscratch = dirutil.get_mast_scratch_path()
    olddirs = list()
    recipedirs = dirutil.immediate_subdirs(
        os.path.join(mastcontrol, "changestatusfiles"))
    for recipedir in recipedirs:
        ingreddirs = dirutil.immediate_subdirs(
            os.path.join(mastcontrol, "changestatusfiles", recipedir))
        for ingreddir in ingreddirs:
            olddirs.append("%s/%s" % (recipedir, ingreddir))
    srecdirs = dirutil.immediate_subdirs(mastscratch)
    for srecdir in srecdirs:
        singreddirs = dirutil.immediate_subdirs(
            os.path.join(mastscratch, srecdir))
        for singreddir in singreddirs:
            csfile = os.path.join(mastscratch, srecdir, singreddir,
                                  "change_status.txt")
            if os.path.isfile(csfile):
                if not "%s/%s" % (srecdir, singreddir) in olddirs:
                    if not srecdir in rdict.keys():
                        rdict[srecdir] = dict()
                    rdict[srecdir]["MAIN"] = "changed"
                    rdict[srecdir][singreddir] = "send"
    return rdict
Esempio n. 3
0
def save_old_change_status_files():
    """Save off old status files from $MAST_SCRATCH
       into $MAST_CONTROL
    """
    mastcontrol = dirutil.get_mast_control_path()
    if not os.path.exists(os.path.join(mastcontrol, "changestatusfiles")):
        os.mkdir(os.path.join(mastcontrol, "changestatusfiles"))
    mastscratch = dirutil.get_mast_scratch_path()
    recipedirs = dirutil.immediate_subdirs(mastscratch)
    for recipedir in recipedirs:
        ingreddirs = dirutil.immediate_subdirs(
            os.path.join(mastscratch, recipedir))
        for ingreddir in ingreddirs:
            csfile = os.path.join(mastscratch, recipedir, ingreddir,
                                  "change_status.txt")
            if os.path.isfile(csfile):
                changestatusfile = MASTFile(csfile)
                trydir = os.path.join(mastcontrol, "changestatusfiles",
                                      recipedir)
                if not os.path.exists(trydir):
                    os.mkdir(trydir)
                trydir2 = os.path.join(trydir, ingreddir)
                if not os.path.exists(trydir2):
                    os.mkdir(trydir2)
                    changestatusfile.to_file("%s/change_status.txt" % trydir2)
    return True
Esempio n. 4
0
def compare_old_and_new_change_status_files():
    """Compare old and new status files from $MAST_CONTROL
        and $MAST_SCRATCH.
        Write an indication whether the status files have changed,
        not changed. Use "archived" if a recipe has been archived or is
        missing from SCRATCH for some other reason.
    """
    rdict=dict()
    mastcontrol=dirutil.get_mast_control_path()
    mastscratch=dirutil.get_mast_scratch_path()
    recipedirs=dirutil.immediate_subdirs(os.path.join(mastcontrol,"changestatusfiles"))
    for recipedir in recipedirs:
        mystatus="unknown"
        rdict[recipedir]=dict()
        changelist=list()
        if not os.path.exists(os.path.join(mastscratch,recipedir)):
            mystatus="archived"
        else:
            ingreddirs = dirutil.immediate_subdirs(os.path.join(mastcontrol,"changestatusfiles",recipedir))
            for ingreddir in ingreddirs:
                scratchstatusfile = MASTFile(os.path.join(mastscratch,recipedir,ingreddir,"change_status.txt"))
                controlstatusfile = MASTFile(os.path.join(mastcontrol,"changestatusfiles",recipedir,ingreddir,"change_status.txt"))
                if scratchstatusfile.data == controlstatusfile.data:
                    mystatus="unchanged"
                else:
                    mystatus="changed"
                    rdict[recipedir][ingreddir]="send"
            rdict[recipedir]["MAIN"]=mystatus
    return rdict
Esempio n. 5
0
def get_new_change_status_files():
    """Compare old and new status files from $MAST_CONTROL
        and $MAST_SCRATCH.
        Write an indication whether the status files have changed,
        not changed. Use "archived" if a recipe has been archived or is
        missing from SCRATCH for some other reason.
    """
    rdict=dict()
    mastcontrol=dirutil.get_mast_control_path()
    mastscratch=dirutil.get_mast_scratch_path()
    olddirs=list()
    recipedirs=dirutil.immediate_subdirs(os.path.join(mastcontrol,"changestatusfiles"))
    for recipedir in recipedirs:
        ingreddirs = dirutil.immediate_subdirs(os.path.join(mastcontrol,"changestatusfiles",recipedir))
        for ingreddir in ingreddirs:
            olddirs.append("%s/%s" % (recipedir, ingreddir))
    srecdirs = dirutil.immediate_subdirs(mastscratch)
    for srecdir in srecdirs:
        singreddirs = dirutil.immediate_subdirs(os.path.join(mastscratch,srecdir))
        for singreddir in singreddirs:
            csfile = os.path.join(mastscratch, srecdir, singreddir, "change_status.txt")
            if os.path.isfile(csfile):
                if not "%s/%s" % (srecdir, singreddir) in olddirs:
                    if not srecdir in rdict.keys():
                        rdict[srecdir]=dict()
                    rdict[srecdir]["MAIN"]="changed"
                    rdict[srecdir][singreddir]="send"
    return rdict
Esempio n. 6
0
def save_ingredient_files(listfilename="",whichfilename=""):
    """Save off old files from ingredients in $MAST_SCRATCH
       into $MAST_CONTROL
       Args:
        listfilename <str>: File name for the list of files to be saved
        whichfilename <str>: Short file name to be saved (identical file
                                for all recipes)
    """
    if listfilename == "":
        raise NameError("No list file name given.")
    if whichfilename == "":
        raise NameError("No file name given for which files to save.")
    mastcontrol=dirutil.get_mast_control_path()
    if not os.path.exists(os.path.join(mastcontrol,listfilename)):
        os.mkdir(os.path.join(mastcontrol,listfilename))
    mastscratch=dirutil.get_mast_scratch_path()
    recipedirs=dirutil.immediate_subdirs(mastscratch)
    for recipedir in recipedirs:
        recipefulldir=os.path.join(mastscratch,recipedir)
        ingreddirs=dirutil.immediate_subdirs(recipefulldir)
        for ingreddir in ingreddirs:
            statfilepath = os.path.join(recipefulldir, ingreddir, whichfilename)
            if os.path.exists(statfilepath):
                statusfile = MASTFile(statfilepath)
                trydir = os.path.join(mastcontrol,listfilename,recipedir,ingreddir)
                if not os.path.exists(trydir):
                    os.mkdir(trydir)
                statusfile.to_file("%s/%s" % (trydir, whichfilename))
    return True
Esempio n. 7
0
def compare_old_and_new_status_files():
    """Compare old and new status files from $MAST_CONTROL
        and $MAST_SCRATCH.
        Write an indication whether the status files have changed,
        not changed. Use "archived" if a recipe has been archived or is
        missing from SCRATCH for some other reason.
    """
    rdict=dict()
    mastcontrol=dirutil.get_mast_control_path()
    mastscratch=dirutil.get_mast_scratch_path()
    recipedirs=dirutil.immediate_subdirs(os.path.join(mastcontrol,"statusfiles"))
    for recipedir in recipedirs:
        mystatus="unknown"
        rdict[recipedir]=dict()
        changelist=list()
        if not os.path.exists(os.path.join(mastscratch,recipedir)):
            mystatus="archived"
	else:
            scratchstatusfile = MASTFile(os.path.join(mastscratch,recipedir,"status.txt"))
            controlstatusfile = MASTFile(os.path.join(mastcontrol,"statusfiles",recipedir,"status.txt"))
            if scratchstatusfile.data == controlstatusfile.data:
                mystatus="unchanged"
            else:
                mystatus="changed"
                myidx=0
                while myidx < len(scratchstatusfile.data):
                    oldline = controlstatusfile.data[myidx]
                    newline = scratchstatusfile.data[myidx]
                    if "#" in oldline:
                        pass
                    else:
                        ingred = oldline.split(":")[0].strip()
                        oldstatus = oldline.split(":")[1].strip()
                        newstatus = newline.split(":")[1].strip()
                        if (oldstatus == "P") and (newstatus == "P"):
                             rdict[recipedir][ingred]="AVOID"
                        elif (oldstatus == "C") and (newstatus == "C"):
                             rdict[recipedir][ingred]="AVOID"
                        else:
                             rdict[recipedir][ingred]="send"
                    myidx = myidx + 1
        rdict[recipedir]["MAIN"]=mystatus
    recipedirs=dirutil.immedate_subdirs(os.path.join(mastcontrol,"changestatusfiles"))
    for recipedir in recipedirs:
        ingreddirs=dirutil.immediate_subdirs(os.path.join(mastcontrol,"changestatusfiles",recipedir))
        for ingreddir in ingreddirs:
            oldchangestatus=MASTFile(os.path.join(mastcontrol,"changestatusfiles",recipedir,ingreddir,"change_status.txt"))
            newchangestatus=MASTFile(os.path.join(mastscratch,recipedir,ingreddir,"change_status.txt"))
            if not (oldchangestatus.data == newchangestatus.data):
                rdict[recipedir]["MAIN"]="changed"
                rdict[recipedir][ingreddir]="send"
    rchangefile = MASTFile()
    for rdir in rdict.keys():
        for key, value in rdict[rdir].iteritems():
            rchangefile.data.append("%s:%s:%s\n" % (rdir,key,value))
    rchangefile.to_file(os.path.join(mastcontrol,"recipechangefile.txt"))
    return True
Esempio n. 8
0
def main(ingname=""):
    """Get the energy from an ingredient.
        Args:
            ingname <str>: Ingredient name, full path
        Returns:
            <string>: "energy (eV);<energy as a string>", ex:
                "energy (eV); 3.0"
                Returns last E0 energy for a VASP run.
                Returns last E0 energy for all images for a VASP neb.
                Returns "N/A" otherwise.
    """
    trymeta = "%s/metadata.txt" % ingname
    if os.path.isfile(trymeta):
        mymeta = Metadata(metafile=trymeta)
        myprogram = mymeta.read_data("program")
    else:
        myprogram = "None"
    if 'induce' in ingname: #skip inducedefect ingredients
        myprogram = "None"
    if 'vasp' in myprogram:
        if os.path.isdir("%s/01" % ingname):
            estr = "energies (eV)"
            for subdir in dirutil.immediate_subdirs(ingname):
                mychecker = VaspChecker(name="%s/%s" % (ingname, subdir))
                estr = estr + ";%3.3f" % mychecker.get_energy_from_energy_file()
            return estr
        else:
            mychecker = VaspChecker(name=ingname)
            return "energy (eV);%3.3f" % mychecker.get_energy_from_energy_file()
    else:
        return "energy (eV);N/A"
Esempio n. 9
0
def main(ingname=""):
    """Get the energy from an ingredient.
        Args:
            ingname <str>: Ingredient name, full path
        Returns:
            <string>: "energy (eV);<energy as a string>", ex:
                "energy (eV); 3.0"
                Returns last E0 energy for a VASP run.
                Returns last E0 energy for all images for a VASP neb.
                Returns "N/A" otherwise.
    """
    trymeta = "%s/metadata.txt" % ingname
    if os.path.isfile(trymeta):
        mymeta = Metadata(metafile=trymeta)
        myprogram = mymeta.read_data("program")
    else:
        myprogram = "None"
    if 'induce' in ingname:  #skip inducedefect ingredients
        myprogram = "None"
    if 'vasp' in myprogram:
        if os.path.isdir("%s/01" % ingname):
            estr = "energies (eV)"
            for subdir in dirutil.immediate_subdirs(ingname):
                mychecker = VaspChecker(name="%s/%s" % (ingname, subdir))
                estr = estr + ";%3.3f" % mychecker.get_energy_from_energy_file(
                )
            return estr
        else:
            mychecker = VaspChecker(name=ingname)
            return "energy (eV);%3.3f" % mychecker.get_energy_from_energy_file(
            )
    else:
        return "energy (eV);N/A"
Esempio n. 10
0
def compare_old_and_new_status_files():
    """Compare old and new status files from $MAST_CONTROL
        and $MAST_SCRATCH.
        Write an indication whether the status files have changed,
        not changed. Use "archived" if a recipe has been archived or is
        missing from SCRATCH for some other reason.
    """
    rdict = dict()
    mastcontrol = dirutil.get_mast_control_path()
    mastscratch = dirutil.get_mast_scratch_path()
    recipedirs = dirutil.immediate_subdirs(
        os.path.join(mastcontrol, "statusfiles"))
    for recipedir in recipedirs:
        mystatus = "unknown"
        rdict[recipedir] = dict()
        changelist = list()
        if not os.path.exists(os.path.join(mastscratch, recipedir)):
            mystatus = "archived"
        else:
            scratchstatusfile = MASTFile(
                os.path.join(mastscratch, recipedir, "status.txt"))
            controlstatusfile = MASTFile(
                os.path.join(mastcontrol, "statusfiles", recipedir,
                             "status.txt"))
            if scratchstatusfile.data == controlstatusfile.data:
                mystatus = "unchanged"
            else:
                mystatus = "changed"
                myidx = 0
                while myidx < len(scratchstatusfile.data):
                    oldline = controlstatusfile.data[myidx]
                    newline = scratchstatusfile.data[myidx]
                    if "#" in oldline:
                        pass
                    else:
                        ingred = oldline.split(":")[0].strip()
                        oldstatus = oldline.split(":")[1].strip()
                        newstatus = newline.split(":")[1].strip()
                        if (oldstatus == "P") and (newstatus == "P"):
                            rdict[recipedir][ingred] = "AVOID"
                        elif (oldstatus == "C") and (newstatus == "C"):
                            rdict[recipedir][ingred] = "AVOID"
                        else:
                            rdict[recipedir][ingred] = "send"
                    myidx = myidx + 1
        rdict[recipedir]["MAIN"] = mystatus
    rchangefile = MASTFile()
    for rdir in rdict.keys():
        for key, value in rdict[rdir].iteritems():
            rchangefile.data.append("%s:%s:%s\n" % (rdir, key, value))
    rchangefile.to_file(os.path.join(mastcontrol, "recipechangefile.txt"))
    return True
Esempio n. 11
0
def save_old_change_status_files():
    """Save off old status files from $MAST_SCRATCH
       into $MAST_CONTROL
    """
    mastcontrol=dirutil.get_mast_control_path()
    if not os.path.exists(os.path.join(mastcontrol,"changestatusfiles")):
        os.mkdir(os.path.join(mastcontrol,"changestatusfiles"))
    mastscratch=dirutil.get_mast_scratch_path()
    recipedirs=dirutil.immediate_subdirs(mastscratch)
    for recipedir in recipedirs:
        ingreddirs=dirutil.immediate_subdirs(os.path.join(mastscratch,recipedir))
        for ingreddir in ingreddirs:
            csfile = os.path.join(mastscratch,recipedir,ingreddir,"change_status.txt")
            if os.path.isfile(csfile):
                changestatusfile = MASTFile(csfile)
                trydir = os.path.join(mastcontrol,"changestatusfiles",recipedir)
                if not os.path.exists(trydir):
                    os.mkdir(trydir)
                trydir2 = os.path.join(trydir, ingreddir)
                if not os.path.exists(trydir2):
                    os.mkdir(trydir2)
                    changestatusfile.to_file("%s/change_status.txt" % trydir2)
    return True
Esempio n. 12
0
def get_new_mast_error_files():
    """Get new MAST_ERROR files.
    """
    rdict = dict()
    mastcontrol = dirutil.get_mast_control_path()
    mastscratch = dirutil.get_mast_scratch_path()
    olddirs = list()
    srecdirs = dirutil.immediate_subdirs(mastscratch)
    for srecdir in srecdirs:
        merrfile = os.path.join(mastscratch, srecdir, "MAST_ERROR")
        if os.path.isfile(merrfile):
            if not srecdir in rdict.keys():
                rdict[srecdir] = dict()
            rdict[srecdir]["MAIN"] = "changed"
    return rdict
Esempio n. 13
0
def get_new_mast_error_files():
    """Get new MAST_ERROR files.
    """
    rdict=dict()
    mastcontrol=dirutil.get_mast_control_path()
    mastscratch=dirutil.get_mast_scratch_path()
    olddirs=list()
    srecdirs = dirutil.immediate_subdirs(mastscratch)
    for srecdir in srecdirs:
        merrfile = os.path.join(mastscratch, srecdir, "MAST_ERROR")
        if os.path.isfile(merrfile):
            if not srecdir in rdict.keys():
                rdict[srecdir] = dict()
            rdict[srecdir]["MAIN"]="changed"
    return rdict
Esempio n. 14
0
def save_old_status_files():
    """Save off old status files from $MAST_SCRATCH
       into $MAST_CONTROL
    """
    mastcontrol=dirutil.get_mast_control_path()
    if not os.path.exists(os.path.join(mastcontrol,"statusfiles")):
        os.mkdir(os.path.join(mastcontrol,"statusfiles"))
    mastscratch=dirutil.get_mast_scratch_path()
    recipedirs=dirutil.immediate_subdirs(mastscratch)
    for recipedir in recipedirs:
        statusfile = MASTFile(os.path.join(mastscratch,recipedir,"status.txt"))
        trydir = os.path.join(mastcontrol,"statusfiles",recipedir)
        if not os.path.exists(trydir):
            os.mkdir(trydir)
        statusfile.to_file("%s/status.txt" % trydir)
    return True
Esempio n. 15
0
def save_old_status_files():
    """Save off old status files from $MAST_SCRATCH
       into $MAST_CONTROL
    """
    mastcontrol = dirutil.get_mast_control_path()
    if not os.path.exists(os.path.join(mastcontrol, "statusfiles")):
        os.mkdir(os.path.join(mastcontrol, "statusfiles"))
    mastscratch = dirutil.get_mast_scratch_path()
    recipedirs = dirutil.immediate_subdirs(mastscratch)
    for recipedir in recipedirs:
        statusfile = MASTFile(
            os.path.join(mastscratch, recipedir, "status.txt"))
        trydir = os.path.join(mastcontrol, "statusfiles", recipedir)
        if not os.path.exists(trydir):
            os.mkdir(trydir)
        statusfile.to_file("%s/status.txt" % trydir)
    return True
Esempio n. 16
0
 def update_atom_index_for_complete(self):
     """Update atom index files with positions for the 
         completed ingredient.
     """
     proceed=False
     mydir = self.keywords['name']
     workdir=os.path.dirname(mydir)
     sdir=os.path.join(workdir,"structure_index_files")
     if os.path.exists(sdir):
         proceed=True
     if not proceed:
         self.logger.warning("Called update atom index for ingredient %s, but no atom indices exist." % self.keywords['name'])
         return
     mymeta=Metadata(metafile="%s/metadata.txt" % mydir)
     phonon_label = mymeta.read_data("phonon_label")
     if not (phonon_label == None): #Don't update atom indices for phonons
         self.logger.debug("Skipping atom index update for phonon calculation %s" % self.keywords['name'])
         return 
     scaling_label=mymeta.read_data("scaling_label")
     defect_label=mymeta.read_data("defect_label")
     neb_label=mymeta.read_data("neb_label")
     if scaling_label == None:
         scaling_label = ""
     if defect_label == None:
         defect_label = ""
     if neb_label == None:
         neb_label = ""
     if neb_label == "":
         mystr=Poscar.from_file("%s/CONTCAR" % self.keywords["name"]).structure
         ing_label=os.path.basename(mydir)
         manname="manifest_%s_%s_%s" % (scaling_label, defect_label, neb_label)
         myatomindex=AtomIndex(structure_index_directory=sdir)
         myatomindex.update_atom_indices_from_structure(mystr, ing_label, manname)
     else:
         nebdirs = dirutil.immediate_subdirs(self.keywords["name"])
         for mysubdir in nebdirs:
             if os.path.isfile("%s/%s/CONTCAR" % (self.keywords["name"],mysubdir)):
                 mystr=Poscar.from_file("%s/%s/CONTCAR" % (self.keywords["name"], mysubdir)).structure
                 ing_label=os.path.join(os.path.basename(mydir), mysubdir)
                 for defect_label in neb_label.split("-"):
                     manname="manifest_%s_%s_%s" % (scaling_label, defect_label, neb_label)
                     myatomindex=AtomIndex(structure_index_directory=sdir)
                     myatomindex.update_atom_indices_from_structure(mystr, ing_label, manname)
             
     return