2.6.2 ParametersAnother method of managing variables in a Mech model is to use the parameters functions. The parameters list is basically a list of rules stored in Mech's internal database that is applied to the mechanism model immediately before the solution phase. By using parameters, problems can be avoided such as failing to define all of the symbols in a model or accidentally defining them before SetConstraints is run and hard coding them into the model. Parameter management functions. Note that when a parameter is set with SetParameters or Parameterize, it is protected until it is unset with ClearParameters. This is to ensure that the parameter cannot be accidentally given a definition in the course of running the model. The crankshaft-piston model, which was built in Section 2.6.1, is used to demonstrate the use of parameters. The definitions of the three symbols in the model are cleared and then added to the parameters list. This adds three symbols to the parameters list.
Out[28]= | |
The crankshaft-piston model can now be built without worrying about the definitions of the parameters. SetParameters can be used at any time in the model-building process. Here the crankshaft-piston model is rebuilt with reference to the body objects previously defined. The parameters are included in the solution rules returned by SolveMech.
Out[30]= | |
Set a new value for crankfreq. Only the specified value is updated, the others are left unchanged.
Out[31]= | |
The parameters are protected.
This removes all of the parameters from the parameters list.
Out[33]= | |
|