示例#1
0
 def test_write_ingredient(self):
     topmetad = MASTFile("files/top_metadata_single")
     topmetad.data.append("origin_dir = %s/files\n" %
                          testdir)  #give origin directory
     topmetad.to_file("recipedir/metadata.txt")
     #metad = MASTFile("files/metadata_single")
     #metad.to_file("%s/metadata.txt" % ingdir)
     rp = RecipePlan("recipedir")
     rp.ingredients['ing2b'] = "I"
     kdict = dict()
     kdict['mast_program'] = 'vasp'
     kdict['mast_xc'] = 'pw91'
     kdict['mast_kpoints'] = [1, 2, 3, "G"]
     rp.ingred_input_options['ing2b'] = dict()
     rp.ingred_input_options['ing2b']['name'] = "recipedir/ing2b"
     rp.ingred_input_options['ing2b']['program_keys'] = kdict
     rp.ingred_input_options['ing2b'][
         'structure'] = pymatgen.io.vaspio.Poscar.from_file(
             "files/perfect_structure").structure
     rp.write_methods['ing2b'] = [['write_singlerun']]
     rp.write_ingredient('ing2b')
     self.assertTrue(os.path.isfile('recipedir/ing2b/INCAR'))
     self.assertTrue(os.path.isfile('recipedir/ing2b/POSCAR'))
     self.assertTrue(os.path.isfile('recipedir/ing2b/POTCAR'))
     self.assertTrue(os.path.isfile('recipedir/ing2b/KPOINTS'))
     self.assertTrue(os.path.isfile('recipedir/ing2b/submit.sh'))
示例#2
0
 def test_print_status(self):
     rp = RecipePlan("%s/recipedir" % testdir)
     rp.ingredients['ing1'] = "S"
     rp.ingredients['ing2a'] = "W"
     rp.ingredients['ing2b'] = "C"
     rp.ingredients['ing3'] = "P"
     rp.print_status()
     mystatus = MASTFile("recipedir/status.txt")
     status_compare = MASTFile("files/status_artificial.txt")
     self.assertEqual(mystatus.data, status_compare.data)
示例#3
0
 def test_print_status(self):
     rp = RecipePlan("%s/recipedir" % testdir)
     rp.ingredients['ing1'] = "S"
     rp.ingredients['ing2a'] = "W"
     rp.ingredients['ing2b'] = "C"
     rp.ingredients['ing3'] = "P"
     rp.print_status()
     mystatus = MASTFile("recipedir/status.txt")
     status_compare = MASTFile("files/status_artificial.txt")
     self.assertEqual(mystatus.data, status_compare.data)
示例#4
0
 def test_complete_ingredient(self):
     topmetad = MASTFile("files/top_metadata_single")
     topmetad.data.append("origin_dir = %s/files\n" %
                          testdir)  #give origin directory
     topmetad.to_file("recipedir/metadata.txt")
     #metad = MASTFile("files/metadata_single")
     #metad.to_file("%s/metadata.txt" % ingdir)
     rp = RecipePlan("recipedir")
     rp.ingredients['ing1'] = "I"
     kdict = dict()
     kdict['mast_program'] = 'vasp'
     kdict['mast_xc'] = 'pw91'
     kdict['mast_kpoints'] = [1, 2, 3, "G"]
     rp.ingred_input_options['ing1'] = dict()
     rp.ingred_input_options['ing1']['name'] = "%s/recipedir/ing1" % testdir
     rp.ingred_input_options['ing1']['program_keys'] = kdict
     rp.ingred_input_options['ing1'][
         'structure'] = pymatgen.io.vaspio.Poscar.from_file(
             "files/perfect_structure").structure
     rp.complete_methods['ing1'] = [['complete_singlerun']]
     self.assertTrue(rp.complete_ingredient('ing1'))
示例#5
0
 def test_get_statuses_from_file(self):
     rp = RecipePlan("recipedir")
     mystatus = MASTFile("files/status_random.txt")
     self.assertRaises(MASTError, rp.get_statuses_from_file)
     mystatus.to_file("recipedir/status.txt")
     rp.ingredients['ing1']="I"
     rp.ingredients['ing2a']="I"
     rp.ingredients['ing2b']="I"
     self.assertRaises(MASTError,rp.get_statuses_from_file)
     rp.ingredients['ing3']="I"
     rp.get_statuses_from_file()
     statusdict=dict()
     statusdict={'ing1':'alpha','ing2a':'beta','ing2b':'gamma','ing3':'delta'}
     self.assertEquals(rp.ingredients, statusdict)
示例#6
0
 def test_complete_ingredient(self):
     topmetad = MASTFile("files/top_metadata_single")
     topmetad.data.append("origin_dir = %s/files\n" % testdir) #give origin directory
     topmetad.to_file("recipedir/metadata.txt")
     #metad = MASTFile("files/metadata_single")
     #metad.to_file("%s/metadata.txt" % ingdir)
     rp = RecipePlan("recipedir")
     rp.ingredients['ing1'] = "I"
     kdict=dict()
     kdict['mast_program']='vasp'
     kdict['mast_xc']='pw91'
     kdict['mast_kpoints']=[1,2,3,"G"]
     rp.ingred_input_options['ing1']=dict()
     rp.ingred_input_options['ing1']['name']="%s/recipedir/ing1" % testdir
     rp.ingred_input_options['ing1']['program_keys']=kdict
     rp.ingred_input_options['ing1']['structure']=pymatgen.io.vaspio.Poscar.from_file("files/perfect_structure").structure
     rp.complete_methods['ing1']=[['complete_singlerun']]
     self.assertTrue(rp.complete_ingredient('ing1'))
示例#7
0
 def test_get_statuses_from_file(self):
     rp = RecipePlan("recipedir")
     mystatus = MASTFile("files/status_random.txt")
     self.assertRaises(MASTError, rp.get_statuses_from_file)
     mystatus.to_file("recipedir/status.txt")
     rp.ingredients['ing1'] = "I"
     rp.ingredients['ing2a'] = "I"
     rp.ingredients['ing2b'] = "I"
     self.assertRaises(MASTError, rp.get_statuses_from_file)
     rp.ingredients['ing3'] = "I"
     rp.get_statuses_from_file()
     statusdict = dict()
     statusdict = {
         'ing1': 'alpha',
         'ing2a': 'beta',
         'ing2b': 'gamma',
         'ing3': 'delta'
     }
     self.assertEquals(rp.ingredients, statusdict)
示例#8
0
 def test_write_ingredient(self):
     topmetad = MASTFile("files/top_metadata_single")
     topmetad.data.append("origin_dir = %s/files\n" % testdir) #give origin directory
     topmetad.to_file("recipedir/metadata.txt")
     #metad = MASTFile("files/metadata_single")
     #metad.to_file("%s/metadata.txt" % ingdir)
     rp = RecipePlan("recipedir")
     rp.ingredients['ing2b'] = "I"
     kdict=dict()
     kdict['mast_program']='vasp'
     kdict['mast_xc']='pw91'
     kdict['mast_kpoints']=[1,2,3,"G"]
     rp.ingred_input_options['ing2b']=dict()
     rp.ingred_input_options['ing2b']['name']="recipedir/ing2b"
     rp.ingred_input_options['ing2b']['program_keys']=kdict
     rp.ingred_input_options['ing2b']['structure']=pymatgen.io.vaspio.Poscar.from_file("files/perfect_structure").structure
     rp.write_methods['ing2b']=[['write_singlerun']]
     rp.write_ingredient('ing2b')
     self.assertTrue(os.path.isfile('recipedir/ing2b/INCAR'))
     self.assertTrue(os.path.isfile('recipedir/ing2b/POSCAR'))
     self.assertTrue(os.path.isfile('recipedir/ing2b/POTCAR'))
     self.assertTrue(os.path.isfile('recipedir/ing2b/KPOINTS'))
     self.assertTrue(os.path.isfile('recipedir/ing2b/submit.sh'))
示例#9
0
 def test_check_recipe_status(self):
     topmetad = MASTFile("files/top_metadata_single")
     topmetad.data.append("origin_dir = %s/files\n" %
                          testdir)  #give origin directory
     topmetad.to_file("recipedir/metadata.txt")
     metad = MASTFile("files/metadata_single")
     metad.to_file("recipedir/ing1/metadata.txt")
     metad = MASTFile("files/metadata_single")
     metad.data.append("defect_label = labela\n")
     metad.to_file("recipedir/ing2a/metadata.txt")
     metad = MASTFile("files/metadata_single")
     metad.data.append("defect_label = labelb\n")
     metad.to_file("recipedir/ing2b/metadata.txt")
     metad = MASTFile("files/metadata_single")
     metad.to_file("recipedir/ing3/metadata.txt")
     rp = RecipePlan("%s/recipedir" % testdir)
     rp.ingredients['ing1'] = "I"
     rp.ingredients['ing2a'] = "I"
     rp.ingredients['ing2b'] = "I"
     rp.ingredients['ing3'] = "I"
     kdict = dict()
     kdict['mast_program'] = 'vasp'
     kdict['mast_xc'] = 'pw91'
     kdict['mast_kpoints'] = [1, 2, 3, "G"]
     my_struc = pymatgen.io.vaspio.Poscar.from_file(
         "files/perfect_structure").structure
     rp.ingred_input_options['ing1'] = dict()
     rp.ingred_input_options['ing1']['name'] = "%s/recipedir/ing1" % testdir
     rp.ingred_input_options['ing1']['program_keys'] = kdict
     rp.ingred_input_options['ing1']['structure'] = my_struc
     rp.complete_methods['ing1'] = [['complete_singlerun']]
     rp.run_methods['ing1'] = [['run_singlerun']]
     rp.update_methods['ing1'] = dict()
     rp.update_methods['ing1']['ing2a'] = [['give_structure']]
     rp.update_methods['ing1']['ing2b'] = [['give_structure']]
     rp.ingred_input_options['ing2a'] = dict()
     rp.ingred_input_options['ing2a'][
         'name'] = "%s/recipedir/ing2a" % testdir
     rp.ingred_input_options['ing2a']['program_keys'] = kdict
     rp.ingred_input_options['ing2a']['structure'] = my_struc
     rp.complete_methods['ing2a'] = [['complete_singlerun']]
     rp.ready_methods['ing2a'] = [['ready_structure']]
     rp.run_methods['ing2a'] = [['run_singlerun']]
     rp.ingred_input_options['ing2b'] = dict()
     rp.ingred_input_options['ing2b'][
         'name'] = "%s/recipedir/ing2b" % testdir
     rp.ingred_input_options['ing2b']['program_keys'] = kdict
     rp.ingred_input_options['ing2b']['structure'] = my_struc
     rp.complete_methods['ing2b'] = [['complete_singlerun']]
     rp.ready_methods['ing2b'] = [['ready_structure']]
     rp.run_methods['ing2b'] = [['run_singlerun']]
     rp.ingred_input_options['ing3'] = dict()
     rp.ingred_input_options['ing3']['name'] = "%s/recipedir/ing3" % testdir
     rp.ingred_input_options['ing3']['program_keys'] = kdict
     rp.ingred_input_options['ing3']['structure'] = my_struc
     rp.complete_methods['ing3'] = [['complete_singlerun']]
     rp.ready_methods['ing3'] = [['ready_structure']]
     rp.run_methods['ing3'] = [['run_singlerun']]
     rp.parents_to_check['ing3'] = ['ing2a', 'ing2b']
     rp.parents_to_check['ing2a'] = ['ing1']
     rp.parents_to_check['ing2b'] = []
     rp.parents_to_check['ing1'] = []
     rp.check_recipe_status()
     mystatus = MASTFile("%s/recipedir/status.txt" % testdir)
     status_compare = MASTFile("%s/files/status_current.txt" % testdir)
     self.assertEqual(mystatus.data, status_compare.data)
示例#10
0
 def test_run_staged_ingredients(self):
     topmetad = MASTFile("files/top_metadata_single")
     topmetad.data.append("origin_dir = %s/files\n" %
                          testdir)  #give origin directory
     topmetad.to_file("recipedir/metadata.txt")
     #metad = MASTFile("files/metadata_single")
     #metad.to_file("%s/metadata.txt" % ingdir)
     rp = RecipePlan("recipedir")
     rp.ingredients['ing1'] = "C"
     rp.ingredients['ing2a'] = "W"
     rp.ingredients['ing2b'] = "S"
     rp.ingredients['ing3'] = "W"
     kdict = dict()
     kdict['mast_program'] = 'vasp'
     kdict['mast_xc'] = 'pw91'
     kdict['mast_kpoints'] = [1, 2, 3, "G"]
     rp.ingred_input_options['ing2b'] = dict()
     rp.ingred_input_options['ing2b']['name'] = "recipedir/ing2b"
     rp.ingred_input_options['ing2b']['program_keys'] = kdict
     rp.ingred_input_options['ing2b'][
         'structure'] = pymatgen.io.vaspio.Poscar.from_file(
             "files/perfect_structure").structure
     rp.write_methods['ing2b'] = [['write_singlerun']]
     rp.write_ingredient('ing2b')
     rp.ready_methods['ing2b'] = [['ready_singlerun']]
     rp.run_methods['ing2b'] = [['run_singlerun']]
     rp.complete_methods['ing2b'] = [['complete_singlerun']]
     rp.run_staged_ingredients()
     mysubmit = MASTFile("test_control/submitlist")
     self.assertEquals(mysubmit.data[0], "recipedir/ing2b\n")
     self.assertEquals(rp.ingredients, {
         'ing1': 'C',
         'ing2a': 'W',
         'ing2b': 'P',
         'ing3': 'W'
     })
示例#11
0
 def test_check_if_parents_are_complete(self):
     rp = RecipePlan("recipedir")
     rp.ingredients['ing1'] = "C"
     rp.ingredients['ing2a'] = "W"
     rp.ingredients['ing2b'] = "I"
     rp.ingredients['ing3'] = "I"
     rp.parents_to_check['ing3'] = ['ing2a', 'ing2b']
     rp.parents_to_check['ing2a'] = ['ing1']
     rp.parents_to_check['ing2b'] = []
     rp.parents_to_check['ing1'] = []
     rp.check_if_parents_are_complete()
     self.assertEquals(rp.ingredients, {
         'ing1': 'C',
         'ing2a': 'S',
         'ing2b': 'I',
         'ing3': 'I'
     })
示例#12
0
 def test_check_if_ready_to_proceed_are_complete(self):
     metad = MASTFile("files/metadata_single")
     metad.to_file("recipedir/ing1/metadata.txt")
     metad = MASTFile("files/metadata_single")
     metad.to_file("recipedir/ing2a/metadata.txt")
     rp = RecipePlan("recipedir")
     rp.ingredients['ing1'] = "P"
     rp.ingredients['ing2a'] = "I"
     rp.ingredients['ing2b'] = "I"
     rp.ingredients['ing3'] = "I"
     kdict = dict()
     kdict['mast_program'] = 'vasp'
     kdict['mast_xc'] = 'pw91'
     kdict['mast_kpoints'] = [1, 2, 3, "G"]
     my_struc = pymatgen.io.vaspio.Poscar.from_file(
         "files/perfect_structure").structure
     rp.ingred_input_options['ing1'] = dict()
     rp.ingred_input_options['ing1']['name'] = "%s/recipedir/ing1" % testdir
     rp.ingred_input_options['ing1']['program_keys'] = kdict
     rp.ingred_input_options['ing1']['structure'] = my_struc
     rp.complete_methods['ing1'] = [['complete_singlerun']]
     rp.update_methods['ing1'] = dict()
     rp.update_methods['ing1']['ing2a'] = [['give_structure']]
     rp.update_methods['ing1']['ing2b'] = [['give_structure']]
     rp.ingred_input_options['ing2a'] = dict()
     rp.ingred_input_options['ing2a'][
         'name'] = "%s/recipedir/ing2a" % testdir
     rp.ingred_input_options['ing2a']['program_keys'] = kdict
     rp.ingred_input_options['ing2a']['structure'] = my_struc
     rp.complete_methods['ing2a'] = [['complete_singlerun']]
     rp.ready_methods['ing2a'] = [['ready_structure']]
     rp.check_if_ready_to_proceed_are_complete()
     self.assertTrue(rp.ready_ingredient('ing2a'))
     self.assertEquals
     self.assertEquals(rp.ingredients, {
         'ing1': 'C',
         'ing2a': 'I',
         'ing2b': 'I',
         'ing3': 'I'
     })
示例#13
0
 def test_check_if_have_parents(self):
     rp = RecipePlan("recipedir")
     rp.ingredients['ing1'] = "I"
     rp.ingredients['ing2a'] = "I"
     rp.ingredients['ing2b'] = "I"
     rp.ingredients['ing3'] = "I"
     rp.parents_to_check['ing3'] = ['ing2a', 'ing2b']
     rp.parents_to_check['ing2a'] = ['ing1']
     rp.parents_to_check['ing2b'] = []
     rp.parents_to_check['ing1'] = []
     rp.check_if_have_parents()
     self.assertEquals(rp.ingredients, {
         'ing1': 'S',
         'ing2a': 'W',
         'ing2b': 'S',
         'ing3': 'W'
     })
示例#14
0
 def test_check_recipe_status(self):
     topmetad = MASTFile("files/top_metadata_single")
     topmetad.data.append("origin_dir = %s/files\n" % testdir) #give origin directory
     topmetad.to_file("recipedir/metadata.txt")
     metad = MASTFile("files/metadata_single")
     metad.to_file("recipedir/ing1/metadata.txt")
     metad = MASTFile("files/metadata_single")
     metad.data.append("defect_label = labela\n")
     metad.to_file("recipedir/ing2a/metadata.txt")
     metad = MASTFile("files/metadata_single")
     metad.data.append("defect_label = labelb\n")
     metad.to_file("recipedir/ing2b/metadata.txt")
     metad = MASTFile("files/metadata_single")
     metad.to_file("recipedir/ing3/metadata.txt")
     rp = RecipePlan("%s/recipedir" % testdir)
     rp.ingredients['ing1'] = "I"
     rp.ingredients['ing2a'] = "I"
     rp.ingredients['ing2b'] = "I"
     rp.ingredients['ing3'] = "I"
     kdict=dict()
     kdict['mast_program']='vasp'
     kdict['mast_xc']='pw91'
     kdict['mast_kpoints']=[1,2,3,"G"]
     my_struc = pymatgen.io.vaspio.Poscar.from_file("files/perfect_structure").structure
     rp.ingred_input_options['ing1']=dict()
     rp.ingred_input_options['ing1']['name']="%s/recipedir/ing1" % testdir
     rp.ingred_input_options['ing1']['program_keys']=kdict
     rp.ingred_input_options['ing1']['structure']=my_struc
     rp.complete_methods['ing1']=[['complete_singlerun']]
     rp.run_methods['ing1']=[['run_singlerun']]
     rp.update_methods['ing1']=dict()
     rp.update_methods['ing1']['ing2a']=[['give_structure']]
     rp.update_methods['ing1']['ing2b']=[['give_structure']]
     rp.ingred_input_options['ing2a']=dict()
     rp.ingred_input_options['ing2a']['name']="%s/recipedir/ing2a" % testdir
     rp.ingred_input_options['ing2a']['program_keys']=kdict
     rp.ingred_input_options['ing2a']['structure']=my_struc
     rp.complete_methods['ing2a']=[['complete_singlerun']]
     rp.ready_methods['ing2a']=[['ready_structure']]
     rp.run_methods['ing2a']=[['run_singlerun']]
     rp.ingred_input_options['ing2b']=dict()
     rp.ingred_input_options['ing2b']['name']="%s/recipedir/ing2b" % testdir
     rp.ingred_input_options['ing2b']['program_keys']=kdict
     rp.ingred_input_options['ing2b']['structure']=my_struc
     rp.complete_methods['ing2b']=[['complete_singlerun']]
     rp.ready_methods['ing2b']=[['ready_structure']]
     rp.run_methods['ing2b']=[['run_singlerun']]
     rp.ingred_input_options['ing3']=dict()
     rp.ingred_input_options['ing3']['name']="%s/recipedir/ing3" % testdir
     rp.ingred_input_options['ing3']['program_keys']=kdict
     rp.ingred_input_options['ing3']['structure']=my_struc
     rp.complete_methods['ing3']=[['complete_singlerun']]
     rp.ready_methods['ing3']=[['ready_structure']]
     rp.run_methods['ing3']=[['run_singlerun']]
     rp.parents_to_check['ing3']=['ing2a','ing2b']
     rp.parents_to_check['ing2a']=['ing1']
     rp.parents_to_check['ing2b']=[]
     rp.parents_to_check['ing1']=[]
     rp.check_recipe_status()
     mystatus = MASTFile("%s/recipedir/status.txt" % testdir)
     status_compare = MASTFile("%s/files/status_current.txt" % testdir)
     self.assertEqual(mystatus.data, status_compare.data)
示例#15
0
 def test_update_children(self):
     topmetad = MASTFile("files/top_metadata_single")
     topmetad.data.append("origin_dir = %s/files\n" % testdir) #give origin directory
     topmetad.to_file("recipedir/metadata.txt")
     #metad = MASTFile("files/metadata_single")
     #metad.to_file("%s/metadata.txt" % ingdir)
     rp = RecipePlan("%s/recipedir" % testdir)
     rp.ingredients['ing1'] = "I"
     kdict=dict()
     kdict['mast_program']='vasp'
     kdict['mast_xc']='pw91'
     kdict['mast_kpoints']=[1,2,3,"G"]
     rp.ingred_input_options['ing1']=dict()
     rp.ingred_input_options['ing1']['name']="%s/ing1" % rp.working_directory
     rp.ingred_input_options['ing1']['program_keys']=kdict
     rp.ingred_input_options['ing1']['structure']=pymatgen.io.vaspio.Poscar.from_file("files/perfect_structure").structure
     rp.update_methods['ing1']=dict()
     rp.update_methods['ing1']['ing2a']=[['give_structure']]
     rp.update_methods['ing1']['ing2b']=[['give_structure_and_restart_files']]
     rp.update_children('ing1')
     self.assertTrue(os.path.isfile("recipedir/ing2a/POSCAR"))
     self.assertTrue(os.path.isfile("recipedir/ing2b/POSCAR"))
     #CHGCAR softlink only sent to second child
     self.assertFalse(os.path.exists("recipedir/ing2a/CHGCAR"))
     self.assertTrue(os.path.exists("recipedir/ing2b/CHGCAR"))
示例#16
0
 def test_check_if_have_parents(self):
     rp = RecipePlan("recipedir")
     rp.ingredients['ing1'] = "I"
     rp.ingredients['ing2a'] = "I"
     rp.ingredients['ing2b'] = "I"
     rp.ingredients['ing3'] = "I"
     rp.parents_to_check['ing3']=['ing2a','ing2b']
     rp.parents_to_check['ing2a']=['ing1']
     rp.parents_to_check['ing2b']=[]
     rp.parents_to_check['ing1']=[]
     rp.check_if_have_parents()
     self.assertEquals(rp.ingredients,{'ing1':'S','ing2a':'W','ing2b':'S','ing3':'W'})
示例#17
0
 def test_check_if_ready_to_proceed_are_complete(self):
     metad = MASTFile("files/metadata_single")
     metad.to_file("recipedir/ing1/metadata.txt")
     metad = MASTFile("files/metadata_single")
     metad.to_file("recipedir/ing2a/metadata.txt")
     rp = RecipePlan("recipedir")
     rp.ingredients['ing1'] = "P"
     rp.ingredients['ing2a'] = "I"
     rp.ingredients['ing2b'] = "I"
     rp.ingredients['ing3'] = "I"
     kdict=dict()
     kdict['mast_program']='vasp'
     kdict['mast_xc']='pw91'
     kdict['mast_kpoints']=[1,2,3,"G"]
     my_struc = pymatgen.io.vaspio.Poscar.from_file("files/perfect_structure").structure
     rp.ingred_input_options['ing1']=dict()
     rp.ingred_input_options['ing1']['name']="%s/recipedir/ing1" % testdir
     rp.ingred_input_options['ing1']['program_keys']=kdict
     rp.ingred_input_options['ing1']['structure']=my_struc
     rp.complete_methods['ing1']=[['complete_singlerun']]
     rp.update_methods['ing1']=dict()
     rp.update_methods['ing1']['ing2a']=[['give_structure']]
     rp.update_methods['ing1']['ing2b']=[['give_structure']]
     rp.ingred_input_options['ing2a']=dict()
     rp.ingred_input_options['ing2a']['name']="%s/recipedir/ing2a" % testdir
     rp.ingred_input_options['ing2a']['program_keys']=kdict
     rp.ingred_input_options['ing2a']['structure']=my_struc
     rp.complete_methods['ing2a']=[['complete_singlerun']]
     rp.ready_methods['ing2a']=[['ready_structure']]
     rp.check_if_ready_to_proceed_are_complete()
     self.assertTrue(rp.ready_ingredient('ing2a'))
     self.assertEquals
     self.assertEquals(rp.ingredients,{'ing1':'C','ing2a':'I','ing2b':'I','ing3':'I'})
示例#18
0
 def test___repr__(self):
     topmetad = MASTFile("files/top_metadata_single")
     topmetad.data.append("origin_dir = %s/files\n" % testdir) #give origin directory
     topmetad.to_file("recipedir/metadata.txt")
     metad = MASTFile("files/metadata_single")
     metad.to_file("recipedir/ing1/metadata.txt")
     metad = MASTFile("files/metadata_single")
     metad.data.append("defect_label = labela\n")
     metad.to_file("recipedir/ing2a/metadata.txt")
     metad = MASTFile("files/metadata_single")
     metad.data.append("defect_label = labelb\n")
     metad.to_file("recipedir/ing2b/metadata.txt")
     metad = MASTFile("files/metadata_single")
     metad.to_file("recipedir/ing3/metadata.txt")
     rp = RecipePlan("recipedir")
     rp.ingredients['ing1'] = "I"
     rp.ingredients['ing2a'] = "I"
     rp.ingredients['ing2b'] = "I"
     rp.ingredients['ing3'] = "I"
     kdict=dict()
     kdict['mast_program']='vasp'
     kdict['mast_xc']='pw91'
     kdict['mast_kpoints']=[1,2,3,"G"]
     my_struc = pymatgen.io.vaspio.Poscar.from_file("files/perfect_structure").structure
     rp.ingred_input_options['ing1']=dict()
     rp.ingred_input_options['ing1']['name']="recipedir/ing1"
     rp.ingred_input_options['ing1']['program_keys']=kdict
     rp.ingred_input_options['ing1']['structure']=my_struc
     rp.complete_methods['ing1']=[['complete_singlerun']]
     rp.run_methods['ing1']=[['run_singlerun']]
     rp.ready_methods['ing1']=[['ready_singlerun']]
     rp.write_methods['ing1']=[['write_singlerun']]
     rp.update_methods['ing1']=dict()
     rp.update_methods['ing1']['ing2a']=[['give_structure']]
     rp.update_methods['ing1']['ing2b']=[['give_structure']]
     rp.ingred_input_options['ing2a']=dict()
     rp.ingred_input_options['ing2a']['name']="recipedir/ing2a"
     rp.ingred_input_options['ing2a']['program_keys']=kdict
     rp.ingred_input_options['ing2a']['structure']=my_struc
     rp.complete_methods['ing2a']=[['complete_singlerun']]
     rp.ready_methods['ing2a']=[['ready_structure']]
     rp.run_methods['ing2a']=[['run_singlerun']]
     rp.write_methods['ing2a']=[['write_singlerun']]
     rp.update_methods['ing2a']=dict()
     rp.update_methods['ing2a']['ing3']=[['give_structure_and_restart_files']]
     rp.ingred_input_options['ing2b']=dict()
     rp.ingred_input_options['ing2b']['name']="recipedir/ing2b"
     rp.ingred_input_options['ing2b']['program_keys']=kdict
     rp.ingred_input_options['ing2b']['structure']=my_struc
     rp.complete_methods['ing2b']=[['complete_singlerun']]
     rp.ready_methods['ing2b']=[['ready_structure']]
     rp.run_methods['ing2b']=[['run_singlerun']]
     rp.write_methods['ing2b']=[['write_singlerun']]
     rp.update_methods['ing2b']=dict()
     rp.update_methods['ing2b']['ing3']=[['give_structure_and_restart_files']]
     rp.ingred_input_options['ing3']=dict()
     rp.ingred_input_options['ing3']['name']="recipedir/ing3"
     rp.ingred_input_options['ing3']['program_keys']=kdict
     rp.ingred_input_options['ing3']['structure']=my_struc
     rp.complete_methods['ing3']=[['complete_singlerun']]
     rp.ready_methods['ing3']=[['ready_structure']]
     rp.run_methods['ing3']=[['run_singlerun']]
     rp.write_methods['ing3']=[['write_singlerun']]
     rp.update_methods['ing3']=dict()
     rp.parents_to_check['ing3']=['ing2a','ing2b']
     rp.parents_to_check['ing2a']=['ing1']
     rp.parents_to_check['ing2b']=[]
     rp.parents_to_check['ing1']=[]
     mylines=rp.__repr__()
     printed =MASTFile()
     printed.data = mylines
     printed.to_file("recipedir/printed.txt")
     compare_print=MASTFile("files/printout.txt")
     printedread = MASTFile("recipedir/printed.txt")
     self.assertEqual(printedread.data, compare_print.data)
示例#19
0
 def test_check_if_parents_are_complete(self):
     rp = RecipePlan("recipedir")
     rp.ingredients['ing1'] = "C"
     rp.ingredients['ing2a'] = "W"
     rp.ingredients['ing2b'] = "I"
     rp.ingredients['ing3'] = "I"
     rp.parents_to_check['ing3']=['ing2a','ing2b']
     rp.parents_to_check['ing2a']=['ing1']
     rp.parents_to_check['ing2b']=[]
     rp.parents_to_check['ing1']=[]
     rp.check_if_parents_are_complete()
     self.assertEquals(rp.ingredients,{'ing1':'C','ing2a':'S','ing2b':'I','ing3':'I'})
示例#20
0
 def test_fast_forward_check_complete(self):
     topmetad = MASTFile("files/top_metadata_single")
     topmetad.data.append("origin_dir = %s/files\n" % testdir) #give origin directory
     topmetad.to_file("recipedir/metadata.txt")
     metad = MASTFile("files/metadata_single")
     metad.to_file("recipedir/ing1/metadata.txt")
     metad = MASTFile("files/metadata_single")
     metad.data.append("defect_label = labela\n")
     metad.to_file("recipedir/ing2a/metadata.txt")
     metad = MASTFile("files/metadata_single")
     metad.data.append("defect_label = labelb\n")
     metad.to_file("recipedir/ing2b/metadata.txt")
     metad = MASTFile("files/metadata_single")
     metad.to_file("recipedir/ing3/metadata.txt")
     rp = RecipePlan("recipedir")
     rp.ingredients['ing1'] = "I"
     rp.ingredients['ing2a'] = "I"
     rp.ingredients['ing2b'] = "I"
     rp.ingredients['ing3'] = "I"
     kdict=dict()
     kdict['mast_program']='vasp'
     kdict['mast_xc']='pw91'
     kdict['mast_kpoints']=[1,2,3,"G"]
     my_struc = pymatgen.io.vaspio.Poscar.from_file("files/perfect_structure").structure
     rp.ingred_input_options['ing1']=dict()
     rp.ingred_input_options['ing1']['name']="%s/recipedir/ing1" % testdir
     rp.ingred_input_options['ing1']['program_keys']=kdict
     rp.ingred_input_options['ing1']['structure']=my_struc
     rp.complete_methods['ing1']=[['complete_singlerun']]
     rp.update_methods['ing1']=dict()
     rp.update_methods['ing1']['ing2a']=[['give_structure']]
     rp.update_methods['ing1']['ing2b']=[['give_structure']]
     rp.ingred_input_options['ing2a']=dict()
     rp.ingred_input_options['ing2a']['name']="%s/recipedir/ing2a" % testdir
     rp.ingred_input_options['ing2a']['program_keys']=kdict
     rp.ingred_input_options['ing2a']['structure']=my_struc
     rp.complete_methods['ing2a']=[['complete_singlerun']]
     rp.ready_methods['ing2a']=[['ready_structure']]
     rp.ingred_input_options['ing2b']=dict()
     rp.ingred_input_options['ing2b']['name']="%s/recipedir/ing2b" % testdir
     rp.ingred_input_options['ing2b']['program_keys']=kdict
     rp.ingred_input_options['ing2b']['structure']=my_struc
     rp.complete_methods['ing2b']=[['complete_singlerun']]
     rp.ready_methods['ing2b']=[['ready_structure']]
     rp.ingred_input_options['ing3']=dict()
     rp.ingred_input_options['ing3']['name']="%s/recipedir/ing3" % testdir
     rp.ingred_input_options['ing3']['program_keys']=kdict
     rp.ingred_input_options['ing3']['structure']=my_struc
     rp.complete_methods['ing3']=[['complete_singlerun']]
     rp.ready_methods['ing3']=[['ready_structure']]
     rp.fast_forward_check_complete()
     #self.assertTrue(rp.complete_ingredient('ing1'))
     self.assertEquals(rp.ingredients, {'ing1':'C','ing2a':'I','ing2b':'I','ing3':'I'})
     self.assertTrue(rp.ready_ingredient('ing2a'))
     self.assertTrue(rp.ready_ingredient('ing2b'))
示例#21
0
 def test_update_children(self):
     topmetad = MASTFile("files/top_metadata_single")
     topmetad.data.append("origin_dir = %s/files\n" %
                          testdir)  #give origin directory
     topmetad.to_file("recipedir/metadata.txt")
     #metad = MASTFile("files/metadata_single")
     #metad.to_file("%s/metadata.txt" % ingdir)
     rp = RecipePlan("%s/recipedir" % testdir)
     rp.ingredients['ing1'] = "I"
     kdict = dict()
     kdict['mast_program'] = 'vasp'
     kdict['mast_xc'] = 'pw91'
     kdict['mast_kpoints'] = [1, 2, 3, "G"]
     rp.ingred_input_options['ing1'] = dict()
     rp.ingred_input_options['ing1'][
         'name'] = "%s/ing1" % rp.working_directory
     rp.ingred_input_options['ing1']['program_keys'] = kdict
     rp.ingred_input_options['ing1'][
         'structure'] = pymatgen.io.vaspio.Poscar.from_file(
             "files/perfect_structure").structure
     rp.update_methods['ing1'] = dict()
     rp.update_methods['ing1']['ing2a'] = [['give_structure']]
     rp.update_methods['ing1']['ing2b'] = [[
         'give_structure_and_restart_files'
     ]]
     rp.update_children('ing1')
     self.assertTrue(os.path.isfile("recipedir/ing2a/POSCAR"))
     self.assertTrue(os.path.isfile("recipedir/ing2b/POSCAR"))
     #CHGCAR softlink only sent to second child
     self.assertFalse(os.path.exists("recipedir/ing2a/CHGCAR"))
     self.assertTrue(os.path.exists("recipedir/ing2b/CHGCAR"))
