Max stress from ODB

570 Views Asked by At

I'm new in programming and I need to write a code that create an odb that visualize max value of six field output of a single step. For every single node I would like represent the max value of each field output. Now I've created a code which results in this this error:

myFieldOutput.addData(position=INTEGRATION_POINT, instance=instance1, data=maxStress)

omu_PrimArray from sequence failed - dimensions.

This is the code:

from abaqus import *
from abaqusConstants import *
import visualization
myViewport = session.Viewport(name='Max_Stess',
origin=(10, 10), width=150, height=100)
# Open the tutorial output database.
myOdb = visualization.openOdb(path='PROVA_04_10.odb', readOnly=False)
# Associate the output database with the viewport.
myViewport.setValues(displayedObject=myOdb)
instance1 = myOdb.rootAssembly.instances['MODIFICA_FUNZIONANTE']
# Create variables that refer to the first steps.
firstStep = myOdb.steps['sigma_equivalenti']

frame = firstStep.frames[-1]
#creo nuovo step

# lettura degli stress dallo step sigma

sigma_eq_1 = frame.fieldOutputs['sigma_eq_1']
sigma_eq_2 = frame.fieldOutputs['sigma_eq_2']
sigma_eq_3 = frame.fieldOutputs['sigma_eq_3']
sigma_eq_4 = frame.fieldOutputs['sigma_eq_4']
sigma_eq_5 = frame.fieldOutputs['sigma_eq_5']
sigma_eq_6 = frame.fieldOutputs['sigma_eq_6']

#calcolo del vettore degli sforzi massimi

maxStress=[]
for i in range(len(sigma_eq_1.values)):
   v1=sigma_eq_1.values[i]
   v2=sigma_eq_2.values[i]
   v3=sigma_eq_3.values[i]
   v4=sigma_eq_4.values[i]
   v5=sigma_eq_5.values[i]
   v6=sigma_eq_6.values[i]
   maxStress.append((max(v1,v2,v3,v4,v5,v6),)) #max(valori)


myFieldOutput = frame.FieldOutput(name='tensioni_max',description='calcolo delle tensioni massime', type=SCALAR)
myFieldOutput.addData(position=INTEGRATION_POINT, instance=instance1, data=maxStress)

#visualizzazione della variabile delle sigma massima sul programma
myViewport.odbDisplay.setPrimaryVariable(field=myFieldOutput,outputPosition=INTEGRATION_POINT)
myViewport.odbDisplay.display.setValues(plotState=(CONTOURS_ON_DEF,))
1

There are 1 best solutions below

0
On

You could use field argument to add the field output data as FieldOutput object. However, you should create the field data from already existing field outputs.
In your case, you could do the following:

  1. Access the field output (NOT the field output data), as you did correctly.
sigma_eq_1 = frame.fieldOutputs['sigma_eq_1']
sigma_eq_2 = frame.fieldOutputs['sigma_eq_2']
sigma_eq_3 = frame.fieldOutputs['sigma_eq_3']
sigma_eq_4 = frame.fieldOutputs['sigma_eq_4']
sigma_eq_5 = frame.fieldOutputs['sigma_eq_5']
sigma_eq_6 = frame.fieldOutputs['sigma_eq_6']
  1. Then, manipulate these field output data. You can do any feasible mathematical operation on these data, for ex. add, substract,etc. In this case, to find maximum value, we have specific command called maxEnvelope.
maxS = maxEnvelope([sigma_eq_1, sigma_eq_2, sigma_eq_3, sigma_eq_4, sigma_eq_5, sigma_eq_6])

Please note, this command takes list as an argument. And this command calculates the new field data at the same position where the original data is availble. In this case, it is available at Integration Point, hence it will be written at Integration Point.
3. Now, you could use field arugment to add field output data.

myFieldOutput = frame.FieldOutput(name='tensioni_max',description='calcolo delle tensioni massime', type=SCALAR)
myFieldOutput.addData(field=maxS[0])

P.S.: As you have imported visualization module as import visualization, you should use maxEnvelope method as visualization.maxEnvelope(...)