Potential Issues/Advanced Topics/Future Features in Physics/Mechanics Module¶

This document will describe some of the more advanced functionality that this module offers but which is not part of the “official” interface. Here, some of the features that will be implemented in the future will also be covered, along with unanswered questions about proper functionality. Also, common problems will be discussed, along with some solutions.

Common Issues¶

Here issues with numerically integrating code, choice of $$dynamicsymbols$$ for coordinate and speed representation, printing, differentiating, and substitution will occur.

Numerically Integrating Code¶

See Future Features: Code Output

Differentiating¶

Differentiation of very large expressions can take some time in SymPy; it is possible for large expressions to take minutes for the derivative to be evaluated. This will most commonly come up in linearization.

Choice of Coordinates and Speeds¶

The Kane object is set up with the assumption that the generalized speeds are not the same symbol as the time derivatives of the generalized coordinates. This isn’t to say that they can’t be the same, just that they have to have a different symbol. If you did this:

>> KM.coords([q1, q2, q3])
>> KM.speeds([q1d, q2d, q3d])

Your code would not work. Currently, kinematic differential equations are required to be provided. It is at this point that we hope the user will discover they should not attempt the behavior shown in the code above.

This behavior might not be true for other methods of forming the equations of motion though.

Printing¶

The default printing options are to use sorting for Vector and Dyad measure numbers, and have unsorted output from the mprint, mpprint, and mlatex functions. If you are printing something large, please use one of those functions, as the sorting can increase printing time from seconds to minutes.

Differentiating¶

Differentiation of very large expressions can take some time in SymPy; it is possible for large expressions to take minutes for the derivative to be evaluated. This will most commonly come up in linearization.

Substitution¶

Substitution into large expressions can be slow, and take a few minutes.

Linearization¶

Currently, the Kane object’s linearize method doesn’t support cases where there are non-coordinate, non-speed dynamic symbols outside of the “dynamic equations”. It also does not support cases where time derivatives of these types of dynamic symbols show up. This means if you have kinematic differential equations which have a non-coordinate, non-speed dynamic symbol, it will not work. It also means if you have defined a system parameter (say a length or distance or mass) as a dynamic symbol, its time derivative is likely to show up in the dynamic equations, and this will prevent linearization.

Acceleration of Points¶

At a minimum, points need to have their velocities defined, as the acceleration can be calculated by taking the time derivative of the velocity in the same frame. If the 1 point or 2 point theorems were used to compute the velocity, the time derivative of the velocity expression will most likely be more complex than if you were to use the acceleration level 1 point and 2 point theorems. Using the acceleration level methods can result in shorted expressions at this point, which will result in shorter expressions later (such as when forming Kane’s equations).

Remember that the Kane object supports bodies which have time-varying masses and inertias, although this functionality isn’t completely compatible with the linearization method.

Operators were discussed earlier as a potential way to do mathematical operations on Vector and Dyad objects. The majority of the code in this module is actually coded with them, as it can (subjectively) result in cleaner, shorter, more readable code. If using this interface in your code, remember to take care and use parentheses; the default order of operations in Python results in addition occurring before some of the vector products, so use parentheses liberally.

Future Features¶

This will cover the planned features to be added to this submodule.

Additional Options on Initialization of Kane, RigidBody, and Particle¶

This would allow a user to specify all relevant information using keyword arguments when creating these objects. This is fairly clear for RigidBody and Point. For Kane, everything but the force and body lists will be able to be entered, as computation of Fr and Fr* can take a while, and produce an output.

Additional Methods for RigidBody and Particle¶

For RigidBody and Particle (not all methods for Particle though), add methods for getting: momentum, angular momentum, and kinetic energy. Additionally, adding a attribute and method for defining potential energy would allow for a total energy method/property.

Also possible is including the method which creates a transformation matrix for 3D animations; this would require a “reference orientation” for a camera as well as a “reference point” for distance to the camera. Development of this could also be tied into code output.

Code Output¶

A function for generating code output for numerical integration is the highest priority feature to implement next. There are a number of considerations here.

Code output for C (using the GSL libraries), Fortran 90 (using LSODA), MATLAB, and SciPy is the goal. Things to be considered include: use of cse on large expressions for MATLAB and SciPy, which are interpretive. It is currently unclear whether compiled languages will benefit from common subexpression elimination, especially considering that it is a common part of compiler optimization, and there can be a significant time penalty when calling cse.

Care needs to be taken when constructing the strings for these expressions, as well as handling of input parameters, and other dynamic symbols. How to deal with output quantities when integrating also needs to be decided, with the potential for multiple options being considered.