1 Introduction

The computer simulation of dynamic systems has proven its value in product development, from early prototyping phase to user training, and emerging digital twins and artificial intelligence applications. In practice, the modeling of mechanisms can be carried out by using multibody system dynamics in which equations of motion describe a force equilibrium for the mechanical system under investigation. The use of multibody system dynamics also allows describing actuator models such as hydraulics or electric drives.

The multibody methods can be, in general, categorized to two main groups according to the selected coordinates [25]. Firstly, there is the group of formulations based on global coordinates, where the absolute positions, velocities, and accelerations of each body are used. In the second case, relative coordinates are employed. Should high computational efficiency be required, as is the case in real-time applications, such as those presented in [22, 23], the use of the relative coordinates is often considered to be an appropriate approach. The selection of an approach is case-dependent, as demonstrated in [17]. The computational efficiency can be significantly effected by implementation details [18], and, among others, the use of the automated differentiation tools [6], and sparse and parallelization techniques [20].

Within the family of methods based on the relative coordinates, the semirecursive approach is often used. In the semirecursive approach, closed loops need to be handled by employing constraint equations. Constraint equations, in turn, can be accounted in the semirecursive approach in many different ways, such as by using the Lagrange multiplier method, the penalty-based approach as proposed by Cuadrado et al. [10] or the double-step approach, which is using a coordinate partitioning as proposed by Rodríguez et al. [33]. The latter two approaches are originated from Featherstone’s articulated inertia method [13]. The penalty-based approach utilizes the index-3 augmented Lagrangian formulation with projections [3, 9] to enforce the constraints. After their original introductions, both methods have also been successfully used in practical applications, such as in real-time vehicle simulations [20, 29]. In this study, the double-step approach based on coordinate partitioning method [24, 33] is referred as the double-step semirecursive formulation, and the penalty-based augmented Lagrangian approach [9, 10] is referred as the penalty-based semirecursive formulation.

Regarding the solution of the multiphysics problem that system-level simulations require, two main approaches exist in the literature. A straightforward one is the monolithic approach, or sometimes referred as unified scheme, where a single set of differential equations is formed and integrated forward in time as a whole. In an alternative approach, namely cosimulation approach, in turn, the system is split into two or more subsystems that are each integrated separately. In this approach, the required variables, such as the state variables, are communicated in predetermined time intervals. Multiple instances of both approaches can be found from the literature. Cosimulation, due to the discrete time information exchange and the resulting coupling error, has especially been under keen research interest in recent years [16, 36]. The studies include important aspects, such as the multirate cosimulation [18], cosimulation configuration [4, 30], and energy-based coupling error minimization [4, 34, 35]. Monolithic schemes, in turn, have been under less active development since the simple coupling requires less research effort. Nevertheless, in [12] a multiphysics model was derived for a semiactive car suspension. Naya et al. [28], in turn, presented a monolithic method for a coupled multibody and hydraulic simulation based on the index-3 augmented Lagrangian [3], followed later in [32] and [31], where the index-3 semirecursive formulation [10] was used.

In the case of a coupled multibody and hydraulic dynamics, which is a common case in mobile working machinery, one of the key aspects to consider is the numerical stiffness introduced by the hydraulics. This problem can be alleviated by proper selection of a multibody approach. While these aspects have been discussed in some sources, such as in [32], few comparisons between the available methods in this context exist in the literature. In the context of the absolute nodal coordinate formulation, in turn, a study in this direction has been done by Matikainen et al. [27], where coordinate partitioning, Lagrange multiplier method with Baumgarte’s stabilization, and penalty formulation were used for constraint enforcement. The results indicated best performance for the Lagrange multiplier method, closely followed by the penalty-based approach, while less efficient solution was sought with the coordinate partitioning method.

The objective of this paper is to introduce the double-step semirecursive formulation [24] and compare it with the penalty-based semirecursive formulation [10, 32] in the framework of hydraulically driven systems. A monolithic scheme for the coupled simulation of the double-step semirecursive formulation and hydraulic systems is introduced in this study. As explained earlier, the modeling of hydraulic actuators often leads to numerically stiff systems. In this study, the hydraulic system will be described by using the lumped fluid theory. While variable-step integrators often provide more efficient solutions, especially with stiff systems when compared with fixed step-size solutions, since the author’s interests lie within the field of real-time simulation, only fixed step-sizes are considered in this work. The coupled systems are referred after the name of the multibody formulations used, such as the double-step semirecursive approach and the penalty-based semirecursive approach. As case studies, hydraulically actuated four-bar and quick-return mechanisms are illustrated. Using the numerical examples, the two approaches are compared based on the work cycle, energy balance, constraint violation, and numerical efficiency of the mechanisms.

2 Semirecursive multibody formulations

The dynamics of a constrained mechanical system can be described by using a multibody system dynamics approach. In the semirecursive formulations, the dynamics of the open-loop multibody systems are formulated in relative joint coordinates, which are independent. In the case of closed-loop multibody systems, in turn, the relative joint coordinates are not independent and cut-joint method is often used to open the loop. In this study, the cut-joint constraints are incorporated by using the coordinate partitioning method [24, 33], referred as the double-step semirecursive formulation, and by using the penalty-based augmented Lagrangian method [2, 9], referred as the penalty-based semirecursive formulation. Since the system is hydraulically actuated, the internal dynamics of the hydraulics are computed and the resultant force, as well as the stroke and stroke velocity, is used to combine the hydraulics to the multibody equations of motion. Therefore, in this study, the constraints are assumed scleronomic. Should kinematic constraints be needed, both methods can easily be extended to rheonomous systems, as shown in the literature [10, 24].

2.1 Semirecursive formulation for an open-loop system

In the semirecursive formulation, a system is considered as an open-loop multibody system with \({N_{b}}\) bodies. The following Cartesian velocity \(\mathbf{{Z}}_{j}\) and acceleration \({\dot{\mathbf{{Z}}}}_{j}\) are used to describe the absolute velocity and acceleration of each body [24]

$$ {\mathbf{{Z}}}_{j} \equiv \begin{bmatrix} {\dot{\mathbf{{s}}}}_{j} \\ {\boldsymbol{\upomega }}_{j} \end{bmatrix} , \qquad {\dot{\mathbf{{Z}}}}_{j} \equiv \begin{bmatrix} {\ddot{\mathbf{{s}}}}_{j} \\ {\dot{\boldsymbol{\upomega }}}_{j} \end{bmatrix} ,$$
(1)

where \({\dot{\mathbf{{s}}}}_{j}\) and \({\ddot{\mathbf{{s}}}}_{j}\) are, respectively, the velocity and acceleration of the point of the body \({j}\), which at that particular time is coincident with the origin of the inertial reference frame, and \({\boldsymbol{\upomega }}_{j}\) and \({\dot{\boldsymbol{\upomega }}}_{j}\) are the angular velocity and angular acceleration, respectively, of the body \({j}\). In this approach, the kinematics of the open-loop system is calculated in a recursive form, either from the base to the leaves, as performed in this study, or from leaves to base, by applying the classical kinematic relations as in [11]. Figure 1 shows an example of an open-loop system. In general case, the position of the system can be described by using the relative joint coordinates \(\mathbf{{z}} = \left [ {z}_{1}, {z}_{2}, \ldots , {z}_{N_{b}} \right ]^{ \text{T}}\).

Fig. 1
figure 1

An example of an open-loop system

The absolute velocity \(\mathbf{{Z}}_{j}\) and acceleration \({\dot{\mathbf{{Z}}}}_{j}\) for body \(j \in \left [ 1, {N_{b}} \right ]\) can be recursively expressed in terms of the previous bodies as [24]

$$ {\mathbf{{Z}}}_{j} = \mathbf{{Z}}_{j-1} + \mathbf{{b}}_{j} {\dot{z}}_{j} ,$$
(2)
$$ {\dot{\mathbf{{Z}}}}_{j} = {\dot{\mathbf{{Z}}}}_{j-1} + \mathbf{{b}}_{j} {\ddot{z}}_{j} + \mathbf{{d}}_{j} ,$$
(3)

where the scalars \({\dot{z}}_{j}\) and \({\ddot{z}}_{j}\) are the first and second time derivatives, respectively, of the relative joint coordinate \({z}_{j}\), and the vectors \(\mathbf{{b}}_{j}\) and \(\mathbf{{d}}_{j}\) depend on the type of joint [11] that connects the bodies \({j-1}\) and \({j}\). Note that the indexes \(j-1\) and \(j\) may not be successive, as the system may branch.

The absolute velocities \(\mathbf{{Z}} \in {\mathbb{R}}^{6 {N_{b}}}\) and accelerations \({\dot{\mathbf{{Z}}}} \in {\mathbb{R}}^{6 {N_{b}}}\) of the open-loop system can respectively be expressed in the matrix forms as \(\mathbf{{Z}} = \left [ {\mathbf{{Z}}}_{1}^{\text{T}}, \mathbf{{Z}}_{2}^{\text{T}}, \ldots , \mathbf{{Z}}_{N_{b}}^{\text{T}} \right ]^{\text{T}}\) and \({\dot{\mathbf{{Z}}}} = \left [ {\dot{\mathbf{{Z}}}}_{1}^{\text{T}}, {\dot{\mathbf{{Z}}}}_{2}^{ \text{T}}, \ldots , {\dot{\mathbf{{Z}}}}_{N_{b}}^{\text{T}} \right ]^{ \text{T}}\). A velocity transformation matrix \(\mathbf{{R}} \in {\mathbb{R}}^{6 {N_{b}} \times {N_{b}}}\) that maps the absolute velocities into a set of relative joint velocities can be written as [11, 24]

