Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

Averaging Threshold Abaqus_Python 1

Status
Not open for further replies.

ZIlyas

Mechanical
Aug 3, 2012
7
Hello Everybody

I am a student and as a part of my project i.e. Simulation of Shear Cutting on Abaqus™ CAE. I am running a Dynamic/Explicit analysis and then using a Python script to export data to rpt and excel. I am exporting VonMises, Stress Components and Reaction Forces.
My question is how can I change the "averaging threshold" value to 75% or 100% using the script. I know I can change it from result options.

I saw abaqus.rpy file and found this command:
Python:
session.viewports['Viewport: 1'].odbDisplay.basicOptions.setValues(averagingThreshold=30)

However, when I tried to add this to script just in the start, nothing happened.

Python:
myViewport = session.Viewport(name='3DShearCutting')
session.viewports['3DShearCutting'].odbDisplay.basicOptions.setValues(averagingThreshold=75.0)

I still get "unaveraged" values.

It is also possible that I am not adding to the correct postion in my script.

Please suggest me a possible remedy. Thanks in advance

Ilyas
 
Replies continue below

Recommended for you

You have to set 'True' first.
session.viewports['Viewport: 1'].odbDisplay.basicOptions.setValues(
averageElementOutput=True)
session.viewports['Viewport: 1'].odbDisplay.basicOptions.setValues(
averagingThreshold=25)
Also, you should take the stresses at integration points instead of averaging. This might depend on what you want to do with ofcourse :).
 
Hello SDEBOCK

Thanks for your help, but it still doesn't work. I have tried alot. [sad] I dont know where to place this averageElementOutput=True statement. I am attaching my code, Please have a look at it and suggest me accordingly.
Code:
##                           -- I N P U T - F I L E --
##--------------------------------INFO--------------------------------
##This python script writes a text file containing maximum values of
##each  requested variable for the odb mentioned in fileName variable.
##Following consideration must be taken to run this script.
##  1-This file should be placed in the abaqus temp folder i.e. the
##  same folder where odb file resides.
##  2-Enter the odb name without extention (.odb)
##  
##The Output of this script will be a text file (*.txt) in the
##same folder containing the maximum values and element_labels.
##
##-------------------------------------------------------------------- Name des zu analysierenden Odbs ohne Endung

###Systemdateien importieren
from abaqus import *
from abaqusConstants import *
import visualization
import odbAccess
import fileinput
import sys, os
from viewerModules import *
from odbAccess import *
from odbMaterial import *
from odbSection import *


#Viewport anlegen
myViewport = session.Viewport(name='3DShearCutting')

#session.viewports['Viewport: 1'].odbDisplay.basicOptions.setValues(averageElementOutput=True)
#session.viewports['Viewport: 1'].odbDisplay.basicOptions.setValues(averagingThreshold=75.0)

session.viewports['3DShearCutting'].makeCurrent()
session.viewports['3DShearCutting'].maximize()

# set working directory
workdir = os.getcwd()+'/'
fileName = '3D10'
#analyzed odb-file
myPath = str(workdir)+str(fileName)+'.odb'
#Output-Database oeffnen
myOdb = openOdb(path=myPath)
#zu analysierenden Step festlegen
Step=myOdb.steps['Forming']

#spaeteres Ausgabefile anlegen und oeffnen
file = open(str(workdir)+'Punch_'+fileName+'.txt', 'w')

# Ueberschrift in File
print >> file, 'Maximum Stresses (vonMises, sigma11, sigma22, sigma33) and Reaction Forces (in x,y and z direction) over all Frames  \n===============================================================================================\n'
print >> file, 'Datenbasis: %s\n\n' % (fileName)

print >> file, 'Frame\tStep-Time\tVM-Stress\tEL-lab\tsigma11\t\tEL-lab\tsigma22\t\tEL-lab\tsigma33\t\tEL-lab\t sumRF-x\t  sumRF-y\t  sumRF-z\n'



# number of Frames auslesen
numFrames=len(Step.frames)

#for m in range(0, numFrames-1):
m = 5

# Frame-Auswahl
Frame = myOdb.steps['Forming'].frames[m]

#enthaelt alle Stress-Daten vom Letzen Frame
stress = Frame.fieldOutputs['S']

#enthaelt die RF Daten vom letzten Frame
rForce = Frame.fieldOutputs['RF']
Punch = str('ABHACKMESSER_5'+chr(176)+'-1,5MM-1')
# Auswahl der Sets
#element
stempelEl = myOdb.rootAssembly.instances[str(Punch)].elementSets['ABHACKMESSER']
#node
stempelNode = myOdb.rootAssembly.instances[str(Punch)].nodeSets['ABHACKMESSER']
Eleset = str('ABHACKMESSER_5'+chr(176)+'-1,5MM-1')+'.ABHACKMESSER'

#Stress-Daten vom Element-Set auslesen
#stempelStressEl = stress.getSubset(region=stempelEl, position=INTEGRATION_POINT)
stempelStressEl = stress.getSubset(region=stempelEl, position=ELEMENT_NODAL)

#ReactionForce-Daten vom Node-Set auslesen
rForceStempel = rForce.getSubset(region=stempelNode, position=NODAL)

