Port-Hamiltonian modeling of ideal fluid flow: Part I. Foundations and kinetic energy

Port-HamiltonianIdealfluidflowStokes-DiracstructuresGeometricfluiddynamics In this two-parts paper, we present a systematic procedure to extend the known Hamiltonian model of ideal inviscid fluid flow on Riemannian manifolds in terms of Lie–Poisson structures to a port-Hamiltonian model in terms of Stokes-Dirac structures. The first novelty of the presented model is the inclusion of non-zero energy exchange through, and within, the spatial boundaries of the domain containing the fluid. The second novelty is that the port-Hamiltonian model is constructed as the interconnection of a small set of building blocks of open energetic subsystems. Depending only on the choice of subsystems one composes and their energy-aware interconnection, the geometric description of a wide range of fluid dynamical systems can be achieved. The constructed port-Hamiltonian models include a number of inviscid fluid dynamical systems with variable boundary conditions. Namely, compressible isentropic flow, compressible adiabatic flow, and incompressible flow. Furthermore, all the derived fluid flow models are valid covariantly and globally on n-dimensional Riemannian manifolds using differential geometric tools of exterior calculus.


Introduction
Fluid mechanics is one of the most fundamental fields that has stimulated many ideas and concepts that are central to modern mathematical sciences. Fluid mechanics has been studied in the literature using both the Lagrangian and Hamiltonian formalism. In the classical Hamiltonian theory for fluid dynamical systems, a fundamental difficulty arises in incorporating the spatial boundary conditions of the system, which is also the case for general distributed parameter systems. Previous Hamiltonian formulations of fluid flow in the literature [10][11][12]15] tend to focus on conservative systems with no energy-exchange with its surrounding environment. Usually, this is imposed by certain assumptions on the system variables. For example, if the spatial domain is non-compact, it is assumed that the system variables decay at infinity. Whereas if the spatial domain is compact, the boundary is assumed impermeable by imposing that the velocity vector field is tangent to the boundary.
Consequently, the traditional Hamiltonian theory is limited to distributed parameter systems on spatial manifolds without a boundary or ones with zero-energy exchange through the boundary. While this is useful for analyzing a system that is isolated from its surroundings, it is certainly an obstacle for practical applications such as simulation and control.
The port-Hamiltonian framework grew out of the interest to extend the applicability of traditional Hamiltonian theory and has proven to be very effective for the treatment of both lumped-parameter [13] and distributed-parameter The work presented in this two-part article stems from the work of [18] for modeling compressible isentropic flow. In Part I, we extend the work of [18] showing how the underlying Stokes-Dirac structure can be systematically derived from first principles exploiting the Lie algebra structure of the space of energy variables. While in Part II, we extend the work of [18] by constructing port-Hamiltonian models of adiabatic compressible as well as incompressible flow.
This first paper is organized as follows: Section 2 introduces the geometric description of ideal fluid flow using differential forms on the spatial domain in the quest of identifying the state space of fluid motion. Then, Section 3 discusses advected quantities, their corresponding governing equations, and their own state space separated from the one of fluid motion. Then, Section 4, will discuss the first two steps of the port-Hamiltonian modeling procedure aiming to construct the open port-Hamiltonian model for the kinetic-energy subsystem with variable boundary conditions and distributed stress forces. Finally, we conclude with some remarks in Section 5.
In Part II, we will present the remaining steps of the port-Hamiltonian procedure which will utilize the distributed stress forces added to the port-Hamiltonian model presented in Section 4 of the present paper to add storage of internal energy for modeling compressible flow, and to add constraint forces to model incompressible flow.

Kinematics of fluid motion
In this section, we provide a brief introduction to the geometric description of ideal fluid flow using differential geometric tools which we will build on in this work. For more details on this background material, the reader is referred to [1,Ch. 8] and [9,Ch. 11]. The majority of the differential geometric and exterior calculus notation used in this paper follows that of [7].

Configuration space and Lie algebra
We start by describing the physical space in which the fluid flows. This region is mathematically represented by an n-dimensional compact manifold M, where for non relativistic physically meaningful spaces we are restricted to n = {2, 3}. The manifold could have a boundary ∂M or could have no boundary (∂M = ∅), like for instance our (almost) spherical Earth.
As the fluid flows within the domain M, the material particles are transported with the flow. Consider the fluid particle passing through a point x ∈ M in the spatial domain at time t, and let v(t, x) denote the velocity of that particle assumed to be smooth in its arguments. For each time t, v t := v(t, ·) ∈ X(M) is a vector field on M. We call v the Eulerian velocity field of the fluid. In order to construct a configuration space that describes motion of the fluid, it is necessary to define a family of motions that move elements of the fluid along the spatial manifold M. The evolution of the fluid particle during a fixed time t is described by the map g t : M → M. Thus, the particle starting at a point x 0 reaches the point g t (x 0 ) ∈ M after time t. The map g t : M → M, referred to as the flow map, defines the current configuration of the fluid at time t. The forward map g t : x 0 ↦ → x takes a fluid parcel from its initial position in the reference configuration (chosen as the Lagrangian labels) to its current spatial position in the domain. Whereas, the inverse map g −1 t : x ↦ → x 0 assigns the Lagrangian labels to a given spatial point. The flow map g t is mathematically the flow or evolution operator of the time dependent vector field v [1, pg. 285].
The set of all diffeomorphisms g t on M is known as the diffeomorphism group D(M). By construction the identity element g 0 of D(M) coincides with the identity map on M. The key property of D(M) is that it is an (infinite-dimensional) Lie Group [10] which allows the construction of a proper analytic framework in which fluid dynamic equations can be derived in the same spirit as for finite-dimensional system. As an example the Lie group D(M) serves as the configuration space for the fluid flow in the same way as the Lie Group SE(3) is the configuration space for rigid body motion. The reader is referred to [6] for a proper introduction to a functional-analytic arguments of considering D(M) as a Lie group, which is out of the scope of this work.
The Lie algebra of D(M), denoted by g v , consists of the space of vector fields on M, i.e. T e D(M) = X(M). We denote the Lie bracket of The Lie bracket on g v is given by minus the standard Jacobi-Lie bracket on X(M), which can be expressed using the Lie Derivative as (1)

Differential form representation of Lie algebra
In this work we rely greatly on representing the Lie algebra g v using the space of differential forms on M. The differential form representation is technically beneficial for a number of reasons. First, the related Grassmannian algebra operators are very efficient in carrying out calculations and proving theorems. Second, well established results like Stokes theorem will be crucial in the development of the Dirac structures of this work. Third, the equations of motion expressed using differential forms are invariant with respect to coordinate changes.
As a Riemannian manifold, M carries a metric M : X(M) × X(M) → C ∞ (M) which induces a compatible volume form µ vol = * 1 ∈ Ω n (M). There are two options to identify the Lie algebra of vector fields g v = X(M) with the space of k-differential forms Ω k (M) on the Riemannian manifold M. The first uses the metric M and produces the 1-form v := M(v, ·) ∈ Ω 1 (M). The second option uses the interior product and the volume form to produce the (n − 1)-form ω v := ι v µ vol ∈ Ω n−1 (M). For future reference, we denote the isomorphism v ↦ → ω v by Ψ vol . Conversely, we will denote the vector field corresponding to an n − 1 form ω ∈ Ω n−1 (M) byω ∈ X(M) and the vector field corresponding to a 1-form α ∈ Ω 1 (M) byα ∈ X(M).
The Hodge star operator makes it possible to commute between the two representations. In particular, using the general identity and the fact that µ vol = * 1, it holds that Remark 2.1. Note that the sign in (2) is positive if α is a top form (i.e. k = n) or is of an odd order, which will always be the case where this identity is used in this work.
The choice we will make in this work is to represent the Lie algebra of D(M), that will be denoted by g, using n − 1 forms. Thus we have g = Ω n−1 (M) and its corresponding Lie bracket, denoted by [·, ·] g , is given by the following result.
where the divergence of a vector field v ∈ X(M) is the function div(v) ∈ C ∞ (M) defined such that L v µ vol = div(v)µ vol , and ω = Ψ −1 vol (ω) ∈ g v is the vector field corresponding to ω ∈ g.

Permeable vs. impermeable boundaries
Before moving on, we turn attention to a fundamental issue that distinguishes between the Hamiltonian and port-Hamiltonian treatments of fluid dynamics with respect to the boundary of the fluid container, as shown in Fig. 2.
The construction presented so far in describing the configuration of a fluid flowing using the diffeomorphism group D(M) rests on the fundamental assumption that the fluid particles always remain within the fluid container. In case M has no boundary, this is obviously always true. However, in case M has a boundary, the Lie algebra of D(M) is constrained to the subspace X T (M) ⊂ X(M) with X T (M) defined as the subset of vector fields on M that are tangent to ∂M. This extra condition on v is synonymous with the boundary of M being impermeable.
The restriction of g v to vector fields that are tangent to ∂M translates to the condition that its corresponding n−1 form is normal to ∂M, i.e. satisfies i * (ω v ) = 0, where i : ∂M → M is the canonical inclusion map. Differential forms normal to ∂M are said to satisfy the Dirichlet boundary condition. Thus, in the case of impermeable boundary, the Lie algebra g for impermeable boundaries becomes Ω n−1 D (M), which denotes the space of normal n − 1 forms on M. The cases for which M has no boundary or ∂M is impermeable correspond to an isolated fluid dynamical system that cannot exchange (mass) flow with its surrounding. Consequently, all results of the traditional Hamiltonian formalism relying on D(M) and Poisson structures are related to such isolated systems.
In order to treat fluid dynamical systems in the port-Hamiltonian framework, it is necessary to treat the fluid container with a boundary that is permeable by default. This is necessary, for instance, if M is to represent a control volume inside a bigger flow domain. Fortunately, the extension of the known geometric formulation of fluids to permeable boundaries is only obstructed at the group level. At the Lie algebra level, this extension is simply afforded by dropping the previously identified Dirichlet constraint from the vector space Ω n−1 D (M), which is the algebra for impermeable boundaries, and taking instead all of Ω n−1 (M) as the underlying vector space.
The deceptive simplicity of this step comes with a drastic conceptual shift. The Lie algebra (g, [·, ·] g ) for permeable boundaries can no longer be the associated Lie algebra of the diffeomorphism group D(M) or any of its subgroups. The intuition behind it is that the flow map g t no longer becomes bijective as the fluid particles in the spatial domain M comprising the reference configuration are no longer constrained to remain in M. Therefore, the treatment of permeable boundaries requires nothing more and nothing less than the ability to phrase any question about the fluid in a form that can be treated entirely at Lie algebra level. The discussion of impermeable and permeable boundaries at this early stage is important, because much of what follows depends on whether one deals with impermeable or permeable boundaries. For instance, the determination of the duals of the vector space underlying the Lie algebra g, crucially depends on the nature of ∂M. Another consequence is that boundary terms, which all vanish for impermeable boundaries, must be carried through in a treatment that aspires to be valid for the three boundary cases.
Indeed, it is precisely the surface terms that make the key difference between the Lie-Poisson structure, underlying the traditional Hamiltonian theory, and the Stokes-Dirac structure, underlying the port-Hamiltonian theory, and will be of extreme importance in this work as it will rigorously reveal the corresponding boundary ports.

Dual space of Lie algebra
The dual space g * to the Lie algebra g is naturally identified with the space of 1-forms Ω 1 (M) by means of the duality pairing ⟨ α| ω⟩ g := which is the natural pairing based on integration on M of differential forms of complementary order. An essential ingredient for deriving the equations of fluid motion in the Hamiltonian formalism is the map ad * ω : g * → g * , which is the formal dual to the adjoint operator of g defined by ad ω (·) := [ω, ·] g , for a given ω ∈ g. The explicit expression for ad * ω is given by the following result.

Proposition 2.3.
For any ω ∈ g, the dual map ad * ω of the adjoint operator ad ω of g = Ω n−1 (M) is given by For a general manifold M with boundary ∂M, the map ad * ω in (7) satisfies for any ω, β ∈ g and α ∈ g * , where the (n − 1)-form η adω (α, β) ∈ Ω n−1 (M) is given by The term η| ∂M ∈ Ω k (∂M) denotes the trace of the form η ∈ Ω k (M) which is defined as the pullback of the inclusion map i : ∂M → M, i.e. η| ∂M := i * η.
Proof. Consider any β ∈ g. By using (4) we have that Using the Leibniz rule for the Lie derivative Lω(α ∧ β) = Lωα ∧ β + α ∧ Lωβ and Cartan's magic formula Lω = dιω + ιωd the second integrand in (10) becomes Substituting (11) in (10), using the definition of divergence and Stokes theorem we have that (ιω(α ∧ β))| ∂M . ■ Remark 2.4. Interestingly (but not surprisingly), this condition on representatives of the Lie algebra in case of impermeable boundary, is exactly the one that nullifies the boundary term in (8), which is easily verified because the pullback in the trace distributes over the wedge. This consideration sheds light on the fact that in classical Hamiltonian theory the state space is constrained such that no energy exchange can happen on the boundary of the spatial manifold, and the surface term in the duality pairing (8) is consequently neglected. As will be shown in what follows, the surface terms are the key difference between the Lie-Poisson structure, underlying the traditional Hamiltonian theory, and the Stokes-Dirac structure, underlying the port-Hamiltonian theory, and will be of extreme importance in this work. Our methodology does not rely on constraining the state space of the fluid, but to consider duality pairings like (8) in their full generality, which will reveal rigorously boundary ports that can be used for modeling or control purposes.

Kinematics of advected quantities
In ideal continuum flow, the material parcels of the fluid are carried by the flow. These parcels are transported (advected) by the ideal flow along with extensive thermodynamic properties such as the parcels' mass and heat. The properties transported by the flow are referred to as advected quantities.
The presence of advected quantities adds more structure to the spaces underlying the motion of fluids g and g * . Understanding this additional structure is crucial for the development of the decomposed model of fluid dynamics we aim for in this work as well as the derivation of the Stokes-Dirac structure underlying the kinetic energy subsystem.
Next, we describe mathematically advected quantities and their governing evolution equations. Then, we introduce the interconnection maps that will allow relating the spaces of fluid motion and the spaces of advected quantities to each other. Finally, we discuss the added semi-direct algebra structure that the presence of these advected quantities introduces into the geometric picture.

Mathematical description
In general, an advected quantity a t is represented mathematically as a time-dependent tensor field. We denote the vector space of advected quantities by V * Specific examples include scalar fields (e.g. buoyancy, entropy), vector fields (e.g. magnetic field), 2-forms (e.g. vorticity), and top forms (e.g. mass form). All advected quantities that will be considered in this work will be represented by differential forms.
The relation between the differential form a t at t > 0 and its initial value a 0 is given by the pullback of the flow map g t ∈ G. Thus, we have that a 0 = g * t a t or a t = (g −1 t ) * a 0 . An important observation is that the Eulerian advected quantity a t is thus completely determined by the flow map g t and its initial value a 0 .
The differential expression for a t to be advected with the flow is that which is an immediate consequence of the Lie derivative formula for time-dependent tensor fields [1,Pg. 372]. An advected quantity is also referred to as being invariant under the flow, frozen into the fluid, or Lie dragged with the flow. The prototypical case of an advected quantity that occurs in all continuum flows is the mass top-form given by The mass conservation (or continuity) equation can be written in terms of the mass form as g * To express the mass continuity in terms of the density function ρ t , we substitute µ t = ρ t µ vol in (13) which can be manipulated to result in By comparing the mass continuity equation in its two forms (13) and (14), it is observed that in general, the mass form µ t is an advected quantity while the mass density function ρ t is not. This observation is the main reason why µ t will be chosen as a state variable later in this work for representing the fluid's kinetic energy, which depends on the density and velocity of the flow.
Other examples of advected quantities, which will be used in Part II, include the entropy function s t ∈ C ∞ (M), in case of adiabatic compressible flow, and the volume form µ vol ∈ Ω n (M) in case of incompressible flow.

Relation between fluid motion and advected quantities
In order to build a decomposed model of fluid flow, it is important to describe the dynamics of advected quantities separately from the dynamics of fluid motion. With reference to Fig. 3, the dynamics of the fluid motion are defined on the space (g × g * ), whereas the dynamics of advected quantities are defined on As discussed in Section 3.1, the evolution of an advected quantity depends on the fluid motion described by ω ∈ g.
On the other hand, the advected quantity carried by the flow influences the flow motion in a power-consistent manner through the bidirectional exchange of kinetic energy of the fluid and the additional energy characterized by the advected quantity (e.g. potential or magnetic energy).
The effect of the fluid motion (ω ∈ g on the advected quantity a ∈ V * is encoded in the primary mapφ a : g → V * , which is defined bỹ In terms of this primary map, the governing equation of an advected quantity (12) is The reverse effect, which the advected quantities has on the fluid motion, is characterized by the (formal) dual map ofφ a given bỹ We refer to the two mapsφ a ,φ * a as the interconnection maps (cf. Fig. 3) as they will serve the fundamental role of interconnecting the space of advected quantities with the space of fluid motion in the port-Hamiltonian model, as will be shown later in this part and in Part II.
The explicit expression forφ * a is given by the following result which depends on a specific choice of V * . For our purpose, we only consider the cases of top-forms and smooth functions relevant to the advected quantities of mass form Proposition 3.1. Let V be a representation space of D(M) and V * its dual space, where both V and V * are spaces of differential forms. For a given a ∈ V * , consider the mapφ a defined by (16) and consider its dual mapφ * a : V → g * . For a general manifold M with boundary ∂M, the dual mapφ * a satisfies for any ω ∈ g ⟨φ * a (ā) where ηφ a (ω,ā) ∈ Ω n−1 (M) is the corresponding n − 1 form representing the surface term. Proof.
Using the fact thatā ∈ C ∞ (M) and the Leibniz rule for the exterior derivative, we can write which concludes the proof of (i).
2. Letb ∈ V = Ω n (M) and b ∈ V * = Ω 0 (M), whereb can be written asb = ( * b)µ vol . Using the definition ofφ b (ω) and the fact that b ∈ C ∞ (M), we write Using the Leibniz rule for the interior product it holds ιω(db ∧b

Semidirect product structure
The presence of advected quantities adds more structure to the Lie algebra structure of g that will be central for deriving the Hamiltonian dynamics in the coming section. On the group level (valid only for impermeable or no boundary), the pullback operation of a flow map g t ∈ D(M) on an advected quantity a t ∈ V * defines a right linear action (i.e. representation) of the group D(M) on the vector space V * , which induces another representation on its dual space V , given also by the pullback operation [9]. Thus, both V and V * are representation spaces of D(M).
On the algebra level, the representation of D(M) on V and V * induces two other representations of g on V and V * that are both related to the Lie derivative operator [9].
Given the group D(M), vector space V = Ω k (M), and the right representation given by the pullback operation, we define the semi-direct product Lie group S as the group with underlying manifold D(M) × V and group operation Usually S is denoted by D(M) ⋉ V . The Lie algebra of S is then given by the semi-direct product algebra s = g ⋉ V , with its corresponding bracket [·, ·] s : s × s → s, is defined using the Lie bracket on g in (4) and the induced action of g on V as The dual space s * = g * ×V * to the Lie algebra s will serve as the Poisson manifold on which the dynamical equations of motion will be formulated later. The duality pairing between an element (α, a) ∈ s * and an element (ω,ā) ∈ s is given by where the duality pairing ⟨ ·| ·⟩ V : V * × V → R is given by As usual we define the adjoint operator ad (ω,ā) : s → s for a given (ω,ā) ∈ s by ad (ω,ā) := [(ω,ā), ·] s . Note that the bold notation for ad (ω,ā) is to distinguish it from the ad ω operator of the Lie algebra g. Then the dual map ad * (ω,ā) : s * → s * is given by the following result, which is an extension of Proposition 2.3 for the case of the semi-direct product s.

Theorem 3.2.
For a given (ω,ā) ∈ s, the formal dual ad * (ω,ā) of the adjoint operator ad (ω,ā) and (20) is given explicitly by where ad * ω : g * → g * is given by Proposition 2.3, and the diamond map ⋄ : For a general n-dimensional manifold M with boundary ∂M, the map ad * (ω 1 ,ā 1 ) satisfies the following equality for any where the surface term η ad (ω 1 ,ā 1 ) (α, a, ω 2 ,ā 2 ) ∈ Ω n−1 (M) is expressed as where the expressions of the surface terms are given in (9) and in Proposition 3.1. (23) is usually introduced in the Hamiltonian mechanics literature, e.g. [8,12,14], as a short-hand notation for the dual map (17) and it describes the effect that the advected quantities impose on the motion of the fluid.
In this notation of the diamond operator, the element of V * plays the role of modulation in the linear maps (16) and (17). Furthermore, the image of ω underφ a belongs to the tangent space at

Port-Hamiltonian modeling of the kinetic energy subsystem
Now we start the port-Hamiltonian modeling procedure of a fluid dynamical system flowing on an arbitrary spatial manifold. Unlike the standard top-down approach in classical Hamiltonian theory for modeling a fluid system starting from the configuration space D(M), the philosophy of the port-Hamiltonian modeling process is based on a bottom-up approach.
The port-Hamiltonian procedure for modeling a general dynamical system can be summarized as follows: 1. Conceptual tearing: The starting point for the port-Hamiltonian approach for modeling is a conceptual tearing process of the overall physical system, viewing it as a set of interconnected energetic subsystems. The ith subsystem is characterized by the energy it possesses, denoted by H i : X i → R. This energy traverses from one subsystem to another through an imaginary boundary dividing both of them. 2. Hamiltonian modeling of isolated energetic subsystems: After identifying the individual energetic subsystems, one can use the standard Hamiltonian theory at this point to develop a Hamiltonian model for each energetic subsystem isolated from the rest of the system. However, the emphasis here is on physical energy variables x i ∈ X i which do not necessarily correspond to the canonical coordinates of some cotangent bundle. In fact, energy variables that are most physically compelling are in general non-canonical [15]. Consequently, the outcome of this stage is a closed Hamiltonian model for each energetic subsystem, defined by the energy function H i (x i ) and its corresponding non-canonical Poisson structure.
where x ∈ X is the state of the overall system corresponding to the combined energy variables, which may have redundancies. The compact model could be either a closed system, or an open one with interaction ports that allows the overall port-Hamiltonian model to be interconnected to its external environment.
For the fluid dynamical system at hand, the conceptual tearing process yields two energetic subsystems; One for storage of kinetic energy and another for storage of internal energy (for the general case of compressible flow). In what remains of Part I, we will only focus on the application of the second and third steps for modeling the kinetic energy subsystem. Indeed, we will derive it as a closed Hamiltonian model and then extend it to an open port-Hamiltonian model.
The non-canonical coordinates we choose to develop the Hamiltonian model belong to the dual space s * = g * × V * of the semi-direct Lie-algebra s = g ⋉ V . In the classical fluid dynamics literature, these coordinates are referred to as the Eulerian representation of the fluid motion, in contrast to the Lagrangian representation corresponding to the canonical coordinates on the cotangent bundle of D(M).
Using the semi-direct product reduction theorem [11,12], we will show in the coming section that the Hamiltonian dynamical equations in terms of the Eulerian variables is derivable from the canonical symplectic Hamiltonian dynamics in terms of the Lagrangian variables. This procedure will yield the Hamiltonian dynamics on the dual space s * = g * × V * of the semi-direct Lie-algebra s = g⋉V . It is important to note that this is the only stage where the diffeomorphism group is used, which is possible since we will deal with an isolated closed dynamical system. Moreover, the material presented in this work will be a mere reproduction of the results of [11,12] with a slight difference that the algebra considered here is n − 1 differential forms.
Afterwards, we will show the derived Hamiltonian model and its corresponding Lie-Poisson structure are extended to an open port-Hamiltonian model based on a Stokes-Dirac structure. In this open model, the group structure will be no longer valid, but all the constructions on the algebra will be extended directly to incorporate the permeable boundaries.

Closed model of kinetic energy
The kinetic co-energy 2 of the fluid flow can be used to construct a (reduced) Hamiltonian functional on s * = g * × V * .
By analogy with the kinetic co-energy of a system of particles, we define the co-energy of the fluid flowing on a manifold M to be where M is the Riemannian metric on M. Now we wish to represent the kinetic co-energy of the fluid in terms of the Lie algebra g and the space of advected quantities V * , which is expressed as which follows from ρ = * µ and the equalities where the second equality follows from identity (2). Thus, L k : g × V * → R is a (reduced Lagrangian) functional on the Lie algebra of D(M) that depends parametrically on µ ∈ V * . Using a partial Legendre transformation, we can thus of course represent the kinetic energy as a functional on g * × V * as follows.

Proof. See Appendix A.2. ■
One of the benefits of the previous systematic construction of the (reduced) Hamiltonian H k is that the correct conjugate momentum variable with respect to ω v ∈ g is chosen, and all variational derivatives are correctly derived. As for the governing equations of motion, the semi-direct product reduction theorem asserts that the Hamiltonian dynamics on s * = g * × V * is given as follows.
where the Hamiltonian H k (α, µ) and its corresponding variational derivatives are given by Theorem 4.1.
The corresponding Lie-Poisson bracket underlying these dynamical equations is given by where F , G ∈ C ∞ (s * ) are smooth functions on s * .

Proof.
To derive the Hamiltonian dynamics using the semidirect product reduction theorem, we need the Hamiltonian H a 0 described on the phase space T * D(M). The goal is to extend the Hamiltonian functional H k : g * × V * → R in (29) to one on T * D(M). Consider the isomorphism Γ : which physically represents the map from the space (T * D(M) × V * ) of Lagrangian coordinates to the space (g * × V * ) of Eulerian coordinates. The action of Γ on (g, π) ∈ T * D(M) is given by the pullback of the right translation map R g : D(M) → D(M), whereas the action of Γ on µ 0 ∈ V * is given by the pullback operator. Then, by construction, the functional H (g, π , µ 0 ) := H k •Γ (g, π, µ 0 ) = H k (α, µ) is a Hamiltonian on T * D(M)×V * . Moreover, define the Hamiltonian H a 0 : T * D(M) → R by H µ 0 (g, π) = H (g, π, µ 0 ). By construction, H a 0 is right-invariant under the action of the stabilizer group G µ 0 of µ 0 ∈ V * given by G µ 0 := {g ∈ D(M)|(g −1 ) * µ 0 = µ 0 }.
As a consequence of the previous construction, the semi-direct product reduction theorem asserts that, for a given Hamiltonian functional H : s * → R, the Hamiltonian dynamics on s * = g * × V * are given bẏ where δ x H ∈ s is the variational derivative of H with respect to x, and ad * δxH is the dual of the adjoint operator ad δxH of s given in (23).
The corresponding Lie-Poisson bracket associated to s * is defined by for any F , G ∈ C ∞ (s * ) and x ∈ s * . ■ A key advantage of the equations of motion in the Hamiltonian form (31) is that the structure of the equations clearly separates the kinetic energy functional H k (α, µ) from the underlying interconnection structure governing the evolution of the energy variables (α, µ). Note that the second equation in (31) represents the advection law for the conservation of mass, whereas the term with the diamond operator in the first equation corresponds to the effect of advection on the momentum balance.

Port-based representation
In the port-based paradigm, the system described by Eqs. (31) is represented by two subsystems that are connected together using ports. The first subsystem corresponds to the storage property of the system's energy (29), while the second subsystem corresponds to the interconnection structure encoded in the Lie-Poisson bracket (32).
In general, an energy-storage system (or element) in the port-Hamiltonian framework is defined by the smooth state space manifold X with a Hamiltonian functional H : X → R representing the stored energy, and x ∈ X is called the energy variable. The rate of change of the energy is given byḢ = ⟨ δ x H|ẋ⟩ X , where (δ x H,ẋ) ∈ T * x X × T x X are referred to as the effort and flow variables of the energy storage element, respectively. The duality pairing between an effort in T * x X and a flow in T x X corresponds to the power entering the energy-storage element at a certain instant of time.
For the case of the kinetic energy Hamiltonian H k in (29), the state space manifold is given by X = s * , the energy variables are given by x = (α, µ), while the effort variable δ x H k and flow variableẋ are given by (36) The energy balance is expressed bẏ Thus, this represents the first subsystem corresponding to the storage of the kinetic energy H k in (29). The second subsystem corresponds to the Lie-Poisson structure defined by the map For the energy variables, x = (α, µ) ∈ g * × V * , we have that e sk = (e α , e µ ) and f sk = (f α , f µ ). Then we can express the Lie-Poisson structure as By substituting the expressions of ad * in Proposition 2.3 and the diamond operator in Proposition 3.1 (case 1), we can rewrite the Lie-Poisson structure (39) as ) , where the second row in (40) follows from Lê α (µ) = dιê α (µ) = d(( * µ)ιê α µ vol ) = d(( * µ)e α ), using identity ιωµ vol = ω for any ω ∈ g, and the fact that µ is a top form. Thus, this represents the second subsystem corresponding the interconnection structure of the system. Since the Lie-Poisson structure (40) is defined in terms of the momentum variable α, we refer to it as the momentum representation of the Lie-Poisson structure. The port-Hamiltonian representation of the system (31) is now given bẏ which is constructed by connecting the two ports (e sk , f sk ) and (δ x H k ,ẋ) together: Graphically, the port-based representation of the Hamiltonian dynamics (31) is shown in Fig. 4, where the left figure is represented using bond graphs and the right figure is represented using block diagrams, explicating causality. The kinetic energy storage subsystem is denoted in generalized bond graphs [4] by a C-element with its energy functional H k . The storage subsystem is connected to the Lie-Poisson structure J x through a port denoted by a double half-arrow. The flow and effort variables are indicated on the right and left of the port, respectively.
At any instant of time, the duality pairing between the flowẋ and the effort δ x H equals the power (rate of change of kinetic energy). The conservation of energy can be seen froṁ which follows from the skew-symmetry of the Lie bracket of s. Consequently, the Lie-Poisson structure J x is a skewsymmetric operator, which corresponds to it being a power-continuous element in port-based terminology.

Remark 4.3.
At this stage, it is extremely important to reflect on the discussion mentioned before in Section 2.3 regarding the permeability of the spatial domain. The treatment presented so far in Sections 4.1 and 4.2 is for a closed dynamical system which implies that the boundary is either empty or impermeable. In these cases, g is the associated Lie algebra of the diffeomorphism group D(M). In case of an impermeable boundary, differential forms in g = Ω n−1 D (M) satisfy the Dirichlet boundary condition and consequently differential forms in g * = Ω 1 N (M) satisfy the Neumann boundary condition. An immediate result of this is that for the closed system (31), the surface terms (24) that should appear in the energy balance (42) naturally disappear.
In summary, the closed port-Hamiltonian system shown in Fig. 4 describes the conservation of kinetic energy H k and the corresponding evolution of the energy variables (α, µ). The conservation of energy follows from the skew-symmetry of the Lie-Poisson structure. The aforementioned port-Hamiltonian system is still equivalent to the standard Hamiltonian one that describes a conservative system that is isolated from any energy-exchange with the external world. Next, we discuss how to allow non-zero energy exchange by replacing the underlying Lie-Poisson structure with a Stokes-Dirac structure.

Open model of kinetic energy
There are two ways in which the port-Hamiltonian system (41) can interact and exchange energy with the world; either through the boundary ∂M of the spatial manifold M or within the domain itself through a distributed port that allows energy exchange at every point in M. The former allows exchange of kinetic energy by mass inflow or outflow, while the latter allows transformation of kinetic energy to another form in a reversible (or irreversible) way.
To add a distributed port based on Newton's second law, a distributed force field f s ∈ g * = Ω 1 (M) is added to the momentum balance equation such that the port-Hamiltonian system (31) is rewritten, using (40) as It is worth noticing how our previous choice of the Lie algebra g as Ω n−1 (M) effects the external force field f s on the dual algebra g * to be a co-vector field, which is the correct geometrical representation of a force field. We can write (43) more compactly aṡ with J x given by (40) and G : g * → g * × V * , G = (1 0) ⊤ representing the input map. The force one-form (co-vector field) f s will be used later in Part II to model stress forces due to pressure. In general, the distributed force can be used for modeling other stress forces due to viscosity, as well as any body (external) forces on the continuum (e.g. due to magnetic fields or gravity and electrostatic accelerations).
The Hamiltonian energy (44), as a functional H k : s * → R, admits its rate of change such that along trajectories x(t), parameterized by time t ∈ R, it holds thaṫ As shown in (42), for an isolated fluid system on a closed manifold (corresponding to G = 0, and either ∂M = ∅ or ∂M is impermeable) the kinetic energy is always conserved. However, for a general open fluid system, the expression for the kinetic energy balance (46) is given by the following result.
where the boundary port variables e ∂k , f ∂k ∈ Ω 0 (∂M) × Ω n−1 (∂M) and distributed port variables e d ,  Proof. For notational simplicity, we denote (e α , e µ ) = (δ α H k , δ µ H k ). By substituting (45) in (46), we have thaṫ where (24) was used, and the first term in the last equality vanishes due to the skew-symmetry property of the Lie bracket ad = [, ] s . Using (25), (9), and Proposition 3.1 (case i), we can express the surface term as Using the interior product properties, we have that where the nil-potency property of the interior product was used in the last equality. Therefore, finally we have thaṫ which concludes the proof. ■ It is interesting to note the physical interpretation of the boundary flow variable f ∂k . Using (30) we have that which represents the incoming mass flow through the boundary. As discussed before in Section 2.3, the condition ω v | ∂M = 0 corresponds to an impermeable boundary ∂M which implies that f ∂k = 0 and thus results in no exchange of power through the boundary, as seen in (47). The physical interpretation of the boundary effort variable e ∂k will be discussed later.
With reference to Fig. 5, the port-Hamiltonian system now has 3 ports; an energy storage port (e sk , f sk ), a boundary port (e ∂k , f ∂k ), and a distributed port (e d , f d ). The port (e ∂k , f ∂k ) represents the power incoming to the system through the boundary, while the port (e d , f d ) represents the power flow from an external distributed source in the spatial domain. The 3 ports are connected together through a power-conserving structure D k that encodes the power balance equation (47). Such mathematical structure is called a Stokes-Dirac structure defined as , where the storage port variables are given by f sk = (f α , f µ ) ∈ s * = Ω 1 (M) × Ω n (M) and e sk = (e α , e µ ) ∈ s = Ω n−1 (M) × Ω 0 (M). The bond-space B k = F k ×E k is the product space of the flow space F k = Ω 1 (M) ×Ω n (M) ×Ω n−1 (∂M) ×Ω n−1 (M) and the effort space E k = Ω n−1 (M) × Ω 0 (M) × Ω 0 (∂M) × Ω 1 (M), represented by smooth differential forms of the appropriate degree.
The Dirac structure (49) is a modulated one, in the sense that it depends on the state variables x = (α, µ). In the absence of the distributed force (e d = 0) and in case of an impermeable (or no) boundary (f ∂k = 0), the Stokes-Dirac structure degenerates to the Lie-Poisson structure (40) which encodes the conservation of kinetic energy (Ḣ k = 0). The sign difference between the Lie-Poisson structure in (40) and its counterpart in (49) is due to the choice of having all power ports entering the Dirac structure. This can be clearly seen in the graphical representation of the port-Hamiltonian system in Fig. 5 in terms of bond graph and block diagram notation.
It is interesting to note that the three power ports shown in Fig. 5 are of different natures and result from different duality pairings. The power in the storage port is expressed by the pairing ⟨ e sk | f sk ⟩ s , the power in the distributed port is expressed by the pairing ⟨ e d | f d ⟩ g , while the power in the distributed port is expressed by ∫ ∂M e ∂k ∧ f ∂k .
The port-Hamiltonian system (43) can be recovered from the Stokes-Dirac structure (49) by imposing , where the minus sign is due to the choice of having the storage port entering the Dirac structure, as shown in Fig. 5. Therefore the implicit port-Hamiltonian dynamics are governed by

Change of coordinates to the velocity representation
In the work of [19], the port-Hamiltonian model for compressible isentropic flow was given in terms of the velocity 1-formṽ ∈ Ω 1 (M) and the mass top-form µ ∈ Ω n (M) as the underlying energy variables. The arguments behind this choice of coordinates where not connected to the geometric structure underlying the state space, as we presented so far in this work. Instead, in [19] the authors defined a canonical version of a Stokes Dirac structure based on exterior derivatives, that is representative of a number of physical systems based on conservation laws of different nature. Then, the authors modified this canonical Dirac structure to represent the fluid dynamical system with the velocity and mass forms as energy variables.
One of the contributions of this article is to present a rigorous derivation of the Stokes Dirac structure presented in [19], starting from (49) based on semi-direct product theory. We will represent the port-Hamiltonian system in (43) in terms of the same energy variables in [19] by means of a change of coordinates, recovering the Dirac structure which was introduced there without a formal derivation.
The following change of coordinates procedure was introduced by [20] for the Lie-Poisson structure only. In this work we extend the coordinate change for the full Stokes-Dirac structure and emphasize its port-based interpretation. It will turn out that in terms of the new variables, the expression of the Dirac structure will be simpler than the momentum representation in (40). In addition, this description yields further advantages such as a trivial derivation of the vorticity equation.
Consider the (nonlinear) diffeomorphism We denote the new state variables (ṽ, µ) byx ∈ s * , i.e. Φ : x ↦ →x. Consider the pushforward map (Φ * ) x and pullback Now we consider the coordinate change for the Lie-Poisson part (40) of the Stokes-Dirac structure. The velocity representation of the Lie-Poisson structure is the mapJx : T * x s * → Txs * , defined bỹ The change of coordinates described above can be represented graphically in an elegant way in the port-based framework as shown in Fig. 6.

Proof. See Appendix A.4. ■
The new energy balance for the kinetic energy Hamiltonian (57) instead of (47) can be now calculated using the pullback map (Φ * ) x in (55) as follows.

Proof. See Appendix A.5 ■
As mentioned before, the boundary flow variable f ∂k is physically the incoming mass flow through the boundary. On the other hand, the boundary effort variable e ∂k is physically the dynamic pressure (modulo the density) which is the only pressure that exists related to the kinetic energy of the fluid since we have not modeled yet any thermodynamic potential.
The new Stokes-Dirac structureD k in terms of the state variables (ṽ, µ) can now be constructed using the velocity representation of the Lie-Poisson structure (56) and the definitions of the boundary and distributed port variables in Theorem 4.7. The expression forD k is given bỹ , where the storage port variables are now given by f sk = (fṽ, f µ ) ∈ s * = Ω 1 (M) × Ω n (M) and e sk = (eṽ, e µ ) ∈ s = Ω n−1 (M) × Ω 0 (M). The bond-space B k is the same as the one defined before for D k in (49).
By excluding the distributed port (e d , f d ), the Stokes-Dirac structure (60) coincides with the one postulated in [19] for an ideal fluid and considered as an extended version of with respect to the one containing only exterior derivative operators.

Conclusion
In part I of this paper, we presented the systematic port-Hamiltonian formulation of the kinetic energy storage subsystem and the derivation of its corresponding Stokes-Dirac structure that routes the energy exchanged with a distributed port (which allows the connection to subsystems that interact with the fluid at every point of its domain) and a boundary port (which allows the connection to subsystems that allow exchange of mass flow).
Using the geometric nature and the semi-direct product algebra structure of the state space underlying the energy variables, we showed that the Stokes-Dirac structure could be systematically constructed in two steps. First one uses Poisson reduction [11,12] to construct the underlying Lie-Poisson structure and its corresponding bracket. The second step then extends the Lie-Poisson structure to a Stokes-Dirac structure that allows non-zero exchange of kinetic energy within the spatial domain and through its boundary. All the surface terms were easily identified thanks to the duality pairings of the different maps constructed on the semi-direct product algebra s. We also highlighted that these surface terms naturally disappear in case of an impermeable boundary (imposing the Dirichlet boundary condition in g), which is a key difference between the Hamiltonian and port-Hamiltonian formulations.
This systematic two-step procedure coincide with the Stokes-Dirac structure of compressible isentropic flow heuristically obtained in [18,19] based on the velocity of the flow as the energy variable. We also presented an alternative Stokes-Dirac structure based on the momentum of the flow, and showed how to relate both representations to each other. While in [18,19] the Stokes-Dirac structure was constructed by manipulating the classical Euler equations into a port-Hamiltonian form, the work presented in this paper clarifies the nature of the different components available in the Stokes-Dirac structure by systematically deriving it.
The constructions of this paper, which only comprise what is needed to describe a universal subsystem for the kinetic energy storage of a fluid and its corresponding Dirac structure, will be combined in part II of this series with corresponding constructions for the description of a universal potential energy subsystem, by whose addition one obtains a number of Euler equations.
Since the Legendre transformation is a diffeomorphism, then L k is hyper-regular, and one can define the Hamiltonian which could be expressed as α ∧ * α.
The variational derivative of H with respect to α follows immediately by applying the chain rule to the construction in (66) Similarly, the variational derivative of H with respect to µ is given by where identity (2) was used. This concludes the proof.
The pullback map (Φ * ) x is defined implicitly by Using the duality pairing definition (21), we have that which concludes the proof of (55).