|
| 1 | +# pynite_plotly: Plotly visualization for PyNiteFEA |
| 2 | + |
| 3 | +## Installation |
| 4 | + |
| 5 | +``` |
| 6 | +pip install pynite-plotly |
| 7 | +``` |
| 8 | + |
| 9 | +## Basic Usage |
| 10 | + |
| 11 | +`pynite-plotly` can be used as a drop-in replacement for PyNite's own PyVista rendering module. |
| 12 | + |
| 13 | +So, simply replace: |
| 14 | + |
| 15 | +```python |
| 16 | +from PyNite.Rendering import Renderer |
| 17 | +``` |
| 18 | + |
| 19 | +with this: |
| 20 | + |
| 21 | +```python |
| 22 | +from pynite_plotly import Renderer |
| 23 | +``` |
| 24 | + |
| 25 | +And then visualize your model according to the API for the PyNite renderer: |
| 26 | + |
| 27 | +```python |
| 28 | +from PyNite import FEModel3D |
| 29 | + |
| 30 | +model = FEModel3D() |
| 31 | + |
| 32 | +### ... build your model here... |
| 33 | + |
| 34 | +vis = Renderer(model) |
| 35 | +vis.render_model() |
| 36 | +``` |
| 37 | + |
| 38 | +## Additional Features |
| 39 | +The `Renderer` class has a few additional attributes beyond the attributes in the PyNite `Renderer`. These are useful for modifying colors and line weights of the elements in the plot. |
| 40 | + |
| 41 | +* `.colors` - A `dict` that has keys corresponding to the different elements in the plot |
| 42 | +* `.line_widths` - A `dict` that has keys corresponding to the different linear elements in the plot |
| 43 | + |
| 44 | +Change the values of the keys and run `.update` to see how they affect the plot! |
| 45 | + |
| 46 | +## Current Limitations |
| 47 | + |
| 48 | +2024-11-01: I have only implemented rendering frames and loads. I have not implemented plates/quads/area loads. It will take a special effort because plotly renderers meshes (the plates) as triangles but PyNite uses a quad mesh for FEA. |
| 49 | + |
| 50 | +So, to render everything like PyVista will require remeshing the quad mesh as triangles and having the ability to plot the lines of the quad mesh overtop of the triangulated quad mesh which can also have gradient shading according to the results being plotted. |
| 51 | + |
| 52 | +Additionally, I have not implemented plotting of nodes and node labels yet. No real reason but I noticed that they were not implemented in the PyNite Renderer so I just kept chill on it...for now. |
| 53 | + |
| 54 | + |
| 55 | +## Motivation |
| 56 | + |
| 57 | +[PyNiteFEA](https://github.com/jwock82/pynite) is excellent and has been becoming more so. In v0.0.94 @JWock82 released PyVista visualization to complement the existing VTK visualization. This has been a great improvement in usability since PyVista can run within a Jupyter notebook as opposed to launching a separate operating system window for the visualization (VTK). |
| 58 | + |
| 59 | +To get PyVista running in Jupyter, requires Trame and a load of other dependencies. These dependencies typically lag behind the latest Python version. Additionally, PyVista does not run everywhere on the web yet (like streamlit). |
| 60 | + |
| 61 | +However, plotly has similar 3D plotting capability to PyVista, runs everywhere, and has a light dependency load. |
| 62 | + |
| 63 | +So, using a helper library I created, [plotly_3d_primitives](https://github.com/structuralpython/plotly_3d_primitives), I then copied the original PyNite `Rendering` module and swapped out the PyVista method names with my new plotly function names. Did a little bit of massaging and...voila! A new rendering module for PyNite! |
| 64 | + |
0 commit comments