30.12.08

每隔100秒从ABAQUS结果文件中取出位移、内力的PYTHON代码

#extract displacement, section force from ABAQUS ODB file every 100s and write to files

import odbAccess
odb = session.openOdb('walk.odb')
elemset = odb.rootAssembly.instances['PART-1-1'].elementSets['BEAMELEM']
Pipenode = odb.rootAssembly.instances['PART-1-1'].nodeSets['PIPENODE']
i = 0
OutDispfile = open('Disp.txt','w+')
OutDispfile.write("Node ")
OutDispfile.write("x disp ")
OutDispfile.write("y disp ")
OutDispfile.write("z disp\n")
OutForcefile = open('SF.txt','w+')
OutForcefile.write("Elem ")
OutForcefile.write("SF1 ")
OutForcefile.write("SF2 ")
OutForcefile.write("SF3\n")
while (i<=7700):
    timeframe = odb.getFrame(i)
    dispp = timeframe.fieldOutputs['U']
    for v in dispp.values:
        print 'Node label =', v.nodeLabel
        OutDispfile.write(str(v.nodeLabel))
        OutDispfile.write(" ")
        print 'x disp =', v.data[0]
        OutDispfile.write(str(v.data[0]))
        OutDispfile.write(" ")
        print 'y disp =', v.data[1]
        OutDispfile.write(str(v.data[1]))
        OutDispfile.write(" ")
        print 'z disp =', v.data[2]
        OutDispfile.write(str(v.data[2]))
        OutDispfile.write("\n")
    inforce = timeframe.fieldOutputs['SF']
    inforce = inforce.getSubset(region=elemset)
    for f in inforce.values:
        print 'Elem label =', f.elementLabel
        OutForcefile.write(str(f.elementLabel))
        OutForcefile.write(" ")
        print 'sf1 =', f.data[0]
        OutForcefile.write(str(f.data[0]))
        OutForcefile.write(" ")
        print 'sf2 =', f.data[1]
        OutForcefile.write(str(f.data[1]))
        OutForcefile.write(" ")
        print 'sf3 =', f.data[2]
        OutForcefile.write(str(f.data[2]))
        OutForcefile.write("\n")
    i = i + 100
OutDispfile.close()
OutForcefile.close()
odb.close()

没有评论: