Utility Functions

Helper functions for calculations and output.

Heat Transfer

enex_analysis_engine.enex_engine.darcy_friction_factor(Re, e_d)[source]

Calculate the Darcy friction factor for given Reynolds number and relative roughness.

Parameters:
  • Re (float) – Reynolds number

  • e_d (float) – Relative roughness (e/D)

Returns:

Darcy friction factor

Return type:

float

enex_analysis_engine.enex_engine.calc_h_vertical_plate(T_s, T_inf, L)[source]

Calculate natural convection heat transfer coefficient for a vertical plate.

This function calculates the heat transfer coefficient due to natural convection using the Churchill & Chu correlation.

Parameters:
  • T_s (float) – Surface temperature [K]

  • T_inf (float) – Fluid temperature [K]

  • L (float) – Characteristic length [m]

Returns:

Heat transfer coefficient [W/m²K]

Return type:

float

Note

Uses Churchill & Chu correlation. Reference: https://doi.org/10.1016/0017-9310(75)90243-4

COP Calculations

enex_analysis_engine.enex_engine.calculate_ASHP_cooling_COP(T_a_int_out, T_a_ext_in, Q_r_int, Q_r_max, COP_ref)[source]

Calculate the Coefficient of Performance (COP) for an Air Source Heat Pump (ASHP) in cooling mode.

Reference: https://publications.ibpsa.org/proceedings/bs/2023/papers/bs2023_1118.pdf

Parameters:
  • T_a_int_out (float) – Indoor air temperature [K]

  • T_a_ext_in (float) – Outdoor air temperature [K]

  • Q_r_int (float) – Indoor heat load [W]

  • Q_r_max (float) – Maximum cooling capacity [W]

  • COP_ref (float) – Reference COP at standard conditions

Returns:

COP value

Return type:

float

Note

COP is calculated based on: - PLR: Part Load Ratio - EIR: Energy input to cooling output ratio

enex_analysis_engine.enex_engine.calculate_ASHP_heating_COP(T0, Q_r_int, Q_r_max)[source]

Calculate the Coefficient of Performance (COP) for an Air Source Heat Pump (ASHP) in heating mode.

Reference: https://www.mdpi.com/2071-1050/15/3/1880

Parameters:
  • T0 (float) – Environmental temperature [K]

  • Q_r_int (float) – Indoor heat load [W]

  • Q_r_max (float) – Maximum heating capacity [W]

Returns:

COP value

Return type:

float

Note

COP is calculated based on PLR (Part Load Ratio).

enex_analysis_engine.enex_engine.calculate_GSHP_COP(Tg, T_cond, T_evap, theta_hat)[source]

Calculate the Carnot-based COP of a GSHP system using the modified formula.

Reference: https://www.sciencedirect.com/science/article/pii/S0360544219304347?via%3Dihub

Formula: COP = 1 / (1 - T0/T_cond + ΔT * θ̂ / T_cond)

Parameters:
  • Tg (float) – Undisturbed ground temperature [K]

  • T_cond (float) – Condenser refrigerant temperature [K]

  • T_evap (float) – Evaporator refrigerant temperature [K]

  • theta_hat (float) – θ̂(x0, k_sb), dimensionless average fluid temperature Reference: Paper Fig 8, Table 1

Returns:

Modified Carnot-based COP. Returns NaN if denominator <= 0.

Return type:

float

Raises:

ValueError – If T_cond <= T_evap (invalid for COP calculation)

Balance Output

enex_analysis_engine.enex_engine.print_balance(balance, decimal=2)[source]

Print energy, entropy, or exergy balance dictionary in a formatted way.

This function prints balance information for subsystems, categorizing entries into in, out, consumed, and generated categories.

Parameters:
  • balance (dict) – Dictionary containing balance information for subsystems. Structure: {subsystem_name: {category: {symbol: value}}} Categories: ‘in’, ‘out’, ‘con’ (consumed), ‘gen’ (generated)

  • decimal (int, optional) – Number of decimal places for output (default: 2)

Returns:

Only prints output

Return type:

None

Example

>>> balance = {
...     "hot water tank": {
...         "in": {"E_heater": 5000.0},
...         "out": {"Q_w_tank": 4500.0, "Q_l_tank": 400.0},
...         "con": {"X_c_tank": 100.0}
...     }
... }
>>> print_balance(balance)

Mathematical Functions

enex_analysis_engine.enex_engine.linear_function(x, a, b)[source]

Linear function: y = a*x + b