$$ {\mathbf{{Z}}} = \mathbf{{R}} {\dot{\mathbf{{z}}}} = \mathbf{{T}} {\mathbf{{R}}}_{\text{d}} { \dot{\mathbf{{z}}}} ,$$
(4)
$$ {\dot{\mathbf{{Z}}}} = \mathbf{{R}} {\ddot{\mathbf{{z}}}} + {\dot{\mathbf{{R}}}} { \dot{\mathbf{{z}}}} = \mathbf{{T}} {\mathbf{{R}}}_{\text{d}} {\ddot{\mathbf{{z}}}} + \mathbf{{T}} {\dot{\mathbf{{R}}}}_{\text{d}} {\dot{\mathbf{{z}}}}, $$
(5)

where \({\dot{\mathbf{{z}}}} \in {\mathbb{R}}^{N_{b}}\) is the vector of relative joint velocities, \(\mathbf{{T}} \in {\mathbb{R}}^{6 {N_{b}} \times 6 {N_{b}}}\) is the path matrix that represents the topology of the open-loop system, and \(\mathbf{{R}}_{\text{d}} \in {\mathbb{R}}^{6 {N_{b}} \times {N_{b}}}\) is a diagonal matrix whose elements are the vectors \(\mathbf{{b}}_{j}\) arranged in an ascending order. The path matrix \(\mathbf{{T}}\) is a lower block-triangular matrix [11] whose elements from diagonal to left are \(\left ({6 \times 6}\right )\) identity matrices \(\mathbf{{I}}_{6}\), if the corresponding body is in between the considered body and the root of the system. Note that the term \({\dot{\mathbf{{R}}}} {\dot{\mathbf{{z}}}}\) in Eq. (5) can be expressed in terms of the vectors \(\mathbf{{d}}_{j}\) by using Eq. (3) [11].

The absolute velocity \(\mathbf{{Y}}_{j}\) and acceleration \({\dot{\mathbf{{Y}}}}_{j}\) of the center of mass of body \(j\) can be written as

$$ {\mathbf{{Y}}}_{j} = \begin{bmatrix} {\dot{\mathbf{{g}}}}_{j} \\ {\boldsymbol{\upomega }}_{j} \end{bmatrix} = \begin{bmatrix} {\mathbf{{I}}}_{3} & - {\widetilde{\mathbf{{g}}}}_{j} \\ \mathbf{{0}} & \mathbf{{I}}_{3} \end{bmatrix} \begin{bmatrix} {\dot{\mathbf{{s}}}}_{j} \\ {\boldsymbol{\upomega }}_{j} \end{bmatrix} = \mathbf{{D}}_{j} {\mathbf{{Z}}}_{j}, $$
(6)

and

$$ {\dot{\mathbf{{Y}}}}_{j} = \begin{bmatrix} {\ddot{\mathbf{{g}}}}_{j} \\ {\dot{\boldsymbol{\upomega }}}_{j} \end{bmatrix} = \begin{bmatrix} {\mathbf{{I}}}_{3} & - {\widetilde{\mathbf{{g}}}}_{j} \\ \mathbf{{0}} & \mathbf{{I}}_{3} \end{bmatrix} \begin{bmatrix} {\ddot{\mathbf{{s}}}}_{j} \\ {\dot{\boldsymbol{\upomega }}}_{j} \end{bmatrix} + \begin{bmatrix} {\widetilde{\boldsymbol{\upomega }}}_{j} { \widetilde{\boldsymbol{\upomega }}}_{j} {\mathbf{{g}}}_{j} \\ \mathbf{{0}} \end{bmatrix} = \mathbf{{D}}_{j} {\dot{\mathbf{{Z}}}}_{j} + \mathbf{{e}}_{j} ,$$
(7)

where \(\mathbf{{g}}_{j}\) is the position vector of the center of mass of body \(j\) with respect to the inertial reference frame, \(\mathbf{{I}}_{3}\) is a \({\left (3 \times 3\right )}\) identity matrix, and \({\dot{\mathbf{{g}}}}_{j}\), \({\ddot{\mathbf{{g}}}}_{j}\), and \({\widetilde{\mathbf{{g}}}}_{j}\), respectively, are the first and second time derivative, and the skew-symmetric matrix of the position vector \(\mathbf{{g}}_{j}\). By using Eqs. (6) and (7), the virtual power of the inertia and external forces acting on the open-loop system can be written as [24]

$$ \sum _{j=1}^{N_{b}} {\mathbf{{Y}}}_{j}^{*{\text{T}}} \left ( \mathbf{{M}}_{j} { \dot{\mathbf{{Y}}}}_{j} - \mathbf{{Q}}_{j} \right ) = \sum _{j=1}^{N_{b}} {\mathbf{{Z}}}_{j}^{*{ \text{T}}} \left ( {\bar{\mathbf{{M}}}}_{j} {\dot{\mathbf{{Z}}}}_{j} - { \bar{\mathbf{{Q}}}}_{j} \right ) = 0, $$
(8)

where the virtual velocities are denoted with an asterisk (*), and the matrices \(\mathbf{{M}}_{j}\), \({\bar{\mathbf{{M}}}}_{j}\), and \({\bar{\mathbf{{Q}}}}_{j}\) can be written as

$$ {\mathbf{{M}}}_{j} = \begin{bmatrix} {m_{j}} {\mathbf{{I}}}_{3} & \mathbf{{0}} \\ \mathbf{{0}} & \mathbf{{J}}_{j} \end{bmatrix} , \qquad {\bar{\mathbf{{M}}}}_{j} = \begin{bmatrix} {m_{j}} {\mathbf{{I}}}_{3} & - {m_{j}} {\widetilde{\mathbf{{g}}}}_{j} \\ {m_{j}} {\widetilde{\mathbf{{g}}}}_{j} & \mathbf{{J}}_{j} - {m_{j}} { \widetilde{\mathbf{{g}}}}_{j} {\widetilde{\mathbf{{g}}}}_{j} \end{bmatrix} ,$$
(9)

and

$$ \begin{aligned} {\bar{\mathbf{{Q}}}}_{j} = \begin{bmatrix} {\mathbf{{f}}}_{j} - {\widetilde{\boldsymbol{\upomega }}}_{j} \left ( { \widetilde{\boldsymbol{\upomega }}}_{j} {m_{j}} {\mathbf{{g}}}_{j}\right ) \\ {\boldsymbol{\uptau }}_{j} - {\widetilde{\boldsymbol{\upomega }}}_{j} { \mathbf{{J}}}_{j} {\boldsymbol{\upomega }}_{j} + {\widetilde{\mathbf{{g}}}}_{j} \left ( \mathbf{{f}}_{j} - {\widetilde{\boldsymbol{\upomega }}}_{j} \left ( {\widetilde{\boldsymbol{\upomega }}}_{j} {m_{j}} {\mathbf{{g}}}_{j}\right ) \right ) \end{bmatrix} \end{aligned} ,$$
(10)

where \({m_{j}}\) is the mass of body \(j\) and \(\mathbf{{J}}_{j}\) is the inertia tensor of body \(j\). The inertia tensor \(\mathbf{{J}}_{j}\) can be written as \(\mathbf{{J}}_{j} = \mathbf{{A}}_{j}^{\text{T}} {\bar{\mathbf{{J}}}}_{j} {\mathbf{{A}}}_{j}\), where \({\bar{\mathbf{{J}}}}_{j}\) is the constant inertia tensor in the body reference frame of body \(j\) and \(\mathbf{{J}}_{j}\) is expressed in the inertial reference frame. Note that both \(\mathbf{{J}}_{j}\) and \({\bar{\mathbf{{J}}}}_{j}\) are defined with respect to the center of mass of body \(j\). In Eq. (10), \(\mathbf{{f}}_{j}\) is the vector of external forces applied on body \(j\) and \({\boldsymbol{\uptau }}_{j}\) is the vector of external moments with respect to the center of mass of body \(j\). By substituting Eqs. (4) and (5) in Eq. (8), a set of ordinary differential equations that describes the motion of the open-loop system can be written as [24]

$$ {\mathbf{{R}}}_{\text{d}}^{\text{T}} {\mathbf{{T}}}^{\text{T}} {\bar{\mathbf{{M}}}} {\mathbf{{T}}} {\mathbf{{R}}}_{\text{d}} {\ddot{\mathbf{{z}}}} = \mathbf{{R}}_{\text{d}}^{\text{T}} { \mathbf{{T}}}^{\text{T}} \left ( {\bar{\mathbf{{Q}}}} - {\bar{\mathbf{{M}}}} {\mathbf{{T}}} { \dot{\mathbf{{R}}}}_{\text{d}} {\dot{\mathbf{{z}}}} \right ) ,$$
(11)

where \({\bar{\mathbf{{M}}}} \in {\mathbb{R}}^{6 {N_{b}} \times 6 {N_{b}}}\) is a diagonal matrix that consists of the mass matrices \({\bar{\mathbf{{M}}}}_{j}\), and \({\bar{\mathbf{{Q}}}} \in {\mathbb{R}}^{6 {N_{b}}}\) is a column vector that consists of the force vectors \({\bar{\mathbf{{Q}}}}_{j}\). Equation (11) can be rewritten as

