1 Introduction

Modern methods for simulating multibody dynamics include algebraic constraint equations to represent mechanical joints. Such equations enforce absolute alignment of the connected bodies in the desired direction of relative motion, and thus represent “ideal joints”. However, real mechanical systems have joints with clearances, and the condition of absolute alignment is not always followed. In real-world applications, the motion is governed by intermittent formation of one or multiple contacts. The resulting contact forces are highly nonlinear phenomena that are challenging to model.

Multibody dynamics studies mechanical systems consisting of several bodies that are interconnected with kinematic constraints. These constraints, in the form of mathematical equations, restrict their relative movement and are subjected to the acting external forces that may include gravitational forces, time dependent forces, or contact forces generated by the contacts between the bodies. Indeed, these kinematic constraints enforce absolute alignment of the interacting bodies in a specific direction of the relative motion. However, in the real-world systems, the mechanical components also have clearances and gaps, and the condition of absolute alignment cannot be always expressed by kinematic constraint equations. In such cases, the motion is governed by the formation of contacts at one or multiple points. Consequently, a contact-evaluation procedure must be able to model the dynamics of the contact between compliant surfaces.

The foundations of pure elastic contact models were laid by Heinrich Rudolf Hertz [1]. He concluded that a contact area can be roughly assumed to be elliptical, and no energy dissipation was considered for the contact to be elastic. This led several researchers to develop more advanced contact-force models that take this energy dissipation into account. Hertz’s contact law relates the contact force to a nonlinear power function of the indentation and can be expressed as

$$ F_{c} = K\,\delta ^{n}, $$
(1)

where \(K\) is the contact-stiffness coefficient and \(\delta \) is the relative indentation between the bodies. The lack of energy dissipation can be overcome by including hysteresis damping after the evaluation of contact force. The model developed by Kelvin and Voigt [2] includes energy dissipation, where contact is modeled as a linear spring and a linear damper element as follows:

$$ F_{c} = K\delta + D\dot{\delta}, $$
(2)

where \(D\) represents the damping coefficient and \(\dot{\delta}\) is the relative normal velocity of indentation. However, the Kelvin and Voigt model does not address the nonlinearity of the contact formation process. Hence, a popular general method for evaluating contact forces has the form

$$ F_{c} = K\delta ^{n} + \chi \delta ^{n} \dot{\delta}. $$
(3)

Several contact force models were formulated based on different methodologies to evaluate the damping coefficient \(\chi \) and the deformation \(\delta \). Some of the most popular contact models include [39]. Further, recent rich literature reviews [1012] provide a comprehensive review of major continuous contact models worked out hitherto.

Besides contact force evaluation, contact detection is another challenge. Corral et al. [13] introduced a geometry-based contact model that considers penetration for evaluating displacement and restitution. One interesting feature of this model is that it formulates infinite planes to identify the contact points; however, this model does not combine well with differential algebraic equations (DAEs) or ordinary differential equations (ODEs) for constrained multibody systems.

Dopico et al. [14, 15] and Choi et al. [16] proposed a contact model that can be incorporated in index-3 DAE models. This approach uses a discretized mesh representation of geometry to identify the contact points. Therefore, the resulting constraint manifold is defined with equations corresponding to each node. These methods account for contact dynamics by forcing penalty factors using an augmented Lagrangian method. The equations of motion at the contact point are solved by projection of velocity and acceleration at contact points to solve for static equilibrium.

The contact model developed by Nikravesh and Lankarani [17] has been widely adopted, including in commercial software packages. This model uses a combination of nonlinear spring and damping elements to simulate the unilateral contact. Using this model, Shen et al. [18] developed a formulation for simulating impact dynamics by using dynamic optimization with energy loss being the objective function. A drawback of this contact model is that high stiffness values of the nonlinear springs result in “stiff” differential equations, which require very small time step sizes for numerical integration. Furthermore, separate detection of each contact and subsequent evaluation of contact forces makes the approach computationally inefficient, especially when multiple contacts occur intermittently. Using interpenetration for evaluating contact forces violates the constraints manifold.

Mechanical joints with clearances pose a special condition of “small gap systems” where contact formation and breaking-off can happen at high frequencies. Dynamics with clearance in joints was studied in Sharf and Zhang [19] and [20]. Sharf and Zhang in [19] founded the geometry-based contact models. Zakhariev [20] described an approach for calculating the reaction and friction forces between pairs of bodies in spatial mechanical systems as well as contact points in joints with clearances. Matrix methods were used to derive the nonlinear kinematic constraint equations, and the external and inertia forces for each configuration of the kinematic chain the contact points and corresponding normal forces were calculated. A drawback of the methodology in [20] is that the derived equality constraints do not account for all the possible orientations of the contact formation.

Further developments regarding joints with clearance include the work by Ibrahimi et al. [21], Flores and Lankarani [22], and Xiang et al. [23], demonstrated through a number of simulations on planar systems formulated as DAEs and contact model referenced from [17]. Time independent sensitivity analysis for planar systems was also included in [21]. Bauchau et al. [24] used unilateral contact conditions to simulate planar and spatial joints by adding additional rotational state variables and using nonholonomic inequality constraints with introduction of slack variables.

Another approach to deal with contact problems is the nonsmooth dynamics method. Moreau formulated the noncontinuous properties of nonsmooth mechanics [2527]. Panagiotopoulos studied problems involving inequalities [28] and developed the formulations for hemivariational inequalities for mechanics, robotics, and neural network problems [29]. Moreover, the book [30] illustrates a proof about the validity of the impact theory given by Jean and Moreau. Since 1970s and 1980s, the theoretical and the mathematical formulation have substantially progressed, and have been demonstrated in industrial applications. Further, a comprehensive textbook by Acary and Brogliato [31, 32] covers a wide range of applications in mechanical and electrical systems. The book by Leine [33] investigates bifurcations of equilibrium in nonsmooth systems. Furthermore, Jean and Moreau [34] contributed substantially to modeling dry friction and frictional impacts. This topic is covered in great detail by Brogliato [35]. The evolution of such processes has been covered in great detail in the literature such as Fremond [36], Glocker [37], Pfeiffer [38], and Wriggers [39].

Solving nonsmooth problems requires effective numerical solution strategies [31, 40]. The problem for planar nonsmooth systems results into a linear complementarity problem (LCP) and for spatial systems a nonlinear complementarity problem (NCP). The extended linear programming theories assure the existence of a solution for LCPs. For NCPs various formulations have been suggested and demonstrated through case-studies [4143]. Further, Cosimo et al. [44, 45] gave efficient numerical algorithms based on decoupling methods applied with \(\alpha \)-integration schemes. The comprehensive work by Brogliato et al. [46] includes various numerical methods for solving nonsmooth problems. Moreover, one of the most efficient theories of multibody systems with contacts, as given by Bremer [47] and Bremer and Pfeiffer [48], essentially applies projection methods on multibody dynamics theory. With time, this type of multibody theory has been combined with inequality formulations to describe the unilateral behavior of multiple contacts [4951]. The applicability of this theory to continuous and discontinuous systems, as well as impact dynamics, makes it a versatile formulation [5254].

Recently, the effectiveness of nonsmooth dynamics approaches has been demonstrated in many-body dynamics problems such as simulation of sand particles, stacking of bricks, and stacking of multiple balls in a box [5557]; in all these applications the formulation of constraints is straightforward. When implementing a nonsmooth dynamics approach to multibody systems, a crucial aspect is the formulation of constraints. Because of shape and geometry of the components, the constraint formulation should capture the possibilities of multiple contact points at different locations while retaining the analytical nature of the constraint expression. Negrut et al. [58] described a methodology through which this can be achieved. The methodology poses the dynamics of the rigid bodies as a nonlinear programming problem (NLP) and uses dynamic optimization for minimizing an objective function derived from augmented Lagrangian approach. The definitions of cylindrical and revolute clearance joints given by Orden [59], Ambrosio et al. [60, 61], Liu [62], and Marques and Flores [6365] consider angular misalignment as an inequality constraint instead of constraining both the possible contact points individually. These definitions have widely been used in \(\mathbf{r}\mathbf{p}\) formulations with continuous contact models. However, in the \(\mathbf{r}\mathbf{A}\) formulation, the constraint on angular misalignment is not needed. This was discussed in detail in Section 3.1. Further, the discussed methodologies were demonstrated on spherical joints [66] and planar prismatic joints in [67], and more recently, on a spatial revolute joints in [6870]. While the formulation explained in [68] uses a similar approach to define revolute joints with clearance as discussed in this paper, it only considers radial clearance in the definition of joint and neglects axial clearance. On the other hand, Akhadkar et al. [69, 70] used commercial software packages for contact detection, and the formulation of joints was not covered by the authors. Further, planar prismatic joints were studied in detail by Flores et al. [67, 71]. However, the spatial prismatic joints have not received much attention, and hence the requirement of a robust definition of a spatial prismatic joint needs to be realized.

Studying a vast background of the literature, a need is thus realized to provide the general reader a framework for computer implementation of nonsmooth methods on multibody systems with clearances. This paper provides the reader a nonsmooth dynamics based framework dedicated to the simulation of multibody systems having frictionless ideal joints and joints with clearances. Specific contributions of this paper are as follows:

  1. 1.

    Analytical constraint expressions are derived for several fundamental joints with clearances: cylindrical, revolute, and prismatic. Key differences between the proposed formulation of cylindrical and revolute joints and their precursors are discussed.

  2. 2.

    Not much work has been previously devoted to spatial prismatic joints with clearance. Here, a detailed definition of spatial prismatic joint with clearances is included.

  3. 3.

    A general NLP formulation is given for discretizing multibody dynamics of systems encompassing these fundamental joints with clearances.

  4. 4.

    An adaptive time-stepping scheme is discussed for the discrete NLP time integration.

  5. 5.

    The versatility of the framework is demonstrated through numerical experiments.

The remainder of this paper is structured as follows. Section 2 reviews the general NLP formulation applied to the time discretization of multibody systems. Section 3 formulates constraint expressions for spatial joints with clearances as functions of the rigid body pair’s geometric features. Section 4 presents the case studies considered for testing the proposed formulation. Section 5 reports numerical results that illustrate the capabilities of the proposed approach and highlight the different dynamical behavior observed when joint clearances are accounted for. Section 6 concludes with key observations and a discussion on further scope of the work.

2 Methodology

2.1 Multibody dynamics in NLP formulation

This section illustrates the formulation of multibody systems in the general form of a nonlinear programming problem. Subsection 2.1.1 describes the equations of motion for rigid bodies undergoing motion in the absence of any constraints. Subsection 2.1.2 illustrates a method to evaluate contact forces on a set of rigid bodies. Subsection 2.1.3 combines the elements of free body dynamics and contact forces into an NLP of a general form. Finally, in Subsection 2.1.4, strategies to solve the general NLP problem through temporal discretization are discussed.

2.1.1 The free body dynamics

Formulation of equations of motion for three-dimensional systems in the body-frame coordinates results in a constant full rank and invertible \(6 \times 6\) mass matrix for each body [7274]. Considering these essential requirements, this section describes the free body dynamics.

Consider a rigid body of mass \(m\), inertia matrix \(\mathbf{J}\), generalized coordinates (placed at the center of mass) \(\mathbf{q}={[\mathbf{r}^{T},\mathbf{p}^{T}]}^{T}\in \mathbb{R}^{7}\) in global frame, and the corresponding time derivatives of generalized coordinates \({\dot{\mathbf{q}}}={[{\dot{\mathbf{r}}}^{T},{\dot{\mathbf{p}}}^{T}]}^{T} \in \mathbb{R}^{7}\), where \(\mathbf{r}\in \mathbb{R}^{3}\) is the set of Cartesian \([x,y,z]\) coordinates and \(\mathbf{p}\in \mathbb{R}^{4}\) is the set of Euler parameters \({[e_{0}, \mathbf{e}^{T}]}^{T}\), all in global frame of reference. The equations of motion from D’Alembert’s principle [75] are as follows:

δ r T ( m r ¨ F A ) +δ π T ( J ω ˙ + ω ˜ J ω τ A ) =0,
(4)

where \(\delta \mathbf{r}\in \mathbb{R}^{3}\) are the infinitesimally small virtual displacements in global coordinate system and \(\delta \boldsymbol{\pi '}\in \mathbb{R}^{3}\) and virtual rotations in body-fixed coordinate system. The operator ‘\(\mathbf{\tilde{.}} \)’ gives out the skew-symmetric matrix of the body-fixed vector of angular velocity ω . The vector \(\mathbf{F_{A}} \in \mathbb{R}^{3}\) represents externally applied forces in global reference frame, and \(\mathbf{\boldsymbol{\tau '}_{A}} \in \mathbb{R}^{3}\) are the externally applied torques in body-fixed reference frames. Equation (4) can thus be decomposed into the following set of equations in the absolute coordinate system, also called \(\mathbf{rA}\) coordinate formulation [76, 77]:

$$\begin{aligned} m\,{\ddot{\mathbf{r}}} =& \mathbf{F_{A}}, \end{aligned}$$
(5a)
J ω ˙ + ω ˜ Jω = τ A .
(5b)

Equations (5a) and (5b) can be written in a matrix form as follows:

[ m I 0 0 J ] [ r ¨ ω ˙ ] + [ 0 ω ˜ J ω ] [ F A τ A ] =0.
(6)

Similarly, for a system of \(N\) bodies, equation (6) takes the form

[ m 1 I 0 0 0 0 0 0 J 1 0 0 0 0 0 0 m 2 I 0 0 0 0 0 0 J 2 0 0 0 0 0 0 m N I 0 0 0 0 0 0 J N ] [ r ¨ 1 ω ˙ 1 r ¨ 2 ω ˙ 2 r ¨ N ω ˙ N ] + [ 0 1 ω ˜ 1 J 1 ω 1 0 2 ω ˜ 2 J 2 ω 2 0 N ω ˜ N J N ω N ] [ F A 1 τ A 1 F A 2 τ A 2 F A N τ A N ] =0,
(7)

which in a matrix form reads

$$ \mathbf{M}\,{\dot{\mathbf{v}}}+\mathbf{S}\,(\mathbf{q},{ \dot{\mathbf{q}}})-\mathbf {Q}_{\mathbf{A}}=\mathbf{0}. $$
(8)

In (8), \({\dot{\mathbf{v}}}\in \mathbb{R}^{6N}\) is the vector of time derivatives of the body-fixed velocity vector \(\mathbf{v}\in \mathbb{R}^{6N}\) for \(N\) bodies. The matrix \(\mathbf{M}\in \mathbb{R}^{6N \times 6N}\) combined mass matrix of \(N\) bodies in the absolute coordinate system. The vector \(\mathbf{S}\,(\mathbf{q},{\dot{\mathbf{q}}}) \in \mathbb{R}^{6N}\) represents the vector of forces because of rotation, and the vector \(\mathbf {Q}_{\mathbf{A}}\in \mathbb{R}^{6N}\) represents external forces (in global frame) and torque (in body fixed coordinate system) acting on the body neglecting friction. The mapping between the body-fixed angular velocity vector ω and the time derivatives of Euler parameters \({\dot{\mathbf{p}}}\) is given using the matrix \(\mathbf{G}(\mathbf{p})\) composed of orthogonal column vectors as follows [75]:

G ( p ) : = [ e e ˜ + e 0 I ] , p ˙ = 1 2 G T ( p ) ω , ω = 2 G ( p ) p ˙ .
(9)

Unless the contact happens, the bodies move freely as an unconstrained system and have the unconstrained accelerations:

$$ {\dot{\mathbf{v}}}_{\mathrm{uc}}=-\mathbf{M}^{-1} \, \big(\mathbf{S}\,( \mathbf{q},{\dot{\mathbf{q}}})-\mathbf {Q}_{\mathbf{A}}\big). $$
(10)

2.1.2 Dynamics with contact

Consider two bodies \(A\) and \(B\) in contact, as shown in Figure 1. Their respective centers of mass are \(c_{A}\) and \(c_{B}\), and their coordinates in the absolute coordinate system are \(\mathbf{r}_{A}\) and \(\mathbf{r}_{B}\), respectively. The contact point is detected at a location indicated by body fixed vectors \(\mathbf {s}\boldsymbol {'}_{A}\) and \(\mathbf {s}\boldsymbol {'}_{B}\) in bodies \(A\) and \(B\) respectively. Let \(\mathbf{n}_{j}\) be the normal unit vector along which the contact force acts on body \(A\) at the \(j^{th}\) contact in the global reference frame. This is required because all the forces are evaluated in the global reference frame [58]. The corresponding unit vector for body \(B\) will be \(-\mathbf{n}_{j}\). If the magnitude of contact force at the \(j^{th}\) contact is denoted by \(\lambda _{j}\), the combined vector of contact forces in the global reference frame and the torques generated by them in body-fixed frame can be evaluated by equation (11), as derived in [58]:

$$ \mathbf{F_{C}}_{j}= \begin{bmatrix} \mathbf{n}_{j} \\ {\mathbf {\tilde {s}}\boldsymbol {'}}_{A}\,\mathbf{A}^{T}(\mathbf{p}_{A})\,\mathbf{n}_{j} \\ -\mathbf{n}_{j} \\ -{\mathbf {\tilde {s}}\boldsymbol {'}}_{B}\,\mathbf{A}^{T}(\mathbf{p}_{B})\,\mathbf{n}_{j} \end{bmatrix} \lambda _{j}=\mathbf{D}_{j}\,\lambda _{j}, $$
(11)

where \(\mathbf{A}\in \mathbb{R}^{3 \times 3}\) is the rotation matrix as a function of the Euler parameters of bodies \(A\) and \(B\), \(\mathbf{D}_{j} \in \mathbb{R}^{6N \times 1}\) is the contact matrix, and the operator ‘\(\mathbf{\tilde{.}} \)’ gives out the skew-symmetric matrix of the underlying arbitrary vector. Similarly, for a number of possible \(M\) contacts between the two bodies, the total contact force \(\mathbf{F_{C}}\) is the sum of all the contact forces acting on the respective bodies, where \(\mathbf{D}\in \mathbb{R}^{6N \times M}\) and , and is given as follows:

(12)

Using the same construct, the relative normal velocity between the two bodies at the contact point \(j\) in the mixed frame of reference is [58]

v r e l j = D j T [ r ˙ A ω A r ˙ B ω B ] = D j T v.
(13)
Fig. 1
figure 1

Schematic representation of bodies in contact (Color figure online)

2.1.3 The nonlinear programming problem

Equation (10) is an expression to evaluate the unconstrained accelerations in the absolute coordinates. In addition, the orthonormality of Euler parameters has to be enforced for each body as a bilateral equality constraint [75]:

$$ \mathbf{B}(\mathbf{q})= \begin{bmatrix} \mathbf{p}_{1}^{T}\,\mathbf{p}_{1} -1 \\ \mathbf{p}_{2}^{T}\,\mathbf{p}_{2} -1 \\ \vdots \\ \mathbf{p}_{N}^{T}\,\mathbf{p}_{N} -1 \end{bmatrix} =\mathbf{0}. $$
(14)

Therefore, there exists a set of Lagrange multipliers such that

(15)

where \(\mathbf{B}_{\mathbf{q}}(\mathbf{q})\) is the Jacobian matrix of \(\mathbf{B}(\mathbf{q})\) in equation (14). The state-of-the-art nonsmooth method proposed by [58] has been demonstrated on granular materials of spherical structure. Such particles have minute inertia and are uniformly distributed because of the spherical shape. In such cases, rotation does not impact the state variables to a significant extent, and hence (14) can be neglected for such cases. However, for rigid bodies, the inertia is significant and is often not uniformly distributed. Indeed, the rotation of the component can affect the stability of the solution [78]. Hence, in cases of rigid bodies, the normalization constraint on Euler parameters needs to be enforced to ensure orthogonality of basis vectors of the body-fixed frame.

Further, let the gap function Φ ineq R M × 1 represent the vector of algebraic inequalities for \(M\) unilateral contacts in the system. Let the condition of nonzero gap be such that Φ j ineq 0, \(j \in 1, 2, \dots , M\), where each element \(j\) of Φ ineq has a negative value. If the contact is formed, i.e., Φ j ineq =0, \(j \in 1, 2, \dots , M\), the addition of the contact forces thus generated results in constrained equation of motion as follows, where \({\dot{\mathbf{v}}}\) is the vector of constrained accelerations:

(16a)
(16b)

where the notation represents the element-wise product of every expression in the constraint manifold and the corresponding magnitude of contact force. This complementarity condition states that when there is no contact, the \(j^{th}\) constraint expression Φ j ineq <0 and the contact force’s magnitude . However, when the contact happens, Φ j ineq =0 and the contact force’s magnitude .

Furthermore, Gauss’ principle of least constraint [79, 80] states that the true acceleration of a mechanical system of \(N\) particulate masses \({\ddot{\mathbf{r}}}_{j} \in \mathbb{R}^{3}\) is the minimum of the following quantity:

$$ \mathcal{J}=\sum _{j=1}^{N} m_{j} \left \Vert \,{\ddot{\mathbf{r}}}_{j}- \frac{\mathbf{F}_{j}}{m_{j}}\,\right \Vert ^{2} \quad \forall j \in [1, 2, 3, ..., N], $$
(17)

where the \(j^{th}\) particle has mass \(m_{j}\), position vector \(\mathbf{r}_{j} \in \mathbb{R}^{3}\), and applied vector of nonconstraint force \(\mathbf{F}_{j} \in \mathbb{R}^{3}\) acting on the mass. Equation (17) is also applicable to rotational accelerations as shown by Udwadia and Yang et al. [79, 80] and Glocker [37]. With a constant mass matrix \(\mathbf{M}\) and plugging equations (10), (16a) and (16b) in equation (17), the governing objective function for the system can be represented as the minimum of the difference between constrained and unconstrained accelerations as shown in equation (18).

(18)

Since \(\mathbf{M}\) is a constant symmetric matrix, equation (18) can be written as follows:

(19)

It must be noticed that the objective function in (17) holds true for hyperstatic case because the contacting bodies are rigid. For simulating soft (flexible) contacts, an additional damping matrix gets added to the Schur complement \([\mathbf{D}\quad \mathbf{B}_{\mathbf{q}}^{T}]^{T} \, \mathbf{M}^{-1}[ \mathbf{D}\quad \mathbf{B}_{\mathbf{q}}^{T}]\), as described in [81]. Further, flexible systems often result in under-constrained mathematical models, and dealing with such systems is out of the scope of the work presented here. Hence the rigid-body dynamics problem can be stated as a nonlinear programming problem (20) for the vector of state variables . Here the objective function (19) is minimized subject to the constraints imposed by equations of motion and the complementary constraints (16a) and (16b), and the normalized Euler parameters (14):

(20)

Furthermore, to simulate a multibody system with a combination of equality type constraints Φ eq =0, i.e., for ideal joints, the manifold Φ eq can be appended to the bilateral constraint manifold (14), as discussed in Section 2.2. The capacity of the described NLP formulation to deal with ideal as well as contact-driven constraints makes it an all-inclusive formulation.

2.1.4 Discretization and solution strategy

Consider now the discrete version of the dynamics. At time \(t_{n-1}\) one has available the global frame time derivatives of generalized coordinates \({\dot{\mathbf{q}}}_{n-1}\), the velocities \(\mathbf{v}_{n-1}\), and the positions of the generalized coordinates \(\mathbf{q}_{n-1}\) as follows:

$$\begin{aligned} \mathbf{q}_{n-1} =& \begin{bmatrix} \mathbf{r}^{T}_{n-1} & \mathbf{p}^{T}_{n-1} \end{bmatrix} ^{T}, \end{aligned}$$
(21a)
$$\begin{aligned} \mathbf{v}_{n-1} =& \begin{bmatrix} {{\dot{\mathbf{r}}}^{T}}_{n-1} & (2\,\mathbf{G}\,(\mathbf{p}_{n-1})\,{ \dot{\mathbf{p}}}_{n-1})^{T} \end{bmatrix} ^{T}, \end{aligned}$$
(21b)
$$\begin{aligned} {\dot{\mathbf{q}}}_{n-1} =& \begin{bmatrix} {{\dot{\mathbf{r}}}^{T}}_{n-1} & {{\dot{\mathbf{p}}}^{T}}_{n-1} \end{bmatrix} ^{T}. \end{aligned}$$
(21c)

Let \(h_{n}\) be the time step size. Then, at the new derivatives of generalized coordinates \({\dot{\mathbf{q}}}_{n}\), the velocities \(\mathbf{v}_{n}\) and the positions of the generalized coordinates \(\mathbf{q}_{n}\) must be evaluated at time \(t_{n} = t_{n-1} + h_{n}\). Hence, using half implicit Euler’s expansion [82], we have the following relationships:

$$\begin{aligned} {\dot{\mathbf{q}}}_{n} =&\begin{bmatrix} {\dot{\mathbf{r}}}^{T}_{n} & {\dot{\mathbf{p}}}^{T}_{n} \end{bmatrix} ^{T}, \end{aligned}$$
(22a)
$$\begin{aligned} \mathbf{q}_{n} =&\mathbf{q}_{n-1}+h_{n}{\dot{\mathbf{q}}}_{n} \end{aligned}$$
(22b)
$$\begin{aligned} \mathbf{v}_{n} =&\begin{bmatrix} {\dot{\mathbf{r}}}^{T}_{n} & (2\,\mathbf{G}\,(\mathbf{p}_{n-1})\,{ \dot{\mathbf{p}}}_{n})^{T} \end{bmatrix} ^{T}, \end{aligned}$$
(22c)
$$\begin{aligned} {\dot{\mathbf{v}}}_{n} =& \frac{\mathbf{v}_{n}-\mathbf{v}_{n-1}}{h_{n}}, \end{aligned}$$
(22d)
$$\begin{aligned} t_{n} =&t_{n-1}+h_{n}. \end{aligned}$$
(22e)

The bilateral constraint expressions (14) can be further discretized using Taylor’s expansion. The unilateral constraints can be discretized using the relative velocities in equation (13). These discretizations are represented in the following equations:

$$ \mathbf{B}\,(\mathbf{q}_{n})\approx \mathbf{B}\,(\mathbf{q}_{n-1})+h_{n} \,\mathbf{B}_{\mathbf{q}}(\mathbf{q}_{n-1})\,{\dot{\mathbf{q}}}_{n}= \mathbf{0}, $$
(23)
Φ ineq ( q n ) Φ ineq ( q n 1 )+ h n D T ( q n 1 ) v n 0.
(24)

Incorporating equations (21a)–(21c), (22a)–(22e), (23), and (24) in NLP (20) we get the following NLP in discretized form, with respect to the vector of optimization variables \([h_{n},\mathbf{Y}_{n}]\):

(25)

where \(\hat{h}_{n}\) and \(\hat{\mathbf{Y}}_{n}\) are the resulting step size and solution, respectively, and \(\mathbf{T}_{n}\) and \(\mathbf{K}_{n}\) are defined as follows:

(26a)
$$ \mathbf{K}_{n} :=\mathbf{T}_{n}+\mathbf{S}\,\left (\mathbf{q}_{n-1},{ \dot{\mathbf{q}}}_{n-1}\right )-\mathbf {Q}_{\mathbf{A}}(\mathbf{q}_{n-1}). $$
(26b)

Here, the optimal values of \(h_{n}\), , , and \({\dot{\mathbf{q}}}_{n}\) need to be found at time \(t_{n}\). The scalar terms \(h_{\min}\) and \(h_{\max}\) respectively are the minimum and maximum finite positive values of time step size. Once the optimization problem (25) has been solved at time \(t_{n}\), the values of \({\dot{\mathbf{q}}}_{n}\) and \(h_{n}\) can then be utilized to evaluate and store the accelerations \({\dot{\mathbf{v}}}_{n}\) and the positions \(\mathbf{q}_{n}\) using equations (22a)–(22e).

It can be noticed that time step size has been considered as a variable parameter bounded by \(h_{\min}\) and \(h_{\max}\) respectively. This time-stepping scheme is purely based on enforcing the feasibility of both: discretized inequality (complementary) constraints representing contact and equality constraints that include equations of motion and discretized equality constraints velocities. Figure 2 shows the feasible region of inequality and equality constraints sets represented by Φ n 0 and \(\mathbf{B}_{n}=\mathbf{0}\) respectively. Equation (22a)–(22e) gives the integrand \(\mathbf{q}_{n}\) at \(n^{th}\) time step. The step size \(h\), essentially, defines the fraction of the length of the vector \({\dot{\mathbf{q}}}\). Further, there could be a situation with fixed step size such that the next step solution lies out of the feasible region hence resulting in violation of constraints. The two plots in Figure 2 represent such a general situation. In the left plot, \(h_{opt}\) indicates the optimal value of \(h\) as per the condition imposed by the linearized inequality constraint. In the right plot, however, a situation is shown where the step size \(h_{opt}\) violates the linearized equality constraints; in such a condition, \(h_{min}\) will be chosen by the algorithm. If the vector \({\dot{\mathbf{q}}}\) is bound to attain a certain magnitude for convergence, then the bounded variable \(h\) provides an extra degree of freedom and helps attain convergence. However, it also results in increase in dimensionality of the problem.

Fig. 2
figure 2

Visual representation of step size variation (Color figure online)

It must be mentioned here that the approach described in this section inherently assumes an inelastic nature of the contact, which is suitable for the scope of this work. The clearances are very small compared to the other dimensions of the components in a machine, and hence the components do not gain enough pre-collision velocities for the contact to fall in the elastic domain.

2.2 Implementation of frictionless ideal joints using the nonsmooth framework

