Exemple #1
0
 def _vasp_poscar_setup(self):
     """Set up the POSCAR file for a single VASP run.
     """
     name = self.keywords['name']
     pospath = os.path.join(name, "POSCAR")
     if os.path.isfile(pospath):
         my_poscar = Poscar.from_file(pospath) 
         #parent should have given a structure
     else: #this is an originating run; mast should give it a structure
         if self.keywords['structure'] is not None:
             my_poscar = Poscar(self.keywords['structure'])
         else:
             pf = os.path.join(os.path.dirname(name),'POSCAR_%s'%os.path.basename(name))
             if os.path.isfile(pf):
                 my_poscar = Poscar.from_file(pf)
         workdir=os.path.dirname(name)
         sdir=os.path.join(workdir,"structure_index_files")
         if os.path.exists(sdir):
             mystr=my_poscar.structure
             manname="manifest___"
             myatomindex=AtomIndex(structure_index_directory=sdir)
             newstr=myatomindex.graft_new_coordinates_from_manifest(mystr, manname, "")
             self.logger.info("Getting original coordinates from manifest.")
             new_pos=Poscar(newstr)
             my_poscar=new_pos
         self.logger.info("No POSCAR found from a parent; base structure used for %s" % self.keywords['name'])
     if 'mast_coordinates' in self.keywords['program_keys'].keys():
         sxtend = StructureExtensions(struc_work1=my_poscar.structure, name=self.keywords['name'])
         coordstrucs=self.get_coordinates_only_structure_from_input()
         newstruc = sxtend.graft_coordinates_onto_structure(coordstrucs[0])
         my_poscar.structure=newstruc.copy()
     dirutil.lock_directory(name)
     my_poscar.write_file(pospath)
     dirutil.unlock_directory(name)
     return my_poscar
Exemple #2
0
 def set_up_neb_folders(self, image_structures):
     """Set up NEB folders.
         Args:
            image_structures <list of Structure>: List
                of image structures
     """
     imct=0
     myname = self.keywords['name']
     if 'mast_coordinates' in self.keywords['program_keys'].keys():
         coordstrucs=self.get_coordinates_only_structure_from_input()
         newstrucs=list()
         sidx = 0 #ex. coordstrucs 0, 1, 2 for 3 images
         while sidx < self.keywords['program_keys']['mast_neb_settings']['images']:
             sxtend = StructureExtensions(struc_work1=image_structures[sidx+1].copy(), name=self.keywords['name'])
             newstrucs.append(sxtend.graft_coordinates_onto_structure(coordstrucs[sidx]))
             sidx = sidx + 1
     while imct < len(image_structures):
         imposcar = Poscar(image_structures[imct])
         num_str = str(imct).zfill(2)
         impath = os.path.join(myname, num_str)
         impospath = os.path.join(myname, "POSCAR_" + num_str)
         if 'mast_coordinates' in self.keywords['program_keys'].keys():
             if imct == 0: #skip endpoint
                 pass 
             elif imct == len(image_structures)-1: #skip other endpt
                 pass
             else:
                 imposcar.structure=newstrucs[imct-1].copy()
         dirutil.lock_directory(myname)
         imposcar.write_file(impospath)
         dirutil.unlock_directory(myname)
         try:
             os.makedirs(impath)
         except OSError:
             self.logger.warning("Directory at %s already exists." % impath)
             return None
         dirutil.lock_directory(impath)
         imposcar.write_file(os.path.join(impath, "POSCAR"))
         dirutil.unlock_directory(impath)
         imct = imct + 1
     return