12.1 Updating SolutionsThe simplest way to get a MechanicalSystems model to run faster is to ask it to do less work. This is usually accomplished by keeping track of and reusing results that have already been obtained, instead of generating them again. When mechanism velocity or acceleration data is needed, or static or dynamic constraint reaction forces, the complete location solution must first be calculated. If this has already been done, the CheckRules option prevents Mech from doing it again. An option for SolveMech. If CheckRules -> False is specified, the solution rules that are passed to SolveMech are not checked against the constraints, they are simply passed to the next phase of the solution block. This is useful if a set of lower-order solution rules has already been obtained (e.g., location solution) and a set of higher-order (i.e., velocity or acceleration) rules is desired. The following example uses a spatial slider-crank model to demonstrate the time savings that can be realized by updating higher-order solutions without regenerating lower-order data. The example mechanism consists of two bodies, a crank and a slider, and a connecting rod that is simply a distance constraint. No initial guesses are needed for the model because both the crank and the slider are initially coincident with the local origin. Here is an entire slider-crank model built in one step. Here is a solution to the model near T = 0.
Out[6]= | |
To show the difference between regenerating solutions, updating solutions, and updating solutions without checking validity, a series of location solutions are generated and then updated to velocity solutions. This generates 21 solutions to the model as time goes from 0 to 1. This generates the complete location and velocity solution at 21 points.
Out[9]= | |
This generates the complete location and velocity solution using the location rules already calculated as initial guesses at each step.
Out[10]= | |
This generates only the new velocity solution using the location rules already calculated without checking that they in fact satisfy the constraints.
Out[11]= | |
This same technique can be used to update a location solution to a static solution, or any other combination of the solution levels generated by SolveMech. If CheckRules -> False is specified, the only part of the solution that is actually calculated anew is the part explicitly requested by the solution option, and any parts of the solution that are not present in the solution rules that are to be updated.
|