Essential Functions (Docstrings)
Contents
Essential Functions (Docstrings)¶
dynamicsymbols¶
- sympy.physics.vector.dynamicsymbols(names, level=0, **assumptions)[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.
assumptions :
- real(bool)This is used to set the dynamicsymbol as real,
by default is False.
- positive(bool)This is used to set the dynamicsymbol as positive,
by default is False.
- commutative(bool)This is used to set the commutative property of
a dynamicsymbol, by default is True.
- integer(bool)This is used to set the dynamicsymbol as integer,
by default is False.
Examples
>>> from sympy.physics.vector import dynamicsymbols >>> from sympy import diff, Symbol >>> q1 = dynamicsymbols('q1') >>> q1 q1(t) >>> q2 = dynamicsymbols('q2', real=True) >>> q2.is_real True >>> q3 = dynamicsymbols('q3', positive=True) >>> q3.is_positive True >>> q4, q5 = dynamicsymbols('q4,q5', commutative=False) >>> bool(q4*q5 != q5*q4) True >>> q6 = dynamicsymbols('q6', integer=True) >>> q6.is_integer True >>> diff(q1, Symbol('t')) Derivative(q1(t), t)
dot¶
- sympy.physics.vector.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.vector import ReferenceFrame, 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.vector.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.vector import ReferenceFrame >>> 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.vector.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.vector import ReferenceFrame, outer >>> N = ReferenceFrame('N') >>> outer(N.x, N.x) (N.x|N.x)
express¶
- sympy.physics.vector.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.vector import ReferenceFrame, outer, dynamicsymbols >>> from sympy.physics.vector import init_vprinting >>> init_vprinting(pretty_print=False) >>> N = ReferenceFrame('N') >>> q = dynamicsymbols('q') >>> B = N.orientnew('B', 'Axis', [q, N.z]) >>> d = outer(N.x, N.x) >>> from sympy.physics.vector 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) - B_y*sin(q)
time_derivative¶
- sympy.physics.vector.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
Examples
>>> from sympy.physics.vector import ReferenceFrame, dynamicsymbols >>> from sympy.physics.vector import init_vprinting >>> init_vprinting(pretty_print=False) >>> 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.vector import time_derivative >>> time_derivative(v, N) u1'*N.x >>> time_derivative(u1*A[0], N) N_x*u1' >>> B = N.orientnew('B', 'Axis', [u1, N.z]) >>> from sympy.physics.vector import outer >>> d = outer(N.x, N.x) >>> time_derivative(d, B) - u1'*(N.y|N.x) - u1'*(N.x|N.y)
References
https://en.wikipedia.org/wiki/Rotating_reference_frame#Time_derivatives_in_the_two_frames