Volumes that are acoustically compact (e.g., plenums, resonator cavities, manifolds) are modelled as lumped elements with a uniform state: mass \(m\) and internal energy \(U\). They follow the ideal gas law \(p = (\gamma-1)U/V\) and \(T = U/(m c_v)\). Pipes also possess geometric volume and thus contribute to the total gas capacity; a volume element should be used only when the spatial extent is truly negligible compared to wavelengths of interest.
Mass conservation:
$$ \frac{dm}{dt} = \sum_k \dot{m}_{\text{in},k}, $$Energy conservation (first law for an open system):
$$ \frac{dU}{dt} = -p\frac{dV}{dt} + \sum_k h_{\text{in},k}\,\dot{m}_{\text{in},k} + \dot{Q}, $$where \(h_{\text{in}} = c_p T_{\text{in}}\) is the specific enthalpy of the incoming flow, and \(\dot{Q}\) accounts for heat transfer (e.g., combustion). The term \(-p\,dV/dt\) represents piston work if the volume is variable (as in a cylinder).
When a pipe connects to a volume, the mass flow \(\dot{m}_k\) can be positive (into the volume) or negative. The enthalpy that accompanies the mass flow must be taken from the upwind donor:
\[ h_{\text{in},k} = \begin{cases} c_p T_{\text{pipe}}, & \dot{m}_k > 0,\\ c_p T_{\text{vol}}, & \dot{m}_k < 0, \end{cases} \]where \(T_{\text{pipe}}\) is the temperature of the pipe’s adjacent cell and \(T_{\text{vol}}\) is the current volume temperature.
A volume exposes power ports: effort = pressure \(p\), flow = net mass flow \(\dot{m} = \sum \dot{m}_{\text{pipe}}\). A pipe connecting to a volume provides the boundary mass flow \(\dot{m} = \rho_{\text{face}} u_{\text{face}} A_{\text{face}}\) and receives the volume pressure as boundary condition. The implicit midpoint solver ensures that the mass and energy updates are consistent with the pipe fluxes, and the global Jacobian includes the coupling terms between volume states and pipe face variables.
// Volume state (part of the global state vector) double m_vol, U_vol; // mass, internal energy double V; // fixed or time‑varying volume // Per‑connection data (from pipe boundary) double mdot = pipe.FaceMassFlow(faceIdx); // ρ_face * u_face * A_face double T_in = (mdot > 0) ? pipe.FaceTemperature(faceIdx) : U_vol / (m_vol * cv); // Implicit midpoint residuals (to be driven to zero by Newton) double volPressure = (gamma - 1.0) * U_vol / V; double resMass = (m_vol - m_vol_old) / dt - mdot; double resEnergy = (U_vol - U_vol_old) / dt + volPressure * dV_dt - cp * T_in * mdot - Qdot; // The volume pressure is the effort that is coupled to the pipe’s boundary port.
For very small cavities, linearisation yields:
$$ \frac{dp}{dt} = \frac{\gamma p_0}{V_0} Q_{\text{net}}, $$but the full thermodynamic model is preferred for consistency with the nonlinear Euler pipes.