Navigation

  • index
  • modules |
  • modules |
  • next |
  • previous |
  • SymPy 0.7.4 documentation »
  • SymPy Modules Reference »
  • Physics Module »
  • Classical Mechanics »

Related Essential Functions (Docstrings)¶

dynamicsymbols¶

sympy.physics.mechanics.essential.dynamicsymbols(names, level=0)[source]¶

Uses symbols and Function for functions of time.

Creates a SymPy UndefinedFunction, which is then initialized as a function of a variable, the default being Symbol(‘t’).

Parameters:

names : str

Names of the dynamic symbols you want to create; works the same way as inputs to symbols

level : int

Level of differentiation of the returned function; d/dt once of t, twice of t, etc.

Examples

>>> from sympy.physics.mechanics import dynamicsymbols
>>> from sympy import diff, Symbol
>>> q1 = dynamicsymbols('q1')
>>> q1
q1(t)
>>> diff(q1, Symbol('t'))
Derivative(q1(t), t)

dot¶

sympy.physics.mechanics.functions.dot(vec1, vec2)[source]¶

Dot product convenience wrapper for Vector.dot(): Dot product of two vectors.

Returns a scalar, the dot product of the two Vectors
Parameters:

other : Vector

The Vector which we are dotting with

Examples

>>> from sympy.physics.mechanics import ReferenceFrame, Vector, dot
>>> from sympy import symbols
>>> q1 = symbols('q1')
>>> N = ReferenceFrame('N')
>>> dot(N.x, N.x)
1
>>> dot(N.x, N.y)
0
>>> A = N.orientnew('A', 'Axis', [q1, N.x])
>>> dot(N.y, A.y)
cos(q1)

cross¶

sympy.physics.mechanics.functions.cross(vec1, vec2)[source]¶

Cross product convenience wrapper for Vector.cross(): The cross product operator for two Vectors.

Returns a Vector, expressed in the same ReferenceFrames as self.
Parameters:

other : Vector

The Vector which we are crossing with

Examples

>>> from sympy.physics.mechanics import ReferenceFrame, Vector
>>> from sympy import symbols
>>> q1 = symbols('q1')
>>> N = ReferenceFrame('N')
>>> N.x ^ N.y
N.z
>>> A = N.orientnew('A', 'Axis', [q1, N.x])
>>> A.x ^ N.y
N.z
>>> N.y ^ A.x
- sin(q1)*A.y - cos(q1)*A.z

outer¶

sympy.physics.mechanics.functions.outer(vec1, vec2)[source]¶

Outer product convenience wrapper for Vector.outer(): Outer product between two Vectors.

A rank increasing operation, which returns a Dyadic from two Vectors
Parameters:

other : Vector

The Vector to take the outer product with

Examples

>>> from sympy.physics.mechanics import ReferenceFrame, outer
>>> N = ReferenceFrame('N')
>>> outer(N.x, N.x)
(N.x|N.x)

express¶

sympy.physics.mechanics.functions.express(expr, frame, frame2=None, variables=False)[source]¶

Global function for ‘express’ functionality.

Re-expresses a Vector, scalar(sympyfiable) or Dyadic in given frame.

Refer to the local methods of Vector and Dyadic for details. If ‘variables’ is True, then the coordinate variables (CoordinateSym instances) of other frames present in the vector/scalar field or dyadic expression are also substituted in terms of the base scalars of this frame.

Parameters:

expr : Vector/Dyadic/scalar(sympyfiable)

The expression to re-express in ReferenceFrame ‘frame’

frame: ReferenceFrame :

The reference frame to express expr in

frame2 : ReferenceFrame

The other frame required for re-expression(only for Dyadic expr)

variables : boolean

Specifies whether to substitute the coordinate variables present in expr, in terms of those of frame

Examples

>>> from sympy.physics.mechanics import ReferenceFrame, outer, dynamicsymbols
>>> N = ReferenceFrame('N')
>>> q = dynamicsymbols('q')
>>> B = N.orientnew('B', 'Axis', [q, N.z])
>>> d = outer(N.x, N.x)
>>> from sympy.physics.mechanics import express
>>> express(d, B, N)
cos(q)*(B.x|N.x) - sin(q)*(B.y|N.x)
>>> express(B.x, N)
cos(q)*N.x + sin(q)*N.y
>>> express(N[0], B, variables=True)
B_x*cos(q(t)) - B_y*sin(q(t))