$$ {\mathbf{{M}}}^{\prime } {\ddot{\mathbf{{z}}}} = \mathbf{{Q}}^{\prime } ,$$
(12)

where \(\mathbf{{M}}^{\prime } = \mathbf{{R}}_{\text{d}}^{\text{T}} {\mathbf{{T}}}^{\text{T}} { \bar{\mathbf{{M}}}} {\mathbf{{T}}} {\mathbf{{R}}}_{\text{d}}\) and \(\mathbf{{Q}}^{\prime } = \mathbf{{R}}_{\text{d}}^{\text{T}} {\mathbf{{T}}}^{\text{T}} \left ( {\bar{\mathbf{{Q}}}} - {\bar{\mathbf{{M}}}} {\mathbf{{T}}} {\dot{\mathbf{{R}}}}_{ \text{d}} {\dot{\mathbf{{z}}}} \right )\).

2.2 Double-step semirecursive formulation

In the double-step semirecursive formulation, the constraints are introduced by using the coordinate partitioning method [24]. This method can be used in frameworks of the explicit and implicit integrators. A set of \(m\) constraint equations \(\boldsymbol{{\Phi }} = \mathbf{{0}}\) are used for the closure of an open-loop. For the sake of simplicity, the constraint equations are assumed holonomic and scleronomic. To account for rheonomic constraints, the reader is referred to [24]. The constraint equations \(\boldsymbol{{\Phi }} = \mathbf{{0}}\) can be expressed in terms of the relative joint coordinates as \(\boldsymbol{{\Phi }} \left ( \mathbf{{z}} \right ) = \mathbf{{0}}\). Figure 2 shows an example of a closed-loop system.

Fig. 2
figure 2

An example of a closed-loop system

By using the coordinate partitioning method, the dependent velocities can be written in terms of the system’s degrees of freedom \(f \) as [25]

$$ {\dot{\mathbf{{z}}}}^{\text{d}} = - \left ( \boldsymbol{{\Phi }}_{\mathbf{{z}}}^{\text{d}} \right )^{-1} {\boldsymbol{{\Phi }}}_{\mathbf{{z}}}^{\text{i}} {\dot{\mathbf{{z}}}}^{\text{i}} ,$$
(13)

where \(\boldsymbol{{\Phi }}_{\mathbf{{z}}}^{\text{d}} \in {\mathbb{R}}^{{m} \times {m}}\) and \(\boldsymbol{{\Phi }}_{\mathbf{{z}}}^{\text{i}} \in {\mathbb{R}}^{{m} \times {f}}\) are, respectively, the dependent and independent columns of Jacobian matrix \(\boldsymbol{{\Phi }}_{\mathbf{{z}}}\), and \({\dot{\mathbf{{z}}}}^{\text{d}} \in {\mathbb{R}}^{{m}}\) and \({\dot{\mathbf{{z}}}}^{\text{i}} \in {\mathbb{R}}^{{f}}\) are, respectively, the dependent and independent relative joint velocities. It is assumed that neither redundant constraints nor singular configurations exist, which guarantees that the inverse of \(\boldsymbol{{\Phi }}_{\mathbf{{z}}}^{\text{d}}\) can be found. A velocity transformation matrix \(\mathbf{{R}}_{\mathbf{{z}}} \in {\mathbb{R}}^{{N_{b}} \times {f}}\) is introduced to transform the dependent relative joint velocities into independent ones as [25]

$$ \begin{bmatrix} {\dot{\mathbf{{z}}}}^{\text{d}} \\ {\dot{\mathbf{{z}}}}^{\text{i}} \end{bmatrix} = \begin{bmatrix} - \left ( \boldsymbol{{\Phi }}_{\mathbf{{z}}}^{\text{d}} \right )^{-1} {\boldsymbol{{\Phi }}}_{ \mathbf{{z}}}^{\text{i}} \\ \mathbf{{I}} \end{bmatrix} {\dot{\mathbf{{z}}}}^{\text{i}} \equiv {\mathbf{{R}}}_{\mathbf{{z}}} {\dot{\mathbf{{z}}}}^{ \text{i}} .$$
(14)

Similarly, accelerations can be written as

$$ {\ddot{\mathbf{{z}}}} = \mathbf{{R}}_{\mathbf{{z}}} {\ddot{\mathbf{{z}}}}^{\text{i}} + { \dot{\mathbf{{R}}}}_{\mathbf{{z}}} {\dot{\mathbf{{z}}}}^{\text{i}} ,$$
(15)

where \({\ddot{\mathbf{{z}}}}^{\text{i}} \in {\mathbb{R}}^{{f}}\) are the independent relative joint accelerations. In this study, the independent relative joint coordinates are identified by using the Gaussian elimination with full pivoting to the Jacobian matrix \(\boldsymbol{{\Phi }}_{\mathbf{{z}}}\). Note that Gaussian elimination with full pivoting is a lower–upper (LU) matrix factorization technique, where the rows and columns of a matrix are interchanged to use the largest element (in absolute value) in the matrix as the pivot [21]. Accordingly, the \(({N_{b}}-m)\) columns of the Jacobian matrix \(\boldsymbol{{\Phi }}_{\mathbf{{z}}}\), where the \(m\) pivots do not appear, determines the independent relative joint coordinates [15, 25]. Fisette and Vaneghem utilized the same technique in the identification of dependent and independent coordinates [14]. This can be considered as a relative drawback of the double-step semirecursive formulation because the penalty-based semirecursive formulation utilizes the full set of coordinates. By substituting Eqs. (14) and (15) into Eq. (11), the dynamic equations of the closed-loop system can be written as [7]

$$ {\mathbf{{R}}}_{\text{z}}^{\text{T}} {\mathbf{{M}}}^{\prime } {\mathbf{{R}}}_{\text{z}} { \ddot{\mathbf{{z}}}}^{\text{i}} = \mathbf{{R}}_{\text{z}}^{\text{T}} {\mathbf{{R}}}_{ \text{d}}^{\text{T}} \left ( \mathbf{{T}}^{\text{T}} {\bar{\mathbf{{Q}}}} - \mathbf{{T}}^{ \text{T}} {\bar{\mathbf{{M}}}} {\mathbf{{D}}} \right ) ,$$
(16)

where \(\mathbf{{D}} \equiv {\mathbf{{T}}} {\mathbf{{R}}}_{\text{d}} \begin{bmatrix} - \left ( \boldsymbol{{\Phi }}_{\mathbf{{z}}}^{\text{d}} \right )^{-1} \left ( { \dot{\boldsymbol{{\Phi }}}}_{\mathbf{{z}}} {\dot{\mathbf{{z}}}} \right ) \\ \mathbf{{0}} \end{bmatrix} + \mathbf{{T}} {\dot{\mathbf{{R}}}}_{\text{d}} {\dot{\mathbf{{z}}}}\) are the absolute accelerations, when vector \({\ddot{\mathbf{{z}}}}\) in Eq. (5) is set to zero. Equation (16) can be expressed in a simplified form as

$$ {\mathbf{{M}}}^{\prime \prime } {\ddot{\mathbf{{z}}}}^{\text{i}} = \mathbf{{Q}}^{\prime \prime } ,$$
(17)

where \(\mathbf{{M}}^{\prime \prime } = \mathbf{{R}}_{\text{z}}^{\text{T}} {\mathbf{{M}}}^{\prime } {\mathbf{{R}}}_{ \text{z}}\) and \(\mathbf{{Q}}^{\prime \prime } = \mathbf{{R}}_{\text{z}}^{\text{T}} {\mathbf{{R}}}_{\text{d}}^{ \text{T}} \left ( \mathbf{{T}}^{\text{T}} {\bar{\mathbf{{Q}}}} - \mathbf{{T}}^{ \text{T}} {\bar{\mathbf{{M}}}} {\mathbf{{D}}} \right )\). Note that the relation between \(\mathbf{{Q}}^{\prime }\) and \(\mathbf{{Q}}^{\prime \prime }\) can be written as \(\mathbf{{Q}}^{\prime \prime } = \mathbf{{R}}_{\text{z}}^{\text{T}} {\mathbf{{Q}}}^{\prime } - \mathbf{{R}}_{ \text{z}}^{\text{T}} {\mathbf{{M}}}^{\prime } {\mathbf{{R}}}_{\text{z}} {\dot{\mathbf{{R}}}}_{ \mathbf{{z}}} {\dot{\mathbf{{z}}}}^{\text{i}}\).

2.3 Penalty-based semirecursive formulation

In the penalty-based semirecursive formulation, the constraints are introduced by using the penalty-based augmented Lagrangian method [10]. In this formulation, the time integration scheme is carried out by using the trapezoidal rule. The loop-closure constraints, a set of \(m\) constraint equations \(\boldsymbol{{\Phi }} = \mathbf{{0}}\), are introduced in Eq. (12) with a penalty method similar to the index-3 augmented Lagrangian with projections to satisfy the constraints on velocity and acceleration levels [3, 9]. The equations of motion for the closed-loop system can be written as

$$ {\mathbf{{M}}}^{\prime } {\ddot{\mathbf{{z}}}} + \boldsymbol{{\Phi }}_{\mathbf{{z}}}^{\text{T}} \alpha { \boldsymbol{{\Phi }}} + \boldsymbol{{\Phi }}_{\mathbf{{z}}}^{\text{T}} {\boldsymbol{\uplambda }} = \mathbf{{Q}}^{\prime } ,$$
(18)

where \(\boldsymbol{{\Phi }}_{\mathbf{{z}}}\) is the Jacobian matrix of \(\boldsymbol{{\Phi }} \left ( \mathbf{{z}} \right ) = \mathbf{{0}}\), \(\alpha \) is the penalty factor that can be set the same for all constraints, and \({\boldsymbol{\uplambda }}\) is the vector of iterated Lagrange multipliers. In this method, these multipliers are obtained at each time-step \(k\) as

$$ {\boldsymbol{\uplambda }}_{k}^{(h+1)} = {\boldsymbol{\uplambda }}_{k}^{(h)} + \alpha {\boldsymbol{{\Phi }}}_{k}^{(h+1)} ,$$
(19)

where \(h\) is the iteration step. The value of \({\boldsymbol{\uplambda }}_{k}^{(0)}\) is the final value of \({\boldsymbol{\uplambda }}_{k-1}\), calculated in the previous time-step [10]. As mentioned earlier, the system is integrated by using an implicit single-step trapezoidal scheme [10]. In this approach, the relative joint velocities \({\dot{\mathbf{{z}}}}\) and accelerations \({\ddot{\mathbf{{z}}}}\) are corrected by using the mass-damping-stiffness-orthogonal projections as [3, 9]

$$ \left [ {\mathbf{{W}}} + {\frac{\Delta t^{2}}{4}} {\boldsymbol{{\Phi }}}_{\mathbf{{z}}}^{ \text{T}} \alpha {\boldsymbol{{\Phi }}}_{\mathbf{{z}}} \right ] {\dot{\mathbf{{z}}}} = \mathbf{{W}} {\dot{\mathbf{{z}}}}^{\prime } ,$$
(20)
$$ \left [ {\mathbf{{W}}} + {\frac{\Delta t^{2}}{4}} {\boldsymbol{{\Phi }}}_{\mathbf{{z}}}^{ \text{T}} \alpha {\boldsymbol{{\Phi }}}_{\mathbf{{z}}} \right ] {\ddot{\mathbf{{z}}}} = \mathbf{{W}} {\ddot{\mathbf{{z}}}}^{\prime } - {\frac{\Delta t^{2}}{4}} {\boldsymbol{{\Phi }}}_{\mathbf{{z}}}^{ \text{T}} \alpha \left ( {\dot{\boldsymbol{{\Phi }}}}_{\mathbf{{z}}} {\dot{\mathbf{{z}}}} \right ) ,$$
(21)

where \({\dot{\mathbf{{z}}}}^{\prime }\) and \({\ddot{\mathbf{{z}}}}^{\prime }\) are, respectively, the relative joint velocities and accelerations obtained from the Newton–Raphson iteration, and \(\mathbf{{W}} = \mathbf{{M}} + {\frac{\Delta t}{2}}{\mathbf{{C}}} + { \frac{\Delta t^{2}}{4}}{\mathbf{{K}}}\), where \(\mathbf{{C}}\) and \(\mathbf{{K}}\) represent the damping and stiffness contributions in the system. Note that in Eqs. (20) and (21), time-dependent constraint terms are not incorporated because the constraints are assumed scleronomic. To account for rheonomic constraints, the reader is referred to [10, 32].

3 Hydraulic actuators

In this study, the hydraulic pressures within a hydraulic circuit is computed by using the lumped fluid theory [37]. By using this approach, a hydraulic circuit is divided into discrete volumes where pressures are assumed to be equally distributed. The effect of acoustic waves is thus assumed to be insignificant. In a hydraulic volume \({V_{k}}\), the pressure \({p_{k}}\) can be computed as

$$ \dot{p}_{k} = \frac{B_{e_{k}}}{V_{k}} \sum _{s=1}^{n_{f}} {Q_{k s}} ,$$
(22)

where \({Q_{k s}}\) is the sum of incoming and outgoing flows associated with the volume \({V_{k}}\), \({n_{f}}\) is the total number of volume flows going in or out of the volume \({V_{k}}\), and \({B_{e_{k}}}\) is the effective bulk modulus associated to the volume \({V_{k}}\). The effective bulk modulus can be written as

$$ {B_{e_{k}}} = \left (\frac{1}{B_{oil}} + \sum _{s=1}^{n_{c}} \frac{V_{s}}{{V_{k}}{B_{s}}} \right )^{-1} ,$$
(23)

where \({B_{oil}}\) is the bulk modulus of oil, \({n_{c}}\) is the total number of subvolumes \({V_{s}}\) that form the volume \({V_{k}}\), and \({B_{s}}\) is the corresponding bulk modulus of the volume \({V_{s}}\).

3.1 Valves

In this study, the valves are described by using a semiempirical modeling method [19]. By using the semiempirical modeling approach, the volume flow rate \({Q_{t}}\) through a simple throttle valve can be written as

$$ {Q_{t}} = {C_{v_{t}}} \hspace{0.05cm} {{\text{sgn}}({\Delta p})} \hspace{0.05cm} {\sqrt{\mid \Delta p \mid }} ,$$
(24)

where \({\Delta p}\) is the pressure difference over the valve, \({{\text{sgn}}({\Delta p})}\) is the sign function that determines the sign of \({\Delta p}\), and \({C_{v_{t}}}\) is the semiempirical flow rate coefficient of the throttle valve that can be calculated as

$$ {C_{v_{t}}} = {C_{d}} {A_{t}} \sqrt{\frac{2}{\rho }} ,$$
(25)

where \({C_{d}}\) is the flow discharge coefficient, \({A_{t}}\) is the area of the throttle valve, and \({\rho }\) is the density of the oil.

Similarly, the volume flow rate \({Q_{d}}\) through a directional control valve can be written as

$$ {Q_{d}} = {C_{v_{d}}} {U} \hspace{0.05cm} {{\text{sgn}}({\Delta p})} \hspace{0.05cm} {\sqrt{\mid \Delta p \mid }} ,$$
(26)

where \({C_{v_{d}}}\) is the semiempirical flow rate constant of the valve procured from the manufacturer catalogues, and \({U}\) is the relative poppet/spool position. If the pressure difference is less than 2 bar, the volume flow is assumed to be laminar, and Eqs. (24) and (26) are modified so that the volume flow and the pressure difference follows a linear relation. Equation (26) is complemented by the following first order differential equation that describes a spool position

$$ \dot{U} = \frac{{U_{ref}} - {U}}{\tau } ,$$
(27)

where \({U_{ref}}\) is the reference voltage signal for the reference spool position, and \({\tau }\) is the time constant, which can be obtained from the Bode-diagram of the valve that describes the dynamics of valve spool.

3.2 Cylinders

The volume flow produced due to the motion of a hydraulic cylinder (shown in Fig. 3) can be written as

$$ {Q_{in}} = {\dot{x}}{A_{1}} , \qquad {Q_{out}} = {\dot{x}}{A_{2}} ,$$
(28)

where \({Q_{in}}\) and \({Q_{out}}\) are, respectively, the volume flow rate going inside and coming out of the cylinder, \({\dot{x}}\) is the piston velocity, and \({A_{1}}\) and \({A_{2}}\) are, respectively, the areas on the piston and piston-rod side of the cylinder. The force \({F_{s}}\) produced by the cylinder can be written in terms of its dimensions and chambers pressure as

$$ {F_{s}} = {p_{1}}{A_{1}} - {p_{2}}{A_{2}} - {F_{\mu }} ,$$
(29)

where \({p_{1}}\) and \({p_{2}}\) are, respectively, the pressure on the piston and piston-rod side that can be calculated by using Eq. (22), and \({F_{\mu }}\) is the total friction force caused by sealing.

Fig. 3
figure 3

Schematic figure of a hydraulic cylinder

4 Coupling of multibody formulations and hydraulic actuators

In this section, the multibody formulations described in Sect. 2 are extended to incorporate the dynamics of the hydraulic actuators described in Sect. 3 in a monolithic approach. The coupling of the double-step semirecursive formulation with the lumped fluid theory is inspired from [28] and [32]. Whereas the coupling of the penalty-based semirecursive formulation with the lumped fluid theory was already carried out in [32]. The force vector \({\bar{\mathbf{{Q}}}}\) in Eqs. (17) and (18) is incremented with the pressure variation equations, leading to the combined system of equations as follows

$$ \begin{aligned} &\left . \begin{aligned} {\mathbf{{M}}}^{\prime \prime } {\ddot{\mathbf{{z}}}}^{\text{i}} &= \mathbf{{Q}}^{\prime \prime } \left ( \mathbf{{z}}, {\dot{\mathbf{{z}}}}, \mathbf{{p}} \right ) \\ {\dot{\mathbf{{p}}}} &= \mathbf{{h}} \left ( \mathbf{{p}}, \mathbf{{z}}, {\dot{\mathbf{{z}}}} \right ) \end{aligned} \, \right \} (\text{double-step semirecursive approach}), \end{aligned} $$
(30)
$$ \begin{aligned} &\left . \begin{aligned} {\mathbf{{M}}}^{\prime } {\ddot{\mathbf{{z}}}} + \boldsymbol{{\Phi }}_{\mathbf{{z}}}^{\text{T}} \alpha { \boldsymbol{{\Phi }}} + \boldsymbol{{\Phi }}_{\mathbf{{z}}}^{\text{T}} {\boldsymbol{\uplambda }} &= \mathbf{{Q}}^{\prime } \left ( \mathbf{{z}}, {\dot{\mathbf{{z}}}}, \mathbf{{p}} \right ) \\ {\boldsymbol{\uplambda }}^{(h+1)} &= {\boldsymbol{\uplambda }}^{(h)} + \alpha {\boldsymbol{{\Phi }}}^{(h+1)} \\ {\dot{\mathbf{{p}}}} &= \mathbf{{h}} \left ( \mathbf{{p}}, \mathbf{{z}}, {\dot{\mathbf{{z}}}} \right ) \end{aligned} \, \right \} (\text{penalty-based semirecursive approach}), \end{aligned} $$
(31)

where \(\mathbf{{p}}\) is a vector of the pressures in the hydraulic subsystem and \({\mathbf{{h}} \left ( \mathbf{{p}}, \mathbf{{z}}, {\dot{\mathbf{{z}}}} \right )}\) are the pressure variation equations. It is assumed that the dependency of both \(\mathbf{{Q}}^{\prime }\) and function \(\mathbf{{h}}\) with respect to \(\mathbf{{z}}\), \({\dot{\mathbf{{z}}}}\), and \(\mathbf{{p}}\) are known.

In this study, both the approaches are integrated by using an implicit single-step trapezoidal rule [26], which is second order and A-stable method. While the trapezoidal rule was often used in structural dynamics, it was, however, seldom used in multibody system dynamics until the study by Bayo et al. [1]. In the study [1], it was agreed that the trapezoidal rule will lead to poor convergence characteristics when applied to multibody system dynamics in a similar way as other multistep integrators, that is, by considering the accelerations as primary variables. However, Bayo et al. [1] and Cuadrado et al. [8,9,10] demonstrated that the trapezoidal rule performs very satisfactorily when it is combined directly with the equations of motion by taking the positions as the primary variables, as shown below. Similarly, for the hydraulic subsystem, pressures are taken as the primary variables, as shown in [28, 32]. Note that this study is more inclined to use the above approaches for real-time applications, such as [23], in future studies. Therefore, a single-step integration method is preferred that can use the same computational cost in each integration step [1]. Furthermore, even though the explicit, multistep integrators can be inexpensive and accurate, however, they do not demonstrate good stability, which is a limiting factor for real-time integration [1], especially for stiff systems. Thus, an implicit method is used. Moreover, A-stability is crucial for a numerically stiff system [1], such as presented in this study.

In the double-step semirecursive approach, the trapezoidal rule can be written as

$$ \left . \begin{aligned} {\mathbf{{z}}}_{k+1}^{\text{i}} &= \mathbf{{z}}_{k}^{\text{i}} + \frac{\Delta t}{2} \left ( {\dot{\mathbf{{z}}}}_{k}^{\text{i}} + { \dot{\mathbf{{z}}}}_{k+1}^{\text{i}} \right ) \\ {\dot{\mathbf{{z}}}}_{k+1}^{\text{i}} &= {\dot{\mathbf{{z}}}}_{k}^{\text{i}} + \frac{\Delta t}{2} \left ( {\ddot{\mathbf{{z}}}}_{k}^{\text{i}} + { \ddot{\mathbf{{z}}}}_{k+1}^{\text{i}} \right ) \\ \mathbf{{p}}_{k+1} &= \mathbf{{p}}_{k} + \frac{\Delta t}{2} \left ( { \dot{\mathbf{{p}}}}_{k} + {\dot{\mathbf{{p}}}}_{k+1} \right ) \end{aligned} \, \right \} ,$$
(32)

where \({\Delta t}\) is the time-step, \(\mathbf{{z}}_{k}^{\text{i}}\) are the independent relative joint coordinates, \({\dot{\mathbf{{z}}}}_{k}^{\text{i}}\) are the independent relative joint velocities, \({\ddot{\mathbf{{z}}}}_{k}^{\text{i}}\) are the independent relative joint accelerations, and \(\mathbf{{p}}_{k}\) and \({\dot{\mathbf{{p}}}}_{k+1}\) are, respectively, the pressures and pressure derivatives. Equation (32) can be rewritten by considering \(\mathbf{{z}}_{k+1}^{\text{i}}\) and \(\mathbf{{p}}_{k+1}\) as the primary variables and, respectively, solving for \({\dot{\mathbf{{z}}}}_{k+1}^{\text{i}}\), \({\ddot{\mathbf{{z}}}}_{k+1}^{\text{i}}\), and \({\dot{\mathbf{{p}}}}_{k+1}\) at time-step \(\left ( k+1 \right )\) as

$$ \left . \begin{aligned} {\dot{\mathbf{{z}}}}_{k+1}^{\text{i}} &= \frac{2}{\Delta t} {\mathbf{{z}}}_{k+1}^{ \text{i}} + {\hat{\dot{\mathbf{{z}}}}}_{k}^{\text{i}} \\ {\ddot{\mathbf{{z}}}}_{k+1}^{\text{i}} &= \frac{4}{\Delta t^{2}} {\mathbf{{z}}}_{k+1}^{ \text{i}} + {\hat{\ddot{\mathbf{{z}}}}}_{k}^{\text{i}} \\ {\dot{\mathbf{{p}}}}_{k+1} &= \frac{2}{\Delta t} {\mathbf{{p}}}_{k+1} + { \hat{\dot{\mathbf{{p}}}}}_{k} \end{aligned} \, \right \} ,$$
(33)

where

$$ \left . \begin{aligned} {\hat{\dot{\mathbf{{z}}}}}_{k}^{\text{i}} &= - \left ( \frac{2}{\Delta t} { \mathbf{{z}}}_{k}^{\text{i}} + \dot{\mathbf{{z}}}_{k}^{\text{i}} \right ) \\ {\hat{\ddot{\mathbf{{z}}}}}_{k}^{\text{i}} &= - \left ( \frac{4}{\Delta t^{2}} {\mathbf{{z}}}_{k}^{\text{i}} + \frac{4}{\Delta t} \dot{\mathbf{{z}}}_{k}^{\text{i}} + \ddot{\mathbf{{z}}}_{k}^{\text{i}} \right ) \\ {\hat{\dot{\mathbf{{p}}}}}_{k} &= - \left ( \frac{2}{\Delta t} {\mathbf{{p}}}_{k} + \dot{\mathbf{{p}}}_{k} \right ) \end{aligned} \, \right \} . $$
(34)

Note that in the double-step semirecursive approach, the rules \({\mathbf{{z}}_{k+1}^{\text{i}} = \mathbf{{z}}_{k}^{\text{i}} + {\dot{\mathbf{{z}}}}_{k}^{ \text{i}} \Delta t + \frac{1}{2} {\ddot{\mathbf{{z}}}}_{k}^{\text{i}} \Delta t^{2}}\) and \({\mathbf{{p}}_{k+1} = \mathbf{{p}}_{k} + {\dot{\mathbf{{p}}}}_{k} \Delta t }\) are applied to \(\mathbf{{z}}_{k+1}^{\text{i}}\) and \(\mathbf{{p}}_{k+1}\), respectively. In the double-step semirecursive approach, given \(\mathbf{{z}}_{k+1}^{\text{i}}\), the dependent relative joint coordinates \(\mathbf{{z}}_{k+1}^{\text{d}}\) are obtained by iteratively solving the loop-closure constraint equations \(\boldsymbol{{\Phi }} \left ( \mathbf{{z}} \right ) = \mathbf{{0}}\), which are highly nonlinear [11]. In this study, the Newton–Raphson method is used to solve the loop-closure position problem and convergence is achieved by providing a reliable estimate for \(\mathbf{{z}}_{k+1}^{\text{d}}\) by using information from the previous time-step as [15] \({\mathbf{{z}}_{k+1}^{\text{d}} = \mathbf{{z}}_{k}^{\text{d}} + {\dot{\mathbf{{z}}}}_{k}^{ \text{d}} \Delta t + \frac{1}{2} {\ddot{\mathbf{{z}}}}_{k}^{\text{d}} \Delta t^{2}}\). The dependent relative joint velocities \({\dot{\mathbf{{z}}}}_{k+1}^{\text{d}}\) and accelerations \({\ddot{\mathbf{{z}}}}_{k+1}^{\text{d}}\) are computed from Eqs. (14) and (15), respectively. In the penalty-based semirecursive approach, the full set of relative joint coordinates \(\mathbf{{z}}_{k+1}\), velocities \({\dot{\mathbf{{z}}}}_{k+1}\), and accelerations \({\ddot{\mathbf{{z}}}}_{k+1}\) are used in the above discussion of Eqs. (32), (33), and (34), instead of \(\mathbf{{z}}_{k+1}^{\text{i}}\), \({\dot{\mathbf{{z}}}}_{k+1}^{\text{i}}\), and \({\ddot{\mathbf{{z}}}}_{k+1}^{\text{i}}\). The dynamic equilibrium, established at time-step \(\left ( k+1 \right )\), for both the approaches can be written as

$$ \begin{aligned} &\left . \begin{aligned} {\mathbf{{M}}}^{\prime \prime } {\mathbf{{z}}}_{k+1}^{\text{i}} - {\frac{\Delta t^{2}}{4}} { \mathbf{{Q}}}_{k+1}^{\prime \prime } + {\frac{\Delta t^{2}}{4}} {\mathbf{{M}}}^{\prime \prime } \hat{\ddot{\mathbf{{z}}}}_{k}^{\text{i}} = 0 \\ {\frac{\Delta t}{2}} {\mathbf{{p}}}_{k+1} - {\frac{\Delta t^{2}}{4}} {\mathbf{{h}}}_{k+1} + {\frac{\Delta t^{2}}{4}} \hat{\dot{\mathbf{{p}}}}_{k} = 0 \end{aligned} \, \right \} (\text{double-step semirecursive approach}), \end{aligned} $$
(35)
$$ \begin{aligned} & \left . \begin{aligned} {\mathbf{{M}}}^{\prime } {\mathbf{{z}}}_{k+1} + {\frac{\Delta t^{2}}{4}} {\boldsymbol{{\Phi }}}_{{ \mathbf{{z}}}_{k+1}}^{\text{T}} \left ( \alpha {\boldsymbol{{\Phi }}}_{k+1} + { \boldsymbol{\uplambda }}_{k+1} \right ) - {\frac{\Delta t^{2}}{4}} { \mathbf{{Q}}}_{k+1}^{\prime } + {\frac{\Delta t^{2}}{4}} {\mathbf{{M}}}^{\prime } \hat{\ddot{\mathbf{{z}}}}_{k} = 0 \\ {\boldsymbol{\uplambda }}_{k+1}^{(h+1)} = {\boldsymbol{\uplambda }}_{k+1}^{(h)} + \alpha {\boldsymbol{{\Phi }}}_{k+1}^{(h+1)} \\ {\frac{\Delta t}{2}} {\mathbf{{p}}}_{k+1} - {\frac{\Delta t^{2}}{4}} {\mathbf{{h}}}_{k+1} + {\frac{\Delta t^{2}}{4}} \hat{\dot{\mathbf{{p}}}}_{k} = 0 \end{aligned} \, \right \} \\ & \hspace{4.5cm} (\text{penalty-based semirecursive approach}). \end{aligned} $$
(36)

Equations (35) and (36) are a nonlinear system of equations that can be denoted as \(\mathbf{{f}} \left ( \mathbf{{x}}_{k+1} \right ) = \mathbf{{0}}\), where \(\mathbf{{x}} = \left [ \left (\mathbf{{z}}^{\text{i}}\right )^{\text{T}}, \mathbf{{p}}^{ \text{T}} \right ]^{\text{T}}\) for the double-step semirecursive approach and \(\mathbf{{x}} = \left [ {\mathbf{{z}}}^{\text{T}}, \mathbf{{p}}^{\text{T}} \right ]^{ \text{T}}\) for the penalty-based semirecursive approach. Such a nonlinear system of equations can be iteratively solved by employing the Newton–Raphson method as

$$ \left [ \frac{\partial {\mathbf{{f}}} \left ( \mathbf{{x}} \right )}{\partial {\mathbf{{x}}}} \right ]_{k+1}^{(h)} \Delta {\mathbf{{x}}}_{k+1}^{(h)} = - \left [ {\mathbf{{f}}} \left ( \mathbf{{x}} \right ) \right ]_{k+1}^{(h)} .$$
(37)

The residual vector \(\left [ {\mathbf{{f}}} \left ( \mathbf{{x}} \right ) \right ]_{k+1}^{(h)}\) can be written as

$$ \begin{aligned} &\left [ {\mathbf{{f}}} \left ( \mathbf{{x}} \right ) \right ]_{k+1}^{(h)} = { \frac{\Delta t^{2}}{4}} \begin{bmatrix} {\mathbf{{M}}}^{\prime \prime } {\ddot{\mathbf{{z}}}}^{\text{i}} - \mathbf{{Q}}^{\prime \prime } \\ {\dot{\mathbf{{p}}}} - \mathbf{{h}} \end{bmatrix} _{k+1}^{(h)} (\text{double-step semirecursive approach}), \end{aligned} $$
(38)
$$ \begin{aligned} &\left [ {\mathbf{{f}}} \left ( \mathbf{{x}} \right ) \right ]_{k+1}^{(h)} = { \frac{\Delta t^{2}}{4}} \begin{bmatrix} {\mathbf{{M}}}^{\prime } {\ddot{\mathbf{{z}}}} + \boldsymbol{{\Phi }}_{\mathbf{{z}}}^{\text{T}} \alpha { \boldsymbol{{\Phi }}} + \boldsymbol{{\Phi }}_{\mathbf{{z}}}^{\text{T}} {\boldsymbol{\uplambda }} - \mathbf{{Q}}^{\prime } \\ {\dot{\mathbf{{p}}}} - \mathbf{{h}} \end{bmatrix} _{k+1}^{(h)} \\ & \hspace{4.5cm} (\text{penalty-based semirecursive approach}), \end{aligned} $$
(39)

where \({\boldsymbol{\uplambda }}\) is obtained as shown in Eq. (19). The approximated tangent matrix \(\left [ \frac{\partial {\mathbf{{f}}} \left ( \mathbf{{x}} \right )}{\partial {\mathbf{{x}}}} \right ]_{k+1}^{(h)}\) can be obtained numerically by using the forward differentiation rule

$$ \frac{d f \left ( x_{0} \right )}{dx} \approx \frac{f \left ( x_{0} + \epsilon \right ) - f \left ( x_{0} \right )}{\epsilon } ,$$
(40)

where \(\epsilon \) is the differentiation increment. To avoid ill-conditioning of the tangent matrix, \(\epsilon \) is computed as in [32], namely

$$ \epsilon = 1 \times 10^{-8} \text{max} \left ( 1 \times 10^{-2}, { \mid x_{0} \mid } \right ) ,$$
(41)

where \(1 \times 10^{-2}\) limits the minimum value for the differentiation increment to \(1 \times 10^{-10}\). Equation (41) is a modification of a method presented in [5]. In the penalty-based semirecursive approach, \({\dot{\mathbf{{z}}}}\) and \({\ddot{\mathbf{{z}}}}\) are corrected by using the mass-damping-stiffness-orthogonal projections [3, 9] as shown in Eqs. (20) and (21).

5 The case studies of hydraulically actuated four-bar and quick-return mechanisms

In this study, a hydraulically actuated four-bar mechanism, as shown in Fig. 4, and a hydraulically actuated quick-return mechanism, as shown in Fig. 5, are used for a comparative study between the two multibody formulations in a numerically stiff coupled environment. The numerical stiffness in the coupled environment is introduced by the hydraulic subsystem. The mechanisms are modeled, first by using the double-step semirecursive formulation, and later by using the penalty-based semirecursive formulation, as explained in Sect. 2. For the planar system in Fig. 4, three joint coordinates are used in the modeling of the structure and two loop-closure constraints are used for a cut-joint (revolute joint) at point \({E}\). Whereas for the planar system in Fig. 5, five joint coordinates are used in the modeling of the structure and four loop-closure constraints are used for two cut-joints (translational joints) at points \({J}\) and \({M}\). Both the mechanisms have one degree of freedom.

Fig. 4
figure 4

A four-bar mechanism actuated by a double-acting hydraulic cylinder

Fig. 5
figure 5

A quick-return mechanism actuated by a double-acting hydraulic cylinder

In Fig. 4, bodies 1, 2, and 3 are assumed as rectangular beams, whose lengths and masses are \(L_{1} = 9\) m, \(L_{2} = \sqrt{2}\) m, and \(L_{3} = 2\) m, and \(m_{1} = 225\) kg, \(m_{2} = 35\) kg, and \(m_{3} = 50\) kg, respectively. The locations of points \({E}\), \({G,}\) and \({C}\) in the inertial reference frame are \(\left [ 0, -1, 0 \right ]^{\text{T}}\) m, \(\left [ 0, -2, 0 \right ]^{\text{T}}\) m, and \(\left [ \frac{L_{1}}{3}, 0, 0 \right ]^{\text{T}}\) m, respectively. Point \({F}\) is located at the center of mass of body-3. In Fig. 4, the relative joint coordinates at points \({O}\), \({C}\), and \({D}\) are respectively represented by \({z_{1}}\), \({z_{2}}\) and \({z_{3}}\) that define the orientation of the respective bodies in the inertial reference frame, \({\mathit{XYZ}}\). Their initial values are considered as \(0^{\text{o}}\), \(-135^{\text{o}}\), and \(-45^{\text{o}}\), respectively. To avoid instabilities in the integration process, the initial values of the relative joint velocities are considered \(0^{\text{o}}\)/s.

In Fig. 5, bodies 1, 2, and 4 are assumed as rectangular beams and bodies 3 and 5 are assumed as cuboid, whose lengths and masses are \(L_{1} = 5\) m, \(L_{2} = 1.2\) m, \(L_{3} = 0.3\) m, \(L_{4} = 1\) m, and \(L_{5} = 0.3\) m, and \(m_{1} = 25\) kg, \(m_{2} = 12\) kg, \(m_{3} = 3\) kg, \(m_{4} = 100\) kg, and \(m_{5} = 30\) kg, respectively. The locations of points \({I}\), \({K,}\) and \({Q}\) in the inertial reference frame are \(\left [ 0, 5, 0 \right ]^{\text{T}}\) m, \(\left [ 0, 3, 0 \right ]^{\text{T}}\) m, and \(\left [-0.96, 3, 0 \right ]^{\text{T}}\) m, respectively. Points \({N}\) and \({L}\) are located at the center of mass of bodies 4 and 5, respectively. In Fig. 5, the relative joint coordinates at points \({O}\), \({H}\), \({I}\), \({K}\), and \({L}\) are respectively represented by \({z_{1}}\), \({z_{2}}\), \({z_{3}}\), \({z_{4}}\), and \({z_{5}}\) that define the orientation of the respective bodies in the inertial reference frame, \({\mathit{XYZ}}\). Their initial values are considered as \(76.22^{\text{o}}\), \(96.89^{\text{o}}\), \(6.89^{\text{o}}\), \(30.59^{\text{o}}\), and \(45.63^{\text{o}}\), respectively. The mass moment of inertia of a rectangular beam and a cuboid are considered as \(\frac{m{L}^{2}}{12}\) and \(\frac{m{L}^{2}}{6}\), respectively, where \(m\) is the mass and \(L\) is the length. The gravity is assumed to act in the negative \({Y}\) direction, whose value is \(g = 9.81\) m/s2.

Both mechanisms are actuated by using the hydraulic actuators, as shown in Figs. 4 and 5. For simplicity, identical hydraulic actuators are used in both mechanisms. In this study, a simple hydraulic circuit is accounted, which consists of a pump, with a constant pressure source \({p_{P}}\), a directional control valve, with a control signal \(U\), a throttle valve, a double-acting hydraulic cylinder, connecting hoses, and a tank, with a constant pressure \({p_{T}}\). The control volumes, \({V_{1}}\), \({V_{2}}\), and \({V_{3}}\), used in the modeling of the hydraulic circuit are marked in Fig. 4. The pressure in the respective control volumes are \({p_{1}}\), \({p_{2}}\), and \({p_{3}}\); and their respective effective bulk modulus are \({B_{e1}}\), \({B_{e2}}\), and \({B_{e3}}\), that are calculated by using Eq. (23). For simplicity, the hydraulic circuit is assumed ideal, that is, the leakage is neglected.

In the hydraulic subsystem, the control volumes \({V_{1}}\), \({V_{2}}\), and \({V_{3}}\) are calculated as

$$ \left . \begin{aligned} {V_{1}} &= {V_{h_{1}}} \\ {V_{2}} &= {V_{h_{2}}} + {A_{2}} {l_{2}} \\ {V_{3}} &= {V_{h_{3}}} + {A_{3}} {l_{3}} \end{aligned} \, \right \} ,$$
(42)

where \({V_{h_{1}}}\), \({V_{h_{2}}}\), and \({V_{h_{3}}}\) are the volumes of the respective hoses; \({A_{2}}\) and \({A_{3}}\) are, respectively, the areas of the piston side and the piston-rod side within a cylinder; and \({l_{2}}\) and \({l_{3}}\) are, respectively, the lengths of the chambers of the cylinder, piston and piston-rod side. The length of the hydraulic cylinder is \({l}\) such that \({l_{2}} + {l_{3}} = {l}\); and the variable chamber lengths, \({l_{2}}\) and \({l_{3}}\), are calculated as

$$ \left . \begin{aligned} {l_{2}} &= l_{2_{0}} + {s_{0}} - {\mid {\mathbf{{s}}} \mid } \\ {l_{3}} &= l_{3_{0}} - {s_{0}} + {\mid {\mathbf{{s}}} \mid } \end{aligned} \, \right \} ,$$
(43)

where \({\mid {\mathbf{{s}}} \mid }\) is the actuator length of the hydraulic cylinder (see Figs. 4 and 5); \(s_{0}\) is the actuator length at \(t=0\); and \(l_{2_{0}} = {{s_{0}} - {l}}\) and \(l_{3_{0}} = {{l} - {l_{2_{0}}}}\) are, respectively, the length of the piston and piston-rod side of the cylinder at \(t=0\). The differential equations of the pressures \({p_{1}}\), \({p_{2}}\), and \({p_{3}}\) are computed based on Eq. (22) as

$$ \left . \begin{aligned} {{\dot{p}}_{1}} &= \frac{B_{e1}}{V_{1}} \left ( {Q_{d1}} - {Q_{t}} \right ) \\ {{\dot{p}}_{2}} &= \frac{B_{e2}}{V_{2}} \left ( {Q_{t}} - {A_{2}} { \dot{s}} \right ) \\ {{\dot{p}}_{3}} &= \frac{B_{e3}}{V_{3}} \left ( {A_{3}} {\dot{s}} - {Q_{3d}} \right ) \end{aligned} \, \right \} ,$$
(44)

where the volume flow rates \({Q_{d1}}\) and \({Q_{3d}}\) are calculated from Eq. (26), the volume flow rate \({Q_{t}}\) is calculated from Eq. (24), and \({\dot{s}}\) is the actuator velocity. The actuator length \({\mid {\mathbf{{s}}} \mid }\) and actuator velocity \({\dot{s}}\) of the hydraulic cylinder are computed as a function of the relative joint coordinates. For example, in Fig. 4, the upper end of the hydraulic cylinder is attached to body-3 at point \({F}\), while, the lower end is attached to ground at point \({G}\), such that \(\mathbf{{r}}_{G} = \left [ 0, -2, 0 \right ]^{\text{T}}\) m. Therefore, \(\mathbf{{s}}\) and \({\dot{s}}\) for the four-bar mechanism can be computed as

$$ \left . \begin{aligned} {\mathbf{{s}}} &= \mathbf{{r}}_{F} - \mathbf{{r}}_{G} \\ {\dot{s}} &= \frac{d{\mid {\mathbf{{s}}} \mid }}{dt} = {\dot{\mathbf{{s}}}} \cdot \frac{\mathbf{{s}}}{{\mid {\mathbf{{s}}} \mid }} = {\dot{\mathbf{{r}}}}_{F} \cdot \frac{\mathbf{{s}}}{{\mid {\mathbf{{s}}} \mid }} \end{aligned} \, \right \} ,$$
(45)

where the position \(\mathbf{{r}}_{F}\) and velocity \({\dot{\mathbf{{r}}}}_{F}\) are calculated by applying the classical kinematic relations as in [11, 22]. For simplicity, the force \({F_{s}}\) produced by the hydraulic cylinder in Eq. (29) is expressed in the form of Eq. (10) as \(\mathbf{{F}}_{s} = \left [ \frac{s_{\text{X}}}{{\mid {\mathbf{{s}}} \mid }}{F_{s}}, \frac{s_{\text{Y}}}{{\mid {\mathbf{{s}}} \mid }}{F_{s}}, \frac{s_{\text{Z}}}{{\mid {\mathbf{{s}}} \mid }}{F_{s}} \right ]^{\text{T}}\), where \({s_{\text{X}}}\), \({s_{\text{Y}}}\), and \({s_{\text{Z}}}\) are the components of vector \(\mathbf{{s}}\) along the axes of the inertial reference frame. The initial value of the force \({F_{s_{0}}}\) produced by the hydraulic cylinder is calculated from the static configurations, as shown in Figs. 4 and 5. For example, in case of four-bar mechanism, \({F_{s_{0}}} = \sqrt{2} {g} \left (3 {m_{1}} + 2 {m_{2}} + {m_{3}} \right )\). In the static configuration, the initial value of pressure \(p_{1}\) is equal to the initial value of pressure \(p_{2}\), which can be calculated based on Eq. (29) as \({p_{2}} = \left ({F_{s_{0}}} + {p_{3}}{A_{3}} \right ) / {A_{2}} \). Note that the friction is neglected in static configuration and the initial value of pressure \(p_{3}\) is assumed 3.5 MPa. The directional control valve, parameter \(U\) in Eq. (27), controls the movement of the cylinder through volume flows and is actuated for 10 s by using the following reference voltage signal \(U_{ref}\) as

$$ \text{(Four-bar mechanism)}\quad U_{ref} = \textstyle\begin{cases} 0, & t < 1 \hspace{0.1cm} \text{s}, \hspace{0.25cm} 2.5 \hspace{0.1cm} \text{s} \leq t < 5 \hspace{0.1cm} \text{s}, \hspace{0.25cm} t \leq 10, \hspace{0.1cm} \\ 10, & 1 \hspace{0.1cm} \text{s} \leq t < 2.5 \hspace{0.1cm} \text{s,} \\ -10, & 5 \hspace{0.1cm} \text{s} \leq t < 8 \hspace{0.1cm} \text{s,} \end{cases} $$
(46)
$$ \text{(Quick-return mechanism)}\quad U_{ref} = \textstyle\begin{cases} 0, & t < 1 \hspace{0.1cm} \text{s}, \hspace{0.25cm} 4 \hspace{0.1cm} \text{s} \leq t < 6.5 \hspace{0.1cm} \text{s}, \hspace{0.25cm} t \leq 10, \hspace{0.1cm} \\ -10, & 1 \hspace{0.1cm} \text{s} \leq t < 4 \hspace{0.1cm} \text{s,} \\ 10, & 6.5 \hspace{0.1cm} \text{s} \leq t < 8 \hspace{0.1cm} \text{s,} \end{cases} $$
(47)

where \({t}\) is the simulation run time. The parameters of the hydraulic circuit are shown in Table 1.

Table 1 Parameters of the hydraulic circuit

The set of variables used to solve the combined system of equations with the proposed integration scheme (Sect. 4) are

$$ \left . \begin{aligned} {\mathbf{{x}}} &= \left [ \left (\mathbf{{z}}^{\text{i}}\right )^{\text{T}}, \; { \mathbf{{p}}}^{\text{T}} \right ]^{\text{T}} ( \text{double-step semirecursive approach}) \\ \mathbf{{x}} &= \left [ {\mathbf{{z}}}^{\text{T}}, \; \mathbf{{p}}^{\text{T}} \right ]^{ \text{T}} (\text{penalty-based semirecursive approach}) \end{aligned} \, \right \} . $$
(48)

Note that, in the double-step semirecursive approach (Eq. (48)), \(\mathbf{{z}}^{\text{i}}\) is identified by using the Gaussian elimination with full pivoting to the Jacobian matrix \(\boldsymbol{{\Phi }}_{\mathbf{{z}}}\). In this study, the error tolerance is considered as \(1 \times 10^{-7}\) rad for positions and \(1 \times 10^{-2}\) Pa for pressures. The voltage that corresponds to the spool position is integrated by using the trapezoidal rule and its error tolerance is considered as \(1 \times 10^{-7}\) V. Furthermore, the penalty factor \(\alpha \) in Eq. (18) is considered as \(1 \times 10^{11}\). Note that in the penalty-based semirecursive approach, the penalty term is analogous to a spring constant by considering that there is a spring attached to the cut-joint location to fulfill the constraints. Due to the high numerical stiffness introduced by the hydraulics, a high penalty term (spring constant) is used. In this study, both the approaches are implemented in the Matlab environment.

6 Results and discussion

This section presents the simulation results of the hydraulically actuated four-bar and quick-return mechanisms presented in the previous section. Figures 6a and 6b show the simulation frames of the four-bar and quick-return mechanisms, respectively, presenting the position of the bodies at different instants of time. Here, the two approaches, namely, the double-step semirecursive approach and the penalty-based semirecursive approach, are compared based on the simulation work cycle, energy balance, constraint violation, and numerical efficiency.

Fig. 6
figure 6

The positions of the mechanisms at every second during the simulation run

6.1 The work cycle

In the four-bar mechanism, the hydraulic cylinder lifts the structure between 1–2.5 s and lowers it down between 5–8 s. Whereas in the quick-return mechanism, the hydraulic cylinder pulls the structure between 1–4 s and pushes it between 6.5–8 s. In the subsequent plots, the regions between the opening and closing of the directional control valve are highlighted in purple for the four-bar mechanism and in cyan for the quick-return mechanism. For both the mechanisms, the relative joint coordinates showed a good agreement in the two approaches, as shown in Figs. 7a and 8a. Thus, the solutions of both the approaches are accurate with respect to each other. The pressures in the hydraulic control volumes are shown in Figs. 7b and 8b, respectively, for the four-bar and quick-return mechanisms. Note that the pressures are identical in both the approaches and the choice of the multibody formulation does not affect the results of the hydraulics.

Fig. 7
figure 7

The relative joint coordinates and pressures for the four-bar mechanism

Fig. 8
figure 8

The relative joint coordinates and pressures for the quick-return mechanism

In the double-step approach, the independent joint coordinate is identified by using the Gaussian elimination with full pivoting on the Jacobian matrix of the constraints. For the presented work cycle, the independent coordinates are identified as \(z_{3}\) for the four-bar mechanism and as \(z_{4}\) for the quick-return mechanism, throughout the simulation. In the double-step approach, if the independent and dependent coordinates are not identified adequately, then it can lead to the numerical problems during the integration because of the poor conditioned matrices. Therefore, the adequate identification of the independent and dependent coordinates is considered a relative drawback of the double-step approach compared with the penalty-based approach because the latter uses the full set of coordinates.

6.2 Energy balance

The energy balances in both the approaches are compared by analyzing the kinetic energy, potential energy, and work done by the actuator. The energy comparison of the four-bar mechanism is shown in Fig. 9 and of the quick-return mechanism is shown in Fig. 10. The energy balance in the double-step and penalty-based approaches showed a good agreement with each other for both the mechanisms. The peak energy drift in case of the four-bar mechanism is 0.84 J, which is 0.09% of the maximum actuator work, 982.95 J, and it occurred at the closing of the valve around 8 s. Whereas in case of the quick-return mechanism, the peak energy drift is 0.23 J, that is, 0.06% of the maximum actuator work, 357.47 J, and it also occurred at the closing of the valve around 8 s. An analogy can be drawn between the hydraulic system and a stiff spring, which supports the structure of the mechanisms.

Fig. 9
figure 9

A comparison of energies for the four-bar mechanism with a time-step of 1 ms

Fig. 10
figure 10

A comparison of energies for the quick-return mechanism with a time-step of 1 ms

6.3 Constraint violation

The basic difference between the double-step and penalty-based approaches is the way they handle constraints in their multibody formulation. Thus, it is worth showing a comparison of the constraint violations in both the approaches for the two mechanisms as shown in Figs. 11 and 12. Note that in the quick-return mechanism, two cut-joints are used in the modeling, but for demonstration purposes, the results for only one of the cut-joint are presented. In both the approaches, the constraints are fulfilled with good accuracy for both mechanisms. Thus, the robustness of the multibody formulations, as explained in the literature [10, 24], is preserved in the application of a monolithic simulation of coupled multibody and hydraulic systems. Furthermore, the double-step approach fulfills constraints to the level of machine precision, or the precision specified, and it maintains a good error control. Therefore, this can be considered as the relative advantage of the double-step approach compared with the penalty-based approach because the latter approach is relatively more relaxed on the fulfillment of constraints.

Fig. 11
figure 11

Magnitude of constraint violations for the four-bar mechanism with a time-step of 1 ms

Fig. 12
figure 12

Magnitude of constraint violations for the quick-return mechanism with a time-step of 1 ms

In the double-step approach, for a possible mapping between independent and dependent relative joint coordinates, there is an assumption that redundant constraints and singular configurations do not exist. This assumption is a relative disadvantage of the double-step approach compared with the penalty-based approach because the latter approach can handle redundant constraints and can deliver accurate solutions in the vicinity of singular configurations [15].

6.4 Numerical efficiency

The numerical efficiencies of both the approaches are compared in Figs. 13 and 14, for the four-bar and quick-return mechanisms, respectively. In the four-bar mechanism, the average and maximum iterations, and the total integration time for the double-step approach are 1.39, 3, and 27.45 s and for the penalty-based approach are 1.56, 4, 21.54 s. Whereas in the quick-return mechanism, the average and maximum iterations, and the total integration time for the double-step approach are 1.49, 3, and 29.03 s and for the penalty-based approach are 1.57, 6, and 28.47 s. The maximum number of iterations occurred during the opening and closing of the directional control valve. Even though the number of iterations are lower in the double-step approach, its integration time is greater compared with the penalty-based approach, which is in accordance with the literature [15, 27]. The poor numerical efficiency of the double-step approach is attributed to the iterative solution of the dependent joint coordinates by using the Newton–Raphson method.

Fig. 13
figure 13

A comparison of numerical efficiencies for the four-bar mechanism with a time-step of 1 ms

Fig. 14
figure 14

A comparison of numerical efficiencies for the quick-return mechanism with a time-step of 1 ms

Note that the examples are implemented in the Matlab environment and for this reason, the result about the integration time may be unreliable because of the implementation details. However, both approaches are carefully implemented such that they have the same number of function calls in each iteration. This was achieved by symbolic precomputation and function generation of the matrix product, as in [32]. Furthermore, both approaches can be potential candidates for real-time applications by implementing them in a lower level language such as C++ or Fortran and by limiting the number of iterations to a lower value.

7 Conclusion

This study introduced the double-step semirecursive formulation and compared it with the penalty-based semirecursive formulation, in a numerically stiff coupled environment. The numerical stiffness was introduced by a hydraulic system. A monolithic scheme for the coupled simulation of the double-step semirecursive formulation and hydraulic systems was introduced in this study. To this end, the hydraulic system was described by using the lumped fluid theory. As case studies, hydraulically actuated four-bar and quick return mechanisms were modeled to compared the double-step semirecursive approach with the penalty-based semirecursive approach. The two approaches were compared based on the work cycle, energy balance, constraint violation, and numerical efficiency of the mechanisms, and similar results were obtained in both the mechanisms.

The relative joint coordinates and energy balances showed a good agreement in both the approaches. In the double-step approach, the adequate identification of the independent and dependent joint coordinates was carried out by using the Gaussian elimination with full pivoting on the Jacobian matrix of the constraints. Its identification is considered a relative drawback compared with the penalty-based approach where the full set of coordinates were used. In both the approaches, the constraints were fulfilled with good accuracy. However, the double-step approach had an advantage of fulfilling the constraints to the level of machine precision, or the precision specified compared with the penalty-based approach. Nevertheless, the double-step approach had an assumption that the redundant constraints and singularity configuration do not exit. This is a relative disadvantage of the double-step approach because the penalty-based approach can handle redundant constraints and can provide accurate solutions in the vicinity of singular configurations. Furthermore, the double-step approach suffered from poor numerical efficiency, which was attributed to the iterative solution of the dependent joint coordinates by using the Newton–Raphson method. To improve the numerical efficiency of the double-step approach, it would be of utmost importance to enhance the iterative solution of dependent coordinates and this is left as a topic for future studies. In conclusion, the penalty-based semirecursive approach has a number of advantages over the double-step semirecursive approach, which is in accordance with the literature [15, 27].

For future studies, alternate multibody formulations can be coupled with hydraulic systems to study on the optimal formulation for simulating coupled multibody and hydraulic systems. Note that the selection of the integrator type is bound to have an effect on the results. In this study, an implicit integrator is used, whereas the double-step semirecursive formulation is usually integrated by using the fourth order Runge–Kutta method, that is, an explicit integrator. Therefore, different integrators can be implemented to study on the optimal integrator choice for such coupled systems. This study utilized the Matlab environment, therefore, to make a firm conclusion on the numerical efficiency of the two approaches, a large-scale, three-dimensional example needs to be investigated in programming languages, such as C++ or Fortran.