# A Nonlinear CFD/Multibody Incremental-Dynamic Model for A Constrained Mechanism
## 2 Materials and Methods
### Algorithm and Problem-Solving for a Four-Degree of Freedom System  
A practical example of a planner system with four-degree of freedom based on the algorithm is shown in Figure 1. All the steps of dynamic and aerodynamic analyses and coding in the UDF environment were investigated. This example approves the credibility of the algorithm. To emphasize the proposed algorithm, a simple model was chosen. This model includes two bodies with the masses of \(m_{1}=2\) kg and \(m_{2}=2\) kg, the lengths of \(l_{1}=0.5\) m and \(l_{2}=0.5\) m, the center of gravity (COG) lengths of \(l_{c_{1}}=0.25\) m and \(l_{c_{2}}=0.25\) m, and the principal inertias of \(l_{1}=1.4\) kg\(\cdot\)m\({}^{2}\) and \(l_{2}=1.4\) kg\(\cdot\)m\({}^{2}\). For the CFD solution, the bodies were imposed to the air flow with velocity of \(v=-3\) m/s and \(v=-5\) m/s for constrained and unconstrained systems, respectively. These bodies were connected to each other by a revolute joint. Due to the flow of fluid, aerodynamic forces and torques were applied to the COGs as presented in Figure 2a. In this figure, the vectors of \([X_{1/20},Y_{1/20}]\), \([X_{1/21},Y_{1/21}]\), and \([X_{1/2},Y_{1/2}]\) show the origin, insertion, and COG of the links 1 and 2, respectively. The vectors of \(\mathbf{R}_{1}\) and \(\mathbf{R}_{2}\) demonstrate the external aerodynamic forces acting on the links of 1 and 2, respectively. The values of \(d_{1}\) and \(d_{2}\) are the distances between the applied external forces and the COGs of links 1 and 2. It is desired to compute the planer configurations of the two bodies, in which the following equality is satisfied during the simulation:  
\[\left[ \begin{array}{c}X_{1I}\\ Y_{1I}\end{array} \right]=\left[ \begin{array}{c}X_{2O}\\ Y_{2O}\end{array} \right] \tag{5}\]The satisfaction of Equation (5) would guarantee the connection of two bodies as a revolute joint. The dynamic equations of the motion can be derived using the Newton-Euler method for the free body diagram of the system as indicated in Figure 2b. In this figure, the external forces of \(\mathbf{R}_{1}\) and \(\mathbf{R}_{2}\) are transmitted to the COGs for bodies 1 and 2, respectively. This creates the torques of \(\tau_{1}\) and \(\tau_{2}\). The external forces were rewritten based on their components (\(R_{1x}\), \(R_{1y}\), \(R_{2x}\) and \(R_{2y}\)). The values of \(F_{rx}\) and \(F_{ry}\) are the internal forces in the directions of \(x\) and \(y\), and the variables of \(\theta_{1}\) and \(\theta_{2}\) are the angles of bodies 1 and 2 with respect to the horizon, respectively. The system of equations of motion for Figure 2 is presented as follows:  
\[R_{1x}+R_{2x}-\left(\ddot{X}_{1}+l_{1c}f_{1}-l_{2c}f_{2}\right)=m_{1}\ddot{X}_ {1} \tag{6}\]  
\[R_{1y}+R_{2y}-m_{2}\left(\ddot{Y}_{1}-l_{1c}h_{1}+l_{2c}h_{2}+g\right)-m_{1}g=m _{1}\ddot{Y}_{1} \tag{7}\]  
\[(q_{1}\sin(\theta_{1})-q_{2}\cos(\theta_{1}))l_{1c}+\tau_{1}=l_{1}\ddot{\theta }_{1} \tag{8}\]  
\[(-q_{1}\sin(\theta_{2})+q_{2}\cos(\theta_{2}))l_{2c}+\tau_{2}=l_{2}\ddot{\theta }_{2} \tag{9}\]  
where:  
\[f_{1}=\ddot{\theta}_{1}\sin(\theta_{1})+\dot{\theta}_{1}^{2}\cos(\theta_{1}) \tag{10}\]  
\[f_{2}=\ddot{\theta}_{2}\sin(\theta_{2})+\dot{\theta}_{2}^{2}\cos(\theta_{2}) \tag{11}\]  
\[h_{1}=\ddot{\theta}_{1}\cos(\theta_{1})-\dot{\theta}_{1}^{2}\sin(\theta_{1}) \tag{12}\]  
\[h_{2}=\ddot{\theta}_{2}\cos(\theta_{2})-\dot{\theta}_{2}^{2}\sin(\theta_{2}) \tag{13}\]  
\[q_{1}=R_{2x}-\ddot{X}_{1}-l_{1c}f_{1}+l_{2c}f_{2} \tag{14}\]  
\[q_{2}=R_{2y}-m_{2}\left(\ddot{Y}_{1}-l_{1c}h_{1}+l_{2c}h_{2}+g\right) \tag{15}\]  
If the external forces and torques were determined, there are four unknown variables (generalized coordinates), including \(X_{1}\), \(Y_{1}\), \(\theta_{1}\) and \(\theta_{2}\), which can be computed by solving the system of motion Equations (6)-(9). The dynamics governing Equations (6)-(9) can be generally solved by two different numerical methods. One is to use Runge-Kutta fourth order to solve the system of ordinary differential equations (ODEs).