Abaqus Script
Abaqus Script
(OP)
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
http://files.engineering.com/getfile.aspx?folder=e...
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[i].data
a = (S_grout.values[i].data[0])*evol
elemId=S_grout.values[i].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()
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
http://files.engineering.com/getfile.aspx?folder=e...
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[i].data
a = (S_grout.values[i].data[0])*evol
elemId=S_grout.values[i].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()





RE: Abaqus Script
With that S is a constant. I wouldn't use it also as a variable.
RE: Abaqus Script
Many thanks !
Duc an
RE: Abaqus Script
Which line is mentioned with the key error?
RE: Abaqus Script