Exemplo n.º 1
0
 def test_place_parent_energy_files(self):
     ingdir="writedir/neb_labelinit-labelfin"
     topmetad = MASTFile("files/top_metadata_neb")
     topmetad.data.append("origin_dir = %s/files\n" % testdir) #give origin directory
     topmetad.to_file("writedir/metadata.txt")
     metad = MASTFile("files/metadata_neb")
     metad.to_file("%s/metadata.txt" % ingdir)
     peinit = MASTFile("files/parent_energy_labelinit")
     peinit.to_file("%s/parent_energy_labelinit" % ingdir)
     pefin = MASTFile("files/parent_energy_labelfin")
     pefin.to_file("%s/parent_energy_labelfin" % ingdir)
     kdict=dict()
     kdict['mast_kpoints']=[3,3,3,"G"]
     kdict['mast_xc']='pbe'
     kdict['mast_program']='vasp_neb'
     kdict['mast_neb_settings']=dict()
     kdict['mast_neb_settings']['images']=3
     my_structure=pymatgen.io.vaspio.Poscar.from_file("files/perfect_structure").structure
     mywi = ChopIngredient(name=ingdir,program_keys=kdict,structure=my_structure)
     os.mkdir(ingdir + '/00')
     os.mkdir(ingdir + '/04')
     mywi.place_parent_energy_files()
     self.assertTrue(os.path.isfile(ingdir + '/00/OSZICAR'))
     self.assertTrue(os.path.isfile(ingdir + '/04/OSZICAR'))
     oszinit = MASTFile(ingdir + "/00/OSZICAR")
     oszfinal = MASTFile(ingdir + "/04/OSZICAR")
     self.assertEqual(oszinit.data, peinit.data)
     self.assertEqual(oszfinal.data, pefin.data)
Exemplo n.º 2
0
 def test_get_parent_structures(self):
     kdict=dict()
     kdict['mast_program'] = 'vasp_neb'
     neblines = list()
     neblines.append(["Cr","0.0 0.9 0.8","0.0 0.8 0.7"])
     neblines.append(["Cr","0.4 0.2 0.1","0.3 0.3 0.2"])
     neblines.append(["Cr","0.29 0.05 0.05","0.01 0.01 0.98"])
     neblines.append(["Ni","0.61 0.99 0.98","0.25 0.01 0.97"])
     kdict['mast_neb_settings']=dict()
     kdict['mast_neb_settings']['images']=3
     kdict['mast_neb_settings']['lines']=neblines
     ingdir = "writedir/neb_labelinit-labelfin"
     topmetad = MASTFile("files/top_metadata_neb")
     topmetad.to_file("writedir/metadata.txt")
     metad = MASTFile("files/metadata_neb")
     metad.to_file("%s/metadata.txt" % ingdir)
     unsorted_init = MASTFile("unsorted/parent_structure_labelinit")
     #unsorted_init = MASTFile("unsorted/parent_structure_labelinit_scrambled")
     unsorted_init.to_file("%s/parent_structure_labelinit" % ingdir)
     unsorted_fin = MASTFile("unsorted/parent_structure_labelfin")
     unsorted_fin.to_file("%s/parent_structure_labelfin" % ingdir)
     my_structure=pymatgen.io.vaspio.Poscar.from_file("files/perfect_structure").structure
     mywi = ChopIngredient(name=ingdir,program_keys=kdict,structure=my_structure)
     [sinit, sfin] = mywi.get_parent_structures()
     init_compare = pymatgen.io.vaspio.Poscar.from_file("files/parent_structure_labelinit").structure
     fin_compare = pymatgen.io.vaspio.Poscar.from_file("files/parent_structure_labelfin").structure
     #print sinit
     #print init_compare
     #print sfin
     #print fin_compare
     self.assertEqual(sinit.sites, init_compare.sites)
     self.assertEqual(sinit.lattice, init_compare.lattice)
     self.assertEqual(sfin.sites, fin_compare.sites)
     self.assertEqual(sfin.lattice, fin_compare.lattice)
Exemplo n.º 3
0
 def test_run_scale(self):
     #raise SkipTest
     ingdir = "%s/writedir/single_label1" % testdir
     recipedir = "%s/writedir" % testdir
     topmetad = MASTFile("files/top_metadata_single")
     topmetad.data.append("origin_dir = %s/files\n" %
                          testdir)  #give origin directory
     topmetad.to_file("writedir/metadata.txt")
     metad = MASTFile("files/metadata_single")
     metad.data.append("defect_label = label1\n")
     metad.data.append("scaling_size = [2,2,2]\n")
     metad.to_file("%s/metadata.txt" % ingdir)
     kdict = dict()
     kdict['mast_program'] = 'vasp'
     my_structure = Poscar.from_file("files/POSCAR_perfect").structure
     myperf = MASTFile("files/POSCAR_perfect")
     myperf.to_file("%s/POSCAR" % ingdir)
     myri = ChopIngredient(name=ingdir,
                           program_keys=kdict,
                           structure=my_structure)
     myri.run_scale()
     my_scaled = Poscar.from_file("%s/CONTCAR" %
                                  ingdir).structure.get_sorted_structure()
     scaled_compare = Poscar.from_file(
         "files/POSCAR_scaled").structure.get_sorted_structure()
     self.assertEquals(my_scaled, scaled_compare)
Exemplo n.º 4
0
 def test_give_phonon_single_forces_and_displacements(self):
     ingdir="%s/writedir/single_phonon_label1" % testdir
     recipedir="%s/writedir" % testdir
     topmetad = MASTFile("files/top_metadata_single")
     topmetad.data.append("origin_dir = %s/files\n" % testdir) #give origin directory
     topmetad.to_file("writedir/metadata.txt")
     metad = MASTFile("files/metadata_single_phonon")
     metad.to_file("%s/metadata.txt" % ingdir)
     mypos = MASTFile("files/phonon_initial_POSCAR")
     mypos.to_file("%s/POSCAR" % ingdir)
     kdict=dict()
     kdict['mast_program'] = 'vasp'
     my_structure = pymatgen.io.vaspio.Poscar.from_file("files/perfect_structure").structure
     myxdat = MASTFile("files/XDATCAR_compare")
     myxdat.to_file("%s/XDATCAR" % ingdir)
     mydynmat = MASTFile("files/DYNMAT_compare")
     mydynmat.to_file("%s/DYNMAT" % ingdir)
     myuci = ChopIngredient(name=ingdir,program_keys=kdict, structure=my_structure)
     myuci.give_phonon_single_forces_and_displacements("next_ingred") 
     newpos = MASTFile("%s/writedir/next_ingred/POSCAR_prePHON" % testdir)
     newdyn = MASTFile("%s/writedir/next_ingred/DYNMAT" % testdir)
     newxdat = MASTFile("%s/writedir/next_ingred/XDATCAR" % testdir)
     comparepos = MASTFile("files/phonon_initial_POSCAR")
     comparedyn = MASTFile("files/DYNMAT_compare")
     comparexdat = MASTFile("%s/XDATCAR" % ingdir)
     self.assertEqual(newpos.data, comparepos.data)
     self.assertEqual(newdyn.data, comparedyn.data)
     self.assertEqual(newxdat.data, comparexdat.data)
Exemplo n.º 5
0
 def test_give_phonon_single_forces_and_displacements(self):
     ingdir = "%s/writedir/single_phonon_label1" % testdir
     recipedir = "%s/writedir" % testdir
     topmetad = MASTFile("files/top_metadata_single")
     topmetad.data.append("origin_dir = %s/files\n" %
                          testdir)  #give origin directory
     topmetad.to_file("writedir/metadata.txt")
     metad = MASTFile("files/metadata_single_phonon")
     metad.to_file("%s/metadata.txt" % ingdir)
     mypos = MASTFile("files/phonon_initial_POSCAR")
     mypos.to_file("%s/POSCAR" % ingdir)
     kdict = dict()
     kdict['mast_program'] = 'vasp'
     my_structure = pymatgen.io.vaspio.Poscar.from_file(
         "files/perfect_structure").structure
     myxdat = MASTFile("files/XDATCAR_compare")
     myxdat.to_file("%s/XDATCAR" % ingdir)
     mydynmat = MASTFile("files/DYNMAT_compare")
     mydynmat.to_file("%s/DYNMAT" % ingdir)
     myuci = ChopIngredient(name=ingdir,
                            program_keys=kdict,
                            structure=my_structure)
     myuci.give_phonon_single_forces_and_displacements("next_ingred")
     newpos = MASTFile("%s/writedir/next_ingred/POSCAR_prePHON" % testdir)
     newdyn = MASTFile("%s/writedir/next_ingred/DYNMAT" % testdir)
     newxdat = MASTFile("%s/writedir/next_ingred/XDATCAR" % testdir)
     comparepos = MASTFile("files/phonon_initial_POSCAR")
     comparedyn = MASTFile("files/DYNMAT_compare")
     comparexdat = MASTFile("%s/XDATCAR" % ingdir)
     self.assertEqual(newpos.data, comparepos.data)
     self.assertEqual(newdyn.data, comparedyn.data)
     self.assertEqual(newxdat.data, comparexdat.data)
Exemplo n.º 6
0
 def test_place_parent_energy_files(self):
     ingdir = "writedir/neb_labelinit-labelfin"
     topmetad = MASTFile("files/top_metadata_neb")
     topmetad.data.append("origin_dir = %s/files\n" %
                          testdir)  #give origin directory
     topmetad.to_file("writedir/metadata.txt")
     metad = MASTFile("files/metadata_neb")
     metad.to_file("%s/metadata.txt" % ingdir)
     peinit = MASTFile("files/parent_energy_labelinit")
     peinit.to_file("%s/parent_energy_labelinit" % ingdir)
     pefin = MASTFile("files/parent_energy_labelfin")
     pefin.to_file("%s/parent_energy_labelfin" % ingdir)
     kdict = dict()
     kdict['mast_kpoints'] = [3, 3, 3, "G"]
     kdict['mast_xc'] = 'pbe'
     kdict['mast_program'] = 'vasp_neb'
     kdict['mast_neb_settings'] = dict()
     kdict['mast_neb_settings']['images'] = 3
     my_structure = pymatgen.io.vaspio.Poscar.from_file(
         "files/perfect_structure").structure
     mywi = ChopIngredient(name=ingdir,
                           program_keys=kdict,
                           structure=my_structure)
     os.mkdir(ingdir + '/00')
     os.mkdir(ingdir + '/04')
     mywi.place_parent_energy_files()
     self.assertTrue(os.path.isfile(ingdir + '/00/OSZICAR'))
     self.assertTrue(os.path.isfile(ingdir + '/04/OSZICAR'))
     oszinit = MASTFile(ingdir + "/00/OSZICAR")
     oszfinal = MASTFile(ingdir + "/04/OSZICAR")
     self.assertEqual(oszinit.data, peinit.data)
     self.assertEqual(oszfinal.data, pefin.data)
Exemplo n.º 7
0
 def test_give_neb_structures_to_neb(self):
     ingdir = "%s/writedir/neb_labelinit-labelfin" % testdir
     recipedir = "%s/writedir" % testdir
     topmetad = MASTFile("files/top_metadata_neb")
     topmetad.data.append("origin_dir = %s/files\n" %
                          testdir)  #give origin directory
     topmetad.to_file("writedir/metadata.txt")
     metad = MASTFile("files/metadata_neb")
     metad.to_file("%s/metadata.txt" % ingdir)
     kdict = dict()
     kdict['mast_program'] = 'vasp_neb'
     kdict['mast_neb_settings'] = dict()
     kdict['mast_neb_settings']['images'] = 3
     my_structure = pymatgen.io.vaspio.Poscar.from_file(
         "files/perfect_structure").structure
     myrelaxed = dict()
     for subdir in ['00', '01', '02', '03', '04']:
         os.mkdir("writedir/neb_labelinit-labelfin/%s" % subdir)
         myrelaxed[subdir] = MASTFile("files/POSCAR_%s" % subdir)
         myrelaxed[subdir].to_file(
             "writedir/neb_labelinit-labelfin/%s/CONTCAR" % subdir)
     myuci = ChopIngredient(name=ingdir,
                            program_keys=kdict,
                            structure=my_structure)
     myuci.give_neb_structures_to_neb("next_ingred")
     for subdir in ['01', '02', '03']:
         givenstr = MASTFile(
             "%s/writedir/next_ingred/parent_structure_labelinit-labelfin_%s"
             % (testdir, subdir))
         self.assertEqual(myrelaxed[subdir].data, givenstr.data)
Exemplo n.º 8
0
 def test_write_phonon_single(self):
     ingdir = "writedir/single_phonon_label1"
     topmetad = MASTFile("files/top_metadata_single_phonon")
     topmetad.data.append("origin_dir = %s/files\n" %
                          testdir)  #give origin directory
     topmetad.to_file("writedir/metadata.txt")
     metad = MASTFile("files/metadata_single_phonon")
     metad.to_file("%s/metadata.txt" % ingdir)
     kdict = dict()
     kdict['mast_kpoints'] = [3, 3, 3, "G"]
     kdict['mast_xc'] = 'pbe'
     kdict['mast_program'] = 'vasp'
     kdict['mast_phonon_settings'] = dict()
     kdict['mast_phonon_settings']['phonon_center_site'] = "0.33 0.25 0.0"
     kdict['mast_phonon_settings']['phonon_center_radius'] = "1"
     kdict['mast_phonon_settings']['threshold'] = "0.075"
     my_structure = pymatgen.io.vaspio.Poscar.from_file(
         "files/perfect_structure").structure
     mywi = ChopIngredient(name=ingdir,
                           program_keys=kdict,
                           structure=my_structure)
     mywi.write_phonon_single()
     self.assertTrue(mywi.checker.is_ready_to_run())
     compare_phon_single = MASTFile("files/phon_single_POSCAR")
     phon_singlepos = MASTFile("%s/POSCAR" % ingdir)
     self.assertEqual(phon_singlepos.data, compare_phon_single.data)
Exemplo n.º 9
0
 def test_get_my_phonon_params(self):
     ingdir = "writedir/single_phonon_label1"
     topmetad = MASTFile("files/top_metadata_single_phonon")
     topmetad.data.append("origin_dir = %s/files\n" %
                          testdir)  #give origin directory
     topmetad.to_file("writedir/metadata.txt")
     metad = MASTFile("files/metadata_single_phonon")
     metad.to_file("%s/metadata.txt" % ingdir)
     kdict = dict()
     kdict['mast_kpoints'] = [3, 3, 3, "G"]
     kdict['mast_xc'] = 'pbe'
     kdict['mast_program'] = 'vasp'
     kdict['mast_phonon_settings'] = dict()
     kdict['mast_phonon_settings']['phonon_center_site'] = "0.33 0.25 0.0"
     kdict['mast_phonon_settings']['phonon_center_radius'] = "1"
     kdict['mast_phonon_settings']['threshold'] = "0.075"
     my_structure = pymatgen.io.vaspio.Poscar.from_file(
         "files/perfect_structure").structure
     mywi = ChopIngredient(name=ingdir,
                           program_keys=kdict,
                           structure=my_structure)
     [mysite, myrad, mythresh] = mywi.get_my_phonon_params()
     self.assertEqual(mysite, "0.33 0.25 0.0")
     self.assertEqual(myrad, "1")
     self.assertEqual(mythresh, "0.075")
Exemplo n.º 10
0
 def test_give_structure_and_charge_density_full_copy(self):
     ingdir = "%s/writedir/single_label1" % testdir
     recipedir = "%s/writedir" % testdir
     topmetad = MASTFile("files/top_metadata_single")
     topmetad.data.append("origin_dir = %s/files\n" %
                          testdir)  #give origin directory
     topmetad.to_file("writedir/metadata.txt")
     metad = MASTFile("files/metadata_single")
     metad.to_file("%s/metadata.txt" % ingdir)
     kdict = dict()
     kdict['mast_program'] = 'vasp'
     my_structure = pymatgen.io.vaspio.Poscar.from_file(
         "files/perfect_structure").structure
     myrelaxed = MASTFile("files/relaxed_structure")
     myrelaxed.to_file("%s/CONTCAR" % ingdir)
     mychg = MASTFile("files/CHGCAR")
     mychg.to_file("%s/CHGCAR" % ingdir)
     mywave = MASTFile("files/WAVECAR")
     mywave.to_file("%s/WAVECAR" % ingdir)
     myuci = ChopIngredient(name=ingdir,
                            program_keys=kdict,
                            structure=my_structure)
     myuci.give_structure_and_charge_density_full_copy("next_ingred")
     givenstr = MASTFile("%s/writedir/next_ingred/POSCAR" % testdir)
     self.assertEqual(myrelaxed.data, givenstr.data)
     self.assertTrue(
         os.path.exists("%s/writedir/next_ingred/CHGCAR" % testdir))
Exemplo n.º 11
0
 def test_give_structure_and_energy_to_neb(self):
     ingdir = "%s/writedir/single_label1" % testdir
     recipedir = "%s/writedir" % testdir
     topmetad = MASTFile("files/top_metadata_single")
     topmetad.data.append("origin_dir = %s/files\n" %
                          testdir)  #give origin directory
     topmetad.to_file("writedir/metadata.txt")
     metad = MASTFile("files/metadata_single")
     metad.data.append("defect_label = label1\n")
     metad.to_file("%s/metadata.txt" % ingdir)
     kdict = dict()
     kdict['mast_program'] = 'vasp'
     my_structure = pymatgen.io.vaspio.Poscar.from_file(
         "files/perfect_structure").structure
     myrelaxed = MASTFile("files/relaxed_structure")
     myrelaxed.to_file("%s/CONTCAR" % ingdir)
     myenergy = MASTFile("files/OSZICAR_relaxed")
     myenergy.to_file("%s/OSZICAR" % ingdir)
     myuci = ChopIngredient(name=ingdir,
                            program_keys=kdict,
                            structure=my_structure)
     myuci.give_structure_and_energy_to_neb("next_ingred")
     givenstr = MASTFile("%s/writedir/next_ingred/parent_structure_label1" %
                         testdir)
     givenenergy = MASTFile("%s/writedir/next_ingred/parent_energy_label1" %
                            testdir)
     self.assertEqual(myrelaxed.data, givenstr.data)
     self.assertEqual(myenergy.data, givenenergy.data)
Exemplo n.º 12
0
 def test_get_parent_image_structures(self):
     kdict=dict()
     kdict['mast_program'] = 'vasp_neb'
     neblines = list()
     neblines.append(["Cr","0.0 0.9 0.8","0.0 0.8 0.7"])
     neblines.append(["Cr","0.4 0.2 0.1","0.3 0.3 0.2"])
     neblines.append(["Cr","0.29 0.05 0.05","0.01 0.01 0.98"])
     neblines.append(["Ni","0.61 0.99 0.98","0.25 0.01 0.97"])
     kdict['mast_neb_settings']=dict()
     kdict['mast_neb_settings']['images']=3
     kdict['mast_neb_settings']['lines']=neblines
     ingdir = "writedir/neb_labelinit-labelfin"
     topmetad = MASTFile("files/top_metadata_neb")
     topmetad.to_file("writedir/metadata.txt")
     metad = MASTFile("files/metadata_neb")
     metad.to_file("%s/metadata.txt" % ingdir)
     unsorted_01 = MASTFile("unsorted/parent_structure_labelinit-labelfin_01")
     unsorted_01.to_file("%s/parent_structure_labelinit-labelfin_01" % ingdir)
     unsorted_02 = MASTFile("unsorted/parent_structure_labelinit-labelfin_02")
     unsorted_02.to_file("%s/parent_structure_labelinit-labelfin_02" % ingdir)
     unsorted_03 = MASTFile("unsorted/parent_structure_labelinit-labelfin_03")
     unsorted_03.to_file("%s/parent_structure_labelinit-labelfin_03" % ingdir)
     my_structure=pymatgen.io.vaspio.Poscar.from_file("files/perfect_structure").structure
     mywi = ChopIngredient(name=ingdir,program_keys=kdict,structure=my_structure)
     imstrs = mywi.get_parent_image_structures()
     compare_01 = pymatgen.io.vaspio.Poscar.from_file("files/parent_structure_labelinit-labelfin_01").structure
     compare_02 = pymatgen.io.vaspio.Poscar.from_file("files/parent_structure_labelinit-labelfin_02").structure
     compare_03 = pymatgen.io.vaspio.Poscar.from_file("files/parent_structure_labelinit-labelfin_03").structure
     self.assertEqual(imstrs[0].sites, compare_01.sites)
     self.assertEqual(imstrs[0].lattice, compare_01.lattice)
     self.assertEqual(imstrs[1].sites, compare_02.sites)
     self.assertEqual(imstrs[1].lattice, compare_02.lattice)
     self.assertEqual(imstrs[2].sites, compare_03.sites)
     self.assertEqual(imstrs[2].lattice, compare_03.lattice)
Exemplo n.º 13
0
 def test_give_saddle_structure(self):
     ingdir="%s/writedir/neb_labelinit-labelfin" % testdir
     recipedir="%s/writedir" % testdir
     topmetad = MASTFile("files/top_metadata_neb")
     topmetad.data.append("origin_dir = %s/files\n" % testdir) #give origin directory
     topmetad.to_file("writedir/metadata.txt")
     metad = MASTFile("files/metadata_neb")
     metad.to_file("%s/metadata.txt" % ingdir)
     kdict=dict()
     kdict['mast_program'] = 'vasp_neb'
     kdict['images'] = 3
     my_structure = pymatgen.io.vaspio.Poscar.from_file("files/perfect_structure").structure
     myrelaxed=dict()
     myosz=dict()
     mywav=dict()
     mychg=dict()
     for subdir in ['00','01','02','03','04']:
         os.mkdir("writedir/neb_labelinit-labelfin/%s" % subdir)
         myrelaxed[subdir] = MASTFile("files/POSCAR_%s" % subdir)
         myrelaxed[subdir].to_file("writedir/neb_labelinit-labelfin/%s/CONTCAR" % subdir)
         myosz[subdir] = MASTFile("files/OSZICAR_%s" % subdir)
         myosz[subdir].to_file("writedir/neb_labelinit-labelfin/%s/OSZICAR" % subdir)
         mychg[subdir] = MASTFile("files/CHGCAR")
         mychg[subdir].to_file("writedir/neb_labelinit-labelfin/%s/CHGCAR" % subdir)
         mywav[subdir] = MASTFile("files/WAVECAR")
         mywav[subdir].to_file("writedir/neb_labelinit-labelfin/%s/WAVECAR" % subdir)
     myuci = ChopIngredient(name=ingdir,program_keys=kdict, structure=my_structure)
     myuci.give_saddle_structure("next_ingred") #should be OSZ3
     saddle = MASTFile("%s/writedir/next_ingred/POSCAR" % testdir)
     self.assertEqual(myrelaxed['03'].data, saddle.data)
     saddledir = myuci.get_saddle_dir()
     self.assertEqual(saddledir, "03")
Exemplo n.º 14
0
 def test_write_neb_subfolders(self):
     ingdir="writedir/neb_labelinit-labelfin"
     topmetad = MASTFile("files/top_metadata_neb")
     topmetad.data.append("origin_dir = %s/files\n" % testdir) #give origin directory
     topmetad.to_file("writedir/metadata.txt")
     metad = MASTFile("files/metadata_neb")
     metad.to_file("%s/metadata.txt" % ingdir)
     parent_01 = MASTFile("statfiles/parent_structure_labelinit-labelfin_01")
     parent_01.to_file(ingdir + "/parent_structure_labelinit-labelfin_01")
     parent_02 = MASTFile("statfiles/parent_structure_labelinit-labelfin_02")
     parent_02.to_file(ingdir + "/parent_structure_labelinit-labelfin_02")
     parent_03 = MASTFile("statfiles/parent_structure_labelinit-labelfin_03")
     parent_03.to_file(ingdir + "/parent_structure_labelinit-labelfin_03")
     parent_init = MASTFile("statfiles/parent_structure_labelinit")
     parent_init.to_file(ingdir + "/parent_structure_labelinit")
     parent_fin = MASTFile("statfiles/parent_structure_labelfin")
     parent_fin.to_file(ingdir + "/parent_structure_labelfin")
     peinit = MASTFile("statfiles/parent_energy_labelinit")
     peinit.to_file("%s/parent_energy_labelinit" % ingdir)
     pefin = MASTFile("statfiles/parent_energy_labelfin")
     pefin.to_file("%s/parent_energy_labelfin" % ingdir)
     kdict=dict()
     kdict['mast_kpoints']=[3,3,3,"G"]
     kdict['mast_xc']='pbe'
     kdict['mast_program']='vasp'
     neblines = list()
     neblines.append(["Cr","0.0 0.9 0.8","0.0 0.8 0.7"])
     neblines.append(["Cr","0.4 0.2 0.1","0.3 0.3 0.2"])
     neblines.append(["Cr","0.29 0.05 0.05","0.01 0.01 0.98"])
     neblines.append(["Ni","0.61 0.99 0.98","0.25 0.01 0.97"])
     kdict['mast_neb_settings']=dict()
     kdict['mast_neb_settings']['images']=3
     kdict['mast_neb_settings']['lines']=neblines
     my_structure=pymatgen.io.vaspio.Poscar.from_file("files/perfect_structure").structure
     mywi = ChopIngredient(name=ingdir,program_keys=kdict,structure=my_structure)
     mywi.write_neb_subfolders()
     self.assertFalse(os.path.isfile("%s/00/submit.sh" % ingdir))
     self.assertTrue(os.path.isfile("%s/01/submit.sh" % ingdir))
     self.assertTrue(os.path.isfile("%s/02/submit.sh" % ingdir))
     self.assertTrue(os.path.isfile("%s/03/submit.sh" % ingdir))
     self.assertFalse(os.path.isfile("%s/04/submit.sh" % ingdir))
     oszinit = MASTFile("%s/00/OSZICAR" % ingdir)
     oszfin = MASTFile("%s/04/OSZICAR" % ingdir)
     pos00 = MASTFile("%s/00/POSCAR" % ingdir)
     pos01 = MASTFile("%s/01/POSCAR" % ingdir)
     pos02 = MASTFile("%s/02/POSCAR" % ingdir)
     pos03 = MASTFile("%s/03/POSCAR" % ingdir)
     pos04 = MASTFile("%s/04/POSCAR" % ingdir)
     self.assertEqual(oszinit.data, peinit.data)
     self.assertEqual(oszfin.data, pefin.data)
     self.assertEqual(pos01.data, parent_01.data)
     self.assertEqual(pos02.data, parent_02.data)
     self.assertEqual(pos03.data, parent_03.data)
     self.assertEqual(pos00.data, parent_init.data)
     self.assertEqual(pos04.data, parent_fin.data)
Exemplo n.º 15
0
 def test_complete_neb_subfolders(self):
     #raise SkipTest
     ingdir="%s/writedir/single_label1" % testdir
     recipedir="%s/writedir" % testdir
     topmetad = MASTFile("files/top_metadata_single")
     topmetad.data.append("origin_dir = %s/files\n" % testdir) #give origin directory
     topmetad.to_file("writedir/metadata.txt")
     metad = MASTFile("files/metadata_single")
     metad.to_file("%s/metadata.txt" % ingdir)
     kdict=dict()
     kdict['mast_program'] = 'vasp'
     kdict['mast_kpoints'] = [2,2,2,"M"]
     kdict['mast_xc'] = 'pw91'
     kdict['mast_neb_settings']=dict()
     kdict['mast_neb_settings']['images'] = 3
     my_structure = pymatgen.io.vaspio.Poscar.from_file("files/perfect_structure").structure
     mywr = ChopIngredient(name=ingdir, program_keys = kdict, structure=my_structure)
     myoutcar = MASTFile("files/OUTCAR_completed")
     myoszicar = MASTFile("files/OSZICAR_completed")
     for subdir in ['00','01','02','03','04']:
         subname = "%s/%s" % (ingdir, subdir)
         os.mkdir(subname)
         mywr.keywords['name'] = subname
         mywr.checker.keywords['name'] = subname
         if not subdir in ['00','04']:
             mywr.write_singlerun()
             mywr.write_submit_script()
             myoutcar.to_file("%s/OUTCAR" % subname)
             myoszicar.to_file("%s/OSZICAR" % subname)
     myci = ChopIngredient(name=ingdir,program_keys=kdict, structure=my_structure)
     self.assertTrue(myci.complete_neb_subfolders())
     os.remove("%s/03/OUTCAR" % ingdir)
     self.assertFalse(myci.complete_neb_subfolders())
Exemplo n.º 16
0
 def test_write_neb_with_parent_image_structures(self):
     ingdir = "writedir/neb_labelinit-labelfin"
     topmetad = MASTFile("files/top_metadata_neb")
     topmetad.data.append("origin_dir = %s/files\n" %
                          testdir)  #give origin directory
     topmetad.to_file("writedir/metadata.txt")
     metad = MASTFile("files/metadata_neb")
     metad.to_file("%s/metadata.txt" % ingdir)
     peinit = MASTFile("files/parent_energy_labelinit")
     peinit.to_file("%s/parent_energy_labelinit" % ingdir)
     pefin = MASTFile("files/parent_energy_labelfin")
     pefin.to_file("%s/parent_energy_labelfin" % ingdir)
     psinit = MASTFile("files/parent_structure_labelinit")
     psinit.to_file("%s/parent_structure_labelinit" % ingdir)
     psfin = MASTFile("files/parent_structure_labelfin")
     psfin.to_file("%s/parent_structure_labelfin" % ingdir)
     kdict = dict()
     kdict['mast_kpoints'] = [3, 3, 3, "G"]
     kdict['mast_xc'] = 'pbe'
     kdict['mast_program'] = 'vasp_neb'
     kdict['mast_coordinates'] = list()
     kdict['mast_coordinates'].append('%s/files/POSCAR_coords_01' % testdir)
     kdict['mast_coordinates'].append('%s/files/POSCAR_coords_02' % testdir)
     kdict['mast_coordinates'].append('%s/files/POSCAR_coords_03' % testdir)
     neblines = list()
     neblines.append(["Cr", "0.0 0.9 0.8", "0.0 0.8 0.7"])
     neblines.append(["Cr", "0.4 0.2 0.1", "0.3 0.3 0.2"])
     neblines.append(["Cr", "0.29 0.05 0.05", "0.01 0.01 0.98"])
     neblines.append(["Ni", "0.61 0.99 0.98", "0.25 0.01 0.97"])
     kdict['mast_neb_settings'] = dict()
     kdict['mast_neb_settings']['images'] = 3
     kdict['mast_neb_settings']['lines'] = neblines
     my_structure = pymatgen.io.vaspio.Poscar.from_file(
         "files/perfect_structure").structure
     mywi = ChopIngredient(name=ingdir,
                           program_keys=kdict,
                           structure=my_structure)
     mywi.write_neb()
     self.assertTrue(mywi.checker.is_ready_to_run())
     pos_compare_00 = MASTFile("files/POSCAR_grafted_00")
     pos_compare_01 = MASTFile("files/POSCAR_grafted_01")
     pos_compare_02 = MASTFile("files/POSCAR_grafted_02")
     pos_compare_03 = MASTFile("files/POSCAR_grafted_03")
     pos_compare_04 = MASTFile("files/POSCAR_grafted_04")
     mypos00 = MASTFile("writedir/neb_labelinit-labelfin/00/POSCAR")
     mypos01 = MASTFile("writedir/neb_labelinit-labelfin/01/POSCAR")
     mypos02 = MASTFile("writedir/neb_labelinit-labelfin/02/POSCAR")
     mypos03 = MASTFile("writedir/neb_labelinit-labelfin/03/POSCAR")
     mypos04 = MASTFile("writedir/neb_labelinit-labelfin/04/POSCAR")
     self.assertEqual(pos_compare_00.data, mypos00.data)
     self.assertEqual(pos_compare_01.data, mypos01.data)
     self.assertEqual(pos_compare_02.data, mypos02.data)
     self.assertEqual(pos_compare_03.data, mypos03.data)
     self.assertEqual(pos_compare_04.data, mypos04.data)
Exemplo n.º 17
0
 def test__fullpath_childname(self):
     ingdir="%s/writedir/single_label1" % testdir
     topmetad = MASTFile("files/top_metadata_single")
     topmetad.data.append("origin_dir = %s/files\n" % testdir) #give origin directory
     topmetad.to_file("writedir/metadata.txt")
     metad = MASTFile("files/metadata_single")
     metad.to_file("%s/metadata.txt" % ingdir)
     kdict=dict()
     kdict['mast_program'] = 'vasp'
     my_structure = pymatgen.io.vaspio.Poscar.from_file("files/perfect_structure").structure
     myuci = ChopIngredient(name=ingdir,program_keys=kdict,structure=my_structure)
     fullpath = myuci._fullpath_childname("next_ingred")
     self.assertEqual(fullpath, "%s/writedir/next_ingred" % testdir)
Exemplo n.º 18
0
 def test_complete_singlerun(self):
     #raise SkipTest
     ingdir = "%s/writedir/single_label1" % testdir
     recipedir = "%s/writedir" % testdir
     topmetad = MASTFile("files/top_metadata_single")
     topmetad.data.append("origin_dir = %s/files\n" %
                          testdir)  #give origin directory
     topmetad.to_file("writedir/metadata.txt")
     metad = MASTFile("files/metadata_single")
     metad.to_file("%s/metadata.txt" % ingdir)
     kdict = dict()
     kdict['mast_program'] = 'vasp'
     kdict['mast_kpoints'] = [2, 2, 2, "M"]
     kdict['mast_xc'] = 'pw91'
     my_structure = pymatgen.io.vaspio.Poscar.from_file(
         "files/perfect_structure").structure
     mywr = ChopIngredient(name=ingdir,
                           program_keys=kdict,
                           structure=my_structure)
     mywr.write_singlerun()
     myoutcar = MASTFile("files/OUTCAR_completed")
     myoutcar.to_file("%s/OUTCAR" % ingdir)
     myoszicar = MASTFile("files/OSZICAR_completed")
     myoszicar.to_file("%s/OSZICAR" % ingdir)
     myrdi = ChopIngredient(name=ingdir,
                            program_keys=kdict,
                            structure=my_structure)
     self.assertTrue(myrdi.complete_singlerun())
     os.remove("%s/OUTCAR" % ingdir)
     self.assertFalse(myrdi.complete_singlerun())
Exemplo n.º 19
0
 def test_run_singlerun(self):
     #raise SkipTest
     ingdir = "%s/writedir/single_label1" % testdir
     recipedir = "%s/writedir" % testdir
     topmetad = MASTFile("files/top_metadata_single")
     topmetad.data.append("origin_dir = %s/files\n" %
                          testdir)  #give origin directory
     topmetad.to_file("writedir/metadata.txt")
     metad = MASTFile("files/metadata_single")
     metad.to_file("%s/metadata.txt" % ingdir)
     kdict = dict()
     kdict['mast_program'] = 'vasp'
     kdict['mast_kpoints'] = [2, 2, 2, "M"]
     kdict['mast_xc'] = 'pw91'
     my_structure = Poscar.from_file("files/perfect_structure").structure
     mywr = ChopIngredient(name=ingdir,
                           program_keys=kdict,
                           structure=my_structure)
     mywr.write_singlerun()
     myri = ChopIngredient(name=ingdir,
                           program_keys=kdict,
                           structure=my_structure)
     myri.run_singlerun()
     self.assertTrue(myri.checker.is_ready_to_run())
     mysubmit = MASTFile("%s/submitlist" % self.test_control)
     self.assertEquals(mysubmit.data[0], "%s\n" % ingdir)
Exemplo n.º 20
0
 def test_write_neb_with_parent_image_structures(self):
     ingdir="writedir/neb_labelinit-labelfin"
     topmetad = MASTFile("files/top_metadata_neb")
     topmetad.data.append("origin_dir = %s/files\n" % testdir) #give origin directory
     topmetad.to_file("writedir/metadata.txt")
     metad = MASTFile("files/metadata_neb")
     metad.to_file("%s/metadata.txt" % ingdir)
     peinit = MASTFile("files/parent_energy_labelinit")
     peinit.to_file("%s/parent_energy_labelinit" % ingdir)
     pefin = MASTFile("files/parent_energy_labelfin")
     pefin.to_file("%s/parent_energy_labelfin" % ingdir)
     psinit = MASTFile("files/parent_structure_labelinit")
     psinit.to_file("%s/parent_structure_labelinit" % ingdir)
     psfin = MASTFile("files/parent_structure_labelfin")
     psfin.to_file("%s/parent_structure_labelfin" % ingdir)
     kdict=dict()
     kdict['mast_kpoints']=[3,3,3,"G"]
     kdict['mast_xc']='pbe'
     kdict['mast_program']='vasp_neb'
     kdict['mast_coordinates']=list()
     kdict['mast_coordinates'].append('%s/files/POSCAR_coords_01' % testdir)
     kdict['mast_coordinates'].append('%s/files/POSCAR_coords_02' % testdir)
     kdict['mast_coordinates'].append('%s/files/POSCAR_coords_03' % testdir)
     neblines = list()
     neblines.append(["Cr","0.0 0.9 0.8","0.0 0.8 0.7"])
     neblines.append(["Cr","0.4 0.2 0.1","0.3 0.3 0.2"])
     neblines.append(["Cr","0.29 0.05 0.05","0.01 0.01 0.98"])
     neblines.append(["Ni","0.61 0.99 0.98","0.25 0.01 0.97"])
     kdict['mast_neb_settings']=dict()
     kdict['mast_neb_settings']['images']=3
     kdict['mast_neb_settings']['lines']=neblines
     my_structure=pymatgen.io.vaspio.Poscar.from_file("files/perfect_structure").structure
     mywi = ChopIngredient(name=ingdir,program_keys=kdict,structure=my_structure)
     mywi.write_neb()
     self.assertTrue(mywi.checker.is_ready_to_run())
     pos_compare_00 = MASTFile("files/POSCAR_grafted_00")
     pos_compare_01 = MASTFile("files/POSCAR_grafted_01")
     pos_compare_02 = MASTFile("files/POSCAR_grafted_02")
     pos_compare_03 = MASTFile("files/POSCAR_grafted_03")
     pos_compare_04 = MASTFile("files/POSCAR_grafted_04")
     mypos00 = MASTFile("writedir/neb_labelinit-labelfin/00/POSCAR")
     mypos01 = MASTFile("writedir/neb_labelinit-labelfin/01/POSCAR")
     mypos02 = MASTFile("writedir/neb_labelinit-labelfin/02/POSCAR")
     mypos03 = MASTFile("writedir/neb_labelinit-labelfin/03/POSCAR")
     mypos04 = MASTFile("writedir/neb_labelinit-labelfin/04/POSCAR")
     self.assertEqual(pos_compare_00.data, mypos00.data)
     self.assertEqual(pos_compare_01.data, mypos01.data)
     self.assertEqual(pos_compare_02.data, mypos02.data)
     self.assertEqual(pos_compare_03.data, mypos03.data)
     self.assertEqual(pos_compare_04.data, mypos04.data)
Exemplo n.º 21
0
 def test_write_singlerun(self):
     ingdir="writedir/single_label1"
     topmetad = MASTFile("files/top_metadata_single")
     topmetad.data.append("origin_dir = %s/files\n" % testdir) #give origin directory
     topmetad.to_file("writedir/metadata.txt")
     metad = MASTFile("files/metadata_single")
     metad.to_file("%s/metadata.txt" % ingdir)
     kdict=dict()
     kdict['mast_kpoints']=[3,3,3,"G"]
     kdict['mast_xc']='pbe'
     kdict['mast_program']='vasp'
     my_structure=pymatgen.io.vaspio.Poscar.from_file("files/perfect_structure").structure
     mywi = ChopIngredient(name=ingdir,program_keys=kdict,structure=my_structure)
     mywi.write_singlerun()
     self.assertTrue(mywi.checker.is_ready_to_run())
Exemplo n.º 22
0
 def test_give_structure(self):
     ingdir="%s/writedir/single_label1" % testdir
     recipedir="%s/writedir" % testdir
     topmetad = MASTFile("files/top_metadata_single")
     topmetad.data.append("origin_dir = %s/files\n" % testdir) #give origin directory
     topmetad.to_file("writedir/metadata.txt")
     metad = MASTFile("files/metadata_single")
     metad.to_file("%s/metadata.txt" % ingdir)
     kdict=dict()
     kdict['mast_program'] = 'vasp'
     my_structure = pymatgen.io.vaspio.Poscar.from_file("files/perfect_structure").structure
     myrelaxed = MASTFile("files/relaxed_structure")
     myrelaxed.to_file("%s/CONTCAR" % ingdir)
     myuci = ChopIngredient(name=ingdir,program_keys=kdict, structure=my_structure)
     myuci.give_structure("next_ingred")
     givenstr = MASTFile("%s/writedir/next_ingred/POSCAR" % testdir)
     self.assertEqual(myrelaxed.data, givenstr.data)
Exemplo n.º 23
0
 def test_get_parent_image_structures(self):
     kdict = dict()
     kdict['mast_program'] = 'vasp_neb'
     neblines = list()
     neblines.append(["Cr", "0.0 0.9 0.8", "0.0 0.8 0.7"])
     neblines.append(["Cr", "0.4 0.2 0.1", "0.3 0.3 0.2"])
     neblines.append(["Cr", "0.29 0.05 0.05", "0.01 0.01 0.98"])
     neblines.append(["Ni", "0.61 0.99 0.98", "0.25 0.01 0.97"])
     kdict['mast_neb_settings'] = dict()
     kdict['mast_neb_settings']['images'] = 3
     kdict['mast_neb_settings']['lines'] = neblines
     ingdir = "writedir/neb_labelinit-labelfin"
     topmetad = MASTFile("files/top_metadata_neb")
     topmetad.to_file("writedir/metadata.txt")
     metad = MASTFile("files/metadata_neb")
     metad.to_file("%s/metadata.txt" % ingdir)
     unsorted_01 = MASTFile(
         "unsorted/parent_structure_labelinit-labelfin_01")
     unsorted_01.to_file("%s/parent_structure_labelinit-labelfin_01" %
                         ingdir)
     unsorted_02 = MASTFile(
         "unsorted/parent_structure_labelinit-labelfin_02")
     unsorted_02.to_file("%s/parent_structure_labelinit-labelfin_02" %
                         ingdir)
     unsorted_03 = MASTFile(
         "unsorted/parent_structure_labelinit-labelfin_03")
     unsorted_03.to_file("%s/parent_structure_labelinit-labelfin_03" %
                         ingdir)
     my_structure = pymatgen.io.vaspio.Poscar.from_file(
         "files/perfect_structure").structure
     mywi = ChopIngredient(name=ingdir,
                           program_keys=kdict,
                           structure=my_structure)
     imstrs = mywi.get_parent_image_structures()
     compare_01 = pymatgen.io.vaspio.Poscar.from_file(
         "files/parent_structure_labelinit-labelfin_01").structure
     compare_02 = pymatgen.io.vaspio.Poscar.from_file(
         "files/parent_structure_labelinit-labelfin_02").structure
     compare_03 = pymatgen.io.vaspio.Poscar.from_file(
         "files/parent_structure_labelinit-labelfin_03").structure
     self.assertEqual(imstrs[0].sites, compare_01.sites)
     self.assertEqual(imstrs[0].lattice, compare_01.lattice)
     self.assertEqual(imstrs[1].sites, compare_02.sites)
     self.assertEqual(imstrs[1].lattice, compare_02.lattice)
     self.assertEqual(imstrs[2].sites, compare_03.sites)
     self.assertEqual(imstrs[2].lattice, compare_03.lattice)
Exemplo n.º 24
0
 def test__fullpath_childname(self):
     ingdir = "%s/writedir/single_label1" % testdir
     topmetad = MASTFile("files/top_metadata_single")
     topmetad.data.append("origin_dir = %s/files\n" %
                          testdir)  #give origin directory
     topmetad.to_file("writedir/metadata.txt")
     metad = MASTFile("files/metadata_single")
     metad.to_file("%s/metadata.txt" % ingdir)
     kdict = dict()
     kdict['mast_program'] = 'vasp'
     my_structure = pymatgen.io.vaspio.Poscar.from_file(
         "files/perfect_structure").structure
     myuci = ChopIngredient(name=ingdir,
                            program_keys=kdict,
                            structure=my_structure)
     fullpath = myuci._fullpath_childname("next_ingred")
     self.assertEqual(fullpath, "%s/writedir/next_ingred" % testdir)
Exemplo n.º 25
0
 def test_ready_structure(self):
     ingdir="%s/writedir/single_label1" % testdir
     recipedir="%s/writedir" % testdir
     topmetad = MASTFile("files/top_metadata_single")
     topmetad.data.append("origin_dir = %s/files\n" % testdir) #give origin directory
     topmetad.to_file("writedir/metadata.txt")
     metad = MASTFile("files/metadata_single")
     metad.to_file("%s/metadata.txt" % ingdir)
     kdict=dict()
     kdict['mast_program'] = 'vasp'
     kdict['mast_kpoints'] = [2,2,2,"M"]
     kdict['mast_xc'] = 'pw91'
     my_pos = pymatgen.io.vaspio.Poscar.from_file("files/perfect_structure")
     my_pos.write_file("writedir/single_label1/POSCAR")
     myrdi = ChopIngredient(name=ingdir,program_keys=kdict, structure=my_pos.structure)
     self.assertTrue(myrdi.ready_structure())
     os.remove("%s/POSCAR" % ingdir)
     self.assertFalse(myrdi.ready_structure())
Exemplo n.º 26
0
 def test_write_singlerun(self):
     ingdir = "writedir/single_label1"
     topmetad = MASTFile("files/top_metadata_single")
     topmetad.data.append("origin_dir = %s/files\n" %
                          testdir)  #give origin directory
     topmetad.to_file("writedir/metadata.txt")
     metad = MASTFile("files/metadata_single")
     metad.to_file("%s/metadata.txt" % ingdir)
     kdict = dict()
     kdict['mast_kpoints'] = [3, 3, 3, "G"]
     kdict['mast_xc'] = 'pbe'
     kdict['mast_program'] = 'vasp'
     my_structure = pymatgen.io.vaspio.Poscar.from_file(
         "files/perfect_structure").structure
     mywi = ChopIngredient(name=ingdir,
                           program_keys=kdict,
                           structure=my_structure)
     mywi.write_singlerun()
     self.assertTrue(mywi.checker.is_ready_to_run())
Exemplo n.º 27
0
 def test_write_singlerun_automesh(self):
     ingdir="writedir/single_label1"
     topmetad = MASTFile("files/top_metadata_single")
     topmetad.data.append("origin_dir = %s/files\n" % testdir) #give origin directory
     topmetad.to_file("writedir/metadata.txt")
     metad = MASTFile("files/metadata_single")
     metad.to_file("%s/metadata.txt" % ingdir)
     kdict=dict()
     kdict['mast_kpoints']=[3,3,3,"G"]
     kdict['mast_xc']='pbe'
     kdict['mast_program']='vasp'
     kdict['mast_kpoint_density']='1000'
     mypos=pymatgen.io.vaspio.Poscar.from_file("files/perfect_structure")
     mypos.write_file("writedir/single_label1/POSCAR")
     mywi = ChopIngredient(name=ingdir,program_keys=kdict,structure=mypos.structure)
     mywi.write_singlerun_automesh()
     mykpts = pymatgen.io.vaspio.Kpoints.from_file("writedir/single_label1/KPOINTS")
     self.assertEqual(mykpts.to_dict['kpoints'][0],[8,8,8])
     #print mykpts
     self.assertTrue(mywi.checker.is_ready_to_run())
Exemplo n.º 28
0
 def test_run_strain(self):
     #raise SkipTest
     ingdir="%s/writedir/single_label1" % testdir
     recipedir="%s/writedir" % testdir
     topmetad = MASTFile("files/top_metadata_single")
     topmetad.data.append("origin_dir = %s/files\n" % testdir) #give origin directory
     topmetad.to_file("writedir/metadata.txt")
     metad = MASTFile("files/metadata_single")
     metad.to_file("%s/metadata.txt" % ingdir)
     kdict=dict()
     kdict['mast_program'] = 'vasp'
     kdict['mast_strain']=" 0.98 0.92 1.03 \n"
     my_structure = Poscar.from_file("files/POSCAR_perfect").structure
     myunstrained = MASTFile("files/POSCAR_unstrained")
     myunstrained.to_file("%s/POSCAR" % ingdir)
     myri = ChopIngredient(name=ingdir,program_keys=kdict, structure=my_structure)
     myri.run_strain()
     my_strained = Poscar.from_file("%s/CONTCAR" % ingdir).structure
     strained_compare = Poscar.from_file("files/POSCAR_strained").structure
     self.assertEquals(my_strained, strained_compare)
     self.assertFalse(os.path.isfile("%s/submitlist" % self.test_control))
