Пример #1
0
    def _nosd_my_dynmat(self):
        """Creates fake blocks in DYNMAT for filling back in the atoms and 
            directions skipped through selective dynamics.
        """
        name=self.keywords['name']
        if not os.path.isfile(name + "/DYNMAT_mod_1"):
            raise MASTError("checker/phon_checker", "No DYNMAT_mod_1 found in %s." % name)
        myvc = VaspChecker(name=self.keywords['name'],program_keys = self.keywords['program_keys'], structure = self.keywords['structure'])
        myforces=myvc.read_my_dynamical_matrix_file(name,"DYNMAT_mod_1")
        numatoms = myforces['numatoms']
        myforces['numdisp'] = numatoms * 3 #full set of all blocks
        for atom in range(1, numatoms+1):
            if not atom in myforces['atoms'].keys():
                myforces['atoms'][atom]=dict()
            for dispct in range(1, 4):
                if not dispct in myforces['atoms'][atom].keys():
                    myforces['atoms'][atom][dispct]=dict()
                    if dispct == 1:
                        displine = "0.0001 0 0"
                    elif dispct == 2:
                        displine = "0 0.0001 0"
                    else:
                        displine = "0 0 0.0001"
                    myforces['atoms'][atom][dispct]['displine']=displine
                    myforces['atoms'][atom][dispct]['dynmat']=list()
                    for act in range(0, numatoms):
                        myforces['atoms'][atom][dispct]['dynmat'].append("0.000 0.000 0.000\n")
        myvc = VaspChecker(name=self.keywords['name'],program_keys = self.keywords['program_keys'], structure = self.keywords['structure'])

        myvc.write_my_dynamical_matrix_file(myforces, name, "DYNMAT_mod_2")
Пример #2
0
 def _replace_my_displacements(self):
     """
         In VASP, 0.01 0 0 in DYNMAT from phonons is 1/Angstroms in the 
         x-direction (XDATCAR shows that it makes fractional coord 
         displacements for all 3 lattice vectors in a non-cubic system to get 
         this strictly-x-direction) 
         In PHON, 0.01 0 0 means 0.01 multiplied by lattice vector a.
         Back out the fractional displacements used by VASP from the XDATCAR, 
         match them up, and use them.
         Konfig =1 is the un-displaced cell.
         Now for NFREE=2,
         there are two Konfigs for each displacment; the first is positive
         POTIM in the x-direction (for example, POTIM = 0.01), then negative
         POTIM in the x-direction, then y, then z.
         So one unfrozen atom has seven Konfigs.
         DYNMAT, however, reports the AVERAGE force from each Konfig pair.
         So we only want Konfigs 2, 4, and 6, corresponding to POTIM 0 0, 
         0 POTIM 0, and 0 0 POTIM
     """
     name = self.keywords['name']
     if not os.path.isfile(name + "/XDATCAR"):
         raise MASTError("checker/phon_checker",
                         "No XDATCAR found in %s." % name)
     myvc = VaspChecker(name=self.keywords['name'],
                        program_keys=self.keywords['program_keys'],
                        structure=self.keywords['structure'])
     myxdat = myvc.read_my_displacement_file(name)
     if not os.path.isfile(name + "/DYNMAT"):
         raise MASTError("checker/phon_checker",
                         "No DYNMAT found in %s." % name)
     myforces = myvc.read_my_dynamical_matrix_file(name)
     atomlist = myforces['atoms'].keys()
     atomlist.sort()
     #first disp needs kfg 2
     #second disp needs kfg 4
     #third disp needs kfg 6...
     dispct = 0
     for atom in atomlist:
         displist = myforces['atoms'][atom].keys()
         displist.sort()
         for disp in displist:
             dispct = dispct + 1
             kfgidx = dispct * 2
             atomline = myxdat['configs'][kfgidx][
                 atom -
                 1]  #indexing of atoms starts at config list entry 0 for atom 1
             baseline = myxdat['configs'][1][atom - 1]
             atomcoords = np.array(atomline.strip().split(), float)
             basecoords = np.array(baseline.strip().split(), float)
             dispcoords = atomcoords - basecoords
             displine = str(dispcoords[0]) + " " + str(
                 dispcoords[1]) + " " + str(dispcoords[2])
             myforces['atoms'][atom][disp]['displine'] = displine
     myvc.write_my_dynamical_matrix_file(myforces, name, "DYNMAT_mod_1")
Пример #3
0
 def _phon_forces_setup(self):
     """Set up the FORCES file. This is like the DYNMAT but with the mass
         line stripped out and no direction indicators. Also, a block must
         be present for every atom, with a displacement, even if all entries
         are zero (e.g. fake block for selective dynamics). First line contains
         only the number of total displacements.
     """
     self._replace_my_displacements()
     self._nosd_my_dynmat()
     name=self.keywords['name']
     if not os.path.isfile(name + "/DYNMAT_mod_2"):
         raise MASTError("checker/phon_checker", "No DYNMAT_mod_2 found in %s." % name)
     myvc = VaspChecker(name=self.keywords['name'],program_keys = self.keywords['program_keys'], structure = self.keywords['structure'])
     mydyn=myvc.read_my_dynamical_matrix_file(name, "DYNMAT_mod_2")
     myvc.write_my_dynmat_without_disp_or_mass(mydyn, name, "FORCES")
Пример #4
0
 def _replace_my_displacements(self):
     """
         In VASP, 0.01 0 0 in DYNMAT from phonons is 1/Angstroms in the 
         x-direction (XDATCAR shows that it makes fractional coord 
         displacements for all 3 lattice vectors in a non-cubic system to get 
         this strictly-x-direction) 
         In PHON, 0.01 0 0 means 0.01 multiplied by lattice vector a.
         Back out the fractional displacements used by VASP from the XDATCAR, 
         match them up, and use them.
         Konfig =1 is the un-displaced cell.
         Now for NFREE=2,
         there are two Konfigs for each displacment; the first is positive
         POTIM in the x-direction (for example, POTIM = 0.01), then negative
         POTIM in the x-direction, then y, then z.
         So one unfrozen atom has seven Konfigs.
         DYNMAT, however, reports the AVERAGE force from each Konfig pair.
         So we only want Konfigs 2, 4, and 6, corresponding to POTIM 0 0, 
         0 POTIM 0, and 0 0 POTIM
     """
     name=self.keywords['name']
     if not os.path.isfile(name + "/XDATCAR"):
         raise MASTError("checker/phon_checker", "No XDATCAR found in %s." % name)
     myvc = VaspChecker(name=self.keywords['name'],program_keys = self.keywords['program_keys'], structure = self.keywords['structure'])
     myxdat=myvc.read_my_displacement_file(name)
     if not os.path.isfile(name + "/DYNMAT"):
         raise MASTError("checker/phon_checker", "No DYNMAT found in %s." % name)
     myforces=myvc.read_my_dynamical_matrix_file(name)
     atomlist = myforces['atoms'].keys()
     atomlist.sort()
     #first disp needs kfg 2
     #second disp needs kfg 4
     #third disp needs kfg 6...
     dispct=0
     for atom in atomlist:
         displist = myforces['atoms'][atom].keys()
         displist.sort()
         for disp in displist:
             dispct = dispct + 1
             kfgidx = dispct * 2
             atomline = myxdat['configs'][kfgidx][atom-1] #indexing of atoms starts at config list entry 0 for atom 1
             baseline = myxdat['configs'][1][atom-1]
             atomcoords = np.array(atomline.strip().split(), float)
             basecoords = np.array(baseline.strip().split(), float)
             dispcoords = atomcoords - basecoords
             displine = str(dispcoords[0]) + " " + str(dispcoords[1]) + " " + str(dispcoords[2])
             myforces['atoms'][atom][disp]['displine'] = displine
     myvc.write_my_dynamical_matrix_file(myforces, name, "DYNMAT_mod_1")
Пример #5
0
 def _phon_forces_setup(self):
     """Set up the FORCES file. This is like the DYNMAT but with the mass
         line stripped out and no direction indicators. Also, a block must
         be present for every atom, with a displacement, even if all entries
         are zero (e.g. fake block for selective dynamics). First line contains
         only the number of total displacements.
     """
     self._replace_my_displacements()
     self._nosd_my_dynmat()
     name = self.keywords['name']
     if not os.path.isfile(name + "/DYNMAT_mod_2"):
         raise MASTError("checker/phon_checker",
                         "No DYNMAT_mod_2 found in %s." % name)
     myvc = VaspChecker(name=self.keywords['name'],
                        program_keys=self.keywords['program_keys'],
                        structure=self.keywords['structure'])
     mydyn = myvc.read_my_dynamical_matrix_file(name, "DYNMAT_mod_2")
     myvc.write_my_dynmat_without_disp_or_mass(mydyn, name, "FORCES")
Пример #6
0
    def _nosd_my_dynmat(self):
        """Creates fake blocks in DYNMAT for filling back in the atoms and 
            directions skipped through selective dynamics.
        """
        name = self.keywords['name']
        if not os.path.isfile(name + "/DYNMAT_mod_1"):
            raise MASTError("checker/phon_checker",
                            "No DYNMAT_mod_1 found in %s." % name)
        myvc = VaspChecker(name=self.keywords['name'],
                           program_keys=self.keywords['program_keys'],
                           structure=self.keywords['structure'])
        myforces = myvc.read_my_dynamical_matrix_file(name, "DYNMAT_mod_1")
        numatoms = myforces['numatoms']
        myforces['numdisp'] = numatoms * 3  #full set of all blocks
        for atom in range(1, numatoms + 1):
            if not atom in myforces['atoms'].keys():
                myforces['atoms'][atom] = dict()
            for dispct in range(1, 4):
                if not dispct in myforces['atoms'][atom].keys():
                    myforces['atoms'][atom][dispct] = dict()
                    if dispct == 1:
                        displine = "0.0001 0 0"
                    elif dispct == 2:
                        displine = "0 0.0001 0"
                    else:
                        displine = "0 0 0.0001"
                    myforces['atoms'][atom][dispct]['displine'] = displine
                    myforces['atoms'][atom][dispct]['dynmat'] = list()
                    for act in range(0, numatoms):
                        myforces['atoms'][atom][dispct]['dynmat'].append(
                            "0.000 0.000 0.000\n")
        myvc = VaspChecker(name=self.keywords['name'],
                           program_keys=self.keywords['program_keys'],
                           structure=self.keywords['structure'])

        myvc.write_my_dynamical_matrix_file(myforces, name, "DYNMAT_mod_2")