# A Nonlinear CFD/Multibody Incremental-Dynamic Model for A Constrained Mechanism
## 3 Results
The \(X\) and \(Y\) forces acting on the joint of bodies 1 and 2 of the constrained mechanism are displayed in Figure 6. These forces were calculated by derivation of the \(V_{x}\) and \(V_{y}\) (velocities) at the center of gravities of bodies 1 and 2 and eventually the \(A_{x}\) and \(A_{y}\) (accelerations). The positive value of \(F_{x}\) implies that the force acts from left to right, while the negative value shows that the force acts from right to left at the joint. The results revealed that the motion of body 2 is dominant and body 1 just is following that. The positive value of \(F_{y}\) at the center of gravity of body 1 implies that the force acts from the down to up. However, since \(F_{y}\) is almost negative during the simulation time it means that  
Figure 3: Streamlines of the (**a**,**c**,**e**) unconstrained and (**b**,**d**,**f**) constrained mechanisms at different simulation times. body 1 experiences a higher force from the upper side, which leads to a rotation in that and take it to an upper right position compared to body 2. To verify the developed UDF code, an arbitrary flow moving from right to left (Supplementary file B: Arbitrary external force field) was simulated using Matlab(r) ODE, and the results were compared to that of the UDF of ANSYS Fluent(r). Since in Matlab(r) ODE the problem was simulated on the basis of the fourth order Runge-Kutta, the resulted error was three orders smaller than that of the UDF. The axial and angular velocities for both bodies 1 and 2 were computed using UDF and Matlab(r) ODE, and the results and their deviations are plotted in Figure 7. The mean percentage errors between the UDF and Matlab(r) ODE for the \(V_{x}\), \(V_{y}\), and \(\omega\) of body 1 were 1.46%, 0.84%, and 1.87%, respectively and for body 2 were 1.15%, 0.82%, and 0.43%, respectively. These trivial errors imply the appropriateness of UDF code in solving a complex multibody mechanism. Figure 4: Contours of the velocity of the (**a**,**c**,**e**) unconstrained and (**b**,**d**,**f**) constrained mechanisms at different simulation times. Selection of the time step size is one of the most important factors in the numerical integration of differential equation systems. To determine the appropriate size of the time step, first, the problem was solved by Matlab(r) ODE for an arbitrary force field with high frequencies (Supplementary file B: Arbitrary external force field) compared to a real force field. The method of ODE45 was selected. All ODE solvers provided by Matlab(r) employ a variety of variable-step methods. The Matlab(r) ODE solvers apply these methods by taking a step, computing the error at this step, checking if the value is greater than or less than the tolerance, and changing the step size accordingly. Utilizing a variable step guarantees that a large step size is utilized for low frequencies and a small step size is utilized for high frequencies. The ODE solvers within MATLAB are improved for a variable step, run faster with a variable step size, and clearly, the outcomes are more accurate. After solving the problem using ODE45 the smallest time step size was selected, and the differential equations of motion Equations (6)-(9) were solved by forward finite-difference Equations (2) and (3) in UDF environment to be sure that the error is less than the tolerance. The problem was solved for both unrealistic and realistic force fields. The reason a variable time step size was not selected for UDF, was that the ANSYS Fluent(r) would not accept variable values for time intervals, but only fixed step size. The proposed methodology can be described in short as computing equations of motion in the presence of external and internal forces applying on a mechanism as aerodynamic and constraint forces, respectively. Then, discretizing and reformulating them based on the next time step. Therefore, the next positions can be estimated by the previous values of positions and forces. The difficult part is to compute the equations of motion.