Get nodal stresses while incorporating power/full graphics
Hello,
I'm currently attempting to retrieve nodal stresses from a model utilizing PyMAPDL. My approach involves employing both mapdl.result.nodal_stress and mapdl.post_processing.nodal_component_stress commands. While these commands successfully fetch stress values at the nodes, I aim to integrate the options 'power graphics' and 'full graphics' from mapdl.graphics. Irrespective of the chosen option within mapdl.graphics, the results obtained via mapdl.result or mapdl.post_processing commands remain consistent across all nodes. I'm seeking guidance on how to obtain nodal stress values while incorporating the mapdl.graphics option.
I experimented with mapdl.prnsol; however, the precision of the results fell short of my requirements. I'm in need of greater precision. Is there an alternative method to achieve the same objective?
Sample code:
from ansys.mapdl.core import launch_mapdl
import numpy as np
mapdl = launch_mapdl()
filename = 'static.db'
mapdl.resume(filename)
mapdl.post1()
mapdl.file('static.rst')
mapdl.graphics("POWER")
mapdl.graphics("FULL")
data = mapdl.result.nodal_stress(0)[0]
Thanks,
Dr. Samukham
Comments
-
Hi @Samukham This PyMAPDL Documentation example does this though for a magnetostatic model. The example uses a MAPDL Theme built into PyMAPDL for the contour colors. But theme is currently kind of broken. Instead you can use this to get a pretty close to the default MAPDL colors.
import matplotlib as mpl cmap1 = (mpl.colors.ListedColormap(['blue','royalblue', 'cyan', '#00FA9A','#7CFC00', '#ADFF2F','yellow', 'orange','red']).with_extremes())
The color map can then be used in the PyVista plot. In the code section where the meshes are being added to the plotter object you can replace
cmap=PyMAPDL_cmap
with
cmap=cmap1
I just finished a blog post on PyMAPDL/PyVista and Full/Power graphics. Not sure when it will be added so keep an eye out.
Mike0 -
Hi @Mike Rife, My goal here is to get the nodal stresses as an array, but not to plot. When I use mapdl.result.nodal_stress(0) command, it returns the nodal stresses for all the nodes regardless of the graphics option I used (power/full).
However, I need the what prnsol() returns when used in APDL along with the graphics option. In APDL if I use the graphics option "POWER" and then use the command prnsol() it returns the nodal values which are on the surface and when I use 'FULL" it lists nodal solution for all the nodes. In similar way, I want to obtain nodal results along with the graphics option "POWER" or "FULL". I've tried using prnsol() along with graphics option PyMAPDL and got nodal solution corresponding to the graphics option I used. But, the problem is that I didn't get the nodal values with high precision. It truncates the result values, which I don't want.
My final goal is to get the nodal results as an array corresponding to the graphics option I use which prnsol() would return, but with high precision.0 -
Hi @Samukham
Whoops sorry, I was a bit biased to plotting there having just finished doing so! Please see the enriched post-processing options in PyMAPDL here. They can be used to gather the result to a list or array and respect the current selection.The 'result' method is using the PyMAPDL Reader to post-process and it is not interacting with Mechanical APDL. So it does not "know" about any MAPDL commands issued i.e. selection.
0