1 Introduction

Dynamical systems may be formulated in various ways. The well-known Lagrangian and Hamiltonian formalisms both consider descriptive energetic scalars and deploy certain operations on them to generate the system’s equations of motion. Another formulation, which unifies both above-mentioned formalisms by means of independent position, velocity and momentum quantities has been proposed by Livens [1]. This Livens principle has been recently taken up by Bou-Rabee [2], Yoshimura & Marsden [3], and Holm [4] under the name of Hamilton-Pontryagin principle due to its close relation to the Pontryagin principle from the field of optimal control [5]. Livens principle allows for an advantageous universal description due to its mixed character.

A large variety of dynamical systems are subject to constraints, which reduce the degrees of freedom of the system and impose some constraint function to be satisfied. When describing the system with redundant coordinates, the equations of motion emerge as a set of differential-algebraic equations (DAEs), which combine both differential equations and algebraic constraint equations. It is to mention that the numerical treatment of DAEs requires some additional effort compared to purely differential equations (cf. Kunkel & Mehrmann [6]). As the constraints have to hold at every point in time (consistency condition), so-called secondary constraints on velocity level are induced.

In a vast majority of dynamical problems, one cannot find an analytical solution. Thus, in recent times, the focus of scientific research has become to derive numerical integration methods, which are capable of solving the equations of motion approximately. In this connection, the class of structure-preserving integrators seeks to inherit the conservation principles of dynamical systems in a discrete sense (cf. monographs such as Hairer et al. [7] or Leimkuhler & Reich [8]). The first contributions can be traced back to symplectic methods (see, e.g., de Vogelaere [9]). In the field of mechanics, structure-preserving integration schemes can be mainly divided into two different groups: variational integrators and energy-momentum integrators (see the book [10] for a summary of important developments).

Variational integrators approximate the action integral and are typically able to conserve the symplectic structure as well as the system’s momentum maps in a discrete sense (cf. Lew & Mata [11]). These are consequences of the variational procedure of derivation (cf. Marsden & West [12]). The main idea to find discrete counterparts of the variational principles goes back to Maeda [13]. Based on this concept, Marsden & West [12] provided a framework of discrete Lagrangian and Hamiltonian mechanics. Until now, variational integrators have been developed for various applications, e.g., for constrained dynamical systems (see, e.g., Leyendecker et al. [14]).

Integration schemes for constrained dynamics typically only account for the constraints on configuration level (primary constraints) but not for the secondary constraints and thus have a differentiation index of 3. This may lead to numerical instabilities (cf. Yoshimura [15]). By replacing the primary constraints on position level with the secondary velocity-level constraints, DAEs with index 2 are obtained. Thus, the numerical problems can be avoided but violations of the primary constraints induce the well-known drift phenomenon (cf. Simeon [16]). However, this issue can be alleviated by extending the system of unknowns and coupling the secondary constraints into the equations. The most famous technique, the Gear-Gupta-Leimkuhler (GGL) stabilization, traces back to Gear et al. [17] in 1985 and is widely used until today (see, e.g., Brüls et al. [18] and Arnold et al. [19]). This classical GGL formulation relies on the direct modification of the equations of motion. Yet, this procedure leads to a destruction of the Hamiltonian structure such that most GGL stabilized integration schemes are not symplectic.

To the best of the authors’ knowledge, numerical integration schemes for constrained dynamics have been formulated either in a Hamiltonian or in a Lagrangian way. Moreover, variational integration schemes have not been yet constructed such that primary and secondary constraints are considered at once. Thus, this work tries to fill both gaps by introducing a novel Livens-based variational framework for the integration of dynamical systems accounting for both primary and secondary constraints. In particular, the new framework makes it possible to justify the commonly used GGL formulation in a variational sense. Contrary to the original version, the newly proposed formalism provides index 2 DAEs with a Hamiltonian structure. Moreover, the novel variational principle opens up the possibility to develop new variational integration schemes with a GGL-type stabilization. A first step in this direction is undertaken in the present work. In particular, a first-order scheme is presented which results from the direct discretization of the newly proposed GGL variational principle.

2 Fundamentals

2.1 Livens principle

Consider a dynamical system with \(d\) degrees of freedom and positions \(\boldsymbol {q} \in \mathbb{R}^{d}\). From Hamilton’s principle of least action, one can proceed by allowing the velocities to be independent variables \(\boldsymbol {v} \in \mathbb{R}^{d}\). Thus, the kinematic relation \(\dot{\boldsymbol {q}} = \boldsymbol {v}\) has to be enforced by means of a Lagrange multiplier \(\boldsymbol {p} \in \mathbb{R}^{d}\). The corresponding augmented functional reads

$$\begin{aligned} \tilde{S}(\boldsymbol {q},\boldsymbol {v},\boldsymbol {p}) = \int _{0}^{T} \left [ L(\boldsymbol {q}, \boldsymbol {v}) + \boldsymbol {p} \cdot (\dot{\boldsymbol {q}} - \boldsymbol {v}) \right ] \, \mathrm {d}t \text{,} \end{aligned}$$
(1)

where \(L(\boldsymbol {q},\boldsymbol {v})\) is the Lagrangian. The functional (1) was firstly termed Livens principle (cf. Sect. 26.2 in Pars [20]) after G.H. Livens who proposed this functional for the first time (cf. Livens [1]). More recently, Marsden and coworkers [2, 3] coined the name Hamilton-Pontryagin principle for this functional due to its close relation to the classical Pontryagin principle from the field of optimal control [5]. Due to its mixed character with three independent fields (\(\boldsymbol {q},\boldsymbol {v}, \boldsymbol {p}\)), it resembles the Hu-Washizu principle from the area of elasticity theory (cf. Washizu [21]). Livens principle unifies both Lagrangian and Hamiltonian viewpoints on mechanics and automatically accounts for the Legendre transformation.

By stating the stationary condition \(\delta \tilde{S}(\boldsymbol {q},\boldsymbol {v},\boldsymbol {p}) = 0\) and computing the variations with respect to every independent variable, one obtains the equations of motion in the form

$$\begin{aligned} \dot{\boldsymbol {q}} & = \boldsymbol {v} \text{,} \end{aligned}$$
(2a)
$$\begin{aligned} \dot{\boldsymbol {p}} & = \mathrm {D} _{1} L(\boldsymbol {q},\boldsymbol {v}) \text{,} \end{aligned}$$
(2b)
$$\begin{aligned} \boldsymbol {p} & = \mathrm {D} _{2} L(\boldsymbol {q},\boldsymbol {v}) \text{,} \end{aligned}$$
(2c)

where \(\mathrm {D} _{\alpha}(\bullet )\) denotes the partial derivative with respect to the \(\alpha \)’s argument. With regard to (2c) the multiplier \(\boldsymbol {p}\) can be identified as the conjugate momentum, which thus directly emanates from the principle. Within the framework of Hamiltonian dynamics, momentum variables have to be defined a priori or emerge from the Legendre transformation as a fiber derivative of \(L(\boldsymbol {q},\dot{\boldsymbol {q}})\). Note that after reinserting (2c) into (2b) and making use of (2a), Livens principle traces back to the Lagrangian equations of the second kind.

Consider a mechanical system with constant mass matrix \(\boldsymbol {M} \in \mathbb{R}^{d \times d}\), such that the Lagrangian takes the form

$$\begin{aligned} L(\boldsymbol {q},\boldsymbol {v}) = \frac{1}{2}\boldsymbol {v}\cdot \boldsymbol {M}\boldsymbol {v}-V(\boldsymbol {q}) \text{,} \end{aligned}$$
(3)

where \(V(\boldsymbol {q})\) is a potential function. Now (2c) yields \(\boldsymbol {p}=\boldsymbol {M}\boldsymbol {v}\), so that (2a) and (2b) can be rewritten as

$$\begin{aligned} \dot{\boldsymbol {q}} & = \boldsymbol {M}^{\mathrm{-1}}\boldsymbol {p} \text{,} \end{aligned}$$
(4a)
$$\begin{aligned} \dot{\boldsymbol {p}} & = - \mathrm {D} V(\boldsymbol {q}) \text{.} \end{aligned}$$
(4b)

Note that \(\mathrm {D} (\bullet )\) represents the gradient operator. These equations correspond to the Hamiltonian form of the equations of motion. Making use of the phase space vector \(\boldsymbol {z}=[\boldsymbol {q} ^{\mathrm{T}}, \boldsymbol {p}^{\mathrm{T}}] ^{\mathrm{T}}\) and the symplectic structure matrix

$$\begin{aligned} \mathbb{J} = \begin{bmatrix} \boldsymbol {0}_{d \times d} & \boldsymbol {I}_{d \times d} \\ -\boldsymbol {I}_{d \times d} & \boldsymbol {0}_{d \times d} \end{bmatrix} \text{,} \end{aligned}$$
(5)

where \(\boldsymbol {I}_{d \times d} \in \mathbb{R}^{d \times d}\) denotes the \(d \times d\) identity matrix, the Hamiltonian equations of motion read

$$\begin{aligned} \dot{\boldsymbol {z}} = \mathbb{J} \, \mathrm {D} H(\boldsymbol {z}) \end{aligned}$$
(6)

where the standard Hamiltonian function corresponding to (3) is given by

$$\begin{aligned} H = \frac{1}{2} \boldsymbol {p} \cdot \boldsymbol {M}^{\mathrm{-1}}\boldsymbol {p} + V( \boldsymbol {q}) \text{.} \end{aligned}$$
(7)

2.2 Symplectic structure of dynamics

Let us firstly introduce a bilinear and skew-symmetric function \(\Omega: \mathbb{R}^{2d} \times \mathbb{R}^{2d} \rightarrow \mathbb{R} \) acting on two elements \(\boldsymbol {\xi}, \boldsymbol {\eta} \in \mathbb{R}^{2d}\), which assume an ordering of components as in the phase space vector such that, exemplarily,

$$\begin{aligned} \boldsymbol {\xi} = \begin{bmatrix} \xi _{1}^{(1)} & \xi _{1}^{(2)} & \ldots & \xi _{1}^{(d)} & \xi _{2}^{(1)} & \xi _{2}^{(2)} & \ldots & \xi _{2}^{(d)} \end{bmatrix}^{\mathrm{T}} \text{.} \end{aligned}$$
(8)

Bilinearity refers to the fact that \(\Omega\) is linear in both arguments. Skew-symmetry implies that \(\Omega(\boldsymbol {\xi}, \boldsymbol {\eta}) = - \Omega(\boldsymbol {\eta}, \boldsymbol {\xi})\). The canonical structure matrix introduced in (5) gives rise to the symplectic two-form

$$\begin{aligned} \Omega(\boldsymbol {\xi}, \boldsymbol {\eta}) = \boldsymbol {\xi} \cdot \mathbb{J}^{ \mathrm{-1}}\boldsymbol {\eta} \text{.} \end{aligned}$$
(9)

A map \(\boldsymbol {\Psi}: \mathbb{R}^{\mathrm{2d}} \rightarrow \mathbb{R}^{ \mathrm{2d}}\) is called symplectic if it leaves the symplectic two-form \(\Omega\) invariant in the sense that

$$\begin{aligned} \Omega( \mathrm {D} \boldsymbol {\Psi}(\boldsymbol {z})\boldsymbol {\xi}, \mathrm {D} \boldsymbol {\Psi}( \boldsymbol {z})\boldsymbol {\eta}) = \Omega(\boldsymbol {\xi}, \boldsymbol {\eta}) \text{,} \end{aligned}$$
(10)

where the original two-form is equal to the two-form of the transports of \(\boldsymbol {\xi}\) and \(\boldsymbol {\eta}\) under the linearization of \(\boldsymbol {\Psi}\). Figure 1 displays the mapping of elements \(\boldsymbol {\xi}\) and \(\boldsymbol {\eta}\) by \(\boldsymbol {\Psi}\) and the preservation of the symplectic two-form, representing the oriented area for \(d=1\). Making use of the definition (9), the last equation leads to a symplecticness condition that reads

$$\begin{aligned} \mathrm {D} \boldsymbol {\Psi}(\boldsymbol {z}) ^{\mathrm{T}}\mathbb{J}^{\mathrm{-1}} \mathrm {D} \boldsymbol {\Psi}(\boldsymbol {z}) = \mathbb{J}^{\mathrm{-1}} \text{.} \end{aligned}$$
(11)
Fig. 1
figure 1

