SDyPy-view project
The Plotter3D is a wrapper around the pyvista.BackgroundPlotter with some added functionality around convenient simplifications for use in structural dynamics.
Notes
Running on Linux
If the viewer does not open, maybe libxcb-cursor0 is missing. Try installing (Ubuntu):
sudo apt install libxcb-cursor0
Also, if running wayland, the following should be added at the top of the file:
os.environ['QT_QPA_PLATFORM'] = 'xcb'
Running from shell
If not running from jupyter notebook, the viewer might close right away. To keep it interactive, run it with:
python -i file.py
Basic usage
import sdypy as sd
nodes = ... # Finite element nodes
elements ... # Finite elements
plotter = sd.view.Plotter3D(nodes, elements)
plotter.add_fem_mesh(nodes, elements)
plotter.show(show_grid=True, show_axes=True)
To animate a mode shape:
mode_shape = ... # Shape (n_nodes, 3)
plotter = sd.view.Plotter3D(nodes, elements)
plotter.add_fem_mesh(nodes, elements, animate=mode_shape)
To animate according to a time history:
time_history = ... # Shape (n_nodes, 3, n_timesteps)
plotter = sd.view.Plotter3D(nodes, elements)
plotter.add_fem_mesh(nodes, elements, animate=time_history)
To color the mesh according to a norm of the mode_shape:
plotter = sd.view.Plotter3D(nodes, elements)
plotter.add_fem_mesh(nodes, elements, animate=mode_shape, field="norm")
Here, if field="norm" is passed, the mesh will be colored according to the norm of the mode_shape (or more generally, according to the norm of the animate argument). To color the mesh according to an arbitrary field, the field argument must be of shape (n_nodes, n_timesteps).
Animation
The Plotter3D class also enables the user to animate the mesh. There are two way to animate the FEM mesh or points:
By passing a 3D array of shape (n_nodes, 3, n_timesteps) to the animate argument. The points/nodes will be animated according to the time history.
By passing a 2D array of shape (n_nodes, 3) to the animate argument. The animate defines the maximum displacement of the nodes. The animation is interpolated with a sine function.
The animate argument can also have the following shapes:
(n_nodes*3): The Plotter3D will automatically convert this to (n_nodes, 3).
(n_nodes*3, n_timesteps): The Plotter3D will automatically convert this to (n_nodes, 3, n_timesteps).
(n_nodes*N): The Plotter3D will automatically convert this to (n_nodes, 3), where N is an arbitrary number. Only the first 3 columns are used. This is useful when animating e.g. a mode shape of a shell (each node has 6 DOF).
(n_nodes*N, n_timesteps): The Plotter3D will automatically convert this to (n_nodes, 3, n_timesteps). Similar to previous point, but with time history.
The n_frames is set to 100 by default, but can be changed to alter the number of frames per one iteration. When providing the time history, the n_frames should match the last dimension of the animate argument.
Here is an example of animating a mode shape:
import sdypy as sd
nodes = ... # Finite element nodes (n_nodes, 3)
elements ... # Finite elements (n_elements, n_nodes_per_element)
mode_shape = ... # Mode shape (n_nodes, 3)
plotter = sd.view.Plotter3D(nodes, elements)
plotter.add_fem_mesh(nodes, elements, animate=mode_shape, field="norm")
plotter.configure_animation(interval=20) # To adjust the interval and camera position
plotter.start_animation() # Optional. To immediately start the animation. Otherwise, the controls are available in the plotter.
plotter.show()
Recording a GIF
To record a GIF, the configure_gif_recorder method must be called. Example:
import sdypy as sd
nodes = ... # Finite element nodes (n_nodes, 3)
elements ... # Finite elements (n_elements, n_nodes_per_element)
mode_shape = ... # Mode shape (n_nodes, 3)
plotter = sd.view.Plotter3D(nodes, elements)
plotter.gif_recorder("mode_shape.gif") # MUST BE CALLED BEFORE THE ANIMATION STARTS
plotter.add_fem_mesh(nodes, elements, animate=mode_shape, field="norm")
plotter.configure_gif_recorder('mode_shape.gif', fps=30) # Configure the GIF recorder
plotter.show()
The recording will start on pressing the “Record” button in the toolbar. Alternatively, the configure_gif_recorder can be called like this:
plotter.configure_gif_recorder('mode_shape.gif', fps=30, start_on_play=True)
This will start the recording when the animation starts. To start the animation, call the start_animation method or press the “Play” button in the toolbar.
The recording will last for 1 iteration of the animation.
Metadata
Release files for sdypy-view 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| sdypy_view-0.2.0.tar.gz | 18.2 kB | Without provenance | Details for sdypy_view-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| sdypy_view-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for sdypy_view-0.2.0-py3-none-any.whl |
Total release size: 30.8 kB
Release files / sdypy_view-0.2.0.tar.gz
| Download URL | sdypy_view-0.2.0.tar.gz |
|---|---|
| Size | 18.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
46087bffccbd0547ed66694ba518b356bacd5392b9f948aaceb2ef8ef37f0720
|
|
BLAKE2b-256 checksum How to use checksums |
b557f1bd74210d85d7c14a0ed5dd0d08ff431d21165d8c777fbd3a98651e6400
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Release files / sdypy_view-0.2.0-py3-none-any.whl
| Download URL | sdypy_view-0.2.0-py3-none-any.whl |
|---|---|
| Size | 12.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4981c8dfa2eac1e87f46eaf6e557aa81409cd8fc684cc37d73f353ce3c7d0ea0
|
|
BLAKE2b-256 checksum How to use checksums |
7d942359f966f4c9e2844ec3584f741458a49532a79d77d8dc1497cde1fc5f24
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Security for sdypy-view 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.