from sympy import * from sympy.matrices import * from sympy.physics.mechanics import dynamicsymbols, init_vprinting import matplotlib.pyplot as plt init_vprinting() def kinvars(*args, **kwargs): return dynamicsymbols(*args, **kwargs) class Vector2D(object): def __init__(self, *args, **kwargs): if "x" in kwargs and "y" in kwargs: self._x = kwargs["x"] self._y = kwargs["y"] self._calculate_magnitude_and_angle() elif "r" in kwargs and "theta" in kwargs: self._r = kwargs["r"] self._theta = kwargs["theta"] self._calculate_rect_components() if len(args) == 2: self._r = args[0] self._theta = args[1] self._calculate_rect_components() def _calculate_rect_components(self): self._x = self.r * cos(self.theta) self._y = self.r * sin(self.theta) def _calculate_magnitude_and_angle(self):
""" Numython R&D, (c) 2020 Moro is a Python library for kinematic and dynamic modeling of serial robots. This library has been designed, mainly, for academic and research purposes, using SymPy as base library. """ from .version import __version__ __author__ = "Pedro Jorge De Los Santos" from .abc import * # To use common symbolic variables from .core import * from .plotting import * from .transformations import * from .util import * # import sympy functions from sympy import solve, symbols, init_printing, pi, simplify, nsimplify from sympy import sin,cos,tan from sympy.matrices import Matrix, eye, zeros, ones from sympy.physics.mechanics import init_vprinting # ~ from .ws import * # not yet ready init_vprinting() # Get "pretty print" # vprinting for dot notation (Newton's notation)
#!/usr/bin/env python # This script generates the equations of motion for a double pendulum where the # bob rotates about the pendulum rod. It can be shown to be chaotic when # simulated. # import sympy and the mechanics module import numpy as np import matplotlib.pyplot as plt import sympy as sym import sympy.physics.mechanics as me from pydy.system import System from pydy.viz import Cylinder, Plane, VisualizationFrame, Scene # Enable pretty printing. me.init_vprinting() # declare the constants # # gravity g = sym.symbols('g') mA, mB, lB = sym.symbols('m_A, m_B, L_B') # plate dimensions w, h = sym.symbols('w, h') # declare the coordinates and speeds and their derivatives # # theta : angle of the rod # phi : angle of the plate relative to the rod # omega : angular speed of the rod # alpha : angular speed of the plate theta, phi, omega, alpha = me.dynamicsymbols('theta phi omega alpha')
from sympy import Symbol, symbols, solve, dsolve, Eq, lambdify from sympy.physics.mechanics import dynamicsymbols, init_vprinting import matplotlib.pyplot as plt import scipy as sp init_vprinting() # Symbols definition t = Symbol('t') C1, C2 = symbols('C1 C2') u, v, teta, psi = dynamicsymbols('u v theta psi') symrep1 = ( 'm I_d I_p Omega k_x1 k_x2 k_y1 k_y2 a b') m, Id, Ip, omega, kx1, kx2, ky1, ky2, a, b = symbols(symrep1, positive=True) symrep2 = ( 'k_xT k_xC k_xR k_yT k_yC k_yR k_T k_C k_R') kxt, kxc, kxr, kyt, kyc, kyr, kt, kc, kr = symbols(symrep2, positive=True) # Equations of motion (see 3.4 of 'Dynamics of rotating machines') eq1 = m*(u.diff(t, t)) + (kx1 + kx2)*u + (-a*kx1 + b*kx2)*psi eq2 = m*(v.diff(t, t)) + (ky1 + ky2)*v + (a*ky1 - b*ky2)*teta eq3 = Id*(teta.diff(t, t)) + Ip*omega*(psi.diff(t)) + (a*ky1 - b*ky2)*v + (a**2*ky1 + b**2*ky2)*teta eq4 = Id*(psi.diff(t, t)) - Ip*omega*(teta.diff(t)) + (-a*kx1 + b*kx2)*u + (a**2*kx1 + b**2*kx2)*psi system = [eq1, eq2, eq3, eq4] class RigidRotor(object): """
############################################################################# # Automatically generated by pymola from __future__ import print_function import sympy import sympy.physics.mechanics as mech sympy.init_printing() mech.init_vprinting() import scipy.integrate import pylab as pl #pylint: disable=too-few-public-methods, too-many-locals, invalid-name, no-member class Model(object): """ Modelica Model. """ def __init__(self): """ Constructor. """ self.t = sympy.symbols('t') # symbols c = \ sympy.symbols('c')