Symplectic area preservation for \(d=1\) (inspired by Hairer et al. [7])

The wedge product of two differential one-forms \(\,\mathrm {d} \boldsymbol {a} \in \mathbb{R}^{d}\) and \(\,\mathrm {d} \boldsymbol {b} \in \mathbb{R}^{d}\) acting on any two vectors \(\boldsymbol {\xi}\), \(\boldsymbol {\eta} \in \mathbb{R}^{2d}\) is given by (cf. Leimkuhler & Reich [8])

$$\begin{aligned} ( \,\mathrm {d} \boldsymbol {a} \wedge \,\mathrm {d} \boldsymbol {b})(\boldsymbol {\xi}, \boldsymbol {\eta}) & = \sum _{i=1}^{d} ( \,\mathrm {d} a_{i} \wedge \,\mathrm {d} b_{i} ) \, (\boldsymbol {\xi}, \boldsymbol {\eta}) = \sum _{i=1}^{d} \left ( \,\mathrm {d} b_{i}(\boldsymbol {\xi}) \,\mathrm {d} a_{i}(\boldsymbol {\eta}) - \,\mathrm {d} a_{i}(\boldsymbol {\xi}) \,\mathrm {d} b_{i}(\boldsymbol {\eta})\right ) \text{.} \end{aligned}$$
(12)

Thus, the symplectic two form (9) can be rewritten in terms of the wedge product as

$$\begin{aligned} \Omega(\boldsymbol {\xi}, \boldsymbol {\eta}) = \sum _{i=1}^{d} \,\mathrm {d} q_{i} \wedge \,\mathrm {d} p_{i} \, (\boldsymbol {\xi}, \boldsymbol {\eta}) \text{,} \end{aligned}$$
(13)

where the differential one-forms \(\,\mathrm {d} q_{i}, \,\mathrm {d} p_{i}\) extract the \(i\)th coordinate or momentum component, respectively, such that

$$\begin{aligned} \,\mathrm {d} q_{i}(\boldsymbol {\xi}) = \xi _{1}^{(i)} \text{,} \quad \,\mathrm {d} p_{i}( \boldsymbol {\xi}) = \xi _{2}^{(i)} \text{.} \end{aligned}$$
(14a)

Omitting the arguments, the symplectic two-form can be rewritten more briefly in vector notation as

$$\begin{aligned} \Omega = \,\mathrm {d} \boldsymbol {q} \wedge \,\mathrm {d} \boldsymbol {p} \text{.} \end{aligned}$$
(15)

Note that this representation is only a briefer notation of (13) that still accounts for the summation of the wedge product of scalar one-forms. One can show that Hamiltonian flow maps are symplectic. Thus, it is equivalent to say that the symplectic two-form (15) is conserved along solutions of the Hamiltonian equations of motions (6), viz.

$$\begin{aligned} \frac{ \,\mathrm {d} }{ \mathrm {d}t} \Omega = \frac{ \,\mathrm {d} }{ \mathrm {d}t} \left ( \,\mathrm {d} \boldsymbol {q} \wedge \,\mathrm {d} \boldsymbol {p} \right ) = 0 \text{.} \end{aligned}$$
(16)

For differential one-forms, given in vector notation as \(\,\mathrm {d} \boldsymbol {a}\), \(\,\mathrm {d} \boldsymbol {b}\) and \(\,\mathrm {d} \boldsymbol {c} \in \mathbb{R}^{d}\), any scalar valued quantities \(\alpha ,\beta \in \mathbb{R}\), any matrix \(\boldsymbol {A} \in \mathbb{R}^{d \times d}\) and any symmetric matrix \(\boldsymbol {B} = \boldsymbol {B}^{\mathrm{T}}\in \mathbb{R}^{d \times d}\) the wedge product defined in (12) has the following properties (see, for example, Leimkuhler & Reich [8]):

$$\begin{aligned} \,\mathrm {d} \boldsymbol {a} \wedge \,\mathrm {d} \boldsymbol {b} & = - \,\mathrm {d} \boldsymbol {b} \wedge \,\mathrm {d} \boldsymbol {a} \text{,} \end{aligned}$$
(17a)
$$\begin{aligned} \,\mathrm {d} \boldsymbol {a} \wedge ( \alpha \, \,\mathrm {d} \boldsymbol {b} + \beta \,\mathrm {d} \boldsymbol {c}) & = \alpha \,\mathrm {d} \boldsymbol {a} \wedge \,\mathrm {d} \boldsymbol {b} + \beta \,\mathrm {d} \boldsymbol {a} \wedge \,\mathrm {d} \boldsymbol {c} \text{,} \end{aligned}$$
(17b)
$$\begin{aligned} \,\mathrm {d} \boldsymbol {a} \wedge (\boldsymbol {A} \,\mathrm {d} \boldsymbol {b}) & = (\boldsymbol {A}^{\mathrm{T}} \,\mathrm {d} \boldsymbol {a}) \wedge \,\mathrm {d} \boldsymbol {b} \text{,} \end{aligned}$$
(17c)
$$\begin{aligned} \,\mathrm {d} \boldsymbol {a} \wedge (\boldsymbol {B} \,\mathrm {d} \boldsymbol {a}) & = 0 \text{.} \end{aligned}$$
(17d)

2.3 GGL method for constrained mechanical systems

Assume that the coordinates \(\boldsymbol {q}\) are redundant due to the presence of \(m\) independent scleronomic, holonomic constraints \(g_{k}: \mathbb{R}^{d} \rightarrow \mathbb{R}\) (\(k=1,\ldots ,m\)). The constraints can be comprised in a column vector \(\boldsymbol {g} \in \mathbb{R}^{m}\) such that

$$\begin{aligned} \boldsymbol {g}(\boldsymbol {q}) = \boldsymbol {0} \text{.} \end{aligned}$$
(18)

Since all constraint functions shall be independent, the constraint Jacobian \(\boldsymbol {G}(\boldsymbol {q}) = \mathrm {D} \boldsymbol {g}(\boldsymbol {q})\) is of rank \(m\). As (18) is true for any point in time, the time derivative has to vanish accordingly (consistency condition). Thus, the constraints on velocity level or secondary constraints

$$\begin{aligned} \frac{ \,\mathrm {d} }{ \mathrm {d}t} \boldsymbol {g}(\boldsymbol {q}) = \boldsymbol {G}(\boldsymbol {q})\dot{\boldsymbol {q}} = \boldsymbol {0} \end{aligned}$$
(19)

are induced. It is well-known that the motion of the constrained mechanical systems under consideration is governed by differential-algebraic equations (DAEs) which have differentiation index \(\nu = 3\). These equations of motion can be derived with a variational approach, which augments Livens principle (1). Accordingly, introducing \(\hat{S}(\boldsymbol {q},\boldsymbol {v},\boldsymbol {p},\boldsymbol {\lambda}) = \tilde{S}(\boldsymbol {q}, \boldsymbol {v},\boldsymbol {p}) + \int \nolimits _{0}^{T}\boldsymbol {\lambda}\cdot \boldsymbol {g}( \boldsymbol {q})\, \mathrm {d}t\), stating the stationary condition \(\delta \hat{S}(\boldsymbol {q},\boldsymbol {v},\boldsymbol {p},\boldsymbol {\lambda}) = 0\) and eliminating the velocities as above leads to an extension of the Hamiltonian equations (4a), (4b) for constrained systems, such that the index-3 DAEs are obtained as

$$\begin{aligned} \dot{\boldsymbol {q}} & = \boldsymbol {M}^{\mathrm{-1}}\boldsymbol {p} \text{,} \end{aligned}$$
(20a)
$$\begin{aligned} \dot{\boldsymbol {p}} & = - \mathrm {D} V(\boldsymbol {q}) - \boldsymbol {G}(\boldsymbol {q})^{\mathrm{T}} \boldsymbol {\lambda} \text{,} \end{aligned}$$
(20b)
$$\begin{aligned} \boldsymbol {0} & = \boldsymbol {g}(\boldsymbol {q}) \text{.} \end{aligned}$$
(20c)

The classical GGL stabilization, which traces back to Gear et al. [17], represents an index reduction technique by minimal extension (see Kunkel & Mehrmann [6]). The main idea of the GGL stabilization is to couple the secondary constraints into the dynamics by making use of additional variables \(\boldsymbol {\gamma} \in \mathbb{R}^{m}\), such that the system of equations of motion is extended and the differentiation index drops to \(\nu = 2\). Correspondingly, the numerical ill-conditioning of index-3 DAEs is alleviated without having the drawback of drift phenomena. The resulting index-2 DAEs can be written in the form

$$\begin{aligned} \dot{\boldsymbol {q}} & = \boldsymbol {M}^{\mathrm{-1}}\boldsymbol {p} + \boldsymbol {G}(\boldsymbol {q})^{ \mathrm{T}}\boldsymbol {\gamma} \text{,} \end{aligned}$$
(21a)
$$\begin{aligned} \dot{\boldsymbol {p}} & = - \mathrm {D} V(\boldsymbol {q}) - \boldsymbol {G}(\boldsymbol {q})^{\mathrm{T}} \boldsymbol {\lambda} \text{,} \end{aligned}$$
(21b)
$$\begin{aligned} \boldsymbol {0} & = \boldsymbol {g}(\boldsymbol {q}) \text{,} \end{aligned}$$
(21c)
$$\begin{aligned} \boldsymbol {0} & = \boldsymbol {G}(\boldsymbol {q})\boldsymbol {M}^{\mathrm{-1}}\boldsymbol {p} \text{.} \end{aligned}$$
(21d)

Ever since, the GGL stabilization has been widely used and is thus of great importance (see, e.g., Brüls et al. [18]). Numerical methods can be constructed directly by discretizing the DAEs (21a)–(21d). Note, however, that due to the GGL modification of the kinematic equation (21a), the system (21a)–(21d) loses its Hamiltonian structure. For the time-continuous case, some algebra leads to \(\boldsymbol {\gamma}=\boldsymbol {0}\). Consequently, the GGL-DAEs boil down to the standard formulation (20a)–(20c).

3 GGL principle

3.1 Governing equations

The newly proposed GGL principle relies on a generalization of Livens principle (1) by considering Lagrange multipliers \(\boldsymbol {\lambda}, \boldsymbol {\gamma} \in \mathbb{R}^{m}\) to enforce the primary constraints (18) and secondary constraints (19), respectively. Imposing stationary on a corresponding augmented action integral

$$\begin{aligned} \delta S_{\mathrm{GGL}}(\boldsymbol {q},\boldsymbol {v},\boldsymbol {p},\boldsymbol {\lambda}, \boldsymbol {\gamma}) = 0 \end{aligned}$$
(22)

with

$$\begin{aligned} S_{\mathrm{GGL}} = \int _{0}^{T} \big[ & L(\boldsymbol {q},\boldsymbol {v}) - \boldsymbol {\lambda} \cdot \boldsymbol {g}(\boldsymbol {q}) + \boldsymbol {p} \cdot ( \dot{\boldsymbol {q}} - \boldsymbol {v} - \boldsymbol {M}^{-1}\, \boldsymbol {G}(\boldsymbol {q})^{\mathrm{T}}\, \boldsymbol {\gamma}) \big] \, \mathrm {d}t \text{,} \end{aligned}$$
(23)

yields the stationary conditions