#Variable, die alle Stress-Daten enthaelt kreieren
valuesStempelStressEl = stempelStressEl.values
session.viewports['3DShearCutting'].odbDisplay.basicOptions.setValues(
    regionBoundaries=ELEMENT_SET, userRegions=(
    str(Eleset), ), averagingThreshold=50)
#Variable, die alle ReactionForce-Daten enthaelt kreieren
valuesrForceStempel = rForceStempel.values

# Stress Vorbelegung der MaxWerte
ELVMmax = 0
VMmax = -1
sig11max = -1
sig22max = -1
sig33max = -1
ELsig11max = 0
ELsig22max = 0
ELsig33max = 0
#maxframe = 0
#maxtime = 0


# Stress Schleife zum MinMax finden (Zaehlvariable: i)
for i in valuesStempelStressEl:
        #a = m
        #b = Frame.frameValue
        if i.mises > VMmax:
                VMmax = i.mises
                ELVMmax = i.elementLabel
                #maxframe = a
                #maxtime = b
        else:
                VMmax = VMmax
                ELVMmax = ELVMmax

        if i.data[0] > sig11max:
                sig11max = i.data[0]
                ELsig11max = i.elementLabel
        else:
                sig11max = sig11max
                ELsig11max = ELsig11max

        if i.data[1] > sig22max:
                sig22max = i.data[1]
                ELsig22max = i.elementLabel
        else:
                sig22max = sig22max
                ELsig22max = ELsig22max

        if i.data[2] > sig33max:
                sig33max = i.data[2]
                ELsig33max = i.elementLabel
        else:
                sig33max = sig33max
                ELsig33max = ELsig33max

# Reaction Force Vorbelegung der Werte
sumRFx = 0
sumRFy = 0
sumRFz = 0

# Reaction Force Schleife zum Aufsummieren (Zaehlvariable: k)
for k in valuesrForceStempel:
        sumRFx = sumRFx + k.data[0]
        sumRFy = sumRFy + k.data[1]
        sumRFz = sumRFz + k.data[2]

# print in file
print >> file, '%2d\t%10.4e\t%10.4f\t%4d\t%10.4f\t%4d\t%10.4f\t%4d\t%10.4f\t%4d\t%10.4f\t%10.4f\t%10.4f' % (m , Frame.frameValue, VMmax, ELVMmax, sig11max, ELsig11max, sig22max, ELsig22max, sig33max, ELsig33max, sumRFx, sumRFy, sumRFz)
#Ausgabefile schliessen
file.close()

Please tell me where shall I place the statement to turn on averaging.

Waiting for a positive reply.
 
So, few remarks:

you will never get nodal averaging for RF, just because there is nothing to average (reaction forces are calculated at the nodes).

For stress, it is calculated at the integration points of elements, and extrapolated to nodes for each element.
Then, you can average the value at that node, for all the connecting elements (which is what you see by default in the viewport because it looks nice and smooth even if your mesh is shit).

What you are asking in your code is the "Element Nodal", "position=ELEMENT_NODAL" which is NOT averaged, because it gives the value for each node of each element.
If you change it to "NODAL", you will either get: 1 value if you average
or 1,2,3,4 ... values if you don't (depending on the number of elements bordering the node).

So IF you want the one averaged value, change the position to "nodal" and put

session.viewports['3DShearCutting'].odbDisplay.basicOptions.setValues(
averageElementOutput=True)
session.viewports['3DShearCutting'].odbDisplay.basicOptions.setValues(
regionBoundaries=ELEMENT_SET, userRegions=(
str(Eleset), ), averagingThreshold=50)
 
So sdebock, thanks for your concern but The problem continues :(

Actually I dont want to average Force (as you rightly said, that's not possible). After your helpful comment, I am now getting averaged(for a given averagingThreshold = value) VonMises stress values in viewport on GUI, but the values in the text file are still unaveraged, I want to write Max.SMises(averaged), Max.Stress Averaged(S11,S22,S33) for each frame in a text file and then plot them for different geometric parameters.

If you could tell me a formula (how in the background) to calculate averaged Stress, I will implement in myself.

Thanks alot for your prompt responses.
 
That's some wierd stuff then, in the small example i use it's working.
the easiest for you would be to:

1. open your odb in CAE
2. set an avering threshold in odb options
3. create XY data -> Stress (mises) -> unique nodal -> select a point -> plot
4. report -> xy -> apply

then check the .rpt file, it should have averaged values.
If that works, you can just c/p from the .rpy file into your script.

As far as I know, the averaging is a simple average with equal weights for each element (or maybe it's by element volume). The percentage you set is a cutoff, if the difference between values for the same nodes (comming from different elements) is higher than the %, abaqus will not average, so maybe that's the issue in your case.

If it doesn't average with the default 75%, I would be concerned about my mesh.
 
Thanks sdebock, it didn't work 100% for me but atleast gave me a step forward to think and improvise a solution. What I found as a solution (not very impressive) but works for me is that

I am writing .rpt file for each frame using python script and then using a VBA script to import the Maximum Values into Excel Sheet and plotting them on a chart.

Hope this solution works for someone with a similar problem.

Goodluck and Bye
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor