Search code examples
pythonscientific-computingabaquspost-processing

Python script in abaqus error: 'numpy.ndarray' object has no attribute 'setValues'


Basically, I am trying to output a report with the two data x0 and x1. I followed the Abaqus .rpy format and tried to rename the calculated variable, but it is giving me this error.

  • AttributeError: 'numpy.ndarray' object has no attribute 'setValues' line 72, in xy2.setValues(sourceDescription=' s + "U3 PI: PLATE-1 N: 40402 NSET RP-1"')

(The line number is different than the one provided in the code below.)

from abaqus import *
from abaqusConstants import *
from caeModules import *
import random  
import mesh
import time
import odbAccess
import visualization


session.XYDataFromHistory(name='U3 PI: PLATE-1 N: 40402 NSET RP-1', odb=odb, 
outputVariableName='Spatial displacement: U3 PI: PLATE-1 Node 40402 in NSET RP', 
steps=('compression', ), __linkedVpName__='Viewport: 1')
xy1 = session.xyDataObjects['U3 PI: PLATE-1 N: 40402 NSET RP-1']
xy2 = s+xy1
xy2.setValues(sourceDescription=' s + "U3 PI: PLATE-1 N: 40402 NSET RP-1"')
tmpName = xy2.name
session.xyDataObjects.changeKey(tmpName, 'XYData-1')
x0=session.XYDataFromHistory(name='RF3 PI: PLATE-1 N: 40402 NSET RP-1', odb=odb, 
outputVariableName='Reaction force: RF3 PI: PLATE-1 Node 40402 in NSET RP', 
steps=('compression', ), __linkedVpName__='Viewport: 1')
x1 = session.xyDataObjects['XYData-1']
session.writeXYReport(fileName='Thickness_Estimation.rpt', xyData=(x0, x1), appendMode=OFF) 

Kindly let me know how to overcome this issue.


Solution

  • Found an answer to this. I just needed to convert xy2 into an XY dataObject.

    xy1 = session.xyDataObjects['U3 PI: PLATE-1 N: 40402 NSET RP-1']
    xy2Data=[]
    for datapoint in xy1.data:
      xy2Data.append([datapoint[0], datapoint[1]+s])
    
    xQuantity = visualization.QuantityType(type=TIME)
    yQuantity = visualization.QuantityType(type=DISPLACEMENT)
    session.XYData(name='Distance', data=xy2Data, 
    sourceDescription='s+U3', axis1QuantityType=xQuantity, 
    axis2QuantityType=yQuantity, )
    xy2 = session.xyDataObjects['Distance']
    x0=session.XYDataFromHistory(name='RF3 PI: PLATE-1 N: 40402 NSET RP-1', 
    odb=odb, 
    outputVariableName='Reaction force: RF3 PI: PLATE-1 Node 40402 in NSET RP', 
    steps=('compression', ), __linkedVpName__='Viewport: 1')
    
    session.writeXYReport(fileName='Load_Caliper.rpt', xyData=(x0,xy2), 
    appendMode=OFF)