$$\begin{aligned} \int _{0}^{T} \delta \boldsymbol {p} \cdot \left ( \dot{\boldsymbol {q}} - \boldsymbol {v} - \boldsymbol {M}^{-1}\, \boldsymbol {G}(\boldsymbol {q})^{\mathrm{T}}\, \boldsymbol {\gamma}) \right ) \, \mathrm {d}t& = 0 \text{,} \end{aligned}$$
(24a)
$$\begin{aligned} \int _{0}^{T} \big( \mathrm {D} _{1} L(\boldsymbol {q},\boldsymbol {v}) \cdot \delta \boldsymbol {q} - \boldsymbol {G}(\boldsymbol {q})^{\mathrm{T}}\boldsymbol {\lambda} \cdot \delta \boldsymbol {q} + \boldsymbol {p} \cdot \delta \dot{\boldsymbol {q}} - \boldsymbol {p} \cdot \boldsymbol {M}^{ \mathrm{-1}}\delta \boldsymbol {G}(\boldsymbol {q})^{\mathrm{T}}\boldsymbol {\gamma} \big) \, \mathrm {d}t& = 0 \text{,} \end{aligned}$$
(24b)
$$\begin{aligned} \int _{0}^{T} \delta \boldsymbol {v} \cdot \left ( \mathrm {D} _{2} L(\boldsymbol {q},\boldsymbol {v}) - \boldsymbol {p} \right ) \, \mathrm {d}t& = 0 \text{,} \end{aligned}$$
(24c)
$$\begin{aligned} \int _{0}^{T} \delta \boldsymbol {\lambda} \cdot \boldsymbol {g}(\boldsymbol {q}) \, \mathrm {d}t& = 0 \text{,} \end{aligned}$$
(24d)
$$\begin{aligned} \int _{0}^{T} \boldsymbol {p} \cdot \boldsymbol {M}^{-1}\, \boldsymbol {G}(\boldsymbol {q})^{ \mathrm{T}}\, \delta \boldsymbol {\gamma} \, \mathrm {d}t& = 0 \text{.} \end{aligned}$$
(24e)

As one can see, relation (24b) requires some more effort in order to achieve the final Euler-Langrange equation. Therefore, \(\delta \dot{\boldsymbol {q}}\) can be replaced through integration by parts such that

$$\begin{aligned} \int _{0}^{T} \boldsymbol {p}\cdot \delta \dot{\boldsymbol {q}} \, \mathrm {d}t= & - \int _{0}^{T} \delta \boldsymbol {q} \cdot \dot{\boldsymbol {p}} \, \mathrm {d}t+ \delta \boldsymbol {q}(T) \cdot \boldsymbol {p}(T) - \delta \boldsymbol {q}(0)\cdot \boldsymbol {p}(0) \text{.} \end{aligned}$$
(25)

The endpoint conditions on admissible variations \(\delta \boldsymbol {q}(0) = \delta \boldsymbol {q}(T)=0\) make the latter two terms vanish. Furthermore, the variation of the gradient of the constraint functions can be executed as

$$\begin{aligned} \delta \boldsymbol {G}(\boldsymbol {q}) = \mathrm {D} \boldsymbol {G}(\boldsymbol {q}) \delta \boldsymbol {q} = \mathrm {D} ^{2} \boldsymbol {g}(\boldsymbol {q}) \delta \boldsymbol {q} \text{.} \end{aligned}$$
(26)

In order to avoid the third-order expression \(\mathrm {D} ^{2}\boldsymbol {g}(\boldsymbol {q})\), the stationary condition (24b) can be written in terms of the individual constraint functions \(g_{\mathrm{k}}(\boldsymbol {q})\) for \(k=1,\dots ,m\). Thus, the variation of the constraint gradients is given by

$$\begin{aligned} \delta ( \mathrm {D} g_{k}(\boldsymbol {q})) = \mathrm {D} ^{2} g_{k}(\boldsymbol {q}) \delta \boldsymbol {q} \text{,} \end{aligned}$$
(27)

where the constraint Hessian \(\mathrm {D} ^{2} g_{k}(\boldsymbol {q}) \in \mathbb{R}^{d \times d}\). Consequently, the arbitrariness of the variations \(\delta \boldsymbol {q}\), \(\delta \boldsymbol {v}\), \(\delta \boldsymbol {p}\), \(\delta \boldsymbol {\lambda}\) and \(\delta \boldsymbol {\gamma}\) can be taken into account such that the governing DAEs are deduced as

$$\begin{aligned} \dot{\boldsymbol {q}} & = \boldsymbol {v} + \boldsymbol {M}^{\mathrm{-1}}\boldsymbol {G}(\boldsymbol {q})^{ \mathrm{T}}\boldsymbol {\gamma} \text{,} \end{aligned}$$
(28a)
$$\begin{aligned} \dot{\boldsymbol {p}} & = \mathrm {D} _{1} L(\boldsymbol {q},\boldsymbol {v}) - \boldsymbol {G}(\boldsymbol {q})^{ \mathrm{T}}\boldsymbol {\lambda} - \sum _{k=1}^{m} \gamma _{k} \mathrm {D} ^{2} g_{k}( \boldsymbol {q}) \boldsymbol {M}^{\mathrm{-1}}\boldsymbol {p} \text{,} \end{aligned}$$
(28b)
$$\begin{aligned} \boldsymbol {p} & = \mathrm {D} _{2} L(\boldsymbol {q},\boldsymbol {v}) \text{,} \end{aligned}$$
(28c)
$$\begin{aligned} \boldsymbol {0} & = \boldsymbol {g}(\boldsymbol {q}) \text{,} \end{aligned}$$
(28d)
$$\begin{aligned} \boldsymbol {0} & = \boldsymbol {G}(\boldsymbol {q})\boldsymbol {M}^{\mathrm{-1}}\boldsymbol {p} \text{.} \end{aligned}$$
(28e)

Thus equations in the fashion of the standard GGL stabilization (21a)–(21d) are obtained with an additional term in the momentum equation. Note that (28c) represents the fiber derivative of the newly proposed variational principle, such that the Lagrange multiplier \(\boldsymbol {p}\) denotes the conjugate momenta. By introducing the secondary constraints to the functional, the resulting Euler-Lagrange equations are DAEs with index \(\nu =2\), similarly to the GGL stabilized equations of motion, whereas the standard DAEs of constrained dynamics have index \(\nu =3\). Thus, the newly established DAEs (28a)–(28e) can be regarded as an extension to the classical GGL stabilization. Similar to the classical GGL stabilization, one obtains \(\boldsymbol {\gamma}=\boldsymbol {0}\) for the time-continuous case. However, the third term on the right-hand side of (28b) is of crucial importance as it maintains the Hamiltonian structure of the equations of motion, in contrast to the classical GGL method.

3.2 Hamiltonian structure

The equations of motion induced by the GGL principle have Hamiltonian structure, viz.

$$\begin{aligned} \dot{\boldsymbol {q}} & = + \mathrm {D} _{2} H_{\mathrm{GGL}}(\boldsymbol {q},\boldsymbol {p}, \boldsymbol {\lambda}, \boldsymbol {\gamma}) \text{,} \end{aligned}$$
(29a)
$$\begin{aligned} \dot{\boldsymbol {p}} & = - \mathrm {D} _{1} H_{\mathrm{GGL}}(\boldsymbol {q},\boldsymbol {p}, \boldsymbol {\lambda}, \boldsymbol {\gamma}) \text{,} \end{aligned}$$
(29b)
$$\begin{aligned} \boldsymbol {0} & = + \mathrm {D} _{3} H_{\mathrm{GGL}}(\boldsymbol {q},\boldsymbol {p},\boldsymbol {\lambda}, \boldsymbol {\gamma}) \text{,} \end{aligned}$$
(29c)
$$\begin{aligned} \boldsymbol {0} & = + \mathrm {D} _{4} H_{\mathrm{GGL}}(\boldsymbol {q},\boldsymbol {p},\boldsymbol {\lambda}, \boldsymbol {\gamma}) \text{,} \end{aligned}$$
(29d)

with a corresponding augmented Hamiltonian

$$\begin{aligned} H_{\mathrm{GGL}}(\boldsymbol {q},\boldsymbol {p},\boldsymbol {\lambda}, \boldsymbol {\gamma}) = \frac{1}{2} & \boldsymbol {p} \cdot \boldsymbol {M}^{\mathrm{-1}}\boldsymbol {p} + V(\boldsymbol {q}) + \boldsymbol {\lambda} \cdot \boldsymbol {g}(\boldsymbol {q}) + \boldsymbol {\gamma} \cdot \boldsymbol {G}( \boldsymbol {q})\boldsymbol {M}^{\mathrm{-1}}\boldsymbol {p} \text{.} \end{aligned}$$
(30)

The above equations can be related to the Euler-Lagrange equations (28a)–(28e) of the GGL functional after elimination of the velocities by employing the Legendre transformation (28c). Next, we show that the equations of motion of the novel framework conserve the Hamiltonian exactly. For that purpose, we compute the time derivative of the augmented Hamiltonian (30) such that

$$\begin{aligned} \frac{ \,\mathrm {d} }{ \mathrm {d}t} H_{\mathrm{GGL}} & = \mathrm {D} _{1} H_{\mathrm{GGL}} \cdot \dot{\boldsymbol {q}} + \mathrm {D} _{2} H_{\mathrm{GGL}} \cdot \dot{\boldsymbol {p}} + \mathrm {D} _{3} H_{\mathrm{GGL}} \cdot \dot{\boldsymbol {\lambda}} + \mathrm {D} _{4} H_{\mathrm{GGL}} \cdot \dot{\boldsymbol {\gamma}} \\ & = \mathrm {D} _{1} H_{\mathrm{GGL}} \cdot \mathrm {D} _{2} H_{\mathrm{GGL}} - \mathrm {D} _{2} H_{ \mathrm{GGL}} \cdot \mathrm {D} _{1} H_{\mathrm{GGL}} + \boldsymbol {0} \cdot \dot{\boldsymbol {\lambda}} + \boldsymbol {0} \cdot \dot{\boldsymbol {\gamma}} = 0 \text{,} \end{aligned}$$
(31)

where the Hamiltonian equations of motion (29a)–(29d) have been considered. As the augmented Hamiltonian (30) is conserved along solutions of the equations of motion, also the Hamiltonian \(H\) itself is conserved since both constraints on configuration level and momentum level are identically zero such that \(\dot{H} = 0\). In contrast to the original GGL formulation (cf. Sect. 2.3), this conservation law holds regardless of the actual value of the Lagrange multipliers \(\boldsymbol {\gamma}\).

3.3 Symplectic structure

We show that the GGL functional inherits the symplectic structure of Hamiltonian systems and thus the symplectic two-form is conserved along solutions of (28a)–(28e) or (29a)–(29d), respectively. We begin by deriving the total differentials based on the equations of motion as

$$\begin{aligned} \,\mathrm {d} \dot{\boldsymbol {q}} & = \mathrm {D} ^{2}_{21} H(\boldsymbol {q},\boldsymbol {p}) \,\mathrm {d} \boldsymbol {q} + \mathrm {D} ^{2}_{22} H(\boldsymbol {q},\boldsymbol {p}) \,\mathrm {d} \boldsymbol {p} + \,\mathrm {d} \left ( \mathrm {D} _{2} \boldsymbol {g}^{ \mathbf{v}}(\boldsymbol {q},\boldsymbol {p})^{\mathrm{T}}\boldsymbol {\gamma} \right ) \text{,} \end{aligned}$$
(32a)
$$\begin{aligned} \,\mathrm {d} \dot{\boldsymbol {p}} & = - \mathrm {D} ^{2}_{11} H(\boldsymbol {q},\boldsymbol {p}) \,\mathrm {d} \boldsymbol {q} - \mathrm {D} ^{2}_{12} H(\boldsymbol {q},\boldsymbol {p}) \,\mathrm {d} \boldsymbol {p} - \,\mathrm {d} \left ( \mathrm {D} \boldsymbol {g}^{ \mathbf{q}}(\boldsymbol {q})^{\mathrm{T}}\boldsymbol {\lambda} \right ) - \,\mathrm {d} \left ( \mathrm {D} _{1} \boldsymbol {g}^{\mathbf{v}}(\boldsymbol {q},\boldsymbol {p})^{\mathrm{T}} \boldsymbol {\gamma} \right ) \text{,} \end{aligned}$$
(32b)
$$\begin{aligned} \boldsymbol {0} & = \mathrm {D} \boldsymbol {g}^{\mathbf{q}}(\boldsymbol {q}) \,\mathrm {d} \boldsymbol {q} \text{,} \end{aligned}$$
(32c)
$$\begin{aligned} \boldsymbol {0} & = \mathrm {D} _{1} \boldsymbol {g}^{\mathbf{v}}(\boldsymbol {q},\boldsymbol {p}) \,\mathrm {d} \boldsymbol {q} + \mathrm {D} _{2} \boldsymbol {g}^{\mathbf{v}}(\boldsymbol {q},\boldsymbol {p}) \,\mathrm {d} \boldsymbol {p} \text{,} \end{aligned}$$
(32d)

where we have introduced the distinct functions \(\boldsymbol {g}^{\mathbf{q}}(\boldsymbol {q}) = \boldsymbol {g}(\boldsymbol {q})\) for the holonomic constraint on configuration level and \(\boldsymbol {g}^{\mathbf{v}}(\boldsymbol {q},\boldsymbol {p}) = \mathrm {D} \boldsymbol {g}(\boldsymbol {q}) \boldsymbol {M}^{ \mathrm{-1}}\boldsymbol {p}\) for the corresponding constraint on momentum level. It is straightforward to compute the temporal evolution of \(\Omega\) by means of the product rule such that

$$\begin{aligned} \frac{ \,\mathrm {d} }{ \mathrm {d}t} \Omega = \,\mathrm {d} \dot{\boldsymbol {q}} \wedge \,\mathrm {d} \boldsymbol {p} + \,\mathrm {d} \boldsymbol {q} \wedge \,\mathrm {d} \dot{\boldsymbol {p}} \text{,} \end{aligned}$$
(33)

into which the above differential equations (32a) and (32b) can be inserted. One can consider the symmetry of the Hessian of \(H\) and make use of the properties of the wedge product. Note that \(\mathrm {D} _{11}^{2} H\) and \(\mathrm {D} ^{2}_{22} H\) both are symmetric matrices such that

$$\begin{aligned} \mathrm {D} ^{2}_{22} H(\boldsymbol {q},\boldsymbol {p}) \,\mathrm {d} \boldsymbol {p} \wedge \,\mathrm {d} \boldsymbol {p} & = 0 \text{,} \end{aligned}$$
(34)
$$\begin{aligned} - \,\mathrm {d} \boldsymbol {q} \wedge \mathrm {D} ^{2}_{11} H(\boldsymbol {q},\boldsymbol {p}) \,\mathrm {d} \boldsymbol {q} & = 0 \text{,} \end{aligned}$$
(35)

due to property (17d). Moreover, the two terms with the off-diagonal entries of the Hessian of \(H\) cancel each other out, because

$$\begin{aligned} \mathrm {D} ^{2}_{21} H(\boldsymbol {q},\boldsymbol {p}) \,\mathrm {d} \boldsymbol {q} \wedge \,\mathrm {d} \boldsymbol {p} = ( \mathrm {D} ^{2}_{12} H(\boldsymbol {q},\boldsymbol {p}))^{\mathrm{T}} \,\mathrm {d} \boldsymbol {q} \wedge \,\mathrm {d} \boldsymbol {p} = \,\mathrm {d} \boldsymbol {q} \wedge \mathrm {D} ^{2}_{12} H(\boldsymbol {q},\boldsymbol {p}) \,\mathrm {d} \boldsymbol {p} \text{,} \end{aligned}$$
(36)

where in the last equation property (17c) has been used. The term stemming from the primary constraints can be written as

$$\begin{aligned} \,\mathrm {d} \left ( \mathrm {D} \boldsymbol {g}^{\mathbf{q}}(\boldsymbol {q}) ^{\mathrm{T}} \boldsymbol {\lambda}\right ) \wedge \,\mathrm {d} \boldsymbol {q} & = \mathrm {D} \boldsymbol {g}^{\mathbf{q}}( \boldsymbol {q})^{\mathrm{T}} \,\mathrm {d} \boldsymbol {\lambda} \wedge \,\mathrm {d} \boldsymbol {q} + \sum _{ \mathrm{k=1}}^{\mathrm{m}} \lambda _{\mathrm{k}} \mathrm {D} ^{2} g_{ \mathrm{k}}(\boldsymbol {q}) \,\mathrm {d} \boldsymbol {q} \wedge \,\mathrm {d} \boldsymbol {q} = \,\mathrm {d} \boldsymbol {\lambda} \wedge \mathrm {D} \boldsymbol {g}^{\mathbf{q}}(\boldsymbol {q}) \,\mathrm {d} \boldsymbol {q} = 0 \text{,} \end{aligned}$$
(37)

where again (17c) and (17d) have been used along with (32c). Therefore, all terms emerging from the right-hand side of (33) cancel out except for those containing the constraint on momentum level \(\boldsymbol {g}^{\mathbf{v}}(\boldsymbol {q},\boldsymbol {p})\). We therefore obtain

$$\begin{aligned} \frac{ \,\mathrm {d} }{ \mathrm {d}t} \Omega & = \,\mathrm {d} \left ( \mathrm {D} _{2} \boldsymbol {g}^{ \mathbf{v}}(\boldsymbol {q},\boldsymbol {p})^{\mathrm{T}}\boldsymbol {\gamma} \right ) \wedge \,\mathrm {d} \boldsymbol {p} - \,\mathrm {d} \boldsymbol {q} \wedge \,\mathrm {d} \left ( \mathrm {D} _{1} \boldsymbol {g}^{ \mathbf{v}}(\boldsymbol {q},\boldsymbol {p})^{\mathrm{T}}\boldsymbol {\gamma} \right ) \\ & = { \mathrm {D} _{2} \boldsymbol {g}^{\mathbf{v}}}^{\mathrm{T}} \,\mathrm {d} \boldsymbol {\gamma} \wedge \,\mathrm {d} \boldsymbol {p} + { \mathrm {D} _{1} \boldsymbol {g}^{\mathbf{v}}} ^{\mathrm{T}} \,\mathrm {d} \boldsymbol {\gamma} \wedge \,\mathrm {d} \boldsymbol {q} + \sum _{k=1}^{m} \gamma _{k} \mathrm {D} ^{2}_{12} g^{\mathbf{v}}_{k} \,\mathrm {d} \boldsymbol {q} \wedge \,\mathrm {d} \boldsymbol {p} + \sum _{k=1}^{m} \gamma _{k} \mathrm {D} ^{2}_{21} g^{\mathbf{v}}_{k} \,\mathrm {d} \boldsymbol {p} \wedge \,\mathrm {d} \boldsymbol {q} \\ & = \,\mathrm {d} \boldsymbol {\gamma} \,{\wedge} \left ( \mathrm {D} _{1} \boldsymbol {g}^{\mathbf{v}}( \boldsymbol {q},\boldsymbol {p}) \,\mathrm {d} \boldsymbol {q} \,{+}\, \mathrm {D} _{2} \boldsymbol {g}^{\mathbf{v}}(\boldsymbol {q}, \boldsymbol {p}) \,\mathrm {d} \boldsymbol {p} \right ) {+}\, \sum _{k=1}^{m} \gamma _{k} \left ( \mathrm {D} ^{2}_{12} g^{\mathbf{v}}_{k} - ( \mathrm {D} ^{2}_{21} g^{\mathbf{v}}_{k})^{ \mathrm{T}}\right ) \,\mathrm {d} \boldsymbol {q} \,{\wedge}\, \,\mathrm {d} \boldsymbol {p} = 0 \text{,} \end{aligned}$$
(38)

where the first term vanishes in view of the total differential of the secondary constraint (32d) and the second one cancels due to the symmetry of the Hessian of \(g_{k}^{\mathbf{v}}\). Note that it has been taken into account that terms including \(\mathrm {D} ^{2}_{11} g_{k}^{\mathbf{v}}\) and \(\mathrm {D} ^{2}_{22} g_{k}^{\mathbf{v}}\), respectively, cancel due to their symmetry. This proofs the symplecticness of the equations of motion emanating from the GGL functional. Again this property does not depend on the Lagrange multiplier \(\boldsymbol {\gamma}\), which is an advantage over the original GGL method by Gear et al. [17], for which \(\boldsymbol {\gamma}=\boldsymbol {0}\) is required in order to conserve \(\Omega\).

4 GGL variational integrator

We next illustrate how the GGL principle introduced in Sect. 3 can be employed to derive a variational integrator. Subsequently, structure-preserving properties of the newly devised variational integrator will be considered.

4.1 Governing equations

Let us construct a time-stepping scheme by means of a direct discretization of the GGL functional (23). Enforcing the constraint on configuration level in the endpoint and the constraint on momentum level in an intermediate state and discretizing the velocity by means of an explicit Euler method, we obtain the discrete action integral

$$\begin{aligned} S_{\mathrm{d}} \,{=} \sum _{n=0}^{N-1} \big[ h\, L(\boldsymbol {q}^{n}, \boldsymbol {v}^{n}) \,{-}\, h\,\boldsymbol {\lambda}^{n+1}\cdot \boldsymbol {g}(\boldsymbol {q}^{n+1}) \,{+}\, \boldsymbol {p}^{n+1} \cdot \left ( \boldsymbol {q}^{n+1}\,{-}\, \boldsymbol {q}^{n}\,{-}\,h\, \boldsymbol {v}^{n}\,{-}\,h\, \boldsymbol {M} ^{ \mathrm{-1}}\boldsymbol {G}(\bar{\boldsymbol {q}}) ^{\mathrm{T}}\boldsymbol {\gamma}^{n+1} \right ) \big] \text{,} \end{aligned}$$
(39)

where the configuration variable \(\bar{\boldsymbol {q}} = \boldsymbol {q}^{n}+ h\, \boldsymbol {v}^{n}\) has been introduced. Stationary conditions can be applied directly to the discrete functional, yielding

$$\begin{aligned} & \sum _{n=0}^{N-1} \delta \boldsymbol {p}^{n+1}\cdot \left ( \boldsymbol {q}^{n+1}- \boldsymbol {q}^{n}-h\, \boldsymbol {v}^{n}-h\, \boldsymbol {M} ^{\mathrm{-1}}\boldsymbol {G}( \bar{\boldsymbol {q}}) ^{\mathrm{T}}\boldsymbol {\gamma}^{n+1}\right ) = 0 \text{,} \end{aligned}$$
(40a)
$$\begin{aligned} & \sum _{n=0}^{N-1} \delta \boldsymbol {q}^{n}\cdot \left ( h\, \mathrm {D} _{1} L( \boldsymbol {q}^{n},\boldsymbol {v}^{n}) - \boldsymbol {p}^{n+1}-h\,\sum _{k=1}^{m} \gamma _{k}^{n+1} \mathrm {D} ^{2} g_{k}(\bar{\boldsymbol {q}}) \boldsymbol {M}^{\mathrm{-1}}\boldsymbol {p}^{n+1} \right ) \end{aligned}$$
(40b)
$$\begin{aligned} & +\sum _{n=0}^{N-1} \delta \boldsymbol {q}^{n+1}\cdot \left (-h\,\boldsymbol {G}( \boldsymbol {q}^{n+1})^{\mathrm{T}}\boldsymbol {\lambda}^{n+1}+ \boldsymbol {p}^{n+1}\right ) = 0 \text{,} \\ & \sum _{n=0}^{N-1} \delta \boldsymbol {v}^{n}\cdot \left ( h\, \mathrm {D} _{2} L( \boldsymbol {q}^{n},\boldsymbol {v}^{n}) - h\, \boldsymbol {p}^{n+1}-h^{2} \,\sum _{k=1}^{m} \gamma _{k}^{n+1} \mathrm {D} ^{2} g_{k}(\bar{\boldsymbol {q}}) \boldsymbol {M}^{\mathrm{-1}} \boldsymbol {p}^{n+1}\right ) = 0 \text{,} \end{aligned}$$
(40c)

along with

$$\begin{aligned} \sum _{n=0}^{N-1} \delta \boldsymbol {\lambda}^{n+1}\cdot \boldsymbol {g}(\boldsymbol {q}^{n+1}) &= 0 \text{,} \end{aligned}$$
(40d)
$$\begin{aligned} \sum _{n=0}^{N-1} \delta \boldsymbol {\gamma}^{n+1}\cdot \boldsymbol {G}( \bar{\boldsymbol {q}})\boldsymbol {M}^{\mathrm{-1}}\boldsymbol {p}^{n+1}&= 0 \text{.} \end{aligned}$$
(40e)

Applying an index shift in the second part of (40b) from \(n+1\) to \(n\) and taking into account the arbitrariness of all variations, we obtain the discrete EL equations

$$\begin{aligned} \boldsymbol {q}^{n+1}- \boldsymbol {q}^{n}& = h\, \boldsymbol {v}^{n}+ h\, \boldsymbol {M} ^{ \mathrm{-1}}\boldsymbol {G}(\bar{\boldsymbol {q}}) ^{\mathrm{T}}\boldsymbol {\gamma}^{n+1} \text{,} \end{aligned}$$
(41a)
$$\begin{aligned} \boldsymbol {p}^{n+1}- \boldsymbol {p}^{n}& = h\, \mathrm {D} _{1} L(\boldsymbol {q}^{n},\boldsymbol {v}^{n}) - h\,\boldsymbol {G}(\boldsymbol {q}^{n})^{\mathrm{T}}\boldsymbol {\lambda}^{n}- h\,\sum _{k=1}^{m} \gamma _{k}^{n+1} \mathrm {D} ^{2} g_{k}(\bar{\boldsymbol {q}}) \boldsymbol {M}^{\mathrm{-1}} \boldsymbol {p}^{n} \text{,} \end{aligned}$$
(41b)
$$\begin{aligned} \mathrm {D} _{2} L(\boldsymbol {q}^{n},\boldsymbol {v}^{n}) & = \left ( \boldsymbol {I}_{d \times d} + h \,\sum _{k=1}^{m} \gamma _{k}^{n+1} \mathrm {D} ^{2} g_{k}(\bar{\boldsymbol {q}}) \boldsymbol {M}^{\mathrm{-1}}\right ) \boldsymbol {p}^{n+1} \text{,} \end{aligned}$$
(41c)
$$\begin{aligned} \boldsymbol {g}(\boldsymbol {q}^{n+1}) & = \boldsymbol {0} \text{,} \end{aligned}$$
(41d)
$$\begin{aligned} \boldsymbol {G}(\bar{\boldsymbol {q}})\boldsymbol {M}^{\mathrm{-1}}\boldsymbol {p}^{n+1}& = \boldsymbol {0} \text{,} \end{aligned}$$
(41e)

for \(n = 0, \dots , N-1\). In total we have obtained a set of \((3\,d+2\,m)\) equations for the unknowns \((\boldsymbol {q}^{n+1},\boldsymbol {p}^{n+1},\boldsymbol {v}^{n},\boldsymbol {\lambda}^{n}, \boldsymbol {\gamma}^{n+1})\) in every time step. These are discrete counterparts of the continuous EL equations given in (28a)–(28e). It is advantageous that, due to the enhancement of the discrete action integral, the secondary constraints are now taken into account as well (cf. relation (41e)). Note that relation (41c) can be interpreted as the discrete fiber derivative of the Legendre transformation, which links velocity and momentum quantities. It is worth mentioning that scheme (41a)–(41e) can be regarded as generalization to constrained mechanical systems of the symplectic Euler method (see Hairer et al. [7] and Euler-B in Leimkuhler & Reich [8]).

4.2 Conservation properties

It is clear that the primary constraints are correctly captured in every time step by design (see relation (41d)). The secondary constraints are enforced in an intermediate sense (cf. (41e)).

Moreover, we can show that the integrator governed by (41a)–(41e) is symplectic. In order to demonstrate this, we calculate the differentials of (41a) to (41c). This yields

$$\begin{aligned} \,\mathrm {d} \boldsymbol {q}^{n+1}- \,\mathrm {d} \boldsymbol {q}^{n}& = h\, \,\mathrm {d} \boldsymbol {v}^{n}+ h\, \,\mathrm {d} \left ( \mathrm {D} _{2} \boldsymbol {g}^{\mathbf{v}}(\bar{\boldsymbol {q}},\boldsymbol {p}^{n+1}) ^{ \mathrm{T}}\boldsymbol {\gamma}^{n+1}\right ) \text{,} \end{aligned}$$
(42a)
$$\begin{aligned} \,\mathrm {d} \boldsymbol {p}^{n+1}- \,\mathrm {d} \boldsymbol {p}^{n}& = h\, \mathrm {D} _{11}^{2} L(\boldsymbol {q}^{n}, \boldsymbol {v}^{n}) \,\mathrm {d} \boldsymbol {q}^{n}- h\, \,\mathrm {d} \left (\boldsymbol {G}(\boldsymbol {q}^{n})^{ \mathrm{T}}\boldsymbol {\lambda}^{n}\right ) - h\, \,\mathrm {d} \left ( \mathrm {D} _{1} \boldsymbol {g}^{ \mathbf{v}}(\bar{\boldsymbol {q}},\boldsymbol {p}^{n+1}) ^{\mathrm{T}}\boldsymbol {\gamma}^{n+1} \right ) , \end{aligned}$$
(42b)
$$\begin{aligned} \mathrm {D} ^{2}_{22}L(\boldsymbol {q}^{n},\boldsymbol {v}^{n}) \,\mathrm {d} \boldsymbol {v}^{n}& = \,\mathrm {d} \boldsymbol {p}^{n+1}+ h\, \,\mathrm {d} \left ( \mathrm {D} _{1} \boldsymbol {g}^{\mathbf{v}}(\bar{\boldsymbol {q}},\boldsymbol {p}^{n+1}) ^{\mathrm{T}}\boldsymbol {\gamma}^{n+1}\right ) \text{.} \end{aligned}$$
(42c)

where \(\boldsymbol {g}^{\mathbf{v}}(\bar{\boldsymbol {q}},\boldsymbol {p}^{n+1})=\boldsymbol {G}( \bar{\boldsymbol {q}})\boldsymbol {M}^{\mathrm{-1}}\boldsymbol {p}^{n+1}\) has been introduced in analogy to the continuous case. Moreover, \(\mathrm {D} _{12}^{2} L(\boldsymbol {q}^{n},\boldsymbol {v}^{n}) = \mathrm {D} _{21}^{2} L(\boldsymbol {q}^{n}, \boldsymbol {v}^{n})^{\mathrm{T}}= \boldsymbol {0}\) as been taken into account which is valid for Lagrangians of the form (3). The differential forms of the constraint equations (41d) and (41e) read

$$\begin{aligned} \,\mathrm {d} \boldsymbol {g}(\boldsymbol {q}^{n+1}) & = \boldsymbol {G}(\boldsymbol {q}^{n+1}) \,\mathrm {d} \boldsymbol {q}^{n+1}= \boldsymbol {0} \text{,} \end{aligned}$$
(43a)
$$\begin{aligned} \,\mathrm {d} \boldsymbol {g}^{\mathbf{v}}(\bar{\boldsymbol {q}},\boldsymbol {p}^{n+1}) & = \mathrm {D} _{1} \boldsymbol {g}^{\mathbf{v}} (\bar{\boldsymbol {q}},\boldsymbol {p}^{n+1}) \,\mathrm {d} \bar{\boldsymbol {q}} + \mathrm {D} _{2} \boldsymbol {g}^{\mathbf{v}} (\bar{\boldsymbol {q}},\boldsymbol {p}^{n+1}) \,\mathrm {d} \boldsymbol {p}^{n+1}= \boldsymbol {0} \text{.} \end{aligned}$$
(43b)

Now, making use of the skew-symmetry of the wedge product, property (17a), one can deduce that

$$ \,\mathrm {d} \boldsymbol {p}^{n+1}\wedge ( \,\mathrm {d} \boldsymbol {q}^{n+1}- \,\mathrm {d} \boldsymbol {q}^{n}) + ( \,\mathrm {d} \boldsymbol {p}^{n+1}- \,\mathrm {d} \boldsymbol {p}^{n}) \wedge \,\mathrm {d} \boldsymbol {q}^{n}= \,\mathrm {d} \boldsymbol {q}^{n} \wedge \,\mathrm {d} \boldsymbol {p}^{n}- \,\mathrm {d} \boldsymbol {q}^{n+1}\wedge \,\mathrm {d} \boldsymbol {p}^{n+1} \text{.} $$
(44)

Substituting from (42a) and (42b) into the last equation, we obtain

$$\begin{aligned} \,\mathrm {d} \boldsymbol {q}^{n}& \wedge \,\mathrm {d} \boldsymbol {p}^{n}- \,\mathrm {d} \boldsymbol {q}^{n+1}\wedge \,\mathrm {d} \boldsymbol {p}^{n+1}= \\ & \,\mathrm {d} \boldsymbol {p}^{n+1}\wedge h\, \,\mathrm {d} \boldsymbol {v}^{n}+ h\, \,\mathrm {d} \boldsymbol {p}^{n+1}\wedge \,\mathrm {d} \left ( \mathrm {D} _{2} \boldsymbol {g}^{\mathbf{v}}( \bar{\boldsymbol {q}},\boldsymbol {p}^{n+1}) ^{\mathrm{T}}\boldsymbol {\gamma}^{n+1}\right ) + h\, \mathrm {D} ^{2}_{11} L(\boldsymbol {q}^{n},\boldsymbol {v}^{n}) \,\mathrm {d} \boldsymbol {q}^{n}\wedge \,\mathrm {d} \boldsymbol {q}^{n} \\ &- h\, \,\mathrm {d} \left (\boldsymbol {G}(\boldsymbol {q}^{n})^{\mathrm{T}} \boldsymbol {\lambda}^{n}\right ) \wedge \,\mathrm {d} \boldsymbol {q}^{n}- h \,\mathrm {d} \big(\sum _{k=1}^{m} \gamma _{k}^{n+1} \mathrm {D} _{1} \boldsymbol {g}_{k}^{\mathbf{v}}(\bar{\boldsymbol {q}}, \boldsymbol {p}^{n+1})\big) \wedge \,\mathrm {d} \boldsymbol {q}^{n} \text{.} \end{aligned}$$
(45)

We next insert \(\,\mathrm {d} \boldsymbol {p}^{n+1}\) from (42c) into the first term on the right-hand side of (45). Moreover, the third term on the right-hand side of (45) vanishes due to property (17d) of the wedge product. The fourth one vanishes in analogy to relation (37). Consequently, we obtain

$$\begin{aligned} \,\mathrm {d} \boldsymbol {q}^{n}& \wedge \,\mathrm {d} \boldsymbol {p}^{n}- \,\mathrm {d} \boldsymbol {q}^{n+1}\,{\wedge}\, \,\mathrm {d} \boldsymbol {p}^{n+1}= \Big( \mathrm {D} ^{2}_{22}L(\boldsymbol {q}^{n}\boldsymbol {v}^{n}) \,\mathrm {d} \boldsymbol {v}^{n}- h \,\mathrm {d} \big(\sum _{k=1}^{m} \gamma _{k}^{n+1} \mathrm {D} _{1} \boldsymbol {g}_{k}^{ \mathbf{v}}(\bar{\boldsymbol {q}},\boldsymbol {p}^{n+1})\big)\Big) \,{\wedge}\, h \, \,\mathrm {d} \boldsymbol {v}^{n} \\ & + h\, \,\mathrm {d} \boldsymbol {p}^{n+1}\wedge \,\mathrm {d} \left ( \mathrm {D} _{2} \boldsymbol {g}^{\mathbf{v}}( \bar{\boldsymbol {q}},\boldsymbol {p}^{n+1}) ^{\mathrm{T}}\boldsymbol {\gamma}^{n+1}\right ) - h \,\mathrm {d} \big(\sum _{k=1}^{m} \gamma _{k}^{n+1} \mathrm {D} _{1} \boldsymbol {g}_{k}^{ \mathbf{v}}(\bar{\boldsymbol {q}},\boldsymbol {p}^{n+1})\big) \wedge \,\mathrm {d} \boldsymbol {q}^{n} \end{aligned}$$
(46)

The symmetric matrix multiplication property of the wedge product (17d) can be used once more to cancel the first term on the right-hand side of (46). Moreover, it is possible to collect the second and fourth term, yielding

$$\begin{aligned} \,\mathrm {d} \boldsymbol {q}^{n}& \wedge \,\mathrm {d} \boldsymbol {p}^{n}- \,\mathrm {d} \boldsymbol {q}^{n+1}\wedge \,\mathrm {d} \boldsymbol {p}^{n+1}= \\ & - h \,\mathrm {d} \big(\sum _{k=1}^{m} \gamma _{k}^{n+1} \mathrm {D} _{1} \boldsymbol {g}_{k}^{ \mathbf{v}}(\bar{\boldsymbol {q}},\boldsymbol {p}^{n+1})\big) \wedge \,\mathrm {d} \bar{\boldsymbol {q}} + h\, \,\mathrm {d} \boldsymbol {p}^{n+1}\wedge \,\mathrm {d} \left ( \mathrm {D} _{2} \boldsymbol {g}^{\mathbf{v}}( \bar{\boldsymbol {q}},\boldsymbol {p}^{n+1}) ^{\mathrm{T}}\boldsymbol {\gamma}^{n+1}\right ) \text{.} \end{aligned}$$
(47)

Executing the remaining differentials leads to the expression

$$\begin{aligned} \,\mathrm {d} \boldsymbol {q}^{n}& \wedge \,\mathrm {d} \boldsymbol {p}^{n}- \,\mathrm {d} \boldsymbol {q}^{n+1}\wedge \,\mathrm {d} \boldsymbol {p}^{n+1}= \\ & \left ( \mathrm {D} _{1} \boldsymbol {g}^{\mathbf{v}}(\bar{\boldsymbol {q}},\boldsymbol {p}^{n+1}) \,\mathrm {d} \bar{\boldsymbol {q}}\right ) \wedge h\, \,\mathrm {d} \boldsymbol {\gamma}^{n+1}+ \left ( \mathrm {D} _{2} \boldsymbol {g}^{\mathbf{v}}(\bar{\boldsymbol {q}},\boldsymbol {p}^{n+1}) \,\mathrm {d} \boldsymbol {p}^{n+1} \right ) \wedge h\, \,\mathrm {d} \boldsymbol {\gamma}^{n+1} \\ & -h\, \sum _{k=1}^{m} \gamma _{k}^{n+1} \mathrm {D} ^{2}_{12} g_{k}^{ \mathbf{v}}(\bar{\boldsymbol {q}},\boldsymbol {p}^{n+1}) \,\mathrm {d} \boldsymbol {p}^{n+1}\wedge \,\mathrm {d} \bar{\boldsymbol {q}} + h \,\mathrm {d} \boldsymbol {p}^{n+1}\wedge \sum _{k=1}^{m} \gamma _{k}^{n+1} \mathrm {D} ^{2}_{21} g_{k}^{\mathbf{v}}(\bar{\boldsymbol {q}},\boldsymbol {p}^{n+1}) \,\mathrm {d} \bar{\boldsymbol {q}}. \end{aligned}$$
(48)

In analogy to the proof given in Sect. 3.3, terms including \(\mathrm {D} ^{2}_{11} g_{k}^{\mathbf{v}}\) and \(\mathrm {D} ^{2}_{22} g_{k}^{\mathbf{v}}\), respectively, cancel due to their symmetry. It becomes obvious that the last two terms on the right-hand side of (48) cancel each other out due to (17c) since \(( \mathrm {D} ^{2}_{12} g_{k}^{\mathbf{v}})^{\mathrm{T}}= \mathrm {D} ^{2}_{12} g_{k}^{ \mathbf{v}}\). The first two terms on the right-hand side of (48) can be collected such that (43b) can be taken into account. Eventually, the whole expression on the right-hand side of (48) vanishes and we obtain

$$\begin{aligned} \,\mathrm {d} \boldsymbol {q}^{n}\wedge \,\mathrm {d} \boldsymbol {p}^{n}= \,\mathrm {d} \boldsymbol {q}^{n+1}\wedge \,\mathrm {d} \boldsymbol {p}^{n+1} \text{,} \end{aligned}$$
(49)

which shows that the present scheme is indeed symplectic.

4.3 Extension to non-conservative systems

Considering dynamical systems being subject to (possibly configuration- and velocity-dependent) non-conservative forces \(\boldsymbol {F}^{\mathrm{nc}}(\boldsymbol {q},\boldsymbol {v}) \in \mathbb{R}^{d}\), the motion is governed by the Lagrange-d’Alembert principle (see, for example, [22]). It augments Hamilton’s principle of least action by adding the virtual work of the non-conservative forces such that

$$\begin{aligned} \delta S_{\mathrm{GGL}}(\boldsymbol {q}, \boldsymbol {v}, \boldsymbol {p}, \boldsymbol {\lambda}, \boldsymbol {\gamma}) + \int _{0}^{T} \boldsymbol {F}^{\mathrm{nc}}(\boldsymbol {q},\boldsymbol {v}) \cdot \delta \boldsymbol {q} \, \,\mathrm {d} t = 0 \text{.} \end{aligned}$$
(50)

The corresponding equations of motion are obtained as

$$\begin{aligned} \dot{\boldsymbol {q}} & = \boldsymbol {v} + \boldsymbol {M}^{\mathrm{-1}}\boldsymbol {G}(\boldsymbol {q})^{ \mathrm{T}}\boldsymbol {\gamma} \text{,} \end{aligned}$$
(51a)
$$\begin{aligned} \dot{\boldsymbol {p}} & = \mathrm {D} _{1} L(\boldsymbol {q},\boldsymbol {v}) - \boldsymbol {G}(\boldsymbol {q})^{ \mathrm{T}}\boldsymbol {\lambda} - \sum _{k=1}^{m} \gamma _{k} \mathrm {D} ^{2} g_{k}( \boldsymbol {q}) \boldsymbol {M}^{\mathrm{-1}}\boldsymbol {p} + \boldsymbol {F}^{\mathrm{nc}}(\boldsymbol {q}, \boldsymbol {v}) \text{,} \end{aligned}$$
(51b)
$$\begin{aligned} \boldsymbol {p} & = \mathrm {D} _{2} L(\boldsymbol {q},\boldsymbol {v}) \text{,} \end{aligned}$$
(51c)
$$\begin{aligned} \boldsymbol {0} & = \boldsymbol {g}(\boldsymbol {q}) \text{,} \end{aligned}$$
(51d)
$$\begin{aligned} \boldsymbol {0} & = \boldsymbol {G}(\boldsymbol {q})\boldsymbol {M}^{\mathrm{-1}}\boldsymbol {p} \text{.} \end{aligned}$$
(51e)

Obviously, the Hamiltonian of such systems is not conserved. Following the procedure from Sect. 3.2 in an analogously manner, we obtain the energy balance

$$\begin{aligned} \frac{ \,\mathrm {d} H}{ \,\mathrm {d} t} = \boldsymbol {v} \cdot \boldsymbol {F}^{\mathrm{nc}}(\boldsymbol {q}, \boldsymbol {v}) \text{.} \end{aligned}$$
(52)

Thus, the change of total energy is related to the power of the non-conservative forces. In the following we want to focus on velocity-dependent viscous forces of the form

$$\begin{aligned} \boldsymbol {F}^{\mathrm{nc}}(\boldsymbol {q},\boldsymbol {v}) = -\boldsymbol {C}(\boldsymbol {q})\boldsymbol {v} \text{,} \end{aligned}$$
(53)

which can be derived from the Rayleigh dissipation function

$$\begin{aligned} G(\boldsymbol {q},\boldsymbol {v}) = \frac{1}{2}\boldsymbol {v} \cdot \boldsymbol {C}(\boldsymbol {q})\boldsymbol {v} \end{aligned}$$
(54)

by differentiating with respect to the velocities such that \(\boldsymbol {F}^{\mathrm{nc}}(\boldsymbol {q},\boldsymbol {v}) = - \mathrm {D} _{2} G(\boldsymbol {q},\boldsymbol {v})\). In the last equation, \(\boldsymbol {C}(\boldsymbol {q}) \in \mathbb{R}^{d \times d}\) denotes the positive semi-definite dissipation matrix. Correspondingly, the rate of change of the Hamiltonian is strictly nonpositive

$$\begin{aligned} \frac{ \,\mathrm {d} H}{ \,\mathrm {d} t} = - \boldsymbol {v} \cdot \boldsymbol {C}(\boldsymbol {q})\boldsymbol {v} = - P_{v} \leq 0 \text{.} \end{aligned}$$
(55)

and matches the dissipated power \(P_{v}=-2G\).

We next show, how the variational integrator developed above can be extended to account for non-conservative forces of the form (53). To this end, we consider the discrete version of (50) given by

$$\begin{aligned} \delta S_{\mathrm{d}} + h \,\sum _{n=0}^{N-1} \boldsymbol {F}^{\mathrm{nc}}_{ \mathrm{d}} \cdot \delta \boldsymbol {q}^{n}= 0 \text{.} \end{aligned}$$
(56)

Here, the discrete action sum \(S_{\mathrm{d}}\) is again given by (39) and \(\boldsymbol {F}^{\mathrm{nc}}_{\mathrm{d}}\) represents a discrete approximation of the non-conservative forces. Evaluating the viscous forces at \(t^{n}\) such that \(\boldsymbol {F}^{\mathrm{nc}}_{\mathrm{d}} = \boldsymbol {C}(\boldsymbol {q}^{n})\boldsymbol {v}^{n}\), one arrives at an integration scheme, which extends the previously deduced method (41a)–(41e) and obeys the discrete Euler-Lagrange equations:

$$\begin{aligned} \boldsymbol {q}^{n+1}- \boldsymbol {q}^{n}& = h\, \boldsymbol {v}^{n}+ h\, \boldsymbol {M} ^{ \mathrm{-1}}\boldsymbol {G}(\bar{\boldsymbol {q}}) ^{\mathrm{T}}\boldsymbol {\gamma}^{n+1} \text{,} \end{aligned}$$
(57a)
$$\begin{aligned} \boldsymbol {p}^{n+1}- \boldsymbol {p}^{n}& = h\, \mathrm {D} _{1} L(\boldsymbol {q}^{n},\boldsymbol {v}^{n}) - h\,\boldsymbol {G}(\boldsymbol {q}^{n})^{\mathrm{T}}\boldsymbol {\lambda}^{n}- h\,\sum _{k=1}^{m} \gamma _{k}^{n+1} \mathrm {D} ^{2} g_{k}(\bar{\boldsymbol {q}}) \boldsymbol {M}^{\mathrm{-1}} \boldsymbol {p}^{n}- h\, \boldsymbol {C}(\boldsymbol {q}^{n})\boldsymbol {v}^{n} \text{,} \end{aligned}$$
(57b)
$$\begin{aligned} \mathrm {D} _{2} L(\boldsymbol {q}^{n},\boldsymbol {v}^{n}) & = \left ( \boldsymbol {I}_{d \times d} + h \,\sum _{k=1}^{m} \gamma _{k}^{n+1} \mathrm {D} ^{2} g_{k}(\bar{\boldsymbol {q}}) \boldsymbol {M}^{\mathrm{-1}}\right ) \boldsymbol {p}^{n+1} \text{,} \end{aligned}$$
(57c)
$$\begin{aligned} \boldsymbol {g}(\boldsymbol {q}^{n+1}) & = \boldsymbol {0} \text{,} \end{aligned}$$
(57d)
$$\begin{aligned} \boldsymbol {G}(\bar{\boldsymbol {q}})\boldsymbol {M}^{\mathrm{-1}}\boldsymbol {p}^{n+1}& = \boldsymbol {0} \text{,} \end{aligned}$$
(57e)

for \(n = 0, \dots , N-1\) with \(\bar{\boldsymbol {q}} = \boldsymbol {q}^{n}+ h\, \boldsymbol {v}^{n}\). For more details on variational integrators for dissipative systems, we refer to the work by Kane et al. [23].

5 Numerical examples

The objective of this section is to analyze the behavior of the previously derived variational integrator by means of representative numerical examples. Equations (41a)–(41e) are solved for the respective systems be means of Newton’s method, where the tolerance has been set to \(\varepsilon _{\mathrm{tol}} = 10^{-9}\). The computation has been performed using the metis code, which is available at [24].

5.1 Steady precession of a gyroscopic top

In this first example, we investigate the motion of a rigid body which is modeled by means of a director formulation proposed by Betsch & Steinmann [25]. The director formulation can be directly linked to natural coordinates [26], as shown in [27]. This formulation describes rigidity using the orthonormality condition of three directors \(\{ \boldsymbol {d}_{i}\}\) positioned in the center of mass \(\boldsymbol {\varphi}\). Every point of the rigid body is uniquely defined by its material coordinates \(X_{i}\) with respect to the director frame’s origin such that we are able to express the spatial placement as a function of the material coordinates and time according to

$$\begin{aligned} \boldsymbol {x}(\boldsymbol {X},t) = \boldsymbol {\varphi}(t) + X_{i} \boldsymbol {d}_{i}(t) \text{,} \end{aligned}$$
(58)

where the summation convention applies. Eventually, it is possible to describe the motion of the rigid body by \(n=3+9 = 12\) redundant coordinates accumulated in the coordinate vector

$$\begin{aligned} \boldsymbol {q} = \begin{bmatrix} \boldsymbol {\varphi} \\ \boldsymbol {d}_{1} \\ \boldsymbol {d}_{2} \\ \boldsymbol {d}_{3} \end{bmatrix} \text{.} \end{aligned}$$
(59)

