SymPy Mechanics Plotter
Project description
SymMePlot
SymMePlot is a visualization tool designed for mechanical systems created using the
mechanics module in SymPy, sympy.physics.mechanics
.
The sympy.physics.mechanics
module allows users to define mechanical systems
symbolically to derive their analytic equations of motion. During this process, users
can construct various objects such as reference frames, points, bodies, and more.
SymMePlot enhances this process by providing a way to visualize these constructed objects. It integrates with visualization backends like Matplotlib, and creates visual representations based on the parametrization of the symbols involved in the system.
To install symmeplot
with the matplotlib
visualization run:
pip install symmeplot matplotlib
Usage
Most of your programs are expected to follow this structure:
- Creation of the system in sympy using the objects from
sympy.physics.mechanics
. - Create a figure with a 3D axes with
matplotlib
. - Initiate a
Scene
with the inertial frame and absolute origin. - Add your frames, vectors and points to the plotter instance.
- Lambdify and evaluate the system.
- Plot the system.
Below is a basic example of how this looks in practise:
import numpy as np
from symmeplot.matplotlib import Scene3D
from sympy.physics.mechanics import Point, ReferenceFrame, dynamicsymbols
# Create the system in sympy
N = ReferenceFrame("N")
A = ReferenceFrame("A")
q = dynamicsymbols("q")
A.orient_axis(N, N.z, q)
N0 = Point("N_0")
v = 0.2 * N.x + 0.2 * N.y + 0.7 * N.z
A0 = N0.locatenew("A_0", v)
# Create the instance of the scene specifying the inertial frame and origin
scene = Scene3D(N, N0, scale=0.5)
# Add the objects to the system
scene.add_vector(v)
scene.add_frame(A, A0, ls="--")
scene.add_point(A0, color="g")
# Evaluate the system.
scene.lambdify_system(q)
scene.evaluate_system(0.5)
# Plot the system
scene.plot()
# You can also animate this system.
ani = scene.animate(lambda q: (q,), frames=np.linspace(0, 2 * np.pi, 60))
ani.save("animation.gif", fps=30)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file symmeplot-0.2.1.tar.gz
.
File metadata
- Download URL: symmeplot-0.2.1.tar.gz
- Upload date:
- Size: 22.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.7.1 CPython/3.10.12 Linux/6.2.0-1019-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 508b8a1a30e4bc753f4ee8f7bc975dce72a883c3dadf3e84c88fd5e4b39aba63 |
|
MD5 | d4388dc940993b7cfaadf42cbcdc36d3 |
|
BLAKE2b-256 | 8f0a4097731b37a1e084e3dee75120451ad4019c070b45560acfe317ff3c79ec |
File details
Details for the file symmeplot-0.2.1-py3-none-any.whl
.
File metadata
- Download URL: symmeplot-0.2.1-py3-none-any.whl
- Upload date:
- Size: 30.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.7.1 CPython/3.10.12 Linux/6.2.0-1019-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0dcb423c104c8f8a255f9d640597cb6351b1b6a71c4fe983eafae42f236fce51 |
|
MD5 | a73e7a8d9a1eb1f37338dd1b551b0e4f |
|
BLAKE2b-256 | 759c08463d94d8c74df1c4cb7e176f66a82397bd0c79b32cfa5cf8553037bb30 |