×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Abaqus Script

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()

RE: Abaqus Script

from abaqusConstants import *
With that S is a constant. I wouldn't use it also as a variable.

RE: Abaqus Script

(OP)
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

RE: Abaqus Script

Did you made that change everywhere where you've used that variable?
Which line is mentioned with the key error?

RE: Abaqus Script

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).

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources