atom1 = Atom() atom2 = Atom() atom1.set_pos(0.0, 0.0, 0.0) atom1.set_id(1) atom1.set_sid(sid1) asys.add_atom(atom1) atom2.set_pos(0.5, 0.0, 0.0) atom2.set_id(2) atom2.set_sid(sid2) asys.add_atom(atom2) hmin = rmin / (2 * rcut) hd = (0.5 - hmin) / nsmpl os.system('cp pmdini pmdorig') fout = open('out.2body', 'w') for ip in range(nsmpl + 1): print '.', d = hmin + hd * ip asys.atoms[1].pos[0] = d asys.write_pmd('pmdini') os.system(pmdexec + ' > out.pmd') epot = get_epot('out.pmd') fout.write(' {0:12.3f} {1:22.14e}\n'.format(d * 2 * rcut, epot)) fout.close() #....restore pmdini os.system('cp pmdorig pmdini') print ' program done.'
asys.add_atom(atom1) hd= distance/(alc*2) atom2= Atom() atom2.set_pos(hd,0.0,0.0) atom2.set_id(2) asys.add_atom(atom2) atom3= Atom() atom3.set_pos(0.0,0.0,0.0) atom3.set_id(3) asys.add_atom(atom3) da = (amax-amin)/nsmpl fout= open('out.3body','w') for ip in range(nsmpl+1): print('.',end='') ang= amin +da*ip x= hd*np.cos(ang/180*np.pi) y= hd*np.sin(ang/180*np.pi) asys.atoms[2].pos[0] = x asys.atoms[2].pos[1] = y asys.write_pmd('pmdini') os.system(pmdexec+' > out.pmd') apot= get_apot('out.pmd') fout.write(' {0:12.3f} {1:22.14e}\n'.format(ang,apot)) fout.close() print(' program done.')
fcmat = np.zeros((natme, natme, 3, 3)) for ia in range(natme): print '.', sys.stdout.flush() ppos = np.array(sysext.atoms[ia].pos) for ixyz in range(3): fam = np.zeros((natme, 3)) fap = np.zeros((natme, 3)) for kd in (-1, 1): sysext.atoms[ia].pos[:] = ppos[:] dx = np.zeros(3) dx[ixyz] = kd * displace hdx = cart2h(dx, hext) sysext.atoms[ia].pos[:] += hdx #...perform pmd here sysext.write_pmd('pmdini') os.system(pmdexec + ' > out.pmd') #os.system('cp frc0000 frc0000-{0:1d}-{1:1d}-{2:1d}'.format(ia,ixyz,kd)) #...obtain forces on atoms ff = open('frc0000', 'r') ntmp = int(ff.readline().split()[0]) for ja in range(natme): data = ff.readline().split() if kd == -1: fam[ja, 0] = float(data[0]) fam[ja, 1] = float(data[1]) fam[ja, 2] = float(data[2]) else: fap[ja, 0] = float(data[0]) fap[ja, 1] = float(data[1]) fap[ja, 2] = float(data[2])
# Make directories for the calculation of those POSCARS poscars= glob.glob("POSCAR-[0-9]??") n= 0 for poscar in poscars: n+=1 dname="disp-{0:03d}".format(n) os.system("mkdir -p {0}".format(dname)) os.system("cp {0} {1}/POSCAR".format(poscar,dname)) print("processing {0}...".format(dname)) # Prepare pmd calculation psystmp= NAPSystem() psystmp.read_POSCAR(poscar) os.system("cp in.* {0}/".format(dname)) if execname == "pmd": psystmp.write_pmd("{0}/pmdini".format(dname)) elif execname == "smd": psystmp.write_pmd("{0}/smd0000".format(dname)) os.system("cd {0}/; {1}/{2} > out.{2}; cd ..".format(dname,pmddir,execname)) # Make FORCE_SETS file from the pmd results natm= int(disp['natom']) ndisps= len(disp['displacements']) with open('FORCE_SETS','w') as f: f.write("{0:d}\n".format(natm)) f.write("{0:d}\n".format(ndisps)) n=0 for ds in disp['displacements']: n+=1 f.write("\n") f.write("{0:d}\n".format(n))
atom1 = Atom() atom2 = Atom() atom1.set_pos(0.0, 0.0, 0.0) atom1.set_id(1) atom1.set_sid(sid1) asys.add_atom(atom1) atom2.set_pos(0.5, 0.0, 0.0) atom2.set_id(2) atom2.set_sid(sid2) asys.add_atom(atom2) hmin = rmin / (2 * rcut) hd = (0.5 - hmin) / nsmpl os.system("cp pmd0000 pmd0000.orig") fout = open("out.2body", "w") for ip in range(nsmpl + 1): print ".", d = hmin + hd * ip asys.atoms[1].pos[0] = d asys.write_pmd("pmd0000") os.system(pmdexec + " > out.pmd") epot = get_epot("out.pmd") fout.write(" {0:12.3f} {1:22.14e}\n".format(d * 2 * rcut, epot)) fout.close() # ....restore pmd0000 os.system("cp pmd0000.orig pmd0000") print " program done."
fcmat= np.zeros((natme,natme,3,3)) for ia in range(natme): print '.', sys.stdout.flush() ppos= np.array(sysext.atoms[ia].pos) for ixyz in range(3): fam= np.zeros((natme,3)) fap= np.zeros((natme,3)) for kd in (-1,1): sysext.atoms[ia].pos[:]= ppos[:] dx= np.zeros(3) dx[ixyz]= kd*displace hdx= cart2h(dx,hext) sysext.atoms[ia].pos[:] += hdx #...perform pmd here sysext.write_pmd('pmd0000') os.system(pmdexec+' > out.pmd') #os.system('cp frc0000 frc0000-{0:1d}-{1:1d}-{2:1d}'.format(ia,ixyz,kd)) #...obtain forces on atoms ff= open('frc0000','r') ntmp= int(ff.readline().split()[0]) for ja in range(natme): data= ff.readline().split() if kd == -1: fam[ja,0]= float(data[0]) fam[ja,1]= float(data[1]) fam[ja,2]= float(data[2]) else: fap[ja,0]= float(data[0]) fap[ja,1]= float(data[1]) fap[ja,2]= float(data[2])
fcmat= np.zeros((natme,natme,3,3)) for ia in range(natme): print '.', sys.stdout.flush() ppos= np.array(sysext.atoms[ia].pos) for ixyz in range(3): fam= np.zeros((natme,3)) fap= np.zeros((natme,3)) for kd in (-1,1): sysext.atoms[ia].pos[:]= ppos[:] dx= np.zeros(3) dx[ixyz]= kd*displace hdx= cart2h(dx,hext) sysext.atoms[ia].pos[:] += hdx #...perform pmd here sysext.write_pmd('pmdini') os.system(pmdexec+' > out.pmd') #os.system('cp frc0000 frc0000-{0:1d}-{1:1d}-{2:1d}'.format(ia,ixyz,kd)) #...obtain forces on atoms ff= open('frc0000','r') ntmp= int(ff.readline().split()[0]) for ja in range(natme): data= ff.readline().split() if kd == -1: fam[ja,0]= float(data[0]) fam[ja,1]= float(data[1]) fam[ja,2]= float(data[2]) else: fap[ja,0]= float(data[0]) fap[ja,1]= float(data[1]) fap[ja,2]= float(data[2])
asys.add_atom(atom1) hd= distance/(alc*2) atom2= Atom() atom2.set_pos(hd,0.0,0.0) atom2.set_id(2) asys.add_atom(atom2) atom3= Atom() atom3.set_pos(0.0,0.0,0.0) atom3.set_id(3) asys.add_atom(atom3) da = (amax-amin)/nsmpl fout= open('out.3body','w') for ip in range(nsmpl+1): print '.', ang= amin +da*ip x= hd*np.cos(ang/180*np.pi) y= hd*np.sin(ang/180*np.pi) asys.atoms[2].pos[0] = x asys.atoms[2].pos[1] = y asys.write_pmd('pmd0000') os.system(pmdexec+' > out.pmd') apot= get_apot('out.pmd') fout.write(' {0:12.3f} {1:22.14e}\n'.format(ang,apot)) fout.close() print ' program done.'