Utility modules
constants
exceptions
functions
- src.utils.functions.calculate_average_flow_velocity(v_flow_m_per_s)[source]
Calculates the average velocity of the fluid flow in the pipeline in [m/s].
- Parameters:
v_flow_m_per_s (
list) – list of fluid values in each pipe section in [m/s]- Return v_avg_m_per_s:
average flow velocity in the pipeline in [m/s]
- Return type:
float
- src.utils.functions.calculate_flow_velocity(den_fluid, mdot_flow, d_pipe_inner)[source]
Calculates the velocity inside an individual segment of the pipeline (based on mass flow) in [m/s].
- Parameters:
den_fluid (
float) – density of the fluid in [kg/m3]mdot_flow (
float) – fluid mass flow in [kg/s]d_pipe_inner (
float) – the internal diameter of the pipeline section in [m]
- Return v_flow:
velocity of flow [m/s]
- Return type:
float
- src.utils.functions.calculate_fluid_density(p, t, fluid='Water')[source]
Defines the fluid density in [kg/m3].
- Parameters:
p (
float) – avrega pressure in the pipeline in [Pa]t (
float) – temperature in [K]fluid (
str) – fluid type
- Return den:
density in [kg/m3]
- Return type:
float
- src.utils.functions.calculate_fluid_specific_heat(p, t, fluid='Water')[source]
Defines the fluid specific heat in [Ws/kgK].
- Parameters:
p (
float) – avrega pressure in the pipeline in [Pa]t (
float) – temperature in [K]fluid (
str) – fluid type
- Return cp:
specific heat coefficient in [Ws/kgK]
- Return type:
float
- src.utils.functions.calculate_heat_flow(t_high, t_low, mdot, cp)[source]
Calculates the flow of thermal energy inside the pipeline [W].
- Parameters:
t_high (
float) – higher temperature in [°C]t_low (
float) – lower temperature in [°C]mdot (
float) – mass flow in [kg/s]cp (
float) – specific heating capacity coefficient in [Ws/kgK]
- Return qdot:
heat flow in [W]
- Return type:
float
- src.utils.functions.calculate_heat_flow_loss(r_tot, t_outer, t_inner)[source]
Calculates the flow of thermal energy loss in [W].
- Parameters:
r_tot (
float) – total thermal resistance of a pipe section in [K/W]t_outer (
float) – ambient temperature in [K]t_inner (
float) – temperature of the fluid inside the pipeline in [K]
- Return qdot_loss:
heat loss flow in [W]
- Return type:
float
- src.utils.functions.calculate_insulation_external_diameter(d_pipe_external, th_insulation)[source]
Calculates the external diameter of the insulation of a chosen pipe section.
- Parameters:
d_pipe_external (
float) – external diameter of the chosen pipe section in [m]th_insulation (
float) – insulation thickness of the chosen section in [m]
- Return d_insulation_external:
external diameter of the chosen section in [m]
- Return type:
float
- src.utils.functions.calculate_insulation_thickness(location, d_pipe_nominal, th_insulation_dict)[source]
Calculates the thickness of pipe section insulation based on its location in [m].
- Parameters:
location (
str) – ‘channel’, ‘surface’, or ‘soil’d_pipe_external – External pipe diameter at the given index in [m]
th_insulation_dict (
dict) – Dictionary with thickness data
- Return th_insulation:
Insulation thickness in [m]
- Return type:
float
- src.utils.functions.calculate_output_temperature(t_in, t_amb, mdot, cp, r_tot, tolerance=0.001)[source]
Iteratively compute the outlet temperature accounting for energy loss and return the final heat loss.
- Parameters:
t_in (
float) – Inlet temperature in [°C]t_amb (
float) – Ambient temperature in [°C]mdot (
float) – Mass flow rate in [kg/s]cp (
float) – Specific heat coefficient in [Ws/kgK]r_tot (
float) – Total thermal resistance in [K/W]tolerance (
float) – Convergence tolerance (default 0.01 = 1%)
- Return type:
Tuple[float,float]- Returns:
t_out_c: Final outlet temperature in [°C] qdot_loss: Final heat flow loss in [W]
- src.utils.functions.calculate_pipe_internal_diameter(d_pipe_external, th_pipe)[source]
Calculates the internal diameter of a chosen pipe section.
- Parameters:
d_pipe_external (
float) – external diameter of the chosen pipe section in [m]th_pipe (
float) – pipe wall thickness of the chosen section in [m]
- Return d_pipe_internal:
internal diameter of the chosen pipe section in [m]
- Return type:
float
- src.utils.functions.calculate_r_conduction(d_outer_m, d_inner_m, l_m, k_w_per_mk)[source]
Calculates the conduction resistance of a cylindrical element.
- Parameters:
d_outer – pipe external diameter in [m]
d_inner – pipe internal diameter in [m]
l_m (
float) – pipe (section) lenght in [m]k_w_per_mk (
float) – the material conductivity coefficient in [W/mK]
- Return r_cond:
conduction resistance in [K/W]
- Return type:
float
- src.utils.functions.calculate_r_convection(d_m, l_m, h_w_per_m2k)[source]
Calculates the convection resistance of a cylindrical element.
- Parameters:
d_m (
float) – diameter of the surface for the convection in [m]l_m (
float) – pipe (section) lenght in [m]h_w_per_m2k (
float) – the material convection coefficient in [W/m2K]
- Return r_conv:
convection resistance in [K/W]
- Return type:
float
- src.utils.functions.calculate_r_total(d_pipe_inner_m, l_m, h_mat1_w_per_m2k, d_pipe_outer_m, k_mat1_w_per_mk, d_ins_outer_m, k_mat2_w_per_mk, h_loc_w_per_m2k)[source]
Calculates the total thermal resistance of a cylindrical element —> fluid-pipe-insulation-air.
- Parameters:
d_pipe_inner_m (
float) – diameter of the surface for the convection inside the pipe section in [m]l_m (
float) – pipe section lenght in [m]h_mat1_w_per_m2k (
float) – the pipe heat transfer coefficient in [W/m2K]d_pipe_outer_m (
float) – external diameter of the pipe section in [m]k_mat1_w_per_mk (
float) – the pipe conductivity coefficient in [W/mK]d_ins_outer_m (
float) – external diameter of the insulation in [m]k_mat2_w_per_mk (
float) – the insulation conductivity coefficient in [W/mK]h_loc_w_per_m2k (
float) – heat transfer coefficient based on the location of the pipe section (surface, channel, soil) in [W/m2K]
- Return r_tot:
total thermal resistance in [K/W]
- Return type:
float
- src.utils.functions.select_ambient_temperature(location)[source]
Selects the external temperature based on the location of the pipeline section.
- Parameters:
location (
str) – position of pipeline section- Return t_amb:
temperature of the sorounding ambient in [°C]
- Return type:
float
- src.utils.functions.select_heat_transfer_coeff(location)[source]
Selects the heat transfer coefficient based on the location of the pipeline section.
- Parameters:
location (
str) – position of pipeline section- Return h_conv:
value of the heat transfer coefficient read from data table
- Return type:
float
validation
- src.utils.validation.validate_damage(mode, percent)[source]
Validates and processes the insulation damage percentage input.
- Parameters:
mode (
str) – The mode of damage input (‘average’ or ‘element’).percent (
Union[float,int,List[Union[float,int]]]) – The value(s) representing insulation damage percentage.
- Return type:
Tuple[Optional[float],Optional[List[float]]]- Returns:
average_percent element_percent_list
- Raises:
TypeError, ValueError –