Пример #1
0
 def set_up_recipe_plan(self, fulldir, verbose=0):
     """Set up a recipe plan from the recipe directory.
         Args:
             fulldir <str>: full path of recipe directory
             verbose <int>: verbosity
     """
     self.logger.info("--------------------------------")
     self.logger.info("Setting up recipe plan for %s" % fulldir)
     self.logger.info("--------------------------------")
     os.chdir(fulldir) #need to change directories in order to submit jobs?
     myipparser = InputParser(inputfile=os.path.join(fulldir, 'input.inp'))
     myinputoptions = myipparser.parse()
     input_options_keys = myinputoptions.get_sections()
     key = 'personal_recipe'
     if key in input_options_keys:
         self.logger.debug("Key - personal recipe was found")
     personal_recipe_contents = myinputoptions.get_item('personal_recipe', 'personal_recipe_list')
     rsetup = RecipeSetup(recipeFile=personal_recipe_contents,
             inputOptions=myinputoptions,
             structure=myinputoptions.get_item('structure','structure'),
             workingDirectory=fulldir)
     recipe_plan_obj = rsetup.start()
     recipe_plan_obj.get_statuses_from_file()
     self.logger.debug("Returning recipe plan object to calling method.")
     return recipe_plan_obj
Пример #2
0
 def test_set_structure_from_inputs(self):
     myip = InputParser(inputfile="neb_with_phonons.inp")
     myoptions = myip.parse()
     compare_struct = pymatgen.io.vaspio.Poscar.from_file(
         "nebphononsposcar").structure
     self.assertEqual(myoptions.options['structure']['structure'],
                      compare_struct)
Пример #3
0
 def set_up_recipe_plan(self, fulldir, verbose=0):
     """Set up a recipe plan from the recipe directory.
         Args:
             fulldir <str>: full path of recipe directory
             verbose <int>: verbosity
     """
     self.logger.info("--------------------------------")
     self.logger.info("Setting up recipe plan for %s" % fulldir)
     self.logger.info("--------------------------------")
     os.chdir(fulldir)  #need to change directories in order to submit jobs?
     myipparser = InputParser(inputfile=os.path.join(fulldir, 'input.inp'))
     myinputoptions = myipparser.parse()
     input_options_keys = myinputoptions.get_sections()
     key = 'personal_recipe'
     if key in input_options_keys:
         self.logger.debug("Key - personal recipe was found")
     personal_recipe_contents = myinputoptions.get_item(
         'personal_recipe', 'personal_recipe_list')
     rsetup = RecipeSetup(recipeFile=personal_recipe_contents,
                          inputOptions=myinputoptions,
                          structure=myinputoptions.get_item(
                              'structure', 'structure'),
                          workingDirectory=fulldir)
     recipe_plan_obj = rsetup.start()
     recipe_plan_obj.get_statuses_from_file()
     self.logger.debug("Returning recipe plan object to calling method.")
     return recipe_plan_obj
Пример #4
0
 def test_parse(self):
     myip = InputParser(inputfile="neb_with_phonons.inp")
     myoptions = myip.parse()
     print myoptions.options.keys()
     self.assertItemsEqual(
         myoptions.options.keys(),
         ['mast', 'structure', 'defects', 'recipe', 'ingredients', 'neb'])
Пример #5
0
 def test_perform_element_mapping(self):
     myip = InputParser(inputfile="element_mapping.inp")
     myoptions = myip.parse()
     self.assertItemsEqual(myoptions.options.keys(), [
         'mast', 'structure', 'defects', 'recipe', 'ingredients', 'neb',
         'chemical_potentials'
     ])
     self.assertEqual(
         myoptions.options['defects']['defects']['group1']['subdefect_1']
         ['symbol'], 'Xe')
     self.assertEqual(
         myoptions.options['defects']['defects']['group1']['subdefect_2']
         ['symbol'], 'Ar')
     self.assertEqual(
         myoptions.options['defects']['defects']['group2']['subdefect_1']
         ['symbol'], 'Ar')
     self.assertEqual(
         myoptions.options['defects']['defects']['group2']['subdefect_2']
         ['symbol'], 'Xe')
     self.assertEqual(
         myoptions.options['neb']['nebs']['group1-group2']['lines'][0][0],
         'Ar')
     self.assertEqual(
         myoptions.options['neb']['nebs']['group1-group2']['lines'][1][0],
         'Xe')
Пример #6
0
 def test_parse_defect_formation(self):
     myip = InputParser(inputfile="defect_formation_energy.inp")
     myoptions = myip.parse()
     print myoptions.options.keys()
     self.assertItemsEqual(myoptions.options.keys(), [
         'mast', 'structure', 'defects', 'recipe', 'ingredients',
         'chemical_potentials', 'summary'
     ])
Пример #7
0
 def check_recipe_dir(self, fulldir, verbose):
     """Check a recipe directory.
         Args:
             fulldir <str>: full path of recipe directory
             verbose <int>: verbosity
     """
     shortdir = os.path.basename(fulldir) #only the recipe directory name
     if not os.path.exists(fulldir):
         raise MASTError(self.__class__.__name__, "No recipe directory at %s" % fulldir)
     if os.path.exists(os.path.join(fulldir, "MAST_SKIP")):
         self.logger.warning("Skipping recipe %s due to the presence of a MAST_SKIP file in the recipe directory." % shortdir)
         return
     if os.path.exists(os.path.join(fulldir, "MAST_ERROR")):
         self.logger.error("ATTENTION!: Skipping recipe %s due to the presence of a MAST_ERROR file in the recipe directory." % shortdir)
         return
     self.logger.info("--------------------------------")
     self.logger.info("Processing recipe %s" % shortdir)
     self.logger.info("--------------------------------")
     os.chdir(fulldir) #need to change directories in order to submit jobs?
     myipparser = InputParser(inputfile=os.path.join(fulldir, 'input.inp'))
     myinputoptions = myipparser.parse()
     input_options_keys = myinputoptions.get_sections()
     key = 'personal_recipe'
     if key in input_options_keys:
         self.logger.debug("Key - personal recipe was found")
     personal_recipe_contents = myinputoptions.get_item('personal_recipe', 'personal_recipe_list')
     rsetup = RecipeSetup(recipeFile=personal_recipe_contents,
             inputOptions=myinputoptions,
             structure=myinputoptions.get_item('structure','structure'),
             workingDirectory=fulldir)
     recipe_plan_obj = rsetup.start()
     recipe_plan_obj.get_statuses_from_file()
     try:
         recipe_plan_obj.check_recipe_status(verbose)
     except Exception:
         import sys,traceback
         #ex_type, ex, trbck = sys.exc_info()
         errortext = traceback.format_exc()
         #del trbck
         errorfile = open(os.path.join(fulldir, "MAST_ERROR"), "ab")
         errorfile.write("ERROR LOGGED %s\n" % time.asctime())
         errorfile.write("%s\n" % errortext)
         errorfile.close()
         self.logger.warning("ERROR in recipe %s. Check MAST_ERROR file in the %s directory." % (shortdir, fulldir))
         #raise MASTError(self.__class__.__name__,"Error in recipe %s as follows: %s %s %s" % (shortdir, ex_type, ex, errortext))
     os.chdir(self.scratch)
     if recipe_plan_obj.status == "C":
         shutil.move(fulldir, self._ARCHIVE)
         summarypath = "%s/%s/SUMMARY.txt" % (self._ARCHIVE, shortdir)
         if os.path.isfile(summarypath):
             self.logger.info("Recipe %s completed." % shortdir)
             self.logger.info("SUMMARY.txt below:")
             summarytext = MASTFile(summarypath)
             for myline in summarytext.data:
                 self.logger.info(myline.strip())
     self.logger.info("-----------------------------")
     self.logger.info("Recipe %s processed." % shortdir)
     self.logger.info("-----------------------------")
Пример #8
0
 def test_perform_element_mapping(self):
     myip = InputParser(inputfile="element_mapping.inp")
     myoptions = myip.parse()
     self.assertItemsEqual(myoptions.options.keys(),['mast','structure','defects','recipe','ingredients','neb','chemical_potentials'])
     self.assertEqual(myoptions.options['defects']['defects']['group1']['subdefect_1']['symbol'],'Xe')
     self.assertEqual(myoptions.options['defects']['defects']['group1']['subdefect_2']['symbol'],'Ar')
     self.assertEqual(myoptions.options['defects']['defects']['group2']['subdefect_1']['symbol'],'Ar')
     self.assertEqual(myoptions.options['defects']['defects']['group2']['subdefect_2']['symbol'],'Xe')
     self.assertEqual(myoptions.options['neb']['nebs']['group1-group2']['lines'][0][0],'Ar')
     self.assertEqual(myoptions.options['neb']['nebs']['group1-group2']['lines'][1][0],'Xe')
Пример #9
0
 def test_parse_defect_formation(self):
     myip = InputParser(inputfile="defect_formation_energy.inp")
     myoptions = myip.parse()
     print myoptions.options.keys()
     self.assertItemsEqual(myoptions.options.keys(),['mast','structure','defects','recipe','ingredients','chemical_potentials','summary'])
Пример #10
0
 def test_parse(self):
     myip = InputParser(inputfile="neb_with_phonons.inp")
     myoptions = myip.parse()
     print myoptions.options.keys()
     self.assertItemsEqual(myoptions.options.keys(),['mast','structure','defects','recipe','ingredients','neb'])
Пример #11
0
 def test_set_structure_from_inputs(self):
     myip = InputParser(inputfile="neb_with_phonons.inp")
     myoptions = myip.parse()
     compare_struct = pymatgen.io.vaspio.Poscar.from_file("nebphononsposcar").structure
     self.assertEqual(myoptions.options['structure']['structure'],compare_struct)
Пример #12
0
 def test_validate_execs(self):
     myip = InputParser(inputfile="neb_with_phonons.inp")
     myoptions = myip.parse()
     myoptions.options['ingredients']['global'].pop('mast_exec')
     myoptions.options['ingredients']['diffcoeff'].pop('mast_exec')
     self.assertRaises(MASTError,myip.validate_execs,myoptions)
Пример #13
0
 def test_validate_execs(self):
     myip = InputParser(inputfile="neb_with_phonons.inp")
     myoptions = myip.parse()
     myoptions.options['ingredients']['global'].pop('mast_exec')
     myoptions.options['ingredients']['diffcoeff'].pop('mast_exec')
     self.assertRaises(MASTError, myip.validate_execs, myoptions)