time_derivative¶

sympy.physics.mechanics.functions.time_derivative(expr, frame, order=1)[source]¶

Calculate the time derivative of a vector/scalar field function or dyadic expression in given frame.

Parameters:

expr : Vector/Dyadic/sympifyable

The expression whose time derivative is to be calculated

frame : ReferenceFrame

The reference frame to calculate the time derivative in

order : integer

The order of the derivative to be calculated

References

http://en.wikipedia.org/wiki/Rotating_reference_frame#Time_derivatives_in_the_two_frames

Examples

>>> from sympy.physics.mechanics import ReferenceFrame, Vector, dynamicsymbols
>>> from sympy import Symbol
>>> q1 = Symbol('q1')
>>> u1 = dynamicsymbols('u1')
>>> N = ReferenceFrame('N')
>>> A = N.orientnew('A', 'Axis', [q1, N.x])
>>> v = u1 * N.x
>>> A.set_ang_vel(N, 10*A.x)
>>> from sympy.physics.mechanics import time_derivative
>>> time_derivative(v, N)
u1'*N.x
>>> time_derivative(u1*A[0], N)
N_x*Derivative(u1(t), t)
>>> B = N.orientnew('B', 'Axis', [u1, N.z])
>>> from sympy.physics.mechanics import outer
>>> d = outer(N.x, N.x)
>>> time_derivative(d, B)
- u1'*(N.y|N.x) - u1'*(N.x|N.y)

get_motion_params¶

sympy.physics.mechanics.functions.get_motion_params(frame, **kwargs)[source]¶

Returns the three motion parameters - (acceleration, velocity, and position) as vectorial functions of time in the given frame.

If a higher order differential function is provided, the lower order functions are used as boundary conditions. For example, given the acceleration, the velocity and position parameters are taken as boundary conditions.

The values of time at which the boundary conditions are specified are taken from timevalue1(for position boundary condition) and timevalue2(for velocity boundary condition).

If any of the boundary conditions are not provided, they are taken to be zero by default (zero vectors, in case of vectorial inputs). If the boundary conditions are also functions of time, they are converted to constants by substituting the time values in the dynamicsymbols._t time Symbol.

This function can also be used for calculating rotational motion parameters. Have a look at the Parameters and Examples for more clarity.

Parameters:

frame : ReferenceFrame

The frame to express the motion parameters in

acceleration : Vector

Acceleration of the object/frame as a function of time

velocity : Vector

Velocity as function of time or as boundary condition of velocity at time = timevalue1

position : Vector

Velocity as function of time or as boundary condition of velocity at time = timevalue1

timevalue1 : sympyfiable

Value of time for position boundary condition

timevalue2 : sympyfiable

Value of time for velocity boundary condition

Examples

>>> from sympy.physics.mechanics import ReferenceFrame, get_motion_params, dynamicsymbols
>>> from sympy import symbols
>>> R = ReferenceFrame('R')
>>> v1, v2, v3 = dynamicsymbols('v1 v2 v3')
>>> v = v1*R.x + v2*R.y + v3*R.z
>>> get_motion_params(R, position = v)
(v1''*R.x + v2''*R.y + v3''*R.z, v1'*R.x + v2'*R.y + v3'*R.z, v1*R.x + v2*R.y + v3*R.z)
>>> a, b, c = symbols('a b c')
>>> v = a*R.x + b*R.y + c*R.z
>>> get_motion_params(R, velocity = v)
(0, a*R.x + b*R.y + c*R.z, a*t*R.x + b*t*R.y + c*t*R.z)
>>> parameters = get_motion_params(R, acceleration = v)
>>> parameters[1]
a*t*R.x + b*t*R.y + c*t*R.z
>>> parameters[2]
a*t**2/2*R.x + b*t**2/2*R.y + c*t**2/2*R.z

Logo

Table Of Contents

  • Related Essential Functions (Docstrings)
    • dynamicsymbols
    • dot
    • cross
    • outer
    • express
    • time_derivative
    • get_motion_params

Previous topic

Essential Components (Docstrings)

Next topic

Kinematics (Docstrings)

This Page

  • Show Source

Quick search

Enter search terms or a module, class or function name.

©2013 SymPy Development Team. | Powered by Sphinx 1.3.1 & Alabaster 0.7.4 | Page source