示例#22
0
 def test___repr__(self):
     topmetad = MASTFile("files/top_metadata_single")
     topmetad.data.append("origin_dir = %s/files\n" %
                          testdir)  #give origin directory
     topmetad.to_file("recipedir/metadata.txt")
     metad = MASTFile("files/metadata_single")
     metad.to_file("recipedir/ing1/metadata.txt")
     metad = MASTFile("files/metadata_single")
     metad.data.append("defect_label = labela\n")
     metad.to_file("recipedir/ing2a/metadata.txt")
     metad = MASTFile("files/metadata_single")
     metad.data.append("defect_label = labelb\n")
     metad.to_file("recipedir/ing2b/metadata.txt")
     metad = MASTFile("files/metadata_single")
     metad.to_file("recipedir/ing3/metadata.txt")
     rp = RecipePlan("recipedir")
     rp.ingredients['ing1'] = "I"
     rp.ingredients['ing2a'] = "I"
     rp.ingredients['ing2b'] = "I"
     rp.ingredients['ing3'] = "I"
     kdict = dict()
     kdict['mast_program'] = 'vasp'
     kdict['mast_xc'] = 'pw91'
     kdict['mast_kpoints'] = [1, 2, 3, "G"]
     my_struc = pymatgen.io.vaspio.Poscar.from_file(
         "files/perfect_structure").structure
     rp.ingred_input_options['ing1'] = dict()
     rp.ingred_input_options['ing1']['name'] = "recipedir/ing1"
     rp.ingred_input_options['ing1']['program_keys'] = kdict
     rp.ingred_input_options['ing1']['structure'] = my_struc
     rp.complete_methods['ing1'] = [['complete_singlerun']]
     rp.run_methods['ing1'] = [['run_singlerun']]
     rp.ready_methods['ing1'] = [['ready_singlerun']]
     rp.write_methods['ing1'] = [['write_singlerun']]
     rp.update_methods['ing1'] = dict()
     rp.update_methods['ing1']['ing2a'] = [['give_structure']]
     rp.update_methods['ing1']['ing2b'] = [['give_structure']]
     rp.ingred_input_options['ing2a'] = dict()
     rp.ingred_input_options['ing2a']['name'] = "recipedir/ing2a"
     rp.ingred_input_options['ing2a']['program_keys'] = kdict
     rp.ingred_input_options['ing2a']['structure'] = my_struc
     rp.complete_methods['ing2a'] = [['complete_singlerun']]
     rp.ready_methods['ing2a'] = [['ready_structure']]
     rp.run_methods['ing2a'] = [['run_singlerun']]
     rp.write_methods['ing2a'] = [['write_singlerun']]
     rp.update_methods['ing2a'] = dict()
     rp.update_methods['ing2a']['ing3'] = [[
         'give_structure_and_restart_files'
     ]]
     rp.ingred_input_options['ing2b'] = dict()
     rp.ingred_input_options['ing2b']['name'] = "recipedir/ing2b"
     rp.ingred_input_options['ing2b']['program_keys'] = kdict
     rp.ingred_input_options['ing2b']['structure'] = my_struc
     rp.complete_methods['ing2b'] = [['complete_singlerun']]
     rp.ready_methods['ing2b'] = [['ready_structure']]
     rp.run_methods['ing2b'] = [['run_singlerun']]
     rp.write_methods['ing2b'] = [['write_singlerun']]
     rp.update_methods['ing2b'] = dict()
     rp.update_methods['ing2b']['ing3'] = [[
         'give_structure_and_restart_files'
     ]]
     rp.ingred_input_options['ing3'] = dict()
     rp.ingred_input_options['ing3']['name'] = "recipedir/ing3"
     rp.ingred_input_options['ing3']['program_keys'] = kdict
     rp.ingred_input_options['ing3']['structure'] = my_struc
     rp.complete_methods['ing3'] = [['complete_singlerun']]
     rp.ready_methods['ing3'] = [['ready_structure']]
     rp.run_methods['ing3'] = [['run_singlerun']]
     rp.write_methods['ing3'] = [['write_singlerun']]
     rp.update_methods['ing3'] = dict()
     rp.parents_to_check['ing3'] = ['ing2a', 'ing2b']
     rp.parents_to_check['ing2a'] = ['ing1']
     rp.parents_to_check['ing2b'] = []
     rp.parents_to_check['ing1'] = []
     mylines = rp.__repr__()
     printed = MASTFile()
     printed.data = mylines
     printed.to_file("recipedir/printed.txt")
     compare_print = MASTFile("files/printout.txt")
     printedread = MASTFile("recipedir/printed.txt")
     self.assertEqual(printedread.data, compare_print.data)
示例#23
0
 def test_fast_forward_check_complete(self):
     topmetad = MASTFile("files/top_metadata_single")
     topmetad.data.append("origin_dir = %s/files\n" %
                          testdir)  #give origin directory
     topmetad.to_file("recipedir/metadata.txt")
     metad = MASTFile("files/metadata_single")
     metad.to_file("recipedir/ing1/metadata.txt")
     metad = MASTFile("files/metadata_single")
     metad.data.append("defect_label = labela\n")
     metad.to_file("recipedir/ing2a/metadata.txt")
     metad = MASTFile("files/metadata_single")
     metad.data.append("defect_label = labelb\n")
     metad.to_file("recipedir/ing2b/metadata.txt")
     metad = MASTFile("files/metadata_single")
     metad.to_file("recipedir/ing3/metadata.txt")
     rp = RecipePlan("recipedir")
     rp.ingredients['ing1'] = "I"
     rp.ingredients['ing2a'] = "I"
     rp.ingredients['ing2b'] = "I"
     rp.ingredients['ing3'] = "I"
     kdict = dict()
     kdict['mast_program'] = 'vasp'
     kdict['mast_xc'] = 'pw91'
     kdict['mast_kpoints'] = [1, 2, 3, "G"]
     my_struc = pymatgen.io.vaspio.Poscar.from_file(
         "files/perfect_structure").structure
     rp.ingred_input_options['ing1'] = dict()
     rp.ingred_input_options['ing1']['name'] = "%s/recipedir/ing1" % testdir
     rp.ingred_input_options['ing1']['program_keys'] = kdict
     rp.ingred_input_options['ing1']['structure'] = my_struc
     rp.complete_methods['ing1'] = [['complete_singlerun']]
     rp.update_methods['ing1'] = dict()
     rp.update_methods['ing1']['ing2a'] = [['give_structure']]
     rp.update_methods['ing1']['ing2b'] = [['give_structure']]
     rp.ingred_input_options['ing2a'] = dict()
     rp.ingred_input_options['ing2a'][
         'name'] = "%s/recipedir/ing2a" % testdir
     rp.ingred_input_options['ing2a']['program_keys'] = kdict
     rp.ingred_input_options['ing2a']['structure'] = my_struc
     rp.complete_methods['ing2a'] = [['complete_singlerun']]
     rp.ready_methods['ing2a'] = [['ready_structure']]
     rp.ingred_input_options['ing2b'] = dict()
     rp.ingred_input_options['ing2b'][
         'name'] = "%s/recipedir/ing2b" % testdir
     rp.ingred_input_options['ing2b']['program_keys'] = kdict
     rp.ingred_input_options['ing2b']['structure'] = my_struc
     rp.complete_methods['ing2b'] = [['complete_singlerun']]
     rp.ready_methods['ing2b'] = [['ready_structure']]
     rp.ingred_input_options['ing3'] = dict()
     rp.ingred_input_options['ing3']['name'] = "%s/recipedir/ing3" % testdir
     rp.ingred_input_options['ing3']['program_keys'] = kdict
     rp.ingred_input_options['ing3']['structure'] = my_struc
     rp.complete_methods['ing3'] = [['complete_singlerun']]
     rp.ready_methods['ing3'] = [['ready_structure']]
     rp.fast_forward_check_complete()
     #self.assertTrue(rp.complete_ingredient('ing1'))
     self.assertEquals(rp.ingredients, {
         'ing1': 'C',
         'ing2a': 'I',
         'ing2b': 'I',
         'ing3': 'I'
     })
     self.assertTrue(rp.ready_ingredient('ing2a'))
     self.assertTrue(rp.ready_ingredient('ing2b'))
示例#24
0
 def test___init__(self):
     rp = RecipePlan("recipedir")
     self.assertEquals(rp.working_directory, "recipedir")
     self.assertEquals(rp.status, "I")
示例#25
0
 def test_run_staged_ingredients(self):
     topmetad = MASTFile("files/top_metadata_single")
     topmetad.data.append("origin_dir = %s/files\n" % testdir) #give origin directory
     topmetad.to_file("recipedir/metadata.txt")
     #metad = MASTFile("files/metadata_single")
     #metad.to_file("%s/metadata.txt" % ingdir)
     rp = RecipePlan("recipedir")
     rp.ingredients['ing1']="C"
     rp.ingredients['ing2a'] = "W"
     rp.ingredients['ing2b'] = "S"
     rp.ingredients['ing3'] = "W"
     kdict=dict()
     kdict['mast_program']='vasp'
     kdict['mast_xc']='pw91'
     kdict['mast_kpoints']=[1,2,3,"G"]
     rp.ingred_input_options['ing2b']=dict()
     rp.ingred_input_options['ing2b']['name']="recipedir/ing2b"
     rp.ingred_input_options['ing2b']['program_keys']=kdict
     rp.ingred_input_options['ing2b']['structure']=pymatgen.io.vaspio.Poscar.from_file("files/perfect_structure").structure
     rp.write_methods['ing2b']=[['write_singlerun']]
     rp.write_ingredient('ing2b')
     rp.ready_methods['ing2b']=[['ready_singlerun']]
     rp.run_methods['ing2b']=[['run_singlerun']]
     rp.complete_methods['ing2b']=[['complete_singlerun']]
     rp.run_staged_ingredients()
     mysubmit = MASTFile("test_control/submitlist")
     self.assertEquals(mysubmit.data[0],"recipedir/ing2b\n")
     self.assertEquals(rp.ingredients,{'ing1':'C','ing2a':'W','ing2b':'P','ing3':'W'})
示例#26
0
    def create_recipe_plan(self):
        """Creates a recipe object which has the ingredients and dependency information
        """
        import inspect
        #'GRJ DEBUG: %s.%s' % (self.__class__.__name__, inspect.stack()[0][3])
        [how_to_update, parents_to_check, how_to_run] = ru.read_recipe(self.recipe_file)

        recipe_obj = RecipePlan(self.work_dir)
        ingredlist = how_to_run.keys()
        for ingred in ingredlist:
            self.update_top_meta_for_ingred(ingred)
            ingredtype = how_to_run[ingred]
            recipe_obj.ingredients[ingred]="I" #set all to initialized
            recipe_obj.ingred_input_options[ingred] = self.get_my_ingredient_options(ingred, ingredtype)
            if not os.path.isdir(os.path.join(self.work_dir, ingred)):
                self.create_ingredient(recipe_obj.ingred_input_options[ingred])
            recipe_obj.write_methods[ingred] = self.get_method_list(ingredtype, "mast_write_method")
            recipe_obj.ready_methods[ingred] = self.get_method_list(ingredtype, "mast_ready_method")
            recipe_obj.run_methods[ingred] = self.get_method_list(ingredtype, "mast_run_method")
            recipe_obj.complete_methods[ingred] = self.get_method_list(ingredtype, "mast_complete_method")
            recipe_obj.update_methods[ingred] = dict()
            for ichild in how_to_update[ingred].keys():
                updingredtype = how_to_update[ingred][ichild]
                recipe_obj.update_methods[ingred][ichild] = self.get_method_list(updingredtype, "mast_update_children_method")
            recipe_obj.parents_to_check = dict(parents_to_check)
        recipe_obj.summary_options = self.get_summary_options()
        return recipe_obj
示例#27
0
    def create_recipe_plan(self):
        """Creates a recipe object which has the ingredients and dependency information
        """
        import inspect
        #'GRJ DEBUG: %s.%s' % (self.__class__.__name__, inspect.stack()[0][3])
        [how_to_update, parents_to_check,
         how_to_run] = ru.read_recipe(self.recipe_file)

        recipe_obj = RecipePlan(self.work_dir)
        ingredlist = how_to_run.keys()
        for ingred in ingredlist:
            self.update_top_meta_for_ingred(ingred)
            ingredtype = how_to_run[ingred]
            recipe_obj.ingredients[ingred] = "I"  #set all to initialized
            recipe_obj.ingred_input_options[
                ingred] = self.get_my_ingredient_options(ingred, ingredtype)
            if not os.path.isdir(os.path.join(self.work_dir, ingred)):
                self.create_ingredient(recipe_obj.ingred_input_options[ingred])
            recipe_obj.write_methods[ingred] = self.get_method_list(
                ingredtype, "mast_write_method")
            recipe_obj.ready_methods[ingred] = self.get_method_list(
                ingredtype, "mast_ready_method")
            recipe_obj.run_methods[ingred] = self.get_method_list(
                ingredtype, "mast_run_method")
            recipe_obj.complete_methods[ingred] = self.get_method_list(
                ingredtype, "mast_complete_method")
            recipe_obj.update_methods[ingred] = dict()
            for ichild in how_to_update[ingred].keys():
                updingredtype = how_to_update[ingred][ichild]
                recipe_obj.update_methods[ingred][
                    ichild] = self.get_method_list(
                        updingredtype, "mast_update_children_method")
            recipe_obj.parents_to_check = dict(parents_to_check)
        recipe_obj.summary_options = self.get_summary_options()
        return recipe_obj