计算机abaqus Python实例操作excel文件Word下载.docx

上传人:b****5 文档编号:20537667 上传时间:2023-01-23 格式:DOCX 页数:7 大小:17.18KB
下载 相关 举报
计算机abaqus Python实例操作excel文件Word下载.docx_第1页
第1页 / 共7页
计算机abaqus Python实例操作excel文件Word下载.docx_第2页
第2页 / 共7页
计算机abaqus Python实例操作excel文件Word下载.docx_第3页
第3页 / 共7页
计算机abaqus Python实例操作excel文件Word下载.docx_第4页
第4页 / 共7页
计算机abaqus Python实例操作excel文件Word下载.docx_第5页
第5页 / 共7页
点击查看更多>>
下载资源
资源描述

计算机abaqus Python实例操作excel文件Word下载.docx

《计算机abaqus Python实例操作excel文件Word下载.docx》由会员分享,可在线阅读,更多相关《计算机abaqus Python实例操作excel文件Word下载.docx(7页珍藏版)》请在冰豆网上搜索。

计算机abaqus Python实例操作excel文件Word下载.docx

myfile='

tensile-'

+str(i+1)

f=open(myfile+'

.TRA'

'

r'

engineer_strain=[]

true_strain=[]

engineer_stress=[]

true_stress=[]

plastic_strain=[]

test_force=[]

s1=f.readline()

s2=f.readline()

s3=f.readline()

s4=f.readline()

s1=re.sub('

"

|\t|;

|\n'

'

s1)

s1=re.split('

+'

name=s1[2]

little=name[-2:

]

s2=re.sub('

s2)

s2=re.split('

times=s2[2]

printname+'

run'

+str(times)

bk=xlrd.open_workbook('

Staticreport.xls'

sh=bk.sheet_by_name("

Stat"

diameter=sh.cell_value(i+2,4)

area=pi*((diameter)**2)/4

E_modulus=sh.cell_value(i+2,7)

state=True

s0=f.readlines()

s0=s0[-2]

s0=re.sub('

;

'

s0)

s0=re.split('

f.seek(0)

whilestate:

s=f.readline()

s=re.sub('

s)

s=re.split('

prints

prints0

if(s=="

EOF"

)|(s==s0):

state=False

else:

force=float(s[1])

eee=float(s[0])/100.0

sss=force/area

test_force.append(force)

engineer_strain.append(eee)

engineer_stress.append(sss)

true_strain.append(log(1.0+eee))

true_stress.append(sss*(1.0+eee))

plastic_strain.append(log(1.0+eee)-sss*(1.0+eee)/E_modulus)

f.close()

##########################################################3

simu_strain=[]

simu_P_strain=[]

simu_triax=[]

simu_force=[]

simu_E=204323.0

simu_little=str(int(little)+3)

simu_name="

New_pass"

+simu_little+"

test.dat"

print'

referto'

+simu_name

simu_f=open(simu_name,'

simu_state=True

s0=simu_f.readlines()

s0=s0[-1]

simu_f.seek(0)

simu_s1=simu_f.readline()

whilesimu_state:

simu_s2=simu_f.readline()

simu_s2=re.sub('

simu_s2)

simu_s2=re.split('

if(simu_s2=="

)|(simu_s2==s0):

simu_state=False

printsimu_s2

s_force=float(simu_s2[5])

s_eee=float(simu_s2[2])

s_triax=float(simu_s2[3])

s_sss=s_force/area

simu_force.append(s_force)

simu_triax.append(s_triax)

simu_strain.append(s_eee)

simu_P_strain.append(log(1.0+s_eee)-s_sss*(1.0+s_eee)/simu_E)

simu_f.close()

##########################################################3 

nrows=3

sheet.write(0,nclown,'

sample'

sheet.write(0,nclown+2,name)

sheet.write(1,nclown,"

area"

sheet.write(1,nclown+2,area)

sheet.write(1,nclown+1,diameter)

sheet.write(1,nclown+3,"

E_modulus"

sheet.write(1,nclown+4,E_modulus)

sheet.write(2,nclown,"

E_strain"

sheet.write(2,nclown+1,"

E_stress"

sheet.write(2,nclown+2,"

T_strain"

sheet.write(2,nclown+3,"

T_stress"

sheet.write(2,nclown+4,"

PL_strain"

foriinrange(len(engineer_strain)):

sheet.write(nrows,nclown,engineer_strain[i])

sheet.write(nrows,nclown+1,engineer_stress[i])

sheet.write(nrows,nclown+2,true_strain[i])

sheet.write(nrows,nclown+3,true_stress[i])

sheet.write(nrows,nclown+4,plastic_strain[i])

nrows+=1

nclown+=5

#outputengineerstrainandstress

sheet1.write(0,nclown_e,'

file'

sheet1.write(0,nclown_e+1,myfile)

sheet1.write(0,nclown_e+2,"

sheet1.write(0,nclown_e+3,E_modulus)

sheet1.write(1,nclown_e,'

sheet1.write(1,nclown_e+1,name)

sheet1.write(1,nclown_e+2,'

sheet1.write(1,nclown_e+3,times)

sheet1.write(2,nclown_e,"

sheet1.write(2,nclown_e+1,"

sheet1.write(nrows,nclown_e,engineer_strain[i])

sheet1.write(nrows,nclown_e+1,engineer_stress[i])

nclown_e+=4

#outputtruestrainandstress

sheet2.write(0,nclown_t,'

sheet2.write(0,nclown_t+1,myfile)

sheet2.write(0,nclown_t+2,"

sheet2.write(0,nclown_t+3,E_modulus)

sheet2.write(1,nclown_t,'

sheet2.write(1,nclown_t+1,name)

sheet2.write(1,nclown_t+2,'

sheet2.write(1,nclown_t+3,times)

sheet2.write(2,nclown_t,"

sheet2.write(2,nclown_t+1,"

sheet2.write(nrows,nclown_t,true_strain[i])

sheet2.write(nrows,nclown_t+1,true_stress[i])

nclown_t+=4

#outputplasticstrainandstress

sheet3.write(0,nclown_p,'

sheet3.write(0,nclown_p+1,myfile)

sheet3.write(0,nclown_p+2,"

sheet3.write(0,nclown_p+3,E_modulus)

sheet3.write(1,nclown_p,'

sheet3.write(1,nclown_p+1,name)

sheet3.write(1,nclown_p+2,'

sheet3.write(1,nclown_p+3,times)

sheet3.write(2,nclown_p,"

sheet3.write(2,nclown_p+1,"

sheet3.write(nrows,nclown_p,plastic_strain[i])

sheet3.write(nrows,nclown_p+1,true_stress[i])

nclown_p+=4

#outputmodifiedplasticstrainandtruestress 

i_temp=1

sheet4.write(0,nclown_pm,'

sheet4.write(0,nclown_pm+1,myfile)

sheet4.write(0,nclown_pm+2,"

sheet4.write(0,nclown_pm+3,E_modulus)

sheet4.write(1,nclown_pm,'

sheet4.write(1,nclown_pm+1,name)

sheet4.write(1,nclown_pm+2,'

sheet4.write(1,nclown_pm+3,times)

sheet4.write(2,nclown_pm,"

sheet4.write(2,nclown_pm+1,"

Force"

running=True

ifrunning:

mincr=150

temp_e=(test_force[i]-test_force[i+mincr])/(plastic_strain[i]-plastic_strain[i+mincr])

iftemp_e>

400000.0:

i_temp=i

running=False

modifed_strain=engineer_strain[i]-engineer_strain[i_temp]

modifed_plastic_strain=log(1.0+modifed_strain)-engineer_stress[i]*(1.0+modifed_strain)/E_modulus

sheet4.write(nrows,nclown_pm,modifed_plastic_strain)

sheet4.write(nrows,nclown_pm+1,test_force[i])

##outputsimulationresult

sheet4.write(2,nclown_pm+2,"

sheet4.write(2,nclown_pm+3,"

sheet4.write(2,nclown_pm+4,"

TRIAX"

forjinrange(len(simu_P_strain)):

sheet4.write(nrows,nclown_pm+2,simu_P_strain[j])

sheet4.write(nrows,nclown_pm+3,simu_force[j])

sheet4.write(nrows,nclown_pm+4,simu_triax[j])

#######################nextfile(Testresult)

nclown_pm+=5

book.save('

material_treat.xls'

另一例子

importcsv

fromodbAccessimport*

fromabaqusConstantsimport*

filename=getInput('

PleaseinputtheODBfilename'

#下面这样都是我定义的字典或list,用来存保存提取数据的

elementArea={} 

elementConn={}

nodeArea 

={}

timeTP 

=[]

#下面可以看做一般的从odb文件中提取结果的步骤

#打开指定的odb文件

odb=openOdb(path=filename)

#得到assembly中所有的instance

inst=odb.rootAssembly.instances

#或取第一个instance中的所有单元,因为我这个odb里面只有一个instance

#.keys()方法可以获得一个list有所有的instance名字

elments=inst[inst.keys()[0]].elements

#下面一段对单元循环,得到每个单元的几个结点,然后记录下来

forelinelments:

label=el.label

nodes=el.connectivity

elementConn[label]=nodes

#节点

nodes=inst[inst.keys()[0]].nodes

forndinnodes:

label=nd.label

nodeArea[label]=0

#打开指定的step

st=odb.steps[odb.steps.keys()[0]]

#对指定step的某个特定场变量做循环

forvinst.frames[-1].fieldOutputs['

EVOL'

].values:

label=v.elementLabel

data=v.data

elementArea[label]=data

fork,vinelementArea.iteritems():

nds=elementConn[k]

forndinnds:

nodeArea[nd]+=0.25*v

#下面是提取每个frame中每个节点的NT11值

frames=st.frames 

forfrinframes:

nt11=fr.fieldOutputs['

NT11'

].values

time=fr.frameValue

sumTp=0

sumAr=0

forvainnt11:

label=va.nodeLabel

data=va.data

ifdata<

0:

area=nodeArea[label]

sumTp+=data*area

sumAr+=area

try:

mean=float(sumTp)/float(sumAr)

timeTP.append((time,mean))

except:

printfr.frameId

pleaeinputthecsvfile\nnametosave'

wr=csv.writer(file(filename,'

wb'

))

#这个把结果写进csv文件,只要一句,很简单,也可以在这一句之前写个表头

wr.writerows(timeTP)

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 高中教育 > 理化生

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1