---
url: /dyad/stable/stdlib/HVACComponents/components/Components.StraightPipe.md
description: >-
  Dyad Components.StraightPipe docs.  Distributed-volume straight pipe with
  circular cross-section.
---

# `Components.StraightPipe` {#Components.StraightPipe}

Distributed-volume straight pipe with circular cross-section.

m_flow > 0 means flow enters through port_a. The pipe is discretised into N cells (inherited from PartialStraightPipe via PartialDistributedVolume); set N and model_structure (av_vb, av_b, a_vb, a_v_b) when instantiating, plus the flow_model_mode. Cross-section and perimeter are derived from diameter, so only length, diameter, and roughness define geometry. Provide phase-specific heat-transfer coefficients (alpha_liq / alpha_2ph / alpha_vap, with alpha0 as a base value and xdot_1, xdot_2 as the two-phase blending vapor qualities) and the friction correlation parameters (dp_nominal, m_flow_nominal, K_dp, dp_exp) used by the staggered flow model.

This component extends from [`HVACComponents.Components.Partial.PartialStraightPipe`](../types/PartialStraightPipe.md)

## Usage {#Usage}

`HVACComponents.Components.StraightPipe(medium_data, p_a_start, p_b_start, h_a_start, h_b_start, m_flow_start, ps_start_explicit=fill(p_a_start, N), hs_start_explicit=fill(h_a_start, N), k_init=1.6, ps_start=missing, hs_start=missing, fluidVolumes=missing, lengths=missing, crossAreas=missing, dimensions=missing, roughnesses=missing, dheights=missing, crossAreas_start=missing, dimensions_start=missing, roughnesses_start=missing, dheights_start=missing, diameters_start=missing, dp_nominal_start=missing, m_flow_nominal_start=missing, K_dp_start=missing, dp_exp_start=missing, length, diameter, crossArea=pi * diameter * diameter / 4, perimeter=pi * diameter, roughness, V=crossArea * length, height_ab=0.0, g=9.80665, dxs=missing, alpha0, alpha_liq, alpha_2ph, alpha_vap, xdot_1, xdot_2, dp_nominal, m_flow_nominal, K_dp, dp_exp)`

## Parameters: {#Parameters:}

