Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

ERROR on Python Script File

Status
Not open for further replies.

GLucas9829

Mechanical
Mar 10, 2016
4
Hi All,

I am using a Matlab algoritm to execute the batch_file to do some simulations on abaqus. I am using the python program to help me extract the displacement output for only the nodeset I am interested in (which are 21 nodes) 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.

P.S: I am using a loop on matlab program to do some simulations in sequence. Some of the simulations is doing well, but in some them the error apears.

Error message:

KeyError: Step-1
File "Out_Node1.py", line 8, in <module>
lastFrame = odb.steps['Step-1'].frames[-1]

Abaqus Error: cae exited with an error.

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.

-George


PROGRAM:

#-----------------------------Out_Node1.py-------------------------------------------------------------
# Out_Node1.py is a python programme which reads the required field output (displacement of 21 nodes) data from an
# output data base and writes it into a text file
#----------------------------------------------------------------------------------------------------------
################################################################################
from odbAccess import *

#open abaqus output database
odb = openOdb(path='InputFile.odb')

# Create a variable that refers to the last frame of the first step.
lastFrame = odb.steps['Step-1'].frames[-1]

# Create a variable that refers to the displacement 'U' in the last frame of the first step.
displacement = lastFrame.fieldOutputs['U']

# Create a variable that refers to the node set 'All-Nodes'. The set is associated with the part instance 'PART-1-1'.
center = odb.rootAssembly.instances['PART-1-1'].nodeSets['NODE-1']

# Create a variable that refers to the displacement of the node set in the last frame of the first step.
centerDisplacement = displacement.getSubset(region=center)

# Finally, print some field output data from each node in the node set.
f = file("DisplacementPostInflation.txt", "w")
my_array = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21] # NODES POSITION (EXCEPTO THE 1ST ONE)
i = 0
for v in centerDisplacement.values:
i = i + 1
f.write (' %s, %16.8E\n'%(my_array,v.data[1])) # 0 = x, 1 = y e 2 = z
# Time must be times total value of pressure, load, etc.
# f.write(' 0000 , 0.000000000000')
f.close()
 
Replies continue below

Recommended for you

Mustaine3, thanks for reply

do you mean in the .inp File?

Yes, a named it as Step-1.

** STEP: Step-1
**
*Step, name=Step-1, nlgeom=YES, inc=50
*Static
0.025, 1., 1e-05, 0.025
** 0.1,1.0,,.1


I am confused, because the simulations go well when I use meshes with less than 1000 nodes. However, when I use meshes with more than 5000 nodes, this error appears.

George
 
Let's assume your script and your analysis are ok. More nodes usually mean longer runtime and larger files.
How is you script started? When it is started automatically from Matlab, then you should check if you analysis is already finished at that time.
Or you odb is large and the openOdb command is not completely executed when the next command comes. Check that by importing the time module and adding time.sleep(3) after the openOdb command.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor