每隔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()
Advertisements

About yhtian

I am an academic researcher working on Offshore Geotechnical Engineering. My blog aims to write down some work related trivial things and tricks about software, programming. It is basically a memo for me to back up some thoughts and small details. But I am more than happy if someone would visit and discuss.
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s