Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

Abaqus Script

Status
Not open for further replies.

montocristo85

Civil/Environmental
Apr 24, 2015
4
Hello,

I would like to homogenize the stress over a region in Abaqus by dividing the sum of stress on each element multiplied by its volume by the volume of all elements: Stress average = Sum (Stress (element)*volume (element))/Sum (volume (element))

For that, I wrote an Abaqus script in Python, in which I defined a new stress data (say: myS11 for exemple = S11 x volume of element). When I run the script,I got an error message: 'KeyError: S'. Beside that, when I opened the odb file, a new fieldOutput: myS11 had been created on each element but its values are set to zero.

I am not a specialist of python, so I could not understand where did come the error?

Could you please help me to check out the script included herein. Thank you very much!
Ducan

import sys, getopt, os, string
import math
from odbAccess import *
from abaqusConstants import *

odbPath = "D:\ho\Desktop\Abaqus Script\M1.odb"
odb = session.openOdb(name=odbPath,readOnly=FALSE)
# retrieve steps from the odb
grout_instance = odb.rootAssembly.instances['COULIS_SMOOTH-1']
numElem = len(grout_instance.elements)
keys = odb.steps.keys()
for stp in keys:
step = odb.steps[stp]
# retrieve frames from the odb
frameRepository = step.frames
numFrames = len(frameRepository)
for fr in range(0,numFrames):
frame=step.frames[fr]
print 'Id = %d, Time = %f\n'%(frame.frameId,frame.frameValue)
# get fieldOutputs object
fo = frame.fieldOutputs
S = fo['S']
EVOL = fo['EVOL']
S_grout = S.getSubset(region=grout_instance, position=INTEGRATION_POINT,
elementType='CAX3')
EVOL_grout = EVOL.getSubset(region=grout_instance)
myStress_data = {} #Declaration of my New stress Data
# Loops over elements to get stpress S11 and Volume
for i in range(0,len(S_grout.values)):
evol= EVOL_grout.values.data
a = (S_grout.values.data[0])*evol
elemId=S_grout.values.elementLabel
myStress_data.setdefault(elemId,[]).append(a)
# Append
elementLabels = []
elementData = []
for key in sorted(myStress_data.iterkeys()):
elementLabels.append(key)
elementData.append(myStress_data[key])
myS11 = frame.FieldOutput(name='myS11',
description='my Principle stpress S11',
type=SCALAR)
myS11.addData(position=INTEGRATION_POINT,
instance=grout_instance,
labels=elementLabels,
data=elementData)
odb.save()
odb.close()
 
Replies continue below

Recommended for you

from abaqusConstants import *
With that S is a constant. I wouldn't use it also as a variable.
 
Could you please explain more preciously. Because when I changed the S variable (S=fo['S'], to Sfield=fo['S']), It could not help.
Many thanks !
Duc an
 
Did you made that change everywhere where you've used that variable?
Which line is mentioned with the key error?
 
Something usefull is to debug your code line by line. You can do this from the abaqus PDE. Or also you can copy and paste line by line of your code in the Kernel Command Line at the bottom of the window of abaqus CAE (you can see it cliking on the >>> icon).
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor