Result animations don't work with the new pyvista default backend (trame)
Opened this issue ยท 6 comments
๐ค Before submitting the issue
- I have visited the Troubleshooting section.
- I have searched among the existing issues.
- I am using a Python virtual environment.
- I am using the latest version of PyMAPDL and its dependencies (fully updated virtual environment). You can update them using
pip install --upgrade --upgrade-strategy eager ansys-mapdl-core
.
๐ Description of the bug
The results object animation method is not compatible with the current backend that PyVista has switched to (trame). When trying to animate a solution (for example, from a nodal analysis) with mapdl.result.animate_nodal_solution(0)
the trame window gets stuck loading until you stop the execution. Once you do, a static mesh is opened in the trame window.
Animations with the notebook=False
option remain operative, but one thing I have noticed is that the mapping of the colorscale to the animation stopped working a few versions ago (so, for example, if you have something vibrating, it will always show the color for 0 deformation, even if it does animate the displacements). add_text=True
has also become less functional, as the text is barely readable.
๐ต๏ธ Steps To Reproduce
Steps:
- Make any simple model and run a modal analysis.
- Animate modal results from the results object.
๐ป Which Operating System are you using?
Windows
๐ Which Python version are you using?
3.11
๐ PyMAPDL Report
'
๐ Installed packages
'
๐ Logger output file
No response
Hi @CesarRodriguezPereira , I would need a minimum working example, can you provide one?
Hi @CesarRodriguezPereira , I would need a minimum working example, can you provide one?
Yes, sure, here's a notebook with a quick test I've just created:
minimum_example.zip
In case it doesn't work:
# IMPORT, LAUNCH AND PRINT
from ansys.mapdl.core import launch_mapdl
mapdl = launch_mapdl(override=True)
print(mapdl)
# MODEL DEFINITION
mapdl.clear()
mapdl.prep7()
#Material + element
mapdl.mp('EX',1, 2.1e5)
mapdl.mp("PRXY", 1, 0.3)
mapdl.mp("DENS", 1, 7850e-12)
mapdl.et(1, 'BEAM188')
mapdl.keyopt(1, 3, 2)
#Geometry
mapdl.k(1,0,0,0)
mapdl.k(2,0,0,2000)
mapdl.l(1,2)
mapdl.sectype(1, 'BEAM', 'RECT') #rectangular beam
mapdl.secoffset('CENT')
mapdl.secdata(40,40) #40x40 mm steel beam
#Mesh
mapdl.mat(1)
mapdl.type(1)
mapdl.secnum(1)
mapdl.lesize(ndiv=20)
mapdl.lmesh(1)
mapdl.dk(1,'ALL',0)
#SOLVE MODAL ANALYSIS
solution= mapdl.modal_analysis(nmode=2)
#Result object to variable, plotting for sanity check
result=mapdl.result
result.plot_nodal_solution(0, show_displacement=True, displacement_factor=10)
#Try to animate within notebook: the window keeps loading until you stop its execution
result.animate_nodal_solution(0, show_displacement=True, displacement_factor=10)
# NOTEBOOK FALSE: notice how the text gets messed up
#notice how all colors are the same regardless of actual deformation
result.animate_nodal_solution(0, show_displacement=True, displacement_factor=10,notebook=False)
Hopefully this helps!
For me (running Python 3.11 in MacOS + docker, PyMAPDL remote mode) both show an animation:
result.animate_nodal_solution(0, show_displacement=True, displacement_factor=10)
and
result.animate_nodal_solution(0, show_displacement=True, displacement_factor=10,notebook=False)
but it gets stuck when I close the window (I need to issue ctrl
+ C
). But I believe this is an MacOS issue.
@clatapie can you confirm this behaviour on Windows?
Regarding the add_text
, and the colorscale, I agree. It does not seems to work propertly.
Hi @germa89
Regarding the animation within the notebook, I haven't been able to get it to work within a notebook in vscode, as it gets stuck loading. When trying it on jupyter notebook or jupyterlab I get no output, as it seems to have issues with widget state (but that may be my juypter environment lacking in configuration due to my use of VScode by default). I'll try to get trame working in the default notebooks (jupyter rather than vscode), to see if I can get more info on the issue (maybe the infinite loading has to do with how vscode handles the widget).
The issue you show when closing the window isn't MacOS related, and has been present at least since I started using the library (around january 2021), I always thought it was a vtk issue and not a pymapdl one. To be a bit more detailed with the behaviour, closing the window manually will kill the kernel, although stopping the cell execution won't (the window becomes unresponsive, as expected, but the kernel is still usable). Trying to close any of the windows (even old inactive ones) will prompt the user with killing the process python.exe, killing the kernel in the process.
My usual solution when performing modal analyses has always been "kill the cell through KeyboardInterrupt" (available at the push of a button in vscode), then launch another animation. Stack until you have so many windows that it's unmanageable, close it all, and repeat.
PS: this is running pymapdl 0.65.0, windows 10 on python 3.11.3. Up until now with python 3.8 and older pymapdl versions the window behavior is the same, the only new addition is the infinite loading due to trame (and the issue with add_text and colorscale).
I have identify your issue also in default jupyter notebook. I will keep investigating
This bug is due to pymapdl-reader
.. transferring and assigning it to @AlejandroFernandezLuces
Please @AlejandroFernandezLuces have a look at this. I believe the problem is on the backend configuration passed in:
pymapdl-reader/ansys/mapdl/reader/rst.py
Line 3032 in aa1501d