Retrieve stresses on GaussPoint

Post Reply
gaetano_cmr
Posts: 7
Joined: Sat Sep 10, 2022 2:28 pm

Retrieve stresses on GaussPoint

Post by gaetano_cmr » Tue Dec 06, 2022 1:44 pm

Dear STKO support,

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

but I got this message:

Code: Select all

Cannot evaluate the virtual results due to the following errors:
MpcOdbElementalResultWithField: Result is NULL
I'm following one of your webinars (https://www.youtube.com/watch?v=TrHhvJ8L9ao) but without success.
Where the error could be?

STKO Team
Posts: 1979
Joined: Tue Oct 29, 2019 8:45 am

Re: Retrieve stresses on GaussPoint

Post by STKO Team » Wed Dec 07, 2022 10:37 am

The error is saying that the result you requested is null, i.e. it does not exist in your MPCO database.
Did you record it?

gaetano_cmr
Posts: 7
Joined: Sat Sep 10, 2022 2:28 pm

Re: Retrieve stresses on GaussPoint

Post by gaetano_cmr » Thu Dec 08, 2022 9:39 am

Yes I did, I’m able to plot it using “data chart” or displaying it in the post-processor GUI.
Don’t know what I’m doing wrong in the script :/

STKO Team
Posts: 1979
Joined: Tue Oct 29, 2019 8:45 am

Re: Retrieve stresses on GaussPoint

Post by STKO Team » Wed Dec 14, 2022 11:45 am

Could you please make a screenshot of your element results?:
ele_res.png
ele_res.png (45.28 KiB) Viewed 975 times
Do you have a result that starts with this "material.stress (Volume; 3 Components {σ11,σ22,σ12};S)"?

gaetano_cmr
Posts: 7
Joined: Sat Sep 10, 2022 2:28 pm

Re: Retrieve stresses on GaussPoint

Post by gaetano_cmr » Fri Dec 16, 2022 9:08 am

Yes, I have it in my model as result; here the screenshot of my elements recorders:
Attachments
immagine_2022-12-16_100838598.png
immagine_2022-12-16_100838598.png (15.95 KiB) Viewed 955 times

STKO Team
Posts: 1979
Joined: Tue Oct 29, 2019 8:45 am

Re: Retrieve stresses on GaussPoint

Post by STKO Team » Fri Dec 16, 2022 2:46 pm

There is a missing white-space at the end ";<missing_here>S"

Nolaraj
Posts: 2
Joined: Thu Jul 06, 2023 9:19 am

Re: Retrieve stresses on GaussPoint

Post by Nolaraj » Sat Sep 16, 2023 5:12 am

I want to derive shear stress vs strain plot from SSPbrick element with PIMY material property assigned for soil. I had used the code below but couldnot get the stress strain for PIMY material but it had efficiently extracted for elasticISotrophic material assigned to foundation which similarly been modelled with SSPbrick element. How could I solve this ?
Note: I had used custom result with stress and strain entity for complete model region in MPCOrecorder.
Attachments
Code.zip
(2.07 KiB) Downloaded 4 times

STKO Team
Posts: 1979
Joined: Tue Oct 29, 2019 8:45 am

Re: Retrieve stresses on GaussPoint

Post by STKO Team » Mon Sep 18, 2023 7:50 am

It's because the PIMY material gives you a 7-components stress vector (the first 6 are stress components, the last one is an internal variable).

Therefore this line is not working as the result has a different name (7 instead of 6). Change this string

Code: Select all

stress = db.getElementalResult('stress (Volumes; 6', match=MpcOdb.Contains)

Post Reply