|                  Name |                                                                                                                 Description | Units |                                                                                                                                       Default value |
| ---------------------:| ---------------------------------------------------------------------------------------------------------------------------:| -----:| ---------------------------------------------------------------------------------------------------------------------------------------------------:|
|                   `N` |                                                                                                   Number of control volumes |     – |                                                                                                                                                     |
|            `N_Plus_1` |                                                                                              Number of cell faces (= N + 1) |     – |                                                                                                                                               N + 1 |
|           `init_mode` |            Initial-condition distribution strategy for the per-cell (p, h) states (Linear, Lumped, Explicit or Exponential) |     – |                                                                                                  HVACComponents.InitializationDistribution.Linear() |
| `initialization_mode` |                   Initialisation mode: FixedInitial_ph sets initial equations on each mediums\[i]; NoInit only seeds guesses |     – |                                                                                     HVACComponents.FiniteVolumeInitializationMode.FixedInitial_ph() |
|     `model_structure` |                                    Staggered-grid model structure controlling how flow cells line up with mass/energy cells |     – |                                                                                                                                                     |
|     `flow_model_mode` |                         Flow formulation: FromPressureDifference computes m_flows from dps_f; FromMassFlow does the reverse |     – |                                                                                                                                                     |
|                 `nFM` |                                Number of momentum cells, derived from model_structure (av_vb: N-1, a_v_b: N+1, otherwise N) |     – | ifelse(model_structure == HVACComponents.ModelStructure.av_vb(), N - 1, ifelse(model_structure == HVACComponents.ModelStructure.a_v_b(), N + 1, N)) |
|          `nFM_Plus_1` |                                                        Number of momentum cells plus one (face count for flow-model arrays) |     – |                                                                                                                                             nFM + 1 |
|         `medium_data` |                                                               Refrigerant medium properties shared by all N control volumes |     – |                                                                                                                                                     |
|           `p_a_start` |                                                                                             Initial pressure at port_a \[Pa] |    Pa |                                                                                                                                                     |
|           `p_b_start` |                                                                                             Initial pressure at port_b \[Pa] |    Pa |                                                                                                                                                     |
|           `h_a_start` |                                                                                  Initial specific enthalpy at port_a \[J/kg] |  J/kg |                                                                                                                                                     |
|           `h_b_start` |                                                                                  Initial specific enthalpy at port_b \[J/kg] |  J/kg |                                                                                                                                                     |
|        `m_flow_start` |                                                                     Initial mass flow rate \[kg/s] (solver guess on m_flows) |  kg/s |                                                                                                                                                     |
|   `ps_start_explicit` |                                     Explicit initial pressure per cell \[Pa] (length N; used only when init_mode = Explicit) |    Pa |                                                                                                                                  fill(p_a_start, N) |
|   `hs_start_explicit` |                          Explicit initial specific enthalpy per cell \[J/kg] (length N; used only when init_mode = Explicit) |  J/kg |                                                                                                                                  fill(h_a_start, N) |
|              `k_init` | Shape exponent of the Exponential enthalpy profile \[-]; larger = more front-loaded (used only when init_mode = Exponential) |     – |                                                                                                                                                 1.6 |
|              `length` |                                                                                                       Total pipe length \[m] |     m |                                                                                                                                                     |
|            `diameter` |                                                                                                     Inner pipe diameter \[m] |     m |                                                                                                                                                     |
|           `crossArea` |                                                                     Pipe cross-sectional area \[m^2] (= pi \* diameter^2 / 4) |    m2 |                                                                                                                        pi \* diameter \* diameter / 4 |
|           `perimeter` |                                                                                      Wetted perimeter \[m] (= pi \* diameter) |     m |                                                                                                                                       pi \* diameter |
|           `roughness` |                                                                                                  Wall surface roughness \[m] |     m |                                                                                                                                                     |
|                   `V` |                                                                    Total internal fluid volume \[m^3] (= crossArea \* length) |    m3 |                                                                                                                                  crossArea \* length |
|           `height_ab` |                                                                                        Elevation of port_b above port_a \[m] |     m |                                                                                                                                                   0 |
|                   `g` |                                                                                          Gravitational acceleration \[m/s^2] |  m/s2 |                                                                                                                                             9.80665 |
|              `alpha0` |                                                                             Reference heat-transfer coefficient \[W/(m^2.K)] |     – |                                                                                                                                                     |
|           `alpha_liq` |                                                                          Liquid-phase heat-transfer coefficient \[W/(m^2.K)] |     – |                                                                                                                                                     |
|           `alpha_2ph` |                                                                             Two-phase heat-transfer coefficient \[W/(m^2.K)] |     – |                                                                                                                                                     |
|           `alpha_vap` |                                                                           Vapor-phase heat-transfer coefficient \[W/(m^2.K)] |     – |                                                                                                                                                     |
|              `xdot_1` |                                                 Lower vapor-quality blending bound between liquid and two-phase regimes \[-] |     – |                                                                                                                                                     |
|              `xdot_2` |                                                  Upper vapor-quality blending bound between two-phase and vapor regimes \[-] |     – |                                                                                                                                                     |
|          `dp_nominal` |                                                                     Nominal pressure drop for the friction correlation \[Pa] |    Pa |                                                                                                                                                     |
|      `m_flow_nominal` |                                                                       Nominal mass flow for the friction correlation \[kg/s] |  kg/s |                                                                                                                                                     |
|                `K_dp` |                                                                                       Friction-correlation gain coefficient |     – |                                                                                                                                                     |
|              `dp_exp` |                                                                                               Friction-correlation exponent |     – |                                                                                                                                                     |

## Connectors {#Connectors}

* `port_a` - ([`FluidPort`](/stdlib/HVACComponents/connectors/FluidPort#FluidPort))

* `port_b` - ([`FluidPort`](/stdlib/HVACComponents/connectors/FluidPort#FluidPort))

## Variables {#Variables}

|       Name |                                                                                 Description | Units |
| ----------:| -------------------------------------------------------------------------------------------:| -----:|
|      `dms` |                                Time derivative of fluid mass in each cell \[kg/s] (length N) |     – |
|      `dUs` |                              Time derivative of internal energy in each cell \[W] (length N) |     – |
|  `m_flows` |                                        Mass flow rate at each cell face \[kg/s] (length N+1) |  kg/s |
|  `H_flows` | Enthalpy flow rate at each cell face \[W] (length N+1); upwind-discretised on internal faces |     – |
| `mb_flows` |          Net convective mass inflow per cell \[kg/s] (length N; = m_flows\[i] - m_flows\[i+1]) |  kg/s |
| `Hb_flows` |         Net convective enthalpy inflow per cell \[W] (length N; = H_flows\[i] - H_flows\[i+1]) |     – |
| `Qb_flows` |                            Source/sink heat flow per cell \[W] (length N); extender supplies |     W |
| `Wb_flows` |                     Source/sink mechanical power per cell \[W] (length N); extender supplies |     W |
|     `Mtot` |                                      Total refrigerant mass inventory across all cells \[kg] |     – |
|     `M_cv` |                                               Refrigerant mass in each cell \[kg] (length N) |     – |
|       `vs` |                                     Mean refrigerant velocity in each cell \[m/s] (length N) |     – |
|        `a` |                            Top-left entry of the (mass, energy) 2x2 system in each cell \[s] |     – |
|        `b` |                    Top-right entry of the (mass, energy) 2x2 system in each cell \[kg.m^3/J] |     – |
|        `c` |                             Bottom-left entry of the (mass, energy) 2x2 system in each cell |     – |
|        `d` |                       Bottom-right entry of the (mass, energy) 2x2 system in each cell \[kg] |     – |
|      `det` |                                   Determinant of the (mass, energy) 2x2 system in each cell |     – |