Exemplo n.º 29
0
 def test_run_scale(self):
     #raise SkipTest
     ingdir="%s/writedir/single_label1" % testdir
     recipedir="%s/writedir" % testdir
     topmetad = MASTFile("files/top_metadata_single")
     topmetad.data.append("origin_dir = %s/files\n" % testdir) #give origin directory
     topmetad.to_file("writedir/metadata.txt")
     metad = MASTFile("files/metadata_single")
     metad.data.append("defect_label = label1\n")
     metad.data.append("scaling_size = [2,2,2]\n")
     metad.to_file("%s/metadata.txt" % ingdir)
     kdict=dict()
     kdict['mast_program'] = 'vasp'
     my_structure = Poscar.from_file("files/POSCAR_perfect").structure
     myperf = MASTFile("files/POSCAR_perfect")
     myperf.to_file("%s/POSCAR" % ingdir)
     myri = ChopIngredient(name=ingdir,program_keys=kdict, structure=my_structure)
     myri.run_scale()
     my_scaled = Poscar.from_file("%s/CONTCAR" % ingdir).structure.get_sorted_structure()
     scaled_compare = Poscar.from_file("files/POSCAR_scaled").structure.get_sorted_structure()
     self.assertEquals(my_scaled, scaled_compare)
Exemplo n.º 30
0
 def test_ready_structure(self):
     ingdir = "%s/writedir/single_label1" % testdir
     recipedir = "%s/writedir" % testdir
     topmetad = MASTFile("files/top_metadata_single")
     topmetad.data.append("origin_dir = %s/files\n" %
                          testdir)  #give origin directory
     topmetad.to_file("writedir/metadata.txt")
     metad = MASTFile("files/metadata_single")
     metad.to_file("%s/metadata.txt" % ingdir)
     kdict = dict()
     kdict['mast_program'] = 'vasp'
     kdict['mast_kpoints'] = [2, 2, 2, "M"]
     kdict['mast_xc'] = 'pw91'
     my_pos = pymatgen.io.vaspio.Poscar.from_file("files/perfect_structure")
     my_pos.write_file("writedir/single_label1/POSCAR")
     myrdi = ChopIngredient(name=ingdir,
                            program_keys=kdict,
                            structure=my_pos.structure)
     self.assertTrue(myrdi.ready_structure())
     os.remove("%s/POSCAR" % ingdir)
     self.assertFalse(myrdi.ready_structure())
Exemplo n.º 31
0
 def test_get_my_phonon_params(self):
     ingdir="writedir/single_phonon_label1"
     topmetad = MASTFile("files/top_metadata_single_phonon")
     topmetad.data.append("origin_dir = %s/files\n" % testdir) #give origin directory
     topmetad.to_file("writedir/metadata.txt")
     metad = MASTFile("files/metadata_single_phonon")
     metad.to_file("%s/metadata.txt" % ingdir)
     kdict=dict()
     kdict['mast_kpoints']=[3,3,3,"G"]
     kdict['mast_xc']='pbe'
     kdict['mast_program']='vasp'
     kdict['mast_phonon_settings']=dict()
     kdict['mast_phonon_settings']['phonon_center_site']="0.33 0.25 0.0"
     kdict['mast_phonon_settings']['phonon_center_radius']="1"
     kdict['mast_phonon_settings']['threshold']="0.075"
     my_structure=pymatgen.io.vaspio.Poscar.from_file("files/perfect_structure").structure
     mywi = ChopIngredient(name=ingdir,program_keys=kdict,structure=my_structure)
     [mysite, myrad, mythresh] = mywi.get_my_phonon_params()
     self.assertEqual(mysite,"0.33 0.25 0.0")
     self.assertEqual(myrad,"1")
     self.assertEqual(mythresh,"0.075")
Exemplo n.º 32
0
 def test_run_subfolders(self):
     #raise SkipTest
     ingdir="%s/writedir/single_label1" % testdir
     recipedir="%s/writedir" % testdir
     topmetad = MASTFile("files/top_metadata_single")
     topmetad.data.append("origin_dir = %s/files\n" % testdir) #give origin directory
     topmetad.to_file("writedir/metadata.txt")
     metad = MASTFile("files/metadata_single")
     metad.to_file("%s/metadata.txt" % ingdir)
     kdict=dict()
     kdict['mast_program'] = 'vasp'
     kdict['mast_kpoints'] = [2,2,2,"M"]
     kdict['mast_xc'] = 'pw91'
     my_structure = Poscar.from_file("files/perfect_structure").structure
     for subfolder in ['sub1','sub2','sub3','sub4']:
         subname = "%s/%s" % (ingdir, subfolder)
         os.mkdir(subname)
         shutil.copy("files/metadata_single","%s/metadata.txt" % subname)
         mywr = ChopIngredient(name=subname, program_keys = kdict, structure=my_structure)
         mywr.write_singlerun()
     myri = ChopIngredient(name=ingdir,program_keys=kdict, structure=my_structure)
     myri.run_subfolders()
     self.assertFalse(myri.checker.is_ready_to_run())
     for subfolder in ['sub1','sub2','sub3','sub4']:
         subname = "%s/%s" % (ingdir, subfolder)
         myri.checker.keywords['name'] = subname
         self.assertTrue(myri.checker.is_ready_to_run())
     mysubmit = MASTFile("%s/submitlist" % self.test_control)
     self.assertEquals(mysubmit.data[0], "%s/sub1\n" % ingdir)
     self.assertEquals(mysubmit.data[1], "%s/sub2\n" % ingdir)
     self.assertEquals(mysubmit.data[2], "%s/sub3\n" % ingdir)
     self.assertEquals(mysubmit.data[3], "%s/sub4\n" % ingdir)
Exemplo n.º 33
0
 def test_give_saddle_structure(self):
     ingdir = "%s/writedir/neb_labelinit-labelfin" % testdir
     recipedir = "%s/writedir" % testdir
     topmetad = MASTFile("files/top_metadata_neb")
     topmetad.data.append("origin_dir = %s/files\n" %
                          testdir)  #give origin directory
     topmetad.to_file("writedir/metadata.txt")
     metad = MASTFile("files/metadata_neb")
     metad.to_file("%s/metadata.txt" % ingdir)
     kdict = dict()
     kdict['mast_program'] = 'vasp_neb'
     kdict['images'] = 3
     my_structure = pymatgen.io.vaspio.Poscar.from_file(
         "files/perfect_structure").structure
     myrelaxed = dict()
     myosz = dict()
     mywav = dict()
     mychg = dict()
     for subdir in ['00', '01', '02', '03', '04']:
         os.mkdir("writedir/neb_labelinit-labelfin/%s" % subdir)
         myrelaxed[subdir] = MASTFile("files/POSCAR_%s" % subdir)
         myrelaxed[subdir].to_file(
             "writedir/neb_labelinit-labelfin/%s/CONTCAR" % subdir)
         myosz[subdir] = MASTFile("files/OSZICAR_%s" % subdir)
         myosz[subdir].to_file(
             "writedir/neb_labelinit-labelfin/%s/OSZICAR" % subdir)
         mychg[subdir] = MASTFile("files/CHGCAR")
         mychg[subdir].to_file("writedir/neb_labelinit-labelfin/%s/CHGCAR" %
                               subdir)
         mywav[subdir] = MASTFile("files/WAVECAR")
         mywav[subdir].to_file(
             "writedir/neb_labelinit-labelfin/%s/WAVECAR" % subdir)
     myuci = ChopIngredient(name=ingdir,
                            program_keys=kdict,
                            structure=my_structure)
     myuci.give_saddle_structure("next_ingred")  #should be OSZ3
     saddle = MASTFile("%s/writedir/next_ingred/POSCAR" % testdir)
     self.assertEqual(myrelaxed['03'].data, saddle.data)
     saddledir = myuci.get_saddle_dir()
     self.assertEqual(saddledir, "03")
Exemplo n.º 34
0
 def test_write_phonon_single(self):
     ingdir="writedir/single_phonon_label1"
     topmetad = MASTFile("files/top_metadata_single_phonon")
     topmetad.data.append("origin_dir = %s/files\n" % testdir) #give origin directory
     topmetad.to_file("writedir/metadata.txt")
     metad = MASTFile("files/metadata_single_phonon")
     metad.to_file("%s/metadata.txt" % ingdir)
     kdict=dict()
     kdict['mast_kpoints']=[3,3,3,"G"]
     kdict['mast_xc']='pbe'
     kdict['mast_program']='vasp'
     kdict['mast_phonon_settings']=dict()
     kdict['mast_phonon_settings']['phonon_center_site']="0.33 0.25 0.0"
     kdict['mast_phonon_settings']['phonon_center_radius']="1"
     kdict['mast_phonon_settings']['threshold']="0.075"
     my_structure=pymatgen.io.vaspio.Poscar.from_file("files/perfect_structure").structure
     mywi = ChopIngredient(name=ingdir,program_keys=kdict,structure=my_structure)
     mywi.write_phonon_single()
     self.assertTrue(mywi.checker.is_ready_to_run())
     compare_phon_single = MASTFile("files/phon_single_POSCAR")
     phon_singlepos = MASTFile("%s/POSCAR" % ingdir)
     self.assertEqual(phon_singlepos.data, compare_phon_single.data)
Exemplo n.º 35
0
 def test_get_parent_structures(self):
     kdict = dict()
     kdict['mast_program'] = 'vasp_neb'
     neblines = list()
     neblines.append(["Cr", "0.0 0.9 0.8", "0.0 0.8 0.7"])
     neblines.append(["Cr", "0.4 0.2 0.1", "0.3 0.3 0.2"])
     neblines.append(["Cr", "0.29 0.05 0.05", "0.01 0.01 0.98"])
     neblines.append(["Ni", "0.61 0.99 0.98", "0.25 0.01 0.97"])
     kdict['mast_neb_settings'] = dict()
     kdict['mast_neb_settings']['images'] = 3
     kdict['mast_neb_settings']['lines'] = neblines
     ingdir = "writedir/neb_labelinit-labelfin"
     topmetad = MASTFile("files/top_metadata_neb")
     topmetad.to_file("writedir/metadata.txt")
     metad = MASTFile("files/metadata_neb")
     metad.to_file("%s/metadata.txt" % ingdir)
     unsorted_init = MASTFile("unsorted/parent_structure_labelinit")
     #unsorted_init = MASTFile("unsorted/parent_structure_labelinit_scrambled")
     unsorted_init.to_file("%s/parent_structure_labelinit" % ingdir)
     unsorted_fin = MASTFile("unsorted/parent_structure_labelfin")
     unsorted_fin.to_file("%s/parent_structure_labelfin" % ingdir)
     my_structure = pymatgen.io.vaspio.Poscar.from_file(
         "files/perfect_structure").structure
     mywi = ChopIngredient(name=ingdir,
                           program_keys=kdict,
                           structure=my_structure)
     [sinit, sfin] = mywi.get_parent_structures()
     init_compare = pymatgen.io.vaspio.Poscar.from_file(
         "files/parent_structure_labelinit").structure
     fin_compare = pymatgen.io.vaspio.Poscar.from_file(
         "files/parent_structure_labelfin").structure
     #print sinit
     #print init_compare
     #print sfin
     #print fin_compare
     self.assertEqual(sinit.sites, init_compare.sites)
     self.assertEqual(sinit.lattice, init_compare.lattice)
     self.assertEqual(sfin.sites, fin_compare.sites)
     self.assertEqual(sfin.lattice, fin_compare.lattice)
Exemplo n.º 36
0
 def test_give_neb_structures_to_neb(self):
     ingdir="%s/writedir/neb_labelinit-labelfin" % testdir
     recipedir="%s/writedir" % testdir
     topmetad = MASTFile("files/top_metadata_neb")
     topmetad.data.append("origin_dir = %s/files\n" % testdir) #give origin directory
     topmetad.to_file("writedir/metadata.txt")
     metad = MASTFile("files/metadata_neb")
     metad.to_file("%s/metadata.txt" % ingdir)
     kdict=dict()
     kdict['mast_program'] = 'vasp_neb'
     kdict['mast_neb_settings']=dict()
     kdict['mast_neb_settings']['images'] = 3
     my_structure = pymatgen.io.vaspio.Poscar.from_file("files/perfect_structure").structure
     myrelaxed=dict()
     for subdir in ['00','01','02','03','04']:
         os.mkdir("writedir/neb_labelinit-labelfin/%s" % subdir)
         myrelaxed[subdir] = MASTFile("files/POSCAR_%s" % subdir)
         myrelaxed[subdir].to_file("writedir/neb_labelinit-labelfin/%s/CONTCAR" % subdir)
     myuci = ChopIngredient(name=ingdir,program_keys=kdict, structure=my_structure)
     myuci.give_neb_structures_to_neb("next_ingred")
     for subdir in ['01','02','03']:
         givenstr = MASTFile("%s/writedir/next_ingred/parent_structure_labelinit-labelfin_%s" % (testdir,subdir))
         self.assertEqual(myrelaxed[subdir].data, givenstr.data)
Exemplo n.º 37
0
 def test_run_strain(self):
     #raise SkipTest
     ingdir = "%s/writedir/single_label1" % testdir
     recipedir = "%s/writedir" % testdir
     topmetad = MASTFile("files/top_metadata_single")
     topmetad.data.append("origin_dir = %s/files\n" %
                          testdir)  #give origin directory
     topmetad.to_file("writedir/metadata.txt")
     metad = MASTFile("files/metadata_single")
     metad.to_file("%s/metadata.txt" % ingdir)
     kdict = dict()
     kdict['mast_program'] = 'vasp'
     kdict['mast_strain'] = " 0.98 0.92 1.03 \n"
     my_structure = Poscar.from_file("files/POSCAR_perfect").structure
     myunstrained = MASTFile("files/POSCAR_unstrained")
     myunstrained.to_file("%s/POSCAR" % ingdir)
     myri = ChopIngredient(name=ingdir,
                           program_keys=kdict,
                           structure=my_structure)
     myri.run_strain()
     my_strained = Poscar.from_file("%s/CONTCAR" % ingdir).structure
     strained_compare = Poscar.from_file("files/POSCAR_strained").structure
     self.assertEquals(my_strained, strained_compare)
     self.assertFalse(os.path.isfile("%s/submitlist" % self.test_control))
Exemplo n.º 38
0
 def test_write_singlerun_automesh(self):
     ingdir = "writedir/single_label1"
     topmetad = MASTFile("files/top_metadata_single")
     topmetad.data.append("origin_dir = %s/files\n" %
                          testdir)  #give origin directory
     topmetad.to_file("writedir/metadata.txt")
     metad = MASTFile("files/metadata_single")
     metad.to_file("%s/metadata.txt" % ingdir)
     kdict = dict()
     kdict['mast_kpoints'] = [3, 3, 3, "G"]
     kdict['mast_xc'] = 'pbe'
     kdict['mast_program'] = 'vasp'
     kdict['mast_kpoint_density'] = '1000'
     mypos = pymatgen.io.vaspio.Poscar.from_file("files/perfect_structure")
     mypos.write_file("writedir/single_label1/POSCAR")
     mywi = ChopIngredient(name=ingdir,
                           program_keys=kdict,
                           structure=mypos.structure)
     mywi.write_singlerun_automesh()
     mykpts = pymatgen.io.vaspio.Kpoints.from_file(
         "writedir/single_label1/KPOINTS")
     self.assertEqual(mykpts.as_dict()['kpoints'][0], [6, 6, 6])
     #print mykpts
     self.assertTrue(mywi.checker.is_ready_to_run())
Exemplo n.º 39
0
 def test_run_neb_subfolders(self):
     #raise SkipTest
     ingdir="%s/writedir/neb_labelinit-labelfin_stat" % testdir
     recipedir="%s/writedir" % testdir
     topmetad = MASTFile("files/top_metadata_neb")
     topmetad.data.append("origin_dir = %s/files\n" % testdir) #give origin directory
     topmetad.to_file("writedir/metadata.txt")
     metad = MASTFile("files/metadata_neb")
     metad.to_file("%s/metadata.txt" % ingdir)
     kdict=dict()
     kdict['mast_program'] = 'vasp'
     kdict['mast_kpoints'] = [2,2,2,"M"]
     kdict['mast_xc'] = 'pw91'
     neblines = list()
     neblines.append(["Cr","0.0 0.9 0.8","0.0 0.8 0.7"])
     neblines.append(["Cr","0.4 0.2 0.1","0.3 0.3 0.2"])
     neblines.append(["Cr","0.29 0.05 0.05","0.01 0.01 0.98"])
     neblines.append(["Ni","0.61 0.99 0.98","0.25 0.01 0.97"])
     kdict['mast_neb_settings']=dict()
     kdict['mast_neb_settings']['lines']=neblines
     kdict['mast_neb_settings']['images']=3
     str_00 = MASTFile("files/POSCAR_00")
     str_00.to_file("%s/parent_structure_labelinit" % ingdir) 
     str_04 = MASTFile("files/POSCAR_04")
     str_04.to_file("%s/parent_structure_labelfin" % ingdir) 
     str_01 = MASTFile("files/POSCAR_01")
     str_01.to_file("%s/parent_structure_labelinit-labelfin_01" % ingdir) 
     str_02 = MASTFile("files/POSCAR_02")
     str_02.to_file("%s/parent_structure_labelinit-labelfin_02" % ingdir) 
     str_03 = MASTFile("files/POSCAR_03")
     str_03.to_file("%s/parent_structure_labelinit-labelfin_03" % ingdir) 
     en_00 = MASTFile("files/OSZICAR_00")
     en_00.to_file("%s/parent_energy_labelinit" % ingdir) 
     en_04 = MASTFile("files/OSZICAR_04")
     en_04.to_file("%s/parent_energy_labelfin" % ingdir) 
     my_structure = Poscar.from_file("files/perfect_structure").structure
     mywr = ChopIngredient(name=ingdir, program_keys = kdict, structure=my_structure)
     mywr.write_neb_subfolders()
     myri = ChopIngredient(name=ingdir,program_keys=kdict, structure=my_structure)
     myri.run_neb_subfolders()
     mysubmit = MASTFile("%s/submitlist" % self.test_control)
     myri.checker.keywords['name'] = "%s/00" % ingdir
     self.assertFalse(myri.checker.is_ready_to_run()) #do not run endpoints again
     myri.checker.keywords['name'] = "%s/01" % ingdir
     self.assertTrue(myri.checker.is_ready_to_run())
     myri.checker.keywords['name'] = "%s/02" % ingdir
     self.assertTrue(myri.checker.is_ready_to_run())
     myri.checker.keywords['name'] = "%s/03" % ingdir
     self.assertTrue(myri.checker.is_ready_to_run())
     myri.checker.keywords['name'] = "%s/04" % ingdir
     self.assertFalse(myri.checker.is_ready_to_run()) #do not run endpoints again
     self.assertEquals(mysubmit.data[0], "%s/01\n" % ingdir)
     self.assertEquals(mysubmit.data[1], "%s/02\n" % ingdir)
     self.assertEquals(mysubmit.data[2], "%s/03\n" % ingdir)
Exemplo n.º 40
0
 def test_run_subfolders(self):
     #raise SkipTest
     ingdir = "%s/writedir/single_label1" % testdir
     recipedir = "%s/writedir" % testdir
     topmetad = MASTFile("files/top_metadata_single")
     topmetad.data.append("origin_dir = %s/files\n" %
                          testdir)  #give origin directory
     topmetad.to_file("writedir/metadata.txt")
     metad = MASTFile("files/metadata_single")
     metad.to_file("%s/metadata.txt" % ingdir)
     kdict = dict()
     kdict['mast_program'] = 'vasp'
     kdict['mast_kpoints'] = [2, 2, 2, "M"]
     kdict['mast_xc'] = 'pw91'
     my_structure = Poscar.from_file("files/perfect_structure").structure
     for subfolder in ['sub1', 'sub2', 'sub3', 'sub4']:
         subname = "%s/%s" % (ingdir, subfolder)
         os.mkdir(subname)
         shutil.copy("files/metadata_single", "%s/metadata.txt" % subname)
         mywr = ChopIngredient(name=subname,
                               program_keys=kdict,
                               structure=my_structure)
         mywr.write_singlerun()
     myri = ChopIngredient(name=ingdir,
                           program_keys=kdict,
                           structure=my_structure)
     myri.run_subfolders()
     self.assertFalse(myri.checker.is_ready_to_run())
     for subfolder in ['sub1', 'sub2', 'sub3', 'sub4']:
         subname = "%s/%s" % (ingdir, subfolder)
         myri.checker.keywords['name'] = subname
         self.assertTrue(myri.checker.is_ready_to_run())
     mysubmit = MASTFile("%s/submitlist" % self.test_control)
     self.assertEquals(mysubmit.data[0], "%s/sub1\n" % ingdir)
     self.assertEquals(mysubmit.data[1], "%s/sub2\n" % ingdir)
     self.assertEquals(mysubmit.data[2], "%s/sub3\n" % ingdir)
     self.assertEquals(mysubmit.data[3], "%s/sub4\n" % ingdir)
Exemplo n.º 41
0
 def test_run_singlerun(self):
     #raise SkipTest
     ingdir="%s/writedir/single_label1" % testdir
     recipedir="%s/writedir" % testdir
     topmetad = MASTFile("files/top_metadata_single")
     topmetad.data.append("origin_dir = %s/files\n" % testdir) #give origin directory
     topmetad.to_file("writedir/metadata.txt")
     metad = MASTFile("files/metadata_single")
     metad.to_file("%s/metadata.txt" % ingdir)
     kdict=dict()
     kdict['mast_program'] = 'vasp'
     kdict['mast_kpoints'] = [2,2,2,"M"]
     kdict['mast_xc'] = 'pw91'
     my_structure = Poscar.from_file("files/perfect_structure").structure
     mywr = ChopIngredient(name=ingdir, program_keys = kdict, structure=my_structure)
     mywr.write_singlerun()
     myri = ChopIngredient(name=ingdir,program_keys=kdict, structure=my_structure)
     myri.run_singlerun()
     self.assertTrue(myri.checker.is_ready_to_run())
     mysubmit = MASTFile("%s/submitlist" % self.test_control)
     self.assertEquals(mysubmit.data[0], "%s\n" % ingdir)
Exemplo n.º 42
0
 def test_complete_singlerun(self):
     #raise SkipTest
     ingdir="%s/writedir/single_label1" % testdir
     recipedir="%s/writedir" % testdir
     topmetad = MASTFile("files/top_metadata_single")
     topmetad.data.append("origin_dir = %s/files\n" % testdir) #give origin directory
     topmetad.to_file("writedir/metadata.txt")
     metad = MASTFile("files/metadata_single")
     metad.to_file("%s/metadata.txt" % ingdir)
     kdict=dict()
     kdict['mast_program'] = 'vasp'
     kdict['mast_kpoints'] = [2,2,2,"M"]
     kdict['mast_xc'] = 'pw91'
     my_structure = pymatgen.io.vaspio.Poscar.from_file("files/perfect_structure").structure
     mywr = ChopIngredient(name=ingdir, program_keys = kdict, structure=my_structure)
     mywr.write_singlerun()
     myoutcar = MASTFile("files/OUTCAR_completed")
     myoutcar.to_file("%s/OUTCAR" % ingdir)
     myoszicar = MASTFile("files/OSZICAR_completed")
     myoszicar.to_file("%s/OSZICAR" % ingdir)
     myrdi = ChopIngredient(name=ingdir,program_keys=kdict, structure=my_structure)
     self.assertTrue(myrdi.complete_singlerun())
     os.remove("%s/OUTCAR" % ingdir)
     self.assertFalse(myrdi.complete_singlerun())
