2.6.1 User-Defined VariablesThis loads the Modeler2D package. Symbolic parameters can enter a kinematic model in two ways. The coordinates of a local point can be given in symbolic form or the arguments of a constraint function that specify a distance or angle can be given as a symbolic expression. The following example shows how local point specifications can be symbolic. This prevents impending spell check warnings. All local coordinates can be specified symbolically. The crankshaft-piston model can be built with several variables in the arguments to its constraint functions. The following example introduces symbols into the model to represent the frequency of the crankshaft rotation, the length of the connecting rod, and the stroke of the crankshaft. Here are the crankshaft-piston body objects, with a symbol included in the points list. This builds the constraint equations with two symbols embedded. If SolveMech is called now to seek a solution, an error message is generated because some of the symbols in the model have not yet been defined. This attempts to find a solution.
Out[19]= | |
A debugging aid. CheckSystem reports the names of any undefined symbols, as well as several other possible errors in the model. This checks the integrity of the model.
Out[20]= | |
This defines the undefined symbols, checks the model, and runs it.
Out[24]= | |
Out[25]= | |
Dependent Variables It is acceptable to use Mech dependent variables explicitly when defining local points or constraints. Highly abstract compound constraints can be specified in this manner. This is an extremely obtuse constraint. This constraint would cause the Y coordinate of a point on body 2 to be equal to the X coordinate of the origin of body 3, squared. When using dependent variables in constraints, care must be taken to ensure that the dependence of the constraint on the variables is explicit at the time that SetConstraints is run. If not, differentiation with respect to those variables cannot occur, and the constraints will not be processed correctly. Note that the names of the dependent variables used by Mech are cleared and protected when SetConstraints is run. Thus, if there happens to be a definition in place such as Y2 = 3, it is removed by SetConstraints.
|