Consider two bodies \(A\) and \(B\) in constrained to each other between points \(P\) and \(Q\) by a set of algebraic equations Φ( q A , q B )=0. Their respective centers of mass Cartesian coordinates in the global coordinate system are \(\mathbf{r}_{A}\) and \(\mathbf{r}_{B}\), respectively. With a set of algebraic constraints defined for the \(k^{th}\) body in the system of \(N\) bodies with \(M\) total constraint equations, the constraint forces \(\mathbf{F}^{k}\) and torques \(\mathbf{T'}^{k}\) acting on the bodies can be evaluated in absolute coordinates using the approach discussed in [77], as presented in equation (27):

(27)

where \(\lambda _{k}\) is the Lagrangian multiplier associated with the \(k^{th}\) body equation Φ k =0 and Φ r is the Jacobian matrix of Φ with respect to Cartesian coordinates \(\mathbf{r}\in [\mathbf{r}_{A}, \mathbf{r}_{B}, \dots , \mathbf{r}_{N}]\). The operator \(\Pi ' \in [\Pi '_{A}, \Pi '_{B}, \dots , \Pi '_{N}]\) on the constraint describes the first order variation of the joint frame located by \(\mathbf {s}\boldsymbol {'}\) in the body frame. In addition to this, the reference [77] also describes the method to formulate following fundamental constraints. Similarly, the vector \(\mathbf{Q}_{c}\) comprising the constraint forces and torques for a system of \(N\) bodies can be defined as in equation (28), where is the vector of all .

(28)

Hence, using the methods for deriving NLP (20), the equations of motion for a smooth system using nonsmooth framework can be stated as NLP (29) for the vector of state variables :

(29)

where

(30)

It can be noticed that the contact matrix \(\mathbf{D}\) in NLP (20) is replaced by a mapping \(\mathbf{C}\) and the inequality constraints vanish, leaving the rest of the structure unchanged. Using equations (21a)–(21c) and (22a)–(22e), the time-discretized equations for continuous systems can thus be written as follows with respect to the vector of optimization variables :

(31)

where \(\hat{\mathbf{Y}}_{n}\) is the resulting solution, and \(\mathbf{H}_{n}\) and \(\mathbf{K}_{n}\) are defined as follows:

(32a)
$$\begin{aligned} \mathbf{K}_{n} :=& \mathbf{H}_{n}+\mathbf{S}\,\left ( \mathbf{q}_{n-1},{\dot{\mathbf{q}}}_{n-1}\right )-\mathbf {Q}_{\mathbf{A}}(\mathbf{q}_{n-1}). \end{aligned}$$
(32b)

2.3 Algorithm

A step-by-step procedure to implement the formulation discussed in Sections 2.1 and 2.2. For a target simulation time \(t_{\mathrm{max}}\), the initial values of \(\mathbf{Y}_{0}\) at time \(t_{0}\) should be such that all constraint equations are satisfied. For the initial values of generalized coordinates satisfying a negative value of gap function, the initial value of Lagrangian multipliers should be assumed zero.

The values of state variables obtained at the \(n^{th}\) time-step in step 7 of the Algorithm 1 can be later used to evaluate contact forces and torques using equation (12).

Algorithm 1
figure 3

Nonsmooth multibody dynamics

3 Parametric definitions of joints with clearances

In this section, the formulations for three fundamental joints used in mechanical systems are presented. The gap function Φ ineq should provide both the normal distance and the normal unit vector between the potential contact points to suit equation (11). Keeping this key requirement in consideration, the parametric formulations for joints with clearances are presented in this section.

3.1 Cylindrical joint with clearances

Figure 3 shows a system of two bodies \(i\) and \(j\) forming a cylindrical joint with radial clearance \(c\). The generalized coordinates of bodies are \(\mathbf{q}_{i}\in \mathbb{R}^{7}\) and \(\mathbf{q}_{j}\in \mathbb{R}^{7}\) respectively. Let points \(P_{i_{1}}\) and \(P_{i_{2}}\) represent the two ends of center-line of body \(i\) in the global frame of reference. Let points \(P_{j_{1}}\) and \(P_{j_{2}}\) represent the two ends of center-line of body \(j\) in the global frame of reference. The perpendicular distances of points \(P_{i_{1}}\) and \(P_{i_{2}}\) from the center axis of body \(j\) are \(d_{s_{1}}\) and \(d_{s_{2}}\), along with the unit vectors \(\mathbf{n}_{s_{1}}\) and \(\mathbf{n}_{s_{2}}\), respectively. Let \(\mathbf{A}(\mathbf{p}_{i})\) and \(\mathbf{A}(\mathbf{p}_{j})\) be the rotation matrices of the respective bodies. Given the local coordinate vector \(\mathbf {s}\boldsymbol {'}_{k_{x}}\) of an arbitrary point \(P_{k_{x}}\) with \(x\in [1,2]\) in a body with respect to the centroid \(k\in [i,j]\), the position of point \(P_{k_{x}}\) can be evaluated in global frame as \(\mathbf{r}_{k_{x}}\) using equation (33).

$$ \mathbf{r}_{k_{x}}= \mathbf{r}_{k}+\mathbf{A}(\mathbf{p}_{k})\, \mathbf {s}\boldsymbol {'}_{k_{x}}. $$
(33)

The body with the smaller axial length will have one or both of the end faces making contact with the longer body. Assuming that body \(i\) is the smaller body and considering \(P_{j_{1}}\) as the reference point with position vector \(\mathbf{r}_{j_{1}}\), the perpendicular vectors \(\mathbf{d}_{s_{x}}\), \(x\in [1,2]\) pointing towards the contact points \(P_{k_{x}}\) can be evaluated via the following equations:

$$ \mathbf{d}_{s_{x}}= (\mathbf{r}_{i_{x}}-\mathbf{r}_{j_{1}})-( \mathbf{r}_{i_{x}}-\mathbf{r}_{j_{1}}) \frac{(\mathbf{r}_{i_{x}}-\mathbf{r}_{j_{1}})^{T}(\mathbf{r}_{j_{2}}-\mathbf{r}_{j_{1}})}{\|\mathbf{r}_{i_{x}}-\mathbf{r}_{j_{1}}\|\,\|\mathbf{r}_{j_{2}}-\mathbf{r}_{j_{1}}\|}, $$
(34)
$$ \mathbf{n}_{s_{x}}=\frac{\mathbf{d}_{s_{x}}}{\|\mathbf{d}_{s_{x}}\|} = \frac{\mathbf{d}_{s_{x}}}{d_{s_{x}}}. $$
(35)

Considering \(c\) of a very small magnitude in comparison to other dimensions of the components, the perpendicular distances \(d_{s_{1}}\) and \(d_{s_{2}}\) must abide the following inequalities:

Φ cylindric ( q ) = [ d s 1 c d s 2 c ] 0.
(36)

Assuming the hole inside the body \(i\) has a radius \(R\), the position of the corresponding contact points \(\mathbf{c}_{x}\) in the global reference frame can be calculated as follows:

$$ \mathbf{c}_{x} =\mathbf{r}_{i}+\mathbf{A}(\mathbf{p}_{i})\mathbf {s}\boldsymbol {'}_{i_{x}}-R \,\mathbf{n}_{s_{x}}. $$
(37)

It must be noticed that the definition of cylindrical and revolute clearance joints defined in [5965] considers angular misalignment as an extra inequality constraint. These definitions have widely been used in \(\mathbf{r}\mathbf{p}\) formulations with continuous contact models. However, the requirement is to define the constraints for clearance joints in the \(\mathbf{r}\mathbf{A}\) formulation such that the normal vector at a contact point must be obtained as a function of the gap present between the colliding points, and the contact matrix thus formed must satisfy equation (24). For this requirement, it is essential that the inequality constraint set Φ must exclusively comprise distance quantities similar to what is defined in [68]. Hence, the cylindrical joint defined in equation (36) is Φ cylindric R 2 . Also, it can be noticed that the normal vector \(\mathbf{n}\) required for evaluating \(\mathbf{D}\) is a direct indicator of the relative normal direction at the contact. Hence, with the proposed definition, the joint is conducive to and can be integrated with the nonsmooth dynamics framework described in the previous sections. Since the function is evaluated in terms of absolute distance with and the normal vector is defined along the direction of the distance vector, the angular misalignment is automatically considered in this approach for all possible combinations of relative orientations of the bodies.

Fig. 3
figure 4

Schematic representation of a spatial cylindrical joint with clearance (Color figure online)

3.2 Prismatic joint with clearances

The spherical, revolute, and cylindrical joints with clearance [5964, 66] and planar prismatic joints [67, 71] have been studied extensively. However, the spatial prismatic joints have not received much attention in the past. The prismatic joint with a clearance poses a special intricacy because of its exclusive dependence on geometric parameters. Traditionally, a prismatic joint consists of shapes with vertices and planes to constrain the rotational motion about the longitudinal axis, and these vertices form the contact points. A prismatic joint without clearance does not require these to be included as the contact forces are not evaluated on individual vertex. However, when clearance is included, each vertex of the inner body (minimum six are required for a spatial prismatic joint) needs to be individually constrained to not penetrate the enveloping body’s two adjacent planes. Hence, the geometric locations of all the vertices are required with respect to the local coordinate system.

Figure 4 shows a system of two bodies \(i\) and \(j\) forming a prismatic joint with clearance. The generalized coordinates of the bodies are \(\mathbf{q}_{i}\in \mathbb{R}^{7}\) and \(\mathbf{q}_{j}\in \mathbb{R}^{7}\) respectively. Each vertex of body \(i\) (inner body) at front and back faces is constrained to two adjacent planes, as shown in Figure 5. For example, points \(P_{4f}\) and \(P_{4b}\) are constrained to planes 1 and 4, points \(P_{1f}\) and \(P_{1b}\) are constrained to plane 1 and plane 3, and so on. It requires at least three points to define a plane. The planes 1–4 are defined by the vertices in the above figure. For example, plane 1 is defined using points \(Q_{1f}\), \(Q_{4f}\), and \(Q_{4b}\), plane 2 is defined by \(P_{1f}\), \(P_{2f}\), \(P_{1b}\), and so on.

Fig. 4
figure 5

Schematic representation of a spatial prismatic joint with clearance

Fig. 5
figure 6

Each pair of vertices results in two values of directional distance vector (Color figure online)

With this methodology, a polygon of any regular or irregular shape can be defined with the help of all the vertices and planes. Each vertex of an \(N\) sided polygon is constrained to two adjacent planes at both the faces. This results in 4\(N\) equations of distance constraint. Obviously, each vertex’s global coordinates need to be calculated as per equation (33). The perpendicular distance between a point \(P\) on body \(i\), where \(P\in [P_{1f},P_{2f},{\ldots},P_{Nf}, P_{1b}, P_{2b},{\ldots}, P_{Nb}]\), and a plane obtained from vertices on body \(j\) can be calculated as follows:

$$ d_{P}=(\mathbf{r}_{P}-\mathbf{r}_{Q})^{T}\mathbf{n}_{QP}\ge 0 , $$
(38)

where \(\mathbf{n}_{QP}\) is the normal vector of the bounding plane pointing towards the point \(P\), \(Q\) is any point in the bounding plane, and \(\mathbf{r}_{P}\) and \(\mathbf{r}_{Q}\) are the vectors associated with point \(P\) and point \(Q\) in the global reference frame evaluated with equation (33). Hence, for a joint of rigid bodies forming a prismatic joint, with the internal body having \(2M\) vertices and bounded by external body having \(M\) planes, the constraint manifold is given as per the following inequality:

Φ prismatic ( q ) = [ d P f 1 d P f 2 M d P b 1 d P b 2 M ] 4 M × 1 0.
(39)

Here, the subscripts ‘\(f\)’ and ‘\(b\)’ respectively signify the vertices in front and back, as shown in Figure 4. It can be inferred from equation (39) that the dimensionality of NLP (25) increases with the number of vertices in the joint. This is another justification for the lack of studies on prismatic joints with clearances, as compared to other fundamental joints.

3.3 Revolute joint with clearances

The spatial revolute joint is essentially an axially constrained cylindrical joint. Let body \(i\) in Figure 3 be axially constrained at the ends of body \(j\) such that there remains an axial clearance \(c_{a}\). The normal vectors \(\mathbf{n}_{j_{1}}\) and \(\mathbf{n}_{j_{2}}\) at the constraining planes at \(P_{j_{1}}\) and \(P_{j_{2}}\), respectively, are evaluated as per the following equations:

$$ \begin{aligned} \mathbf{n}_{j_{1}} = \frac{\mathbf{r}_{j_{2}}-\mathbf{r}_{j_{1}}}{\|\mathbf{r}_{j_{2}}-\mathbf{r}_{j_{1}}\|}, \qquad \mathbf{n}_{j_{2}} =-\mathbf{n}_{j_{1}}. \end{aligned} $$
(40)

Consequently, the construction of the joint requires that the distance of points \(P_{i_{1}}\) and \(P_{i_{2}}\) from \(P_{j_{1}}\) and \(P_{j_{2}}\), projected on the normal vectors \(\mathbf{n}_{j_{1}}\) and \(\mathbf{n}_{j_{2}}\), respectively, is positive.

$$ \begin{aligned} -(\mathbf{r}_{i_{1}}-\mathbf{r}_{j_{1}})^{T}\mathbf{n}_{j_{1}} \le 0 , \\ -(\mathbf{r}_{i_{2}}-\mathbf{r}_{j_{2}})^{T}\mathbf{n}_{j_{2}}\le 0. \end{aligned} $$
(41)

Hence, the constraint manifold for a revolute joint with clearances is given as the following set of inequalities:

Φ revolute ( q ) = [ Φ cylindric ( q ) ( r i 1 r j 1 ) T n j 1 ( r i 2 r j 2 ) T n j 2 ] 0.
(42)

4 Case studies

This section discusses the three relevant case studies that were used to test the methodology discussed in Sections 2 and 3.

4.1 Case study: cylindrical joint

Figure 6 shows a simple case study of a spatial cylindrical joint with clearance to illustrate the proof of concept for the proposed formulation. The case study comprises of a slider of mass \(m\) with its center of mass denoted by the generalized coordinates \(\mathbf{q}\in \mathbb{R}^{7}\) and a mass-less rod of radius \(R\) fixed at both ends. There is a radial clearance \(c = 0.1\text{ mm}\) between the slider and the rod and gravity acts along the \(-\mathbf{Y}\) axis. An external force \(F\) acts on the slider at a point marked by a body-frame vector \(\mathbf {s}\boldsymbol {'}_{f}\). The system specific details illustrated in Figure 6 are shown in Table 1.

Fig. 6
figure 7

Schematic diagram of the cylindrical joint with clearance

Table 1 Case study specifications: Cylindrical joint (Color figure online)

4.2 Case study: prismatic joint

Figure 7 shows a simple case study of a spatial prismatic joint with clearance \(c = 0.3\) mm. As it can be observed, the bodies have triangular cross-section with each edge of the cavity in body \(j\) of length \(e_{j}\); the corresponding length for body \(i\) is \(e_{i}\). The slider \(i\) has mass \(m\) with its center of mass denoted by the generalized coordinates \(\mathbf{q}\in \mathbb{R}^{7}\) and a mass-less triangular prism is fixed at both ends. The gravity acts along the \(-\mathbf{Y}\) axis and an external force \(F\) acts on the slider at a point marked by a body-frame vector \(\mathbf {s}\boldsymbol {'}_{f}\). The topmost vertices of the slider are labeled \(P_{f_{1}}\) and \(P_{b_{1}}\) respectively. The trajectory of these two contact points is tracked and discussed in Section 5.2. The system specific details illustrated in Figure 7 are shown in Table 2.

Fig. 7
figure 8

Schematic diagram of the triangular prismatic joint with clearance (Color figure online)

Table 2 Case study specifications: Prismatic joint (Color figure online)

4.3 Case study: revolute joint

Figure 8 shows a simple case study of a pendulum \(i\) forming a revolute joint with a hinge pin \(j\) of radius \(R\). The radial and axial clearances are denoted by \(c\) and \(c_{a}\). The center of mass of the pendulum is located at \(cm_{x}\) and \(cm_{z}\) units along local X and Z directions. As can be observed, the bob of the pendulum is a rod protruding out of the XZ plane. This odd shape has been chosen to induce motion along Z direction as well. The pendulum \(i\) has mass \(m\) with its center of mass denoted by the generalized coordinates \(\mathbf{q}\in \mathbb{R}^{7}\) and the hinge pin \(j\) is mass-less and fixed at both ends. The gravity acts along the \(-\mathbf{Y}\) axis. The system specific details illustrated in Figure 8 are shown in Table 3.

Fig. 8
figure 9

Schematic diagram of the revolute joint with clearance (Color figure online)

Table 3 Case study specifications: Revolute joint

5 Results and discussion

The simulation results were achieved using sequential quadratic programming (SQP) available in MATLAB® toolbox. The SQP algorithm uses the penalty method proposed by [83, 84], where the penalty parameter for \(k^{th}\) iteration \(r_{k_{i}}\) corresponding to \(i^{th}\) constraint is given as follows:

$$ r_{k_{i}}= \max (\lambda _{i}, \frac{\lambda _{i}+r_{{k-1}_{i}}}{2}), $$
(43)

where \(\lambda _{i}\) is the Lagrange multiplier associated with \(i^{th}\) constraint.

The case-studies of cylindrical and prismatic joints were conducted with time step \(h\) varying between \(h_{\min}=10^{-3}\) and \(h_{\max}=10^{-2}\) seconds, while the revolute joint case study was conducted with \(h\) varying between \(h_{\min}= 10^{-3}\) and \(h_{\max}=2\times 10^{-3}\) seconds. Further, to study the convergence and stability properties and to highlight the effects of numerical damping, the total mechanical energy in the pendulum (revolute joint with clearance) was studied with different ranges of step sizes. The SQP algorithm comes with the advantage of fast convergence and its ability to efficiently deal with a large number of constraints [85]. The constraint violation was observed Φ ineq (q) 10 10 upon the contact formation. At the same time the equations of motion (16a) and (16b) were satisfied within the limits of \(10^{-9}\).

5.1 Cylindrical joint

As shown in Figure 9, the equations of motion residuals were found to be of order \(10^{-9}\). Figure 10 shows the positions of X and Y components of the left-hand and the right-hand ends of the slider. As can be expected, the external force \(F\) generates torques and tilts the slider. Hence, the left end descends down and makes contact with the shaft, while the right end moves up to make contact with the shaft. After the contact is formed at the diametrically opposite ends of the rod \(j\), the slider starts moving in the Z direction. Figure 11 shows the contact forces \(CF-x\), \(CF-y\), and \(CF-z\) in X, Y, and Z directions respectively. Figure 12 represents the X and Y velocities of the center of mass. The lateral velocities (in X-Y directions) gained by slider are very small, though periodically varying. These oscillations of low magnitude arise because in the absence of friction, minute perturbations in X-Y plane can rotate the slider about Z axis, which also happens to be the major axis of the slider. Figure 13 represents the Z-velocity of the center of mass of the slider, and Figure 14 represents the displacement of slider Z direction from the initial position. Since the external force is constant, the acceleration is constant, and hence the velocity and position profiles are straight-line and parabola respectively.

Fig. 9
figure 10

Cylindrical joint in Figure 6: Residuals Equation of motion (Color figure online).

Fig. 10
figure 11

Cylindrical joint in Figure 6: X and Y coordinates of the centers of left and right ends (Color figure online).

Fig. 11
figure 12

Cylindrical joint in Figure 6: Contact forces against time (Color figure online).

Fig. 12
figure 13

Cylindrical joint in Figure 6: X and Y velocities of center of mass (Color figure online).

Fig. 13
figure 14

Cylindrical joint in Figure 6: Z velocity of center of mass.

Fig. 14
figure 15

Cylindrical joint in Figure 6: Z coordinate of center of mass.

Figure 15 shows the step size adaptation over time. It can be observed that the dramatic fluctuations in the step size correlate well with the lateral micro-oscillations of the contact points that undergo sliding while maintaining the contact, as observed in Figure 10. In cylindrical slider, the rotational degree of freedom about Z axis is free and remains so even after contact is formed. Moreover, the torque generated by external force is acting about the intermediate axis of the slider. The torque generated by external force is acting throughout the simulation. Since rotation about intermediate axis is unstable to numerical perturbations along global X and Y [78], the step size also oscillates between the bounds in this case.

Fig. 15
figure 16

Cylindrical joint in Figure 6: Time step size.

5.2 Prismatic joint

The equations of motion residuals, as shown in Figure 16, are in order of \(10^{-9}\). Figure 17 shows the positions of Y components of the points \(P_{f_{1}}\) and \(P_{b_{1}}\) shown in Figure 7. The external force \(F\) generates a torque and tilts the slider, similar to the cylindrical joint’s case. However, the contact happens on all the six vertices. After the contact is formed at the body \(j\), the slider starts moving in the Z direction. Figure 18 shows the contact forces \(CF-x\), \(CF-y\) and \(CF-z\) in X, Y, and Z directions respectively. Figure 19 represents the X and Y velocities of the center of mass. Once the steady contact is formed (around \(t=0.2s\)), the center of mass does not move in X-Y plane. Figure 20 represents the Z-velocity of the center of mass, and Figure 21 represents the motion of slider’s center of mass along Z direction. Since the external force is constant, the acceleration is constant, and hence the velocity profile is straight line and the position profile is parabolic. The Figure 22 represents the step size adaptations against time. In case of prismatic slider, the external torque (by the applied force) is acting about the intermediate axis, which eventually tilts the slider until the contact is made at the vertices such that the only remaining degree of freedom remains sliding along the Z axis. It can be observed that once a steady contact is maintained, the step size also stabilizes to the maximum value of \(10^{-2}\). The main reason why Figure 15 is noisy and Figure 22 is not is that in prismatic slider, rotational perturbations about Z cannot destabilize the solution as formation of contact at vertices immediately nullifies that degree of freedom.

Fig. 16
figure 17

Prismatic joint in Figure 7: Equations of motion residuals.

Fig. 17
figure 18

Prismatic joint in Figure 7: Y coordinates of contact points \(P_{f1}\) and \(P_{b1}\) (Color figure online).

Fig. 18
figure 19

Prismatic joint in Figure 7: Contact forces against time (Color figure online).

Fig. 19
figure 20

Prismatic joint in Figure 7: X and Y velocities of center of mass (Color figure online).

Fig. 20
figure 21

Prismatic joint in Figure 7: Z velocity of center of mass.

Fig. 21
figure 22

Prismatic joint in Figure 7: Z position of center of mass.

Fig. 22
figure 23

Prismatic joint in Figure 7: Time step size.

5.3 Revolute joint

In this section, the results obtained from the proposed methodology have been discussed for the revolute joint case study. The counterparts from an ideal joint case, i.e., without any clearance, have also been compared. The ideal joint case was evaluated using tangent space ODE (TSODE) formulation [75]. For brevity, the term “NLP” represents the nonsmooth solution of the respective system with clearance. The rationale behind choosing a separate well-established methodology for simulating an ideal joint case was to check the credibility of the solution obtained from the method proposed in this work.

Figure 23 shows the residuals of equations of motion. Figure 24 shows the positions of X and Y components of the contact points on the hinge pin’s surface. It can be observed that because of rotation the system undergoes intermittent formation and breaking off of the contact. Figure 25 shows the contact forces \(CF-x\), \(CF-y\), and \(CF-z\) in X, Y, and Z directions respectively. The counterparts from an ideal joint case, i.e., without any clearance, have also been compared. It can be observed that the general pattern of the variation of the contact forces is sinusoidal, excluding the peaks. When juxtaposed to the ideal-joint case, a similar pattern can be observed; however, with a slight lag. This lag can be attributed to the fact that the pendulum, when released, first falls as a free body and consumes the clearance. Then the contact is made and the expected motion begins. Figure 26 represents the X and Y velocities of the center of mass.

Fig. 23
figure 24

Revolute joint in Figure 8: 2-norm residuals of equations of motion

Fig. 24
figure 25

Revolute joint in Figure 8: X and Y coordinates of the centers of left and right ends (Color figure online).

Fig. 25
figure 26

Revolute joint in Figure 8: Contact forces against time. Joint with clearance formulated as NLP (25). Ideal joint case formulated as a TSODE [75] (Color figure online).

Fig. 26
figure 27

Revolute joint in Figure 8: X and Y velocities of center of mass (Color figure online).

The effect of lag can also be observed in the initial moments of time in Figure 26, while the rest of the velocity profiles overlap the ideal-joint counterparts. This overlap can also be observed in the position profiles. Figure 27 represents the positions of center of mass in X-Y plane. In Figure 28, the axial displacement of the center of mass of the pendulum is shown evolving with time. As can be expected, the ideal-joint case does not exhibit any displacement along the Z direction. Furthermore, it must be noticed that the center of mass is located at a significant distance from the axis of rotation. Hence, the displacement of center of mass along Z is a combination of the tilting effect on the hinge pin because of radial clearance as well as the prismatic displacement in the Z direction because of axial clearance.

Fig. 27
figure 28

Revolute joint in Figure 8: X and Y coordinates of center of mass (Color figure online).

Fig. 28
figure 29

Revolute joint in Figure 8: Z coordinates of center of mass (Color figure online).

Figure 29 represents the variation of step size with time. It can be observed that step size changes when the contact points acquire high relative sliding speeds. Moreover, the numerical damping because of large range of step size happens to be a source of dissipation. This is confirmed in Figure 30 where the total mechanical energy is plotted for different ranges of step size. Recall that our base-line step size range was \(10^{-3}< h<2\times 10^{-3}\). The convergence analysis shows that limiting the range to smaller values of maximum step size (\(5 \times 10^{-4}< h<10^{-3}\)) resulted in significant improvement in energy conserving properties. Further, the stability analysis compares the two baseline convergence ranges with their respective increased and decreased range, keeping the maximum step size same, i.e., \(10^{-3}\) and \(2\times 10^{-3}\) respectively. It can be observed that energy loss is expected with larger step sizes, but it can be restored using smaller step sizes. Further, with the maximum step size fixed, improved stability comes with smaller minimum step size.

Fig. 29
figure 30

Revolute joint in Figure 8: Time step size variation in NLP solution of the system with clearance.

Fig. 30
figure 31

Revolute joint in Figure 8: Stability and convergence properties for different ranges of step size (Color figure online).

5.4 Ideal joint pendulum

Figure 31 shows a simple case study of a pendulum \(i\) forming a revolute joint with a hinge pin \(j\) of radius \(R\). The center of mass of the pendulum is located at \(cm_{x}\) along the local X direction. The pendulum \(i\) has mass \(m\) with its center of mass denoted by the generalized coordinates \(\mathbf{q}_{i}\in \mathbb{R}^{7}\) and the hinge pin \(j\) is mass-less and fixed at both ends. The gravity acts along the \(-\mathbf{Y}\) axis and the clearance in the revolute joint is \(c\). The system specific details illustrated in Figure 31 are shown in Table 4. Two cases of the showed pendulum are considered: 1. Joint with clearance using NLP (25); 2. Ideal joint using NLP (31). Further, the fixed step size studies were conducted with two step size values: \(h =2 \times 10^{-4}\) and \(h =10^{-3}\) for both cases. The effect of step size range bounds was also compared by simulated both cases with two ranges of bounded step size: \(2 \times 10^{-4}\le h \le 10^{-3}\) and \(10^{-3}\le h\le 2\times 10^{-3}\). Based on inferences from Figure 30, the aim is to investigate the effect of numerical damping on entities other than mechanical energy.

Fig. 31
figure 32

Schematic diagram of a pendulum demonstrating a revolute joint (Color figure online)

Table 4 Case study specifications: Revolute joint

Figures 32 and 33 respectively compare the X-Y positions and velocities of the center of mass. The effect of clearances is more noticeable in velocity plots, especially in the beginning. Figure 34 compares the total mechanical energy and its kinetic and potential components for the two cases, where only gravitational potential energy was considered to calculate total mechanical energy. The nonsmooth behavior in total energy can be observed in the interval \(0< t<2\).

Fig. 32
figure 33

Pendulum in Figure 31: The center of mass position represented in X-Y coordinates (Color figure online)

Fig. 33
figure 34

Pendulum in Figure 31: Center of mass velocity represented as the rate of change of X-Y coordinates (Color figure online)

Fig. 34
figure 35

Pendulum in Figure 31: Total, kinetic, and potential energies (Color figure online)

Figure 35 compares the variation in spatial components of contact forces between clearance joint and ideal joint, both cases simulated by the discussed NLP approach. In Figure 35, it can be observed that numerical damping comes into effect with large step sizes as the number of peaks go down with range of larger step sizes. Figure 36 shows that the formulation does satisfy the kinematic constraints in case of ideal joint. The plot in the top represents the X and Y coordinates of left and right ends of the pivot end’s centerline. It can be noticed that the clearance constraint of 0.1 m is not violated. In case of ideal joint, the constraints are satisfied well. This case study demonstrates the effectiveness of the proposed framework to deal with smooth as well as nonsmooth systems. Further, Figure 37 compares the computational aspects of the two cases studied in this section. The advantage of bounded step size over fixed step size can hence be argued based on the observations in case of joints with clearances. However, there is no significant improvement in case of ideal joints if the \(h_{min}\) is kept same, i.e., \(10^{-4}\) or \(10^{-3}\). However, increasing the step size range indeed reduces the computation time and induces numerical damping, at the cost of energy loss, as observed in Figure 30. Moreover, it must be noticed that contact problems consume significantly more computational resources than smooth problems.

Fig. 35
figure 36

Pendulum in Figure 31: Contact forces along global X, Y, and Z directions. Large step size induces numerical damping that reduces the number of peaks (Color figure online).

Fig. 36
figure 37

Pendulum in Figure 31 with ideal joint: Norm of kinematic constraints (Color figure online).

Fig. 37
figure 38

Pendulum in Figure 31: Total iterations between \(t=0s\) and \(t=10s\), and computational time (Color figure online).

6 Conclusions

This work provides a nonsmooth dynamics based framework for the purpose of simulating multibody systems with clearances in the joints. Nonsmooth dynamics of spatial cylindrical, prismatic, and revolute joints with clearances have been derived assuming inelastic nature of the contact. The mathematical representations of constraint inequalities have been carefully derived to ensure that they capture all the possible scenarios of contact formation. Simulation results demonstrate the computational effectiveness of the proposed framework. Moreover, the tolerance limits of constraints during contact are also satisfied within significant accuracy. The proposed framework was also successfully applied to simulate ideal joints in \(\mathbf{r}\mathbf{A}\) formulation, and constraint requirements were also well preserved.

The paper proposes a novel adaptive time step strategy based on treating the time step size \(h\) as a variable in the NLP problem. To preserve rotations, normalization constraint on Euler parameters was enforced. As a result, the velocity of generalized coordinates \({\dot{\mathbf{q}}}\) was included as an optimization variable and the integration scheme was incorporated within the optimization process. The stability analysis showed that the deviation in total energy can be mitigated by selecting appropriate bounds on the step size. Smaller values of minimum bounds were found conducive to reduce energy deviation. Furthermore, looking at the level of complexity of problems considered and the computational time consumed, a limitation of the proposed framework can be observed. Indeed, this is an open task for future work.

This work focuses on frictionless contacts in the joints with clearances. On-going work by the authors seeks to extend this study to the simulation of joints with clearance and friction, which will shed further light on the impact of clearances on multibody system dynamics.

The industrial approach of assigning tolerances, and hence clearances, is primarily based on manufacturability related aspects. However, the effects of accumulated clearances on the kinematic and dynamic parameters of a mechanical system are often neglected. The presented work can be impactful in rationalizing the design procedures because tolerance assignment is a critical task on engineering drawings. Understanding the effect of tolerances on the system’s dynamic response can be helpful in optimizing the design of a machine’s components.