Exemplo n.º 43
0
 def test_run_scale_defect(self):
     #raise SkipTest
     ingdir = "%s/writedir/single_label1" % testdir
     recipedir = "%s/writedir" % testdir
     topmetad = MASTFile("files/top_metadata_single")
     topmetad.data.append("origin_dir = %s/files\n" %
                          testdir)  #give origin directory
     topmetad.to_file("writedir/metadata.txt")
     metad = MASTFile("files/metadata_single")
     metad.data.append("defect_label = label1\n")
     metad.data.append("scaling_size = [2,2,2]\n")
     metad.to_file("%s/metadata.txt" % ingdir)
     kdict = dict()
     kdict['label1'] = dict()
     kdict['label1']['subdefect1'] = dict()
     kdict['label1']['subdefect1']['symbol'] = 'Cr'
     kdict['label1']['subdefect1']['type'] = 'interstitial'
     kdict['label1']['subdefect1']['coordinates'] = np.array(
         [0.8, 0.7, 0.6])
     kdict['label1']['subdefect2'] = dict()
     kdict['label1']['subdefect2']['symbol'] = 'Sr'
     kdict['label1']['subdefect2']['type'] = 'antisite'
     kdict['label1']['subdefect2']['coordinates'] = np.array(
         [0.5, 0.5, 0.0])
     kdict['label1']['subdefect3'] = dict()
     kdict['label1']['subdefect3']['symbol'] = 'Cr'
     kdict['label1']['subdefect3']['type'] = 'interstitial'
     kdict['label1']['subdefect3']['coordinates'] = np.array(
         [0.3, 0.3, 0.2])
     kdict['label1']['subdefect4'] = dict()
     kdict['label1']['subdefect4']['symbol'] = 'Fe'
     kdict['label1']['subdefect4']['type'] = 'substitution'
     kdict['label1']['subdefect4']['coordinates'] = np.array(
         [0.25, 0.75, 0.75])
     kdict['label1']['subdefect5'] = dict()
     kdict['label1']['subdefect5']['symbol'] = 'O'
     kdict['label1']['subdefect5']['type'] = 'vacancy'
     kdict['label1']['subdefect5']['coordinates'] = np.array(
         [0.5, 0.25, 0.75])
     kdict['label1']['subdefect6'] = dict()
     kdict['label1']['subdefect6']['symbol'] = 'Fe'
     kdict['label1']['subdefect6']['type'] = 'substitution'
     kdict['label1']['subdefect6']['coordinates'] = np.array(
         [0.25, 0.25, 0.25])
     kdict['label1']['subdefect7'] = dict()
     kdict['label1']['subdefect7']['symbol'] = 'La'
     kdict['label1']['subdefect7']['type'] = 'vacancy'
     kdict['label1']['subdefect7']['coordinates'] = np.array([0, 0, 0.5])
     kdict['label1']['subdefect8'] = dict()
     kdict['label1']['subdefect8']['symbol'] = 'Ni'
     kdict['label1']['subdefect8']['type'] = 'interstitial'
     kdict['label1']['subdefect8']['coordinates'] = np.array(
         [0.4, 0.1, 0.3])
     kdict['label1']['coord_type'] = 'fractional'
     kdict['label1']['threshold'] = 0.01
     kdict['label1']['charge'] = '2'
     mdict = dict()
     mdict['mast_program'] = 'vasp'
     mdict['mast_defect_settings'] = dict()
     mdict['mast_defect_settings'].update(kdict['label1'])
     my_structure = Poscar.from_file("files/POSCAR_perfect").structure
     myperf = MASTFile("files/POSCAR_perfect")
     myperf.to_file("%s/POSCAR" % ingdir)
     myri = ChopIngredient(name=ingdir,
                           program_keys=mdict,
                           structure=my_structure)
     myri.run_scale()
     #copy contcar to poscar
     os.rename("%s/CONTCAR" % ingdir, "%s/POSCAR" % ingdir)
     myri.run_defect()
     my_defected = Poscar.from_file(
         "%s/CONTCAR" % ingdir).structure.get_sorted_structure()
     defected_compare = Poscar.from_file(
         "files/POSCAR_scaled_defected").structure.get_sorted_structure()
     self.assertEquals(my_defected, defected_compare)
Exemplo n.º 44
0
 def test_write_neb_subfolders(self):
     ingdir = "writedir/neb_labelinit-labelfin"
     topmetad = MASTFile("files/top_metadata_neb")
     topmetad.data.append("origin_dir = %s/files\n" %
                          testdir)  #give origin directory
     topmetad.to_file("writedir/metadata.txt")
     metad = MASTFile("files/metadata_neb")
     metad.to_file("%s/metadata.txt" % ingdir)
     parent_01 = MASTFile(
         "statfiles/parent_structure_labelinit-labelfin_01")
     parent_01.to_file(ingdir + "/parent_structure_labelinit-labelfin_01")
     parent_02 = MASTFile(
         "statfiles/parent_structure_labelinit-labelfin_02")
     parent_02.to_file(ingdir + "/parent_structure_labelinit-labelfin_02")
     parent_03 = MASTFile(
         "statfiles/parent_structure_labelinit-labelfin_03")
     parent_03.to_file(ingdir + "/parent_structure_labelinit-labelfin_03")
     parent_init = MASTFile("statfiles/parent_structure_labelinit")
     parent_init.to_file(ingdir + "/parent_structure_labelinit")
     parent_fin = MASTFile("statfiles/parent_structure_labelfin")
     parent_fin.to_file(ingdir + "/parent_structure_labelfin")
     peinit = MASTFile("statfiles/parent_energy_labelinit")
     peinit.to_file("%s/parent_energy_labelinit" % ingdir)
     pefin = MASTFile("statfiles/parent_energy_labelfin")
     pefin.to_file("%s/parent_energy_labelfin" % ingdir)
     kdict = dict()
     kdict['mast_kpoints'] = [3, 3, 3, "G"]
     kdict['mast_xc'] = 'pbe'
     kdict['mast_program'] = 'vasp'
     neblines = list()
     neblines.append(["Cr", "0.0 0.9 0.8", "0.0 0.8 0.7"])
     neblines.append(["Cr", "0.4 0.2 0.1", "0.3 0.3 0.2"])
     neblines.append(["Cr", "0.29 0.05 0.05", "0.01 0.01 0.98"])
     neblines.append(["Ni", "0.61 0.99 0.98", "0.25 0.01 0.97"])
     kdict['mast_neb_settings'] = dict()
     kdict['mast_neb_settings']['images'] = 3
     kdict['mast_neb_settings']['lines'] = neblines
     my_structure = pymatgen.io.vaspio.Poscar.from_file(
         "files/perfect_structure").structure
     mywi = ChopIngredient(name=ingdir,
                           program_keys=kdict,
                           structure=my_structure)
     mywi.write_neb_subfolders()
     self.assertFalse(os.path.isfile("%s/00/submit.sh" % ingdir))
     self.assertTrue(os.path.isfile("%s/01/submit.sh" % ingdir))
     self.assertTrue(os.path.isfile("%s/02/submit.sh" % ingdir))
     self.assertTrue(os.path.isfile("%s/03/submit.sh" % ingdir))
     self.assertFalse(os.path.isfile("%s/04/submit.sh" % ingdir))
     oszinit = MASTFile("%s/00/OSZICAR" % ingdir)
     oszfin = MASTFile("%s/04/OSZICAR" % ingdir)
     pos00 = MASTFile("%s/00/POSCAR" % ingdir)
     pos01 = MASTFile("%s/01/POSCAR" % ingdir)
     pos02 = MASTFile("%s/02/POSCAR" % ingdir)
     pos03 = MASTFile("%s/03/POSCAR" % ingdir)
     pos04 = MASTFile("%s/04/POSCAR" % ingdir)
     self.assertEqual(oszinit.data, peinit.data)
     self.assertEqual(oszfin.data, pefin.data)
     self.assertEqual(pos01.data, parent_01.data)
     self.assertEqual(pos02.data, parent_02.data)
     self.assertEqual(pos03.data, parent_03.data)
     self.assertEqual(pos00.data, parent_init.data)
     self.assertEqual(pos04.data, parent_fin.data)
Exemplo n.º 45
0
 def test_run_defect(self):
     #raise SkipTest
     ingdir = "%s/writedir/single_label1" % testdir
     recipedir = "%s/writedir" % testdir
     topmetad = MASTFile("files/top_metadata_single")
     topmetad.data.append("origin_dir = %s/files\n" %
                          testdir)  #give origin directory
     topmetad.to_file("writedir/metadata.txt")
     metad = MASTFile("files/metadata_single")
     metad.data.append("defect_label = label1\n")
     metad.data.append("scaling_size = [1,1,1]\n")
     metad.to_file("%s/metadata.txt" % ingdir)
     kdict = dict()
     kdict['label1'] = dict()
     kdict['label1']['subdefect1'] = dict()
     kdict['label1']['subdefect1']['symbol'] = 'Cr'
     kdict['label1']['subdefect1']['type'] = 'interstitial'
     kdict['label1']['subdefect1']['coordinates'] = np.array(
         [0.8, 0.7, 0.6])
     kdict['label1']['subdefect2'] = dict()
     kdict['label1']['subdefect2']['symbol'] = 'Sr'
     kdict['label1']['subdefect2']['type'] = 'antisite'
     kdict['label1']['subdefect2']['coordinates'] = np.array(
         [0.5, 0.5, 0.0])
     kdict['label1']['subdefect3'] = dict()
     kdict['label1']['subdefect3']['symbol'] = 'Cr'
     kdict['label1']['subdefect3']['type'] = 'interstitial'
     kdict['label1']['subdefect3']['coordinates'] = np.array(
         [0.3, 0.3, 0.2])
     kdict['label1']['subdefect4'] = dict()
     kdict['label1']['subdefect4']['symbol'] = 'Fe'
     kdict['label1']['subdefect4']['type'] = 'substitution'
     kdict['label1']['subdefect4']['coordinates'] = np.array(
         [0.25, 0.75, 0.75])
     kdict['label1']['subdefect5'] = dict()
     kdict['label1']['subdefect5']['symbol'] = 'O'
     kdict['label1']['subdefect5']['type'] = 'vacancy'
     kdict['label1']['subdefect5']['coordinates'] = np.array(
         [0.5, 0.25, 0.75])
     kdict['label1']['subdefect6'] = dict()
     kdict['label1']['subdefect6']['symbol'] = 'Fe'
     kdict['label1']['subdefect6']['type'] = 'substitution'
     kdict['label1']['subdefect6']['coordinates'] = np.array(
         [0.25, 0.25, 0.25])
     kdict['label1']['subdefect7'] = dict()
     kdict['label1']['subdefect7']['symbol'] = 'La'
     kdict['label1']['subdefect7']['type'] = 'vacancy'
     kdict['label1']['subdefect7']['coordinates'] = np.array([0, 0, 0.5])
     kdict['label1']['subdefect8'] = dict()
     kdict['label1']['subdefect8']['symbol'] = 'Ni'
     kdict['label1']['subdefect8']['type'] = 'interstitial'
     kdict['label1']['subdefect8']['coordinates'] = np.array(
         [0.4, 0.1, 0.3])
     kdict['label1']['coord_type'] = 'fractional'
     kdict['label1']['threshold'] = 0.01
     kdict['label1']['charge'] = '2'
     ddict = dict()
     ddict['mast_defect_settings'] = dict()
     ddict['mast_defect_settings'].update(
         kdict['label1'])  #single defect grouping
     ddict['mast_program'] = 'vasp'
     my_structure = Poscar.from_file("files/POSCAR_perfect").structure
     myperf = MASTFile("files/POSCAR_perfect")
     myperf.to_file("%s/POSCAR" % ingdir)
     myri = ChopIngredient(name=ingdir,
                           program_keys=ddict,
                           structure=my_structure)
     myri.run_defect()
     #
     #defect = kdict['label1']
     #base_structure = my_structure.copy()
     #from MAST.ingredients.pmgextend.structure_extensions import StructureExtensions
     #for key in defect:
     #    if 'subdefect' in key:
     #        subdefect = defect[key]
     #        sxtend = StructureExtensions(struc_work1=base_structure)
     #        base_structure = sxtend.induce_defect(subdefect, defect['coord_type'], defect['threshold'])
     #        print base_structure
     #    else:
     #        pass
     #return
     #
     #
     my_defected = Poscar.from_file(
         "%s/CONTCAR" % ingdir).structure.get_sorted_structure()
     defected_compare = Poscar.from_file(
         "files/POSCAR_multi").structure.get_sorted_structure()
     self.assertEquals(my_defected, defected_compare)
     self.assertFalse(os.path.isfile("%s/submitlist" % self.test_control))
Exemplo n.º 46
0
 def test_run_scale_defect(self):
     #raise SkipTest
     ingdir="%s/writedir/single_label1" % testdir
     recipedir="%s/writedir" % testdir
     topmetad = MASTFile("files/top_metadata_single")
     topmetad.data.append("origin_dir = %s/files\n" % testdir) #give origin directory
     topmetad.to_file("writedir/metadata.txt")
     metad = MASTFile("files/metadata_single")
     metad.data.append("defect_label = label1\n")
     metad.data.append("scaling_size = [2,2,2]\n")
     metad.to_file("%s/metadata.txt" % ingdir)
     kdict=dict()
     kdict['label1']=dict()
     kdict['label1']['subdefect1']=dict()
     kdict['label1']['subdefect1']['symbol']='Cr'
     kdict['label1']['subdefect1']['type']='interstitial'
     kdict['label1']['subdefect1']['coordinates']=np.array([0.8, 0.7, 0.6])
     kdict['label1']['subdefect2']=dict()
     kdict['label1']['subdefect2']['symbol']='Sr'
     kdict['label1']['subdefect2']['type']='antisite'
     kdict['label1']['subdefect2']['coordinates']=np.array([0.5,0.5,0.0])
     kdict['label1']['subdefect3']=dict()
     kdict['label1']['subdefect3']['symbol']='Cr'
     kdict['label1']['subdefect3']['type']='interstitial'
     kdict['label1']['subdefect3']['coordinates']=np.array([0.3,0.3,0.2])
     kdict['label1']['subdefect4']=dict()
     kdict['label1']['subdefect4']['symbol']='Fe'
     kdict['label1']['subdefect4']['type']='substitution'
     kdict['label1']['subdefect4']['coordinates']=np.array([0.25,0.75,0.75])
     kdict['label1']['subdefect5']=dict()
     kdict['label1']['subdefect5']['symbol']='O'
     kdict['label1']['subdefect5']['type']='vacancy'
     kdict['label1']['subdefect5']['coordinates']=np.array([0.5,0.25,0.75])
     kdict['label1']['subdefect6']=dict()
     kdict['label1']['subdefect6']['symbol']='Fe'
     kdict['label1']['subdefect6']['type']='substitution'
     kdict['label1']['subdefect6']['coordinates']=np.array([0.25,0.25,0.25])
     kdict['label1']['subdefect7']=dict()
     kdict['label1']['subdefect7']['symbol']='La'
     kdict['label1']['subdefect7']['type']='vacancy'
     kdict['label1']['subdefect7']['coordinates']=np.array([0,0,0.5])
     kdict['label1']['subdefect8']=dict()
     kdict['label1']['subdefect8']['symbol']='Ni'
     kdict['label1']['subdefect8']['type']='interstitial'
     kdict['label1']['subdefect8']['coordinates']=np.array([0.4,0.1,0.3])
     kdict['label1']['coord_type'] = 'fractional'
     kdict['label1']['threshold'] = 0.01
     kdict['label1']['charge'] = '2'
     mdict=dict()
     mdict['mast_program'] = 'vasp'
     mdict['mast_defect_settings']=dict()
     mdict['mast_defect_settings'].update(kdict['label1'])
     my_structure = Poscar.from_file("files/POSCAR_perfect").structure
     myperf = MASTFile("files/POSCAR_perfect")
     myperf.to_file("%s/POSCAR" % ingdir)
     myri = ChopIngredient(name=ingdir,program_keys=mdict, structure=my_structure)
     myri.run_scale()
     #copy contcar to poscar
     os.rename("%s/CONTCAR" % ingdir, "%s/POSCAR" % ingdir)
     myri.run_defect()
     my_defected = Poscar.from_file("%s/CONTCAR" % ingdir).structure.get_sorted_structure()
     defected_compare = Poscar.from_file("files/POSCAR_scaled_defected").structure.get_sorted_structure()
     self.assertEquals(my_defected, defected_compare)
Exemplo n.º 47
0
 def test_complete_neb_subfolders(self):
     #raise SkipTest
     ingdir = "%s/writedir/single_label1" % testdir
     recipedir = "%s/writedir" % testdir
     topmetad = MASTFile("files/top_metadata_single")
     topmetad.data.append("origin_dir = %s/files\n" %
                          testdir)  #give origin directory
     topmetad.to_file("writedir/metadata.txt")
     metad = MASTFile("files/metadata_single")
     metad.to_file("%s/metadata.txt" % ingdir)
     kdict = dict()
     kdict['mast_program'] = 'vasp'
     kdict['mast_kpoints'] = [2, 2, 2, "M"]
     kdict['mast_xc'] = 'pw91'
     kdict['mast_neb_settings'] = dict()
     kdict['mast_neb_settings']['images'] = 3
     my_structure = pymatgen.io.vaspio.Poscar.from_file(
         "files/perfect_structure").structure
     mywr = ChopIngredient(name=ingdir,
                           program_keys=kdict,
                           structure=my_structure)
     myoutcar = MASTFile("files/OUTCAR_completed")
     myoszicar = MASTFile("files/OSZICAR_completed")
     for subdir in ['00', '01', '02', '03', '04']:
         subname = "%s/%s" % (ingdir, subdir)
         os.mkdir(subname)
         mywr.keywords['name'] = subname
         mywr.checker.keywords['name'] = subname
         if not subdir in ['00', '04']:
             mywr.write_singlerun()
             mywr.write_submit_script()
             myoutcar.to_file("%s/OUTCAR" % subname)
             myoszicar.to_file("%s/OSZICAR" % subname)
     myci = ChopIngredient(name=ingdir,
                           program_keys=kdict,
                           structure=my_structure)
     self.assertTrue(myci.complete_neb_subfolders())
     os.remove("%s/03/OUTCAR" % ingdir)
     self.assertFalse(myci.complete_neb_subfolders())
Exemplo n.º 48
0
 def test_run_defect(self):
     #raise SkipTest
     ingdir="%s/writedir/single_label1" % testdir
     recipedir="%s/writedir" % testdir
     topmetad = MASTFile("files/top_metadata_single")
     topmetad.data.append("origin_dir = %s/files\n" % testdir) #give origin directory
     topmetad.to_file("writedir/metadata.txt")
     metad = MASTFile("files/metadata_single")
     metad.data.append("defect_label = label1\n")
     metad.data.append("scaling_size = [1,1,1]\n")
     metad.to_file("%s/metadata.txt" % ingdir)
     kdict=dict()
     kdict['label1']=dict()
     kdict['label1']['subdefect1']=dict()
     kdict['label1']['subdefect1']['symbol']='Cr'
     kdict['label1']['subdefect1']['type']='interstitial'
     kdict['label1']['subdefect1']['coordinates']=np.array([0.8, 0.7, 0.6])
     kdict['label1']['subdefect2']=dict()
     kdict['label1']['subdefect2']['symbol']='Sr'
     kdict['label1']['subdefect2']['type']='antisite'
     kdict['label1']['subdefect2']['coordinates']=np.array([0.5,0.5,0.0])
     kdict['label1']['subdefect3']=dict()
     kdict['label1']['subdefect3']['symbol']='Cr'
     kdict['label1']['subdefect3']['type']='interstitial'
     kdict['label1']['subdefect3']['coordinates']=np.array([0.3,0.3,0.2])
     kdict['label1']['subdefect4']=dict()
     kdict['label1']['subdefect4']['symbol']='Fe'
     kdict['label1']['subdefect4']['type']='substitution'
     kdict['label1']['subdefect4']['coordinates']=np.array([0.25,0.75,0.75])
     kdict['label1']['subdefect5']=dict()
     kdict['label1']['subdefect5']['symbol']='O'
     kdict['label1']['subdefect5']['type']='vacancy'
     kdict['label1']['subdefect5']['coordinates']=np.array([0.5,0.25,0.75])
     kdict['label1']['subdefect6']=dict()
     kdict['label1']['subdefect6']['symbol']='Fe'
     kdict['label1']['subdefect6']['type']='substitution'
     kdict['label1']['subdefect6']['coordinates']=np.array([0.25,0.25,0.25])
     kdict['label1']['subdefect7']=dict()
     kdict['label1']['subdefect7']['symbol']='La'
     kdict['label1']['subdefect7']['type']='vacancy'
     kdict['label1']['subdefect7']['coordinates']=np.array([0,0,0.5])
     kdict['label1']['subdefect8']=dict()
     kdict['label1']['subdefect8']['symbol']='Ni'
     kdict['label1']['subdefect8']['type']='interstitial'
     kdict['label1']['subdefect8']['coordinates']=np.array([0.4,0.1,0.3])
     kdict['label1']['coord_type'] = 'fractional'
     kdict['label1']['threshold'] = 0.01
     kdict['label1']['charge'] = '2'
     ddict=dict()
     ddict['mast_defect_settings']=dict()
     ddict['mast_defect_settings'].update(kdict['label1']) #single defect grouping
     ddict['mast_program'] = 'vasp'
     my_structure = Poscar.from_file("files/POSCAR_perfect").structure
     myperf = MASTFile("files/POSCAR_perfect")
     myperf.to_file("%s/POSCAR" % ingdir)
     myri = ChopIngredient(name=ingdir,program_keys=ddict, structure=my_structure)
     myri.run_defect()
     #
     #defect = kdict['label1']
     #base_structure = my_structure.copy()
     #from MAST.ingredients.pmgextend.structure_extensions import StructureExtensions
     #for key in defect:
     #    if 'subdefect' in key:
     #        subdefect = defect[key]
     #        sxtend = StructureExtensions(struc_work1=base_structure)
     #        base_structure = sxtend.induce_defect(subdefect, defect['coord_type'], defect['threshold'])
     #        print base_structure
     #    else:
     #        pass
     #return
     #
     #
     my_defected = Poscar.from_file("%s/CONTCAR" % ingdir).structure.get_sorted_structure()
     defected_compare = Poscar.from_file("files/POSCAR_multi").structure.get_sorted_structure()
     self.assertEquals(my_defected, defected_compare)
     self.assertFalse(os.path.isfile("%s/submitlist" % self.test_control))
Exemplo n.º 49
0
 def test_run_neb_subfolders(self):
     #raise SkipTest
     ingdir = "%s/writedir/neb_labelinit-labelfin_stat" % testdir
     recipedir = "%s/writedir" % testdir
     topmetad = MASTFile("files/top_metadata_neb")
     topmetad.data.append("origin_dir = %s/files\n" %
                          testdir)  #give origin directory
     topmetad.to_file("writedir/metadata.txt")
     metad = MASTFile("files/metadata_neb")
     metad.to_file("%s/metadata.txt" % ingdir)
     kdict = dict()
     kdict['mast_program'] = 'vasp'
     kdict['mast_kpoints'] = [2, 2, 2, "M"]
     kdict['mast_xc'] = 'pw91'
     neblines = list()
     neblines.append(["Cr", "0.0 0.9 0.8", "0.0 0.8 0.7"])
     neblines.append(["Cr", "0.4 0.2 0.1", "0.3 0.3 0.2"])
     neblines.append(["Cr", "0.29 0.05 0.05", "0.01 0.01 0.98"])
     neblines.append(["Ni", "0.61 0.99 0.98", "0.25 0.01 0.97"])
     kdict['mast_neb_settings'] = dict()
     kdict['mast_neb_settings']['lines'] = neblines
     kdict['mast_neb_settings']['images'] = 3
     str_00 = MASTFile("files/POSCAR_00")
     str_00.to_file("%s/parent_structure_labelinit" % ingdir)
     str_04 = MASTFile("files/POSCAR_04")
     str_04.to_file("%s/parent_structure_labelfin" % ingdir)
     str_01 = MASTFile("files/POSCAR_01")
     str_01.to_file("%s/parent_structure_labelinit-labelfin_01" % ingdir)
     str_02 = MASTFile("files/POSCAR_02")
     str_02.to_file("%s/parent_structure_labelinit-labelfin_02" % ingdir)
     str_03 = MASTFile("files/POSCAR_03")
     str_03.to_file("%s/parent_structure_labelinit-labelfin_03" % ingdir)
     en_00 = MASTFile("files/OSZICAR_00")
     en_00.to_file("%s/parent_energy_labelinit" % ingdir)
     en_04 = MASTFile("files/OSZICAR_04")
     en_04.to_file("%s/parent_energy_labelfin" % ingdir)
     my_structure = Poscar.from_file("files/perfect_structure").structure
     mywr = ChopIngredient(name=ingdir,
                           program_keys=kdict,
                           structure=my_structure)
     mywr.write_neb_subfolders()
     myri = ChopIngredient(name=ingdir,
                           program_keys=kdict,
                           structure=my_structure)
     myri.run_neb_subfolders()
     mysubmit = MASTFile("%s/submitlist" % self.test_control)
     myri.checker.keywords['name'] = "%s/00" % ingdir
     self.assertFalse(
         myri.checker.is_ready_to_run())  #do not run endpoints again
     myri.checker.keywords['name'] = "%s/01" % ingdir
     self.assertTrue(myri.checker.is_ready_to_run())
     myri.checker.keywords['name'] = "%s/02" % ingdir
     self.assertTrue(myri.checker.is_ready_to_run())
     myri.checker.keywords['name'] = "%s/03" % ingdir
     self.assertTrue(myri.checker.is_ready_to_run())
     myri.checker.keywords['name'] = "%s/04" % ingdir
     self.assertFalse(
         myri.checker.is_ready_to_run())  #do not run endpoints again
     self.assertEquals(mysubmit.data[0], "%s/01\n" % ingdir)
     self.assertEquals(mysubmit.data[1], "%s/02\n" % ingdir)
     self.assertEquals(mysubmit.data[2], "%s/03\n" % ingdir)