Is there anyway to plot excess pore water pressure ratio?

Hello! In this section we'll talk about the post processing module and the data visualization.
yuweihwang
Posts: 37
Joined: Wed Apr 29, 2020 4:54 am

Is there anyway to plot excess pore water pressure ratio?

Post by yuweihwang » Sun Sep 26, 2021 10:58 pm

Hello,

May I ask if it is possible to use Python API to plot the excess pore water pressure ratio for a surface color map?
excess pore pressure ratio = (pore pressure for each node-pore pressure for each node at the beginning)/vertical stress (e.g., Sigma_22)
Would it be possible to guide me on how to use Python API to get these results?

Many thanks for your help

marafini.f
Posts: 363
Joined: Fri Nov 13, 2020 1:52 pm

Re: Is there anyway to plot excess pore water pressure ratio?

Post by marafini.f » Mon Sep 27, 2021 7:00 am

Hi yuweihwang,

yes that is possible. You can check out these webinars.

#20 from Dr. Petracca https://www.youtube.com/watch?v=TrHhvJ8L9ao
and #21 from me https://www.youtube.com/watch?v=MJFf51Vi6ts

In both we discuss how to create virtual results from existing results in the postprocessor in STKO.
You can find the support scripts for these webinars here https://asdeasoft.net/?stkowebinars-for-opensees

What you need to do is create a virtual result with the existing results and add it to the database. There is an example called criticaldamage.py and the last two utils from my webinar were designed to plot an envelope of the results for different load combinations on a frame structure.

You can try to develop a script and we can help you if you find troubles with it.

Enjoy your modelling and programming
Francesca :geek:

yuweihwang
Posts: 37
Joined: Wed Apr 29, 2020 4:54 am

Re: Is there anyway to plot excess pore water pressure ratio?

Post by yuweihwang » Mon Sep 27, 2021 10:24 pm

Hi Marafini,

Thank you for your suggestion. I have created a python file attached.
Python_Script.rar
(987 Bytes) Downloaded 42 times
Here is my mpco file. (https://drive.google.com/file/d/1nVYQm- ... sp=sharing)

I am trying to compute the pore pressure at each node during the earthquake minus the pore pressure at the beginning.
But the code doesn't work, can you help me take a look?
Many thanks for your help,

Best,
Yu-Wei

marafini.f
Posts: 363
Joined: Fri Nov 13, 2020 1:52 pm

Re: Is there anyway to plot excess pore water pressure ratio?

Post by marafini.f » Tue Sep 28, 2021 4:35 pm

Dear Yu-Wei

try to edit this:

Code: Select all

from PyMpc import *
from PyMpc import MpcOdbVirtualResult as vr

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()  # get all model stages
last_stage = all_stages[-1]  # get the last stage (pushover)
first_stage = all_stages[0] # get the first stage
all_stage1_steps = db.getStepIDs(first_stage)
all_stage1_times = db.getStepTimes(first_stage)
all_steps = db.getStepIDs(last_stage)  # get all steps of the last stage
all_times = db.getStepTimes(last_stage)  # get all step times of the last stage

step = all_stage1_steps[-1]
InitialReactionForce = db.getNodalResult("Force", match = MpcOdb.Contains, time = vr.stageEnd(1))

App.processEvents()

# initialize the evaluation options with the last stage
ReactionForce = db.getNodalResult("Force", match = MpcOdb.Contains)

NewReactionForce = ReactionForce - InitialReactionForce
NewReactionForce.setDisplayName("NewReactionForce")
NewReactionForce.setComponentLabels(["Rx0", "Ry0", "Rz0"])

# add the new result to the database
db.addVirtualResult(NewReactionForce)
You don't need a loop nor any evaluation options.
Let me know how it goes.
Francesca

yuweihwang
Posts: 37
Joined: Wed Apr 29, 2020 4:54 am

Re: Is there anyway to plot excess pore water pressure ratio?

Post by yuweihwang » Tue Sep 28, 2021 8:17 pm

Hello Francesca,

Many thanks for your help. I appreciate it a lot!
May I ask you few more questions?

(1)May I ask you why this "time = vr.stageEnd(1)" refers to the initial state?

(2)If I want to run an if/else loop to set those negative values to equals zero, do you know how to do it?
After I get the pore pressure response for each node:
PWP = db.getNodalResult("Pressure", match = MpcOdb.Contains)
I am not sure how to run a if/else loop for this data. For example, Will PWP be a three-dimensional data frame?
If there's any example about this, I can try it!

Best,
Yu-Wei

marafini.f
Posts: 363
Joined: Fri Nov 13, 2020 1:52 pm

Re: Is there anyway to plot excess pore water pressure ratio?

Post by marafini.f » Wed Sep 29, 2021 8:47 am

(1)May I ask you why this "time = vr.stageEnd(1)" refers to the initial state?
stageEnd(1) means take the last step of the stage 1.
you can find more here
https://asdeasoft.net/stko-wiki/class_p ... esult.html
(2)If I want to run an if/else loop to set those negative values to equals zero, do you know how to do it?
After I get the pore pressure response for each node:
PWP = db.getNodalResult("Pressure", match = MpcOdb.Contains)
As for this question I did not get what you want to do. Do you want to set all negative values to 0? Or get the absolute value?

Francesca

yuweihwang
Posts: 37
Joined: Wed Apr 29, 2020 4:54 am

Re: Is there anyway to plot excess pore water pressure ratio?

Post by yuweihwang » Wed Sep 29, 2021 2:27 pm

Hello Francesca,

Yes, I want to set all the negative values to 0.

Best,
Yu-Wei

marafini.f
Posts: 363
Joined: Fri Nov 13, 2020 1:52 pm

Re: Is there anyway to plot excess pore water pressure ratio?

Post by marafini.f » Thu Sep 30, 2021 1:19 pm

You can use the max() method in the MpcOdbVirtualResult class.

For example, from the previous example, I made to show just positive reaction forces.

PositiveReaction = vr.max(NewReactionForce, 0)

You can use this method also with two compatible results to create an envelope.

Enjoy your modelling
Francesca :geek:

yuweihwang
Posts: 37
Joined: Wed Apr 29, 2020 4:54 am

Re: Is there anyway to plot excess pore water pressure ratio?

Post by yuweihwang » Thu Sep 30, 2021 7:28 pm

Hello Francesca,

Thank you for your suggestions. May I ask you few more questions?
In OpenSees, we only can get the stress component from the gauss point.
But in STKO, we still can show the stress contour from the surface plot.
May I ask you is that possible to directly get the initial stress component at each node?

Many many thanks for your help.

Best,
Yu-Wei

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

Re: Is there anyway to plot excess pore water pressure ratio?

Post by STKO Team » Mon Oct 04, 2021 8:17 am

Hello Yu-Wei

In standard FEM, stress is a variable evaluated at gauss points (and so does OpenSees).
In STKO, if you plot the stress using a GaussPlot, you see the "real" result (where "real" means "calculated by opensees").

In the STKO, if you plot the stress using a SurfacePlot or VolumePlot, you don't have a graphic representation of a gauss point, but only the nodes of the surface/volume. Therefore, STKO performs an extrapolation from the gauss points to the node. Note that in this case the results a linearly interpolated to the node, so they are not anymore the real values computed by OpenSees.

After extrapolation, the results is still an Element-Result, meaning that it might be discontinuous among element, so you don't have a unique result at each node.

Optionally, you can use the "smooth" option, to perform the Nodal-Average. In this case, the Element-Result becomes a Node-Result.

To do so, before you evaluate the result you can set the extrapolate and smooth properties of the MpcOdbVirtualResultEvaluationOptions to True:

Code: Select all

S = db.getElementalResult("stress", match = MpcOdb.Contains)
opt = MpcOdbVirtualResultEvaluationOptions()
opt.stage = stage_id
opt.step = step_id
opt.extrapolate = True
opt.smooth = True
element_field = S.evaluate(opt)
print(element_field[MpcOdbResultField.node(node_id)])

Post Reply