||
一个二层的结构,固定底部一层,上面一层结构发生应变,层间距沿x轴逐渐变大。下午写了一个python脚本来实现。
import sys f=open('POSCAR','r+') lines=f.readlines() #print lines # judge the c3 value and calculate the new c3 value with open ('POSCAR','r+') as ff: for i in lines[0:9]: i_n=i.replace("\r\n",'\n') ff.write(i_n) for i in lines[9:]: c1=float(i.split()[0]) c3=float(i.split()[2]) print(c1,c3) if c3>0.32: c3_new=c3+25.1345/31.31*c1*0.01 print(str(c3), str(c3_new)) # str() transform values into string and replace().replace() in one line l=i.replace(str(c3),str(c3_new)).replace("\r\n",' ')+"T T T \n" ff.write(l) else: m=i.replace("\r\n",' ')+"F F F \n" ff.write(m) # lines.insert(9,'Selective dynamics') # 'Selective dynamics' has been inserted manually ff.close # write lines in a new POSCAR fp=file('POSCAR') lines=[] for line in fp: lines.append(line) fp.close
搭建的结构如图所示:
然后将搭建的结构作为初始结构,进行固定部分原子的结构优化。
Archiver|手机版|科学网 ( 京ICP备07017567号-12 )
GMT+8, 2024-11-25 08:24
Powered by ScienceNet.cn
Copyright © 2007- 中国科学报社