For simplicity, we assume that the directors \(\{\boldsymbol {d}_{i}\}\) coincide with the principal axes of the body. This framework consequently allows for a representation of the system’s Lagrangian in the standard fashion (3) with the constant and diagonal mass matrix

$$\begin{aligned} \boldsymbol {M} = \begin{bmatrix} m \boldsymbol {I} & & \boldsymbol {0} & & \boldsymbol {0} & & \boldsymbol {0} \\ \boldsymbol {0} & & E_{1} \boldsymbol {I} & & \boldsymbol {0} & & \boldsymbol {0} \\ \boldsymbol {0} & & \boldsymbol {0} & & E_{2} \boldsymbol {I} & & \boldsymbol {0} \\ \boldsymbol {0} & & \boldsymbol {0} & & \boldsymbol {0} & & E_{3} \boldsymbol {I} \end{bmatrix} \text{,} \end{aligned}$$
(60)

where principal values of the Euler tensor can be computed with the principal moments of inertia as \(E_{i} = 1/2\left ( J_{j} + J_{k} - J_{i}\right )\) for even permutations of the indices (\(i,j,k\)). The primary constraints enforce the directors to stay orthonormal for all times due to the rigidity of the body, viz.

$$\begin{aligned} \boldsymbol {g}(\boldsymbol {q}) = \tilde{\boldsymbol {g}}(\{\boldsymbol {d}_{\mathrm{i}}\}) = \begin{bmatrix} \frac{1}{2}(\boldsymbol {d}_{1} \cdot \boldsymbol {d}_{1} - 1) \\ \frac{1}{2}(\boldsymbol {d}_{2} \cdot \boldsymbol {d}_{2} - 1) \\ \frac{1}{2}(\boldsymbol {d}_{3} \cdot \boldsymbol {d}_{3} - 1) \\ \boldsymbol {d}_{1} \cdot \boldsymbol {d}_{2} \\ \boldsymbol {d}_{1} \cdot \boldsymbol {d}_{3} \\ \boldsymbol {d}_{2} \cdot \boldsymbol {d}_{3} \end{bmatrix} = \boldsymbol {0} \text{.} \end{aligned}$$
(61)

Specifically in this example, a gyroscopic top, as depicted in Fig. 2, has been investigated for a total simulation time of \(T=2\,\mathrm{s}\) with a time step size of \(h=0.002\,\mathrm{s}\) computed with the symplectic variational integrator from Sect. 4.

Fig. 2
figure 2

Initial configuration of the gyroscopic top

The total mass of the top amounts to \(m=0.7069\,\mathrm{kg}\) and the moments of inertia read \(J_{1} = J_{2} = J_{3} = 5.3014 \cdot 10^{-4}\,\mathrm{kg}\, \mathrm{m}^{2}\). This examplarily corresponds to a symmetric cone with mass density \(\rho =2700\, \mathrm{kg}/\mathrm{m}^{3}\), height \(a=0.1\mathrm{m}\), top radius \(r=a/2\), and a location of the center of mass along the symmetry axis \(l=3/4\,a\). In this case, the moments of inertia can be computed via

$$\begin{aligned} J_{1} = J_{2} & = \frac{3}{80}m (4r^{2} + a^{2}) \text{,} \quad J_{3} = \frac{3}{10}m r^{2} \text{,} \end{aligned}$$
(62a)

and the total mass is given by \(m = \frac{1}{3} \rho \pi r^{2} a\). Gravitation acts in the negative \(\boldsymbol {e}_{3}\)-direction with \(\boldsymbol {b} = [0 \, , \, 0 \, , \, -9.81 \mathrm{m}/\mathrm{s}^{2} ] ^{ \mathrm{T}}\) such that the potential energy of the system only depends on the position of the center of mass \(\boldsymbol {\varphi}\), viz.

$$\begin{aligned} V(\boldsymbol {q}) = \hat{V}(\boldsymbol {\varphi}) = - m \, \boldsymbol {b} \cdot \boldsymbol {\varphi} \text{.} \end{aligned}$$
(63)

It is crucially important that the top is subject to an additional constraint

$$\begin{aligned} g_{\mathrm{cm}}(\boldsymbol {q}) = \boldsymbol {\varphi} - l \boldsymbol {d}_{3} = 0 \text{,} \end{aligned}$$
(64)

which fixes the tip of the gyroscopic top to the origin of \(\{\boldsymbol {e}_{i}\}\) by enforcing that the center of mass is located on the axis of symmetry with a distance of \(l\) to the origin. The initial nutation angle is \(\alpha _{0} = \pi /3\) and the gyroscopic top is subject to an initial angular velocity vector

$$\begin{aligned} \boldsymbol {\omega}_{0} = \omega _{\mathrm{p}}\,\boldsymbol {e}_{3} + \omega _{ \mathrm{s}}\,\boldsymbol {d}_{3} \text{,} \end{aligned}$$
(65)

where the initial precession rate is chosen as \(\omega _{p} = 10\, \mathrm{s}^{-1}\) and the initial spin rate for the case of steady precession can be computed via the relation

$$\begin{aligned} \omega _{\mathrm{s}} = \frac{m\,g\,l}{J_{\mathrm{3}}\, \omega _{\mathrm{p}}} + \frac{J_{1} + m\, l^{2} - J_{3}}{J_{3}}\,\omega _{p}\, \cos (\alpha _{0}) \end{aligned}$$
(66)

(cf. p. 221 in Goldstein [28]), which amounts to \(\omega _{\mathrm{s}} = 135.6\, \mathrm{s}^{-1}\) for the present case. Note that \(g=9.81\, \mathrm{m}/\mathrm{s}^{2}\) denotes the magnitude of gravitational acceleration here.

The transformation from the global \(\boldsymbol {e}_{i}\) coordinate system to the initially inclined system can easily be done by the use of a rotation matrix \(\boldsymbol {R}_{0} \in SO(3)\) with the well-known property \(\boldsymbol {R}_{0} ^{\mathrm{T}}= \boldsymbol {R}_{0} ^{\mathrm{-1}}\). For the present case, this reads

$$\begin{aligned} \boldsymbol {R}_{0} = \begin{bmatrix} 1 & 0 & 0 \\ 0 & \cos (\alpha _{0}) & -\sin (\alpha _{0}) \\ 0 & \sin (\alpha _{0}) & \cos (\alpha _{0}) \end{bmatrix} \text{,} \end{aligned}$$
(67)

which prescribes a rotation about the \(\boldsymbol {e}_{1}\)-axis with the angle \(\alpha _{0}\) as can be seen in Fig. 2. Thus, the initial velocities of the center of mass and the directors can be computed by taking the cross product with the initial configuration

$$\begin{aligned} \dot{\boldsymbol {\varphi}}(t=0) & = \boldsymbol {\omega}_{0} \times \boldsymbol {\varphi}(t=0) \text{,} \end{aligned}$$
(68a)
$$\begin{aligned} \dot{\boldsymbol {d}}_{i}(t=0) & = \boldsymbol {\omega}_{0} \times \boldsymbol {d}_{i}(t=0) \text{,} \end{aligned}$$
(68b)

where \(\boldsymbol {\omega}_{0}\) can be transformed to the global coordinate system first with the aid of \(\boldsymbol {R}_{0}\) to simplify the computation.

By ensuring the condition for a steady precession (66) the center of mass is rotating on a constant height \(\varphi _{3}\) around the vertical axis since gravitational forces and restabilizing effects due to the rotation are in an equilibrium. The horizontal coordinate of the center of mass \(\varphi _{3}\) can thus be regarded as an analytical reference to the solutions. The results given by the symplectic integration scheme oscillates around this analytical solution, as can be seen in Fig. 10. The evolution of the energetic quantities \(T\), \(V\), and \(H\) is shown in Fig. 3. The total energy of the system is not conserved identically along the solutions of this integration scheme as it can be seen in Fig. 5 which displays the increments in \(H\) from one time step to another. However, as it is typical for symplectic methods (cf. Fig. 16 in Lew & Mata [11]), \(H(t)\) oscillates around its true value and the energy error remains stable. Furthermore, as the gyroscopic top is subject to external forces acting in the \(\boldsymbol {e}_{3}\)-direction, the symmetry of the system reduces to a conservation of the angular momentum about the \(\boldsymbol {e}_{3}\)-axis such that \(L_{3} = \mathrm{constant}\). This is correctly captured by the symplectic method and can be seen in Fig. 4. Differences in \(L_{3}\) from one point in time to another are close to computer precision (cf. Fig. 6).

Fig. 3
figure 3

Energy quantities. (Color figure online)

Fig. 4
figure 4

Angular momentum. (Color figure online)

Fig. 5
figure 5

Hamiltonian difference

Fig. 6
figure 6

Angular momentum difference

By design, the constraints on configuration level \(g^{\mathbf{q}}_{k}(t)\) corresponding to (41d) are identically fulfilled which can be observed in Fig. 7 (each line corresponds to one specific \(k \in \{1, \dots , 9 \}\)). In contrast to that, in each time step the secondary constraints \(g^{\mathbf{v}}_{k}(t)\) are merely enforced in an intermediate configuration, corresponding to (41e). This leads to the results depicted in Fig. 8. We can moreover analyze the h-convergence of the symplectic variational integrator. Therefore we have investigated the relative error in the vertical coordinate of the center of mass, which is supposed to remain constantly \(\varphi _{\mathrm{3,ana}}=0.0375\, \mathrm{m}\), after a total simulation time of \(t=0.001\,\mathrm{s}\) for various time step sizes. In Fig. 9 we display the relative error

$$\begin{aligned} e = \frac{ | \varphi _{3}(t=0.001\,\mathrm{s}) - \varphi _{3,\text{ana}} |}{\varphi _{3,\text{ana}}} \end{aligned}$$
(69)

for different time step sizes \(h\). It becomes visible that the present method is first-order accurate.

Fig. 7
figure 7

Constraints on configuration level

Fig. 8
figure 8

Constraints on velocity level

Fig. 9
figure 9

h-convergence

Fig. 10
figure 10

Vertical coordinate of center of mass

5.2 Double four-bar linkage

In the second example, we consider a classical benchmark system for multibody dynamics, the double four-bar linkage (cf. González et al. [29] and Bayo & Avello [30]). As depicted in Fig. 11, the closed-chain structure at hand consists of five rigid bars with uniformly distributed mass \(m=1\, \mathrm{kg}\) and length \(l=1\,\mathrm{m}\) and seven joints interconnecting them. The lower three bodies (\(\mathsf{B}_{1}\) to \(\mathsf{B}_{3}\)) are connected to the ground by revolute support joints (\(\mathsf{P}_{1}\) to \(\mathsf{P}_{3}\)), whereas the upper two bodies (\(\mathsf{B}_{4}\) and \(\mathsf{B}_{5}\)) are connected by four revolute joints in \(\mathsf{P}_{4}\) to \(\mathsf{P}_{6}\). The multibody system is under the effect of gravity with \(\boldsymbol {b} = -9.81 \frac{\mathrm{m}}{\mathrm{s}^{2}} \boldsymbol {e}_{2}\). At \(t=0\) the system is in an upright position (\(\theta =\pi /2\)) and is subject to an initial velocity of \(v_{0} = 1 \frac{\mathrm{m}}{\mathrm{s}}\) on the upper bodies in positive \(\boldsymbol {e}_{1}\)-direction. For consistency the initial velocity in the center of mass of the lower three bars amounts to \(v_{0}/2\) in the same direction. The system has been investigated for a total time of \(T=10\,\mathrm{s}\) with \(h=1\cdot 10^{-3}\,\mathrm{s}\).

Fig. 11
figure 11

Double four-bar linkage

The configuration of the system is described by the same director-based framework as in the first example. Further details about the planar director formulation of rigid body dynamics can be found in [31]. For each body, we make use of the position vector to the center of mass \(\boldsymbol {\varphi}^{(i)} \in \mathbb{R}^{2}\) and two directors \(\boldsymbol {d}_{\alpha}^{(i)} \in \mathbb{R}^{2}\) (\(\alpha \in \{ 1,2\}\)) specifying the orientation of the rigid body. Thus, we obtain six redundant coordinates

$$\begin{aligned} \boldsymbol {q}^{(i)} = \begin{bmatrix} \boldsymbol {\varphi}^{(i)} \\ \boldsymbol {d}_{1}^{(i)} \\ \boldsymbol {d}_{2}^{(i)} \end{bmatrix}, \end{aligned}$$
(70)

along with the mass matrix

$$\begin{aligned} \boldsymbol {M}^{(i)} = \begin{bmatrix} m^{(i)} \boldsymbol {I} & & \boldsymbol {0} & & \boldsymbol {0} \\ \boldsymbol {0} & & E_{1}^{(i)} \boldsymbol {I} & & \boldsymbol {0} \\ \boldsymbol {0} & & \boldsymbol {0} & & E_{2}^{(i)} \boldsymbol {I} \end{bmatrix} \text{,} \end{aligned}$$
(71)

for each rigid body, where \(E_{\alpha}^{(i)} = \frac{1}{2}J^{(i)}\) and \(J^{(i)}\) is the moment of inertia about the center of mass. The system’s potential energy is given by

$$\begin{aligned} V = \sum _{i=1}^{5} V^{(i)} = \sum _{i=1}^{5} -m^{(i)} \boldsymbol {b} \cdot \boldsymbol {\varphi}^{(i)} \text{.} \end{aligned}$$
(72)

To enforce rigidity each body is subject to three internal holonomic constraints

$$\begin{aligned} \boldsymbol {g}^{\mathrm{int}}_{i}(\boldsymbol {q}^{(i)}) = \begin{bmatrix} \frac{1}{2}(\boldsymbol {d}_{1}^{(i)} \cdot \boldsymbol {d}_{1}^{(i)} - 1) \\ \frac{1}{2}(\boldsymbol {d}_{2}^{(i)} \cdot \boldsymbol {d}_{2}^{(i)} - 1) \\ \boldsymbol {d}_{1}^{(i)} \cdot \boldsymbol {d}_{2}^{(i)} \end{bmatrix} = \boldsymbol {0} \text{.} \end{aligned}$$
(73)

Moreover, there are seven external constraints due to the revolute joints. They are exemplarily given by

$$\begin{aligned} \boldsymbol {g}^{\mathrm{ext}}_{1} & = \boldsymbol {\varphi}^{(1)} - \frac{l}{2} \boldsymbol {d}_{1}^{(1)} = \boldsymbol {0} \text{,} \end{aligned}$$
(74a)
$$\begin{aligned} \boldsymbol {g}^{\mathrm{ext}}_{4} & = \boldsymbol {\varphi}^{(1)} + \frac{l}{2} \boldsymbol {d}_{1}^{(1)} - (\boldsymbol {\varphi}^{(4)} - \frac{l}{2} \boldsymbol {d}_{1}^{(4)}) = \boldsymbol {0} \end{aligned}$$
(74b)

for the joints \(\mathsf{P}_{1}\) and \(\mathsf{P}_{4}\), respectively. Eventually, for the double four-bar linkage, we have a set of \(5\cdot 6 = 30\) redundant coordinates and \(5\cdot 3 + 7\cdot 2 = 29\) scalar-valued holonomic constraints. Consequently, the system has one degree of freedom, e.g., the inclination angle \(\theta \) (cf. Fig. 11). According to González et al. [29], this benchmark problem can be used to test the ability of numerical formulations to overcome singular states, which occur for horizontal configurations of the linkage (e.g., for \(\theta =0\)).

With the present variational integrator there were no numerical problems throughout the simulation. Correspondingly, one obtains smooth evolutions of the position and velocity components. This is exemplarily shown for the 1-components of the position \(x_{4}\) and the velocity \(v_{4}\) in point \(\mathsf{P}_{4}\) in Figs. 12 and 13, respectively.

Fig. 12
figure 12

1-coordinate of \(\mathsf{P}_{4}\)

Fig. 13
figure 13

1-velocity of \(\mathsf{P}_{4}\)

It is straightforward to compute the energetic quantities over time. The results can be found in Fig. 14, where the energy transfer between potential and kinetic energy becomes visible. Furthermore, it can be observed that the typical oscillations in the total energy of symplectic schemes are present again. Increments in the Hamiltonian are of the order of \(10^{-3}\) and remain stable (see Fig. 16). The angular momentum in two dimensions for the given director formulation can be computed according to [31] as

$$\begin{aligned} L = \sum _{i=1}^{5} \left ( m^{(i)} \boldsymbol {\varphi}^{(i)} \cdot \boldsymbol {K} \dot{\boldsymbol {\varphi}}^{(i)} + \sum _{\alpha =1}^{2} E_{\alpha}^{(i)} \boldsymbol {d}_{\alpha}^{(i)} \cdot \boldsymbol {K} \dot{\boldsymbol {d}}_{\alpha}^{(i)} \right ) \end{aligned}$$
(75)

with

$$\begin{aligned} \boldsymbol {K} = \begin{bmatrix} 0 & 1 \\ -1 & 0 \end{bmatrix} \text{.} \end{aligned}$$
(76)

Due to the presence of gravity, the system’s Lagrangian does not have rotational symmetry and thus the angular momentum varies over time (cf. Figs. 15 and 17).

Fig. 14
figure 14

Energy quantities. (Color figure online)

Fig. 15
figure 15

Angular momentum

Fig. 16
figure 16

Hamiltonian difference

Fig. 17
figure 17

Angular momentum difference

Concerning the holonomic constraints several observations can be made. The constraints on position level are identically fulfilled by the integration scheme in each time step. This is depicted both for the internal constraints (cf. Fig. 18) and the external constraints (cf. Fig. 20). The internal constraints (73) in the first bar \(\mathsf{B}_{1}\) and the external constraints (74b) in the revolute joint \(\mathsf{P}_{4}\) have been chosen as representative examples.

Fig. 18
figure 18

Internal constraints for first bar on configuration level. (Color figure online)

By design of the present method, the velocity level constraints are not satisfied at the endpoints, but rather in an intermediate sense (cf. equation (41e)). Correspondingly, the internal constraints on velocity level exhibit slight deviations at the endpoints (see Fig. 19), which are more pronounced in regions close to the singular configurations. Due to the linearity of the external constraints (e.g., relation (74b)), the constraint Jacobian is constant, such that the corresponding velocity constraints are exactly fulfilled at the endpoints as well (cf. Fig. 21).

Fig. 19
figure 19

Internal constraints for first bar on velocity level. (Color figure online)

Fig. 20
figure 20

External constraints in revolute joint \(\mathsf{P_{1}}\) on configuration level. (Color figure online)

Fig. 21
figure 21

External constraints in revolute joint \(\mathsf{P_{1}}\) on velocity level. (Color figure online)

Eventually, we include physical damping in the system by applying the method developed in Sect. 4.3. To this end, we add two viscous damping elements to the double four-bar linkage. Those elements with constants \(\eta _{1} = \eta _{2} = 0.5\, \mathrm{Ns/m}\) connect the points \(\mathsf{P}_{1}\) and \(\mathsf{P}_{5}\) as well as \(\mathsf{P}_{2}\) and \(\mathsf{P}_{6}\). Defining the relative velocities between the respective points as \(\boldsymbol {v}_{\mathrm{rel,1}}\) and \(\boldsymbol {v}_{\mathrm{rel,2}}\), respectively, the Rayleigh dissipation function (54) is given by

$$\begin{aligned} G = \sum _{i=1}^{2} \frac{1}{2} \eta _{i} \,\boldsymbol {v}_{\mathrm{rel,}i} \cdot \boldsymbol {v}_{\mathrm{rel,}i} \text{.} \end{aligned}$$
(77)

Since \(\mathsf{P}_{1}\) and \(\mathsf{P}_{2}\) are fixed to the ground, the relative velocities are given by

$$\begin{aligned} \boldsymbol {v}_{\mathrm{rel,}1} & = \dot{\boldsymbol {\varphi}}^{(4)} + \frac{l}{2} \dot{\boldsymbol {d}}_{1}^{(4)} \text{,} \end{aligned}$$
(78a)
$$\begin{aligned} \boldsymbol {v}_{\mathrm{rel,}2} & = \dot{\boldsymbol {\varphi}}^{(5)} + \frac{l}{2} \dot{\boldsymbol {d}}_{1}^{(5)} \text{.} \end{aligned}$$
(78b)

Thus, the dissipation matrix introduced in (53) for the system at hand reads

$$\begin{aligned} \boldsymbol {C} = \mathrm{diag}(\boldsymbol {0}_{6 \times 6}, \boldsymbol {0}_{6 \times 6}, \boldsymbol {0}_{6 \times 6}, \boldsymbol {C}_{1}, \boldsymbol {C}_{2}) \text{,} \end{aligned}$$
(79)

in which

$$\begin{aligned} \boldsymbol {C}_{i} = \eta _{i} \begin{bmatrix} -\boldsymbol {I}_{2 \times 2} & -\frac{l}{2} \boldsymbol {I}_{2 \times 2} & \boldsymbol {0}_{2 \times 2} \\ \boldsymbol {0}_{2 \times 2} & \boldsymbol {0}_{2 \times 2} & \boldsymbol {0}_{2 \times 2} \\ -\frac{l}{2} \boldsymbol {I}_{2 \times 2} & -\frac{l^{2}}{4} \boldsymbol {I}_{2 \times 2} & \boldsymbol {0}_{2 \times 2} \end{bmatrix} \end{aligned}$$
(80)

for \(i \in \{1, 2 \}\). As a result, the total energy \(H\) of the systems decays over time as it is dissipated by the two viscous damping elements. This can be observed in the energy plot in Fig. 22. In Fig. 23 it becomes visible that the lost amount of total energy in each time step is due to the dissipated power \(P_{v}^{n}\) of the damping elements.

Fig. 22
figure 22

Energy quantities with dissipation. (Color figure online)

Fig. 23
figure 23

Dissipated energy increments. (Color figure online)

6 Conclusion and outlook

In this work, a new variational principle for the analysis of constrained dynamics has been proposed. The underlying functional takes account of both primary and secondary constraints. Due to its mixed character with independent position, velocity and momentum quantities, it generalizes Livens principle [1] and thus unites Lagrangian and Hamiltonian viewpoints. By coupling constraints on position and velocity level into the equations we have obtained a set of DAEs which can be regarded as an extension of the well-known GGL stabilization [17]. Contrary to the original formulation, however, the emanating equations of motion have Hamiltonian structure.

The novel GGL functional gives rise to DAEs with differentiation index 2 and thus circumvents the numerical problems of the standard index-3 DAEs pertaining to mechanical systems subject to holonomic constraints. We could show, that the formulation is symplectic and has Hamiltonian structure. The conservation principles of constrained dynamics can be carried over to the novel augmented formulation. We have demonstrated that, in analogy to the classical GGL formulation [17], in the time-continuous case the additional Lagrange multipliers need to vanish. However, in contrast to the original GGL formulation, this property is not required to retain the conservation of the Hamiltonian and the symplectic structure.

Based on the newly proposed variational principle, we have successfully derived a new first-order variational integrator. This integrator satisfies the primary constraints and is capable to conserve the angular momentum of the system. The secondary constraints have been taken into account in an intermediate sense. We could show that the method is symplectic, which is a typical property of variational integrators (cf. Marsden & West [12]). Moreover, due to an appropriate extension, a scheme which accounts for viscous damping has been derived.

The numerical properties of the present method could be demonstrated in representative examples of multibody dynamics, making use of a rotationless director-formulation.

The novel variational framework represents a promising basis for the construction of structure-preserving integration schemes. The method which has been deduced throughout this work can thus be seen as a starting point for further developments. In particular, due to the close relationship of the GGL principle to optimal control, previously developed direct methods based on the philosophy ‘‘first discretize then optimize’’ (see, for example, Betsch & Becker [32]) can be used to obtain higher-order variational integrators for constrained mechanical systems. These integrators are symplectic by design. Other approaches for the design of higher-order methods (see, e.g., Wenger et al. [33] or Altmann & Herzog [34]) might be of interest for the discretization of the GGL principle as well. Furthermore, slight modifications can be applied to obtain energy-momentum consistent integrators, which are second-order accurate and represent another important class of structure-preserving time-stepping schemes.

We eventually note that in the present work we have put the focus on constrained mechanical systems with nonsingular mass matrices. Since singular mass matrices present additional challenges (see, for example, Udwadia & Phohomsiri [35] and García de Jalón & Gutiérrez [36]), this case would also be of interest for future investigations.