BraveZhao的个人博客分享 http://blog.sciencenet.cn/u/BraveZhao

博文

python小脚本加应变

已有 401 次阅读 2019-10-10 21:23 |个人分类:Pyhton|系统分类:科研笔记

#!/usr/bin/python

# -*- coding: UTF-8 -*-

#by Zhiqiang-Zhao  


#import module !

import os

import fileinput as fi

import numpy as np

import math



#specify input and outputfile !

in_file= 'CONTCAR'  

out1_file='strain.vasp'




for i in range(1,16):   #1~15


#read file !

file=fi.input(in_file,inplace=False)

data_1=open(out1_file,'w')

j=0

with file as f1,data_1 as data_1:

for line in f1:

j+=1

if len(line)!=0:

if j in np.arange(3,5,1): #3-4

line=line.split()

print(line)

x=float(line[0])*(1+i*0.05)

Value=i*0.05

y=float(line[1])

z=float(line[2])

data_1.writelines(' {0:.16f}  {1:.16f} {2:.16f}'.format(x,y,z)+'\n')

else:

data_1.writelines(line)

else:

pass

os.rename('strain.vasp','{0:.2f}'.format(Value)+'.vasp')


deformVector.py



http://blog.sciencenet.cn/blog-3388193-1201439.html

上一篇:[转载]Numpy高维数组的理解
下一篇:python小脚本对原文件进行直接修改:删除、替换

0

该博文允许注册用户评论 请点击登录 评论 (0 个评论)

数据加载中...

Archiver|手机版|科学网 ( 京ICP备14006957 )

GMT+8, 2019-12-13 18:34

Powered by ScienceNet.cn

Copyright © 2007- 中国科学报社

返回顶部