################################################ Main routine ########## if __name__ == "__main__": args= docopt(__doc__) rcut= float(args['--cutoff']) pmddir= args['--pmddir'] execname= args['--exec'] infname= args['PMDFILE'] plot= args['--plot'] #print(args) sys0= NAPSystem() sys0.read_pmd(infname) sys0.write_POSCAR() print(' POSCAR was written.') natm0= sys0.num_atoms() h0=np.zeros((3,3)) h0[0]= sys0.a1 *sys0.alc h0[1]= sys0.a2 *sys0.alc h0[2]= sys0.a3 *sys0.alc n1,n2,n3= calc_extention_ratio(h0,rcut) print("n1,n2,n3 = {0:d} {1:d} {2:d}".format(n1,n2,n3)) # Make displaced POSCARS via phonopy os.system("phonopy -d --dim=\"{0:d} {1:d} {2:d}\"".format(n1,n2,n3)) with open('disp.yaml','r') as f: disp= yaml.load(f)
dest="pmdexec", type="string", default='../pmd/pmd', help="path to the pmd executable.") (options, args) = parser.parse_args() displace = options.displace print ' displacement = ', displace, ' Ang.' rcut = options.rcut print ' rcut = ', rcut, ' Ang.' pmdexec = options.pmdexec infname = args[0] sys0 = NAPSystem() sys0.read_pmd(infname) sys0.write_POSCAR() print ' POSCAR was written.' natm0 = sys0.num_atoms() h0 = np.zeros((3, 3)) h0[0] = sys0.a1 * sys0.alc h0[1] = sys0.a2 * sys0.alc h0[2] = sys0.a3 * sys0.alc n1, n2, n3 = calc_extention_ratio(h0, rcut) r1 = 2 * n1 + 1 r2 = 2 * n2 + 1 r3 = 2 * n3 + 1 print ' num of cells in each axis=', r1, r2, r3 print ' num of atoms in extended system=', natm0 * r1 * r2 * r3
hmat= psnew.get_hmat() hi = np.linalg.inv(hmat) for ia,posi in enumerate(expos): sposi = np.dot(hi,posi) if 0.0 <= sposi[0] < 1.0 and \ 0.0 <= sposi[1] < 1.0 and \ 0.0 <= sposi[2] < 1.0: atom = Atom() symbol = exsymbols[ia] print('{0:5d} {1:s}'.format(ia,symbol) +' {0:12.5f} {1:12.5f} {2:12.5f}'.format(sposi[0], sposi[1], sposi[2])) atom.set_symbol(symbol) atom.set_pos(sposi[0],sposi[1],sposi[2]) psnew.add_atom(atom) tmp = None #tmp = raw_input('Input periodic shift vector if you want: ') tmp = ' 0.5, 0.0, 0.5' if tmp: shift = [ float(x) for x in tmp.split(',')] for a in psnew.atoms: a.pos[0] += shift[0] a.pos[1] += shift[1] a.pos[2] += shift[2] psnew.assign_pbc() psnew.write_POSCAR(infile+'.new') print('Check '+infile+'.new')