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")
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")