Every component in a port‑Hamiltonian network interacts through power ports. A port carries an effort and a flow whose product is the instantaneous power exchanged. In this document, for fluid ports, the effort is pressure \(p\) and the flow is mass flow rate \(\dot{m}\). Power conjugacy means the port variables are chosen such that the product \(p \cdot \dot{m}\) has units of Watts and equals the rate of energy transfer.
Ports are connected by algebraic relations that enforce conservation laws without storing energy. These relations are precisely the Dirac structures of the PHS formalism.
Junctions are power‑continuous interconnections. The two elementary types (from bond‑graph theory) are:
All connected ports share the same effort, and the sum of flows is zero:
\[ e_1 = e_2 = \dots = e_n, \qquad \sum_{k=1}^n f_k = 0. \]This is the junction that enforces pressure equality and mass conservation, exactly what we need when pipes meet at a point (a manifold or an exhaust collector). All multi‑port junctions in this engine model are 0‑junctions.
All ports share the same flow, and the sum of efforts is zero:
\[ f_1 = f_2 = \dots = f_n, \qquad \sum_{k=1}^n e_k = 0. \]In acoustics, a 1‑junction would connect parts that move together (e.g., a series of duct sections with the same mass flow). Our staggered‑grid pipe implicitly uses 1‑junction behaviour when assembling momentum equations at faces, but no explicit 1‑junction component is required in the network.
External influences that supply or extract power are modelled as sources. They either prescribe an effort or a flow, and the complementary variable is left free.
In the global implicit solver, an effort source adds a simple equation \(p - p_{\text{prescribed}} = 0\); a flow source directly fixes the boundary mass flow in the pipe’s face residual. Both are power‑consistent: an effort source may supply or absorb power depending on the sign of the resulting flow.
Purely dissipative elements that convert mechanical energy into heat. In the PHS framework they are represented by a static or dynamic relation between effort and flow that always removes energy.
The compressible orifice flow model described in Chapter 6 is a nonlinear resistive element: mass flow \(\dot{m}\) is a function of the pressure difference and temperatures. It stores no energy, so it is a static R‑element. Its power balance is \(\dot{E} = \dot{m} (h_{\text{in}} - h_{\text{out}}) \le 0\) when the flow is dissipative.
The pipe’s internal dissipation (Darcy–Weisbach friction, Newton‑cooling) is not a separate component but is embedded in the pipe’s R matrix (see Chapter 7). This R matrix is positive semi‑definite and appears in the state equations as \(-\mathbf{R}\nabla H\), guaranteeing that the pipe loses mechanical and thermal energy according to real physics. The pipe thus acts as a distributed resistive element in addition to its energy‑storage role.
All exhaust‑network junctions are instances of a 0‑junction because they enforce a common pressure and mass conservation. The descriptions below explain how they appear in the engine model.
For an \(n\)-port junction:
Because junctions store no energy, these are algebraic constraints. In the global implicit midpoint solve they are handled by Lagrange multipliers. For an \(n\)-port junction, we introduce one extra unknown (the common pressure \(p_J\)) and \(n\) equations: one for the sum of flows, plus \(n-1\) pressure‑equality conditions. The resulting expanded system remains sparse and preserves passivity exactly.
For a pipe boundary, the mass flow is \(\dot{m} = \rho_{\text{face}} \, u_{\text{face}} \, A_{\text{face}}\). The face density \(\rho_{\text{face}}\) is taken directly from the adjacent interior cell (zero‑order extrapolation, see §3).
Used for side‑branch connections (e.g., a resonator or a branch pipe). Three pipes meet at a zero‑volume point; the junction enforces \(p_1 = p_2 = p_3\) and \(\dot{m}_1 + \dot{m}_2 + \dot{m}_3 = 0\). This model correctly reproduces the transmission loss characteristic of T‑junctions in exhaust systems [2].
All four pipes meet at a single point. The same pressure and mass‑flow sum constraints apply. An X‑pipe (or balance pipe) in a V‑engine exhaust cancels certain low‑frequency resonances by allowing wave crossover.
An H‑pipe consists of two separate T‑junctions connected by a cross‑bar pipe of length \(L_{\text{cross}}\). This finite connecting pipe acts as an acoustic filter with notch frequencies at $$f_n = \frac{n c}{2 L_{\text{cross}}}, \quad n = 1,2,\ldots$$ The H‑pipe reduces low‑frequency boom while preserving higher‑frequency content, a common design in performance cars. In the PHS model, it is simply two T‑junctions and a short pipe segment – no special code needed.
A Connection object binds two ports (from two different components) with the power‑continuous relations:
This is the most basic Dirac structure. In the global solver, a connection is treated as a pair of constraints (or equivalently a direct substitution that eliminates one port variable). For efficiency, the Connection can be resolved at assembly time: the two components share a single index in the state vector for the effort, and the flow equations are summed into a single conservation equation. The global Jacobian then has a zero block for the eliminated variables.
EffortSource – contributes a constant pressure to the coupled boundary. In the residual, it sets the boundary port equation \(p_{\text{port}} - p_{\text{prescribed}} = 0\).FlowSource – contributes a prescribed mass flow. In the residual, it directly imposes \(\dot{m}_{\text{port}} - \dot{m}_{\text{prescribed}} = 0\), overriding the pipe’s boundary flux calculation.Both sources are added to the component list and participate in the global Newton‑Krylov solve just like any other component.