Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations GregLocock on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Python Script File( Abaqus customised output) 1

Status
Not open for further replies.

hiwiansys

Mechanical
May 4, 2007
23
Hi All,

I have written a simple python program which will help me extract the coordinates and displacement output for only the nodeset I am interested in and writes it into a text file.
Unfortunately it is giving me an error while I run the below program though I have used the right syntax

Error message:
In line 12 (coordinatefield=odb.steps['Step_Load'].frames[1].fieldOutputs['COORD'])
Key Error : 'COORD'

PS: if anyone of you can help me figure out what is wrong in the above code, it will be really helpful.

I thank you in advance

Hoping to hear from some one soon.

-Anjali


PROGRAM:

#-----------------------------OUTPUT.PY-------------------------------------------------------------
# output.py is a python programme which reads the required field output data from an
# output data base and writes it into a text file
#----------------------------------------------------------------------------------------------------------
from odbAccess import *
from textRepr import *
from abaqusConstants import *
import odbAccess
odb=openOdb(path='shear.odb')
n='NODESET1'
first_node=odb.rootAssembly.nodeSets['NODESET1']
coordinatefield=odb.steps['Step_Load'].frames[1].fieldOutputs['COORD']
coord1=coordinatefield.getSubset(region=first_node)
coordvalues1=coord1.values
disp1file=open('disp1.txt','a')
for v in dispvalues1:
disp1file.write(str("NODE=")+str(v.nodeLabel)+"\n")
for v in coordvalues1:
disp1file.write(str("COORDINATES=")+str(v.data[0])+","+str(v.data[1])+","+str(v.data[2])+"\n")
if n == 'NODESET1':
i=1
m=2
while i<=m:
first_node=odb.rootAssembly.nodeSets['NODESET1']
displacementfield=odb.steps['Step_Load'].frames.fieldOutputs['U']
disp1=displacementfield.getSubset(region=first_node)
dispvalues1=disp1.values
#disp1file=open('disp1.txt','a')
for v in dispvalues1:
#disp1file.write(str("NODE"))
#disp1file.write(str(v.nodeLabel)+"\n")
print (v.data[0], v.data[1], v.data[2])
disp1file.write(str("DISPLACEMENTS=")+str(v.data[0])+","+str(v.data[1])+","+str(v.data[2])+"\n")
i+=1
 
Replies continue below

Recommended for you

Make sure you have requested output for COORD before you run the analysis.
 
Hi Brep,

Thank you for your reply. I have requested COORD output in my input file along with displacement output. Do you think soemthing is wrong with the python script I have written? It said Key error in error message when i tried running the program.
 
To start debugging, try a print statement before your coordinateField line in your script. Something like this:

print odb.steps['Step_Load'].frames[1].fieldOutputs

This will list all the field outputs you have in the frame. Make sure COORD is in there... (A key error message means that you tried to reference something in the list that did not exist.)
 
Thank you brep,

You were right. COORD is not a field output variable. Unfortunately I could not find out from scripting manual in abaqus as to how to get the COORDINATES data for any particular node.Could you possibly help me with that?

Regards
Anjali
 
hiwiansys ,

If you want to get the coordinates of the UNDEFORMED mesh nodes then you get that from you node object (i.e. node.coordinates). However if you want the displacement of the nodes than I believe the fieldOutput value you want is "U".

There is an example that illustrates the basics of this. The title of the section is "9.5 Reading from an output database". There is also an example for reading the data from only a set. The first section of the code grabs the displacement values of the DEFORMED mesh nodes in a particular set, the second section of code gets the coordinates of the UNDEFORMED mesh nodes.

Here is some code from a script that I just wrote a few days ago that does essentially the same thing. I hope this helps.

<FIRST SECTION>
assembly=theODB.rootAssembly
theInstance=theODB.rootAssembly.instances['TMPLENS-1']

#print "theInstance=",theInstance
lastFrame=theODB.steps['coolDown'].frames[-1]
theDisplacement=lastFrame.fieldOutputs['U']
dispValues=theDisplacement.values

#print "nodes sets=", assembly.nodeSets.keys()

upperNodes=theInstance.nodeSets['THEUPPERSURFACESET']
print "found nodeset=",upperNodes
#lowerNodes=theInstance.nodeSets['THELOWERSURFACESET']

upperNodeDisplacement=theDisplacement.getSubset(region=upperNodes)
#lowerNodeDisplacement=theDisplacement.getSubset(region=lowerNodes)

upperNodeDisplacementValues=upperNodeDisplacement.values

<SECOND SECTION>
outputFile.writelines('Values for the UNDFEFORMED UPPER SURFACE NODES\n')
for node in upperNodes.nodes:
outputFile.writelines( '%s,%s\n' % (node.label,node.coordinates))
 
Thank you Danstro,
I shall try that and let you know about the results.

Thanks again
Anjali
 
Hi Danstro,

I altered my script as per your suggesstion. Unfortunately I still get the error message.

Script:
from odbAccess import *
from textRepr import *
from abaqusConstants import *
import odbAccess
odb=openOdb(path='shear.odb')
n='NODESET1'
first_node=odb.rootAssembly.nodeSets['NODESET1']
displacementfield=odb.steps['Step_Load'].frames[1].fieldOutputs['U']
disp1=displacementfield.getSubset(region=first_node)
dispvalues1=disp1.values
disp1file=open('disp1.txt','a')
for v in dispvalues1:
disp1file.write(str("NODE=")+str(v.nodeLabel)+"\n")
disp1file.writelines('COORDINATES'\n')
for node in first_node.nodes:
disp1file.writelines('%s\n' % (node.coordinates))


Error :
AttributeError: 'OdbMeshNodeArray' object has no attribute 'coordinates'


Kindly help me with this problem.

Thank you

Regards

Anjali


 
I think one of the problems is in your definition of 'first_node'. In my script this is of the instance of the part.

From my script:
theInstance=theODB.rootAssembly.instances['TMPLENS-1']
upperNodes=theInstance.nodeSets['THEUPPERSURFACESET']

then you loop through the nodes in the instance

for node in upperNodes.nodes:
outputFile.writelines( '%s,%s\n' % (node.label,node.coordinates))

There may be others. I am still new to both Python and Abaqus so it takes me a while to get through these.

Dan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor