I'm facing a problem retreaving stresses on specific gausspoint in my STKO model.
I load the postprocessor results and I tryed to retrieve "σ22" using this script:
Code: Select all
from PyMpc import *
from PyMpc import MpcOdbVirtualResult as vr
from time import sleep
import traceback
import numpy as np
from time import sleep
import traceback
from PySide2.QtCore import (
QObject,
Signal,
Slot,
QCoreApplication,
QTimer,
QThread,
QEventLoop,
)
from PySide2.QtWidgets import (
QWidget,
QDialog,
QSizePolicy,
QVBoxLayout,
)
################################################################################
# clear terminal
App.clearTerminal()
# get document
doc = App.postDocument()
# get first database
if len(doc.databases) == 0:
raise Exception("You need a database with ID = 1 for this test")
db = doc.getDatabase(1)
# create evaluation options
# here we want to extract data for all steps of the last stage
all_stages = db.getStageIDs()
last_stage = all_stages[-1]
all_steps = db.getStepIDs(last_stage)
opt = MpcOdbVirtualResultEvaluationOptions()
opt.stage = last_stage
# signals
finished = Signal()
# gauss result
result_x = db.getElementalResult("material.stress (Volume; 3 Components {σ11,σ22,σ12};S)", match = MpcOdb.Contains)
row = MpcOdbResultField.gauss(1130, 1) # the gauss field object is the row identifier in the result field
num_steps = len(all_steps)
x = []
for i in range(num_steps):
opt.step = all_steps[i]
field_x = result_x.evaluate(opt)
x.append(field_x[row, 0])
Code: Select all
Cannot evaluate the virtual results due to the following errors:
MpcOdbElementalResultWithField: Result is NULL
Where the error could be?