pvtlib.equipment.compressors

MIT License

Copyright (c) 2025 Christian Hågenvik

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Functions

dh(mass_enthalpy_1, mass_enthalpy_2)

Calculate the specific mass enthalpy rise of the compressor.

flow_coeff(Q, N, D[, DefType])

Calculate the flow coefficient of a compressor.

impeller_tang_vel(N, D)

Calculate impeller tangential velocity.

poly_eff(head, enthalpy_rise)

Calculate the polytropic efficiency of the stage.

poly_exp(p_suction, p_discharge, ...)

Calculate the polytropic exponent.

poly_head(n, p_suction, p_discharge, ...)

Calculate the polytropic head of a compressor.

poly_head_coeff(head, sigma_u_sq)

Calculate the polytropic head coefficient of the compressor.

sigma_u_squared(tipSpeedArray)

Calculate the sigma U squared of the compressor.

work_coefficient(enthalpy_rise, sigma_u_sq)

Calculate the work coefficient of the compressor.

pvtlib.equipment.compressors.poly_exp(p_suction, p_discharge, rho_suction, rho_discharge)[source]

Calculate the polytropic exponent.

Parameters:
  • p_suction (float) – Suction pressure in bara. Must be positive.

  • p_discharge (float) – Discharge pressure in bara. Must be positive.

  • rho_suction (float) – Suction density in kg/m^3. Must be positive.

  • rho_discharge (float) – Discharge density in kg/m^3. Must be positive.

Returns:

float – The polytropic exponent in [-], or np.nan if any input is zero.

Notes

Returns np.nan for invalid measurement values (zero pressures or densities) to prevent crashes during batch processing of measurement data.

Examples

>>> p_suction = 1.5
>>> p_discharge = 5.0
>>> rho_suction = 6.0
>>> rho_discharge = 12.0
>>> n = poly_exp(p_suction, p_discharge, rho_suction, rho_discharge)
>>> print(n)
1.7369655941662063

Invalid measurements return NaN:

>>> poly_exp(0, 5.0, 6.0, 12.0)
nan
pvtlib.equipment.compressors.poly_head(n, p_suction, p_discharge, rho_suction, rho_discharge)[source]

Calculate the polytropic head of a compressor.

Parameters:
  • n (float) – The polytropic exponent of the compressor in [-]. Must be positive.

  • p_suction (float) – Suction pressure in bara. Must be positive.

  • p_discharge (float) – Discharge pressure in bara. Must be positive.

  • rho_suction (float) – Suction density in kg/m^3. Must be positive.

  • rho_discharge (float) – Discharge density in kg/m^3. Must be positive.

Returns:

float – The polytropic head in kJ/kg, or np.nan if density values are zero.

Notes

Returns np.nan for invalid measurement values (zero densities) to prevent crashes during batch processing of measurement data.

Examples

Calculate the polytropic head for given parameters:

>>> n = 1.25
>>> p_suction = 1.0
>>> p_discharge = 5.0
>>> rho_suction = 10
>>> rho_discharge = 40
>>> result = poly_head(n, p_suction, p_discharge, rho_suction, rho_discharge)
>>> print(result)
480.0

Invalid measurements return NaN:

>>> poly_head(1.25, 1.0, 5.0, 0, 40)
nan
pvtlib.equipment.compressors.poly_eff(head, enthalpy_rise)[source]

Calculate the polytropic efficiency of the stage.

Parameters:
  • head (float) – The polytropic head of the stage in kJ/kg. Must be positive.

  • enthalpy_rise (float) – The specific mass enthalpy rise over the stage in kJ/kg. Must be non-zero.

Returns:

float – The polytropic efficiency in [-], or np.nan if enthalpy_rise is zero.

Notes

Returns np.nan for invalid measurement values (zero enthalpy rise) to prevent crashes during batch processing of measurement data.

Examples

Calculate the polytropic efficiency for given parameters:

>>> head = 80.0
>>> enthalpy_rise = 100.0
>>> result = poly_eff(head, enthalpy_rise)
>>> print(result)
0.8

Invalid measurements return NaN:

>>> poly_eff(80.0, 0)
nan
pvtlib.equipment.compressors.dh(mass_enthalpy_1, mass_enthalpy_2)[source]

Calculate the specific mass enthalpy rise of the compressor.

Parameters:
  • mass_enthalpy_1 (float) – The inlet specific mass enthalpy in kJ/kg.

  • mass_enthalpy_2 (float) – The discharge specific mass enthalpy in kJ/kg.

Returns:

float – The specific mass enthalpy rise in kJ/kg.

Examples

Calculate the specific mass enthalpy rise for given parameters:

>>> mass_enthalpy_1 = 100.0
>>> mass_enthalpy_2 = 150.0
>>> result = dh(mass_enthalpy_1, mass_enthalpy_2)
>>> print(result)
50.0
pvtlib.equipment.compressors.flow_coeff(Q, N, D, DefType='MAN')[source]

Calculate the flow coefficient of a compressor.

Parameters:
  • Q (float) – Fluid volumetric flow at compressor inlet in m^3/s.

  • N (float) – Compressor speed in rpm.

  • D (float) – First impeller diameter in m.

  • DefType (str, optional) – Definition type for flow coefficient calculation. Must be either ‘MAN’ or ‘ISO 5389’. Default is ‘MAN’.

Returns:

float – Flow coefficient in [-], or np.nan if denominator is zero.

Raises:

ValueError – If DefType is not ‘MAN’ or ‘ISO 5389’.

Notes

Returns np.nan for invalid measurement values (zero denominator) to prevent crashes during batch processing of measurement data.

The function supports two definition types: - ‘MAN’: Manufacturer’s definition - ‘ISO 5389’: ISO standard definition

Examples

Calculate flow coefficient using manufacturer’s definition:

>>> Q = 10.0
>>> N = 3000
>>> D = 0.5
>>> result = flow_coeff(Q, N, D, DefType='MAN')
>>> isinstance(result, float)
True

Invalid DefType raises ValueError:

>>> flow_coeff(10.0, 3000, 0.5, DefType='INVALID')
Traceback (most recent call last):
    ...
ValueError: DefType must be one of ['MAN', 'ISO 5389'], got 'INVALID'
pvtlib.equipment.compressors.impeller_tang_vel(N, D)[source]

Calculate impeller tangential velocity.

Parameters:
  • N (float) – Compressor speed in rpm.

  • D (float) – Impeller outer diameter in m.

Returns:

float – Impeller tangential velocity in m/s.

Examples

Calculate impeller tangential velocity:

>>> N = 3000
>>> D = 0.5
>>> result = impeller_tang_vel(N, D)
>>> isinstance(result, float)
True
pvtlib.equipment.compressors.sigma_u_squared(tipSpeedArray)[source]

Calculate the sigma U squared of the compressor.

Parameters:

tipSpeedArray (numpy.ndarray or float) – Tip speeds in m/s.

Returns:

float – The sigma U squared in m^2/s^2 (J/kg).

Notes

This function calculates the sum of squared tip speeds, which is used in compressor performance calculations.

Examples

Calculate the sigma U squared for given parameters:

>>> import numpy as np
>>> tipSpeedArray = np.array([3, 4, 5, 3, 4, 5])
>>> result = sigma_u_squared(tipSpeedArray)
>>> print(result)
100
pvtlib.equipment.compressors.poly_head_coeff(head, sigma_u_sq)[source]

Calculate the polytropic head coefficient of the compressor.

Parameters:
  • head (float) – The polytropic head of the compressor in kJ/kg.

  • sigma_u_sq (float) – Sigma U^2 in J/kg (m^2/s^2). Must be non-zero.

Returns:

float – The polytropic head coefficient in [-], or np.nan if sigma_u_sq is zero.

Notes

Returns np.nan for invalid measurement values (zero sigma_u_sq) to prevent crashes during batch processing of measurement data.

This function calculates the polytropic head coefficient using the provided parameters.

Examples

Calculate the polytropic head coefficient for given parameters:

>>> head = 500
>>> sigma_u_sq = 900000
>>> result = poly_head_coeff(head, sigma_u_sq)
>>> print(result)
0.5555555555555556

Invalid measurements return NaN:

>>> poly_head_coeff(500, 0)
nan
pvtlib.equipment.compressors.work_coefficient(enthalpy_rise, sigma_u_sq)[source]

Calculate the work coefficient of the compressor.

Parameters:
  • enthalpy_rise (float) – The specific mass enthalpy rise of the compressor in kJ/kg.

  • sigma_u_sq (float) – Sigma U^2 in J/kg (m^2/s^2). Must be non-zero.

Returns:

float – The work coefficient of the compressor in [-], or np.nan if sigma_u_sq is zero.

Notes

Returns np.nan for invalid measurement values (zero sigma_u_sq) to prevent crashes during batch processing of measurement data.

This function calculates the work coefficient using the provided parameters.

Examples

Calculate the work coefficient for given parameters:

>>> enthalpy_rise = 1000
>>> sigma_u_sq = 2000000.0
>>> result = work_coefficient(enthalpy_rise, sigma_u_sq)
>>> print(result)
0.5

Invalid measurements return NaN:

>>> work_coefficient(1000, 0)
nan