Refrigerant & thermodynamics

CoolProp-backed state-point helpers, cycle-level analysis (compression ratio, COP), compressor operating-envelope guards, COP correlations, and the compressor maps with their scale factors and catalogue calibration.

Refrigerant state points

Refrigerant cycle calculations and optimization.

tmhp.refrigerant.calc_ref_state(T_evap_K, T_cond_K, refrigerant, *, eta_ov, f_loss, mode='heating', dT_superheat=0.0, dT_subcool=0.0, is_active=True, x_suction=1.0)[source]

Compute the four thermodynamic state points of the refrigerant cycle.

The discharge state follows from the compressor’s energy balance, h_2 = h_1 + (1 - f_loss) (h_2s - h_1) / eta_ov (tmhp.compressor_efficiency.discharge_enthalpy()).

The vapour-compression cycle has four canonical state points:

  • State 1 (cmp_in): compressor inlet — low-pressure superheated vapour at the evaporator outlet.

  • State 2 (cmp_out): compressor outlet — high-pressure superheated vapour at the condenser inlet.

  • State 3 (exp_in): expansion-valve inlet — high-pressure subcooled liquid at the condenser outlet.

  • State 4 (exp_out): expansion-valve outlet — low-pressure two-phase mixture at the evaporator inlet.

Keys in the returned dict are always assigned by the physical compressor / expander ports; the mode argument is preserved verbatim under the "mode" key but does not change the key naming.

Wet suction

x_suction < 1 puts State 1 inside the two-phase dome at the evaporating pressure (the evaporator outlet is two-phase, so the evaporator duty is m_dot (h_1 - h_4) with the wet h_1). The suction density is the homogeneous two-phase density 1 / (x v_g + (1 - x) v_l) – it is what sets the swept mass flow – and the isentropic discharge state is the isentropic compression of that two-phase state. Used by the discharge-temperature control of tmhp.compressor_envelope.

Note

Whether a given heat exchanger acts as the evaporator or the condenser in heating versus cooling mode is decided by the caller (_calc_state), which chooses T_evap_K and T_cond_K accordingly before calling this function.

type T_evap_K:

float

param T_evap_K:

type T_cond_K:

float

param T_cond_K:

type refrigerant:

str

param refrigerant:

type eta_ov:

float

param eta_ov:

type f_loss:

float

param f_loss:

type mode:

str

param mode:

type dT_superheat:

float

param dT_superheat:

type dT_subcool:

float

param dT_subcool:

type is_active:

bool

param is_active:

type x_suction:

float

param x_suction:

rtype:

dict[str, Any]

tmhp.refrigerant.create_lmtd_constraints()[source]

Create LMTD-based constraint functions for cycle optimization.

Optimization requires that the heat transfer calculated by LMTD matches the heat transferred by the refrigerant cycle.

Returns:

Tuple of constraint functions (constraint_tank, constraint_hx).

Return type:

tuple[Any, Any]

tmhp.refrigerant.find_ref_loop_optimal_operation(simulator_func, refrigerant, load_W, initial_guess, bounds, constraint_funcs=None)[source]

Find the optimal operation point for the refrigerant loop.

Minimizes compressor power while satisfying target load and LMTD constraints.

Parameters:
  • simulator_func (Any) – Function that takes [dT_ref_HX, dT_ref_tank] and returns a perf dict.

  • refrigerant (str) – Refrigerant name.

  • load_W (float) – Target heat load [W].

  • initial_guess (list[float]) – Initial guess for [dT_evap, dT_cond].

  • bounds (list[tuple[float, float]]) – Bounds for [dT_evap, dT_cond].

  • constraint_funcs (list[Any] | None) – List of constraint functions. Each takes perf and returns a value that should be 0.

Returns:

Optimal performance dictionary, or None if optimization fails.

Return type:

dict[str, Any] | None

tmhp.refrigerant.props_si(output, name1, value1, name2, value2, refrigerant)[source]

CoolProp.PropsSI for one of P, T, H, S, D (mass based), without its per-call set-up.

A drop-in for the cycle solvers’ inner loops: the same value and the same ValueError on an invalid state as CP.PropsSI(output, name1, value1, name2, value2, refrigerant), evaluated on a CoolProp state kept between calls. Input pairs (T, Q), (P, Q), (T, P), (P, S) and (P, H) of a single Helmholtz-backend fluid take the fast path; anything else is passed to CP.PropsSI.

Parameters:
  • output (str)

  • name1 (str)

  • value1 (float)

  • name2 (str)

  • value2 (float)

  • refrigerant (str)

Return type:

float

Cycle analysis

Thermodynamic property and exergy calculations.

tmhp.thermodynamics.calc_energy_flow(G, T, T0)[source]

Calculate energy flow rate.

Parameters:
  • G (float or pd.Series) – Heat capacity flow rate (mass_flow * Cp) [W/K].

  • T (float or pd.Series) – Current temperature [K].

  • T0 (float or pd.Series) – Reference/dead state temperature [K].

Returns:

Energy flow rate [W].

Return type:

float or pd.Series

tmhp.thermodynamics.calc_exergy_flow(G, T, T0)[source]

Calculate exergy flow rate.

Parameters:
  • G (float or pd.Series) – Heat capacity flow rate (mass_flow * Cp) [W/K].

  • T (float or pd.Series) – Current temperature [K].

  • T0 (float or pd.Series) – Reference/dead state temperature [K].

Returns:

Exergy flow rate [W].

Return type:

float or pd.Series

tmhp.thermodynamics.calc_refrigerant_exergy(df, ref, T0_K, P0=101325)[source]

Calculate refrigerant state-point exergy using pre-computed properties.

Uses the entropy (s_ref_*) and enthalpy (h_ref_*) columns already present in df (produced by calc_ref_state) to compute specific exergy and exergy flow rate for each refrigerant state point.

Dead-state properties (h0, s0) are evaluated at (T0, P0) for the given refrigerant using CoolProp (vectorized via unique T0 values).

Parameters:
  • df (DataFrame) – DataFrame containing pre-computed enthalpy h_ref_* [J/kg], entropy s_ref_* [J/(kg·K)], and mass-flow m_dot_ref [kg/s] columns.

  • ref (str) – CoolProp refrigerant identifier (e.g. 'R410A').

  • T0_K (Series) – Dead-state (environment) temperature per row [K].

  • P0 (float) – Dead-state pressure [Pa] (default 101325).

Returns:

df with columns added per state point: x_ref_{name} [J/kg], X_ref_{name} [W].

Return type:

DataFrame

Notes

  • Exergy equation: x = (h − h0) − T0·(s − s0) [J/kg]

  • Exergy flow: X = ṁ · x [W]

  • Rows with NaN enthalpy/entropy propagate NaN naturally.

tmhp.thermodynamics.convert_electricity_to_exergy(df)[source]

Copy all electricity columns (E_*) to exergy columns (X_*).

Electrical energy is 100 %% pure exergy, so X = E for all electricity-consumption columns.

The function searches for columns matching the pattern E_xxx [W] and creates corresponding X_xxx [W] columns.

Parameters:

df (DataFrame) – DataFrame with E_xxx [W] columns.

Returns:

df with X_xxx [W] columns added.

Return type:

DataFrame

tmhp.thermodynamics.generate_entropy_exergy_term(fluid, T, P, Q, T0, P0, phase='gas')[source]

Calculate entropy, enthalpy, and exergy.

Parameters:
  • fluid (str) – Fluid name.

  • T (float) – Temperature [K].

  • P (float) – Pressure [Pa].

  • Q (float) – Quality (0 to 1).

  • T0 (float) – Dead state temperature [K].

  • P0 (float) – Dead state pressure [Pa].

  • phase (Literal['gas', 'liquid', 'twophase']) – Fluid phase. Default is ‘gas’.

Returns:

Entropy [J/kg-K], Enthalpy [J/kg], Exergy [J/kg].

Return type:

tuple[float, float, float]

COP correlations

Heat pump Coefficient of Performance (COP) models.

Provides empirical COP correlations for: - Air source heat pumps (cooling and heating modes) - Ground source heat pumps (EnergyPlus water-to-air EquationFit curves)

tmhp.cop.calc_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

tmhp.cop.calc_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).

tmhp.cop.GSHP_EQFIT_DOMAIN = {'cooling': {'w': (1.0, 1.04905), 'x': (1.0, 1.13734), 'y': (0.75, 1.25), 'z': (0.5, 1.0)}, 'heating': {'w': (1.0, 1.05886), 'x': (0.96076, 1.07848), 'y': (0.75, 1.25), 'z': (0.5, 1.0)}}

Fitted domain of each curve variable, copied from the IDF Minimum/Maximum Value of w, x, y, z fields (dimensionless, ×283 K for temperatures). In °C: cooling entering wet-bulb 9.85–23.73, cooling EWT 9.85–48.72; heating entering dry-bulb 9.85–26.51, heating EWT −1.25–32.06.

exception tmhp.cop.EquationFitRangeError(variable, value, bounds, mode)[source]

Bases: ValueError

An EquationFit curve was asked to evaluate outside its fitted domain.

Parameters:
  • variable (str)

  • value (float)

  • bounds (tuple[float, float])

  • mode (str)

__init__(variable, value, bounds, mode)[source]
Parameters:
  • variable (str)

  • value (float)

  • bounds (tuple[float, float])

  • mode (str)

tmhp.cop.gshp_equation_fit_ratios(T_a_iu_in_K, T_f_out_K, dV_a_ratio, mode, dV_w_ratio=1.0)[source]

Capacity and power ratios of the TCH072_GLHP EquationFit curves.

Raises EquationFitRangeError (a ValueError) when any curve variable lies outside the fitted domain GSHP_EQFIT_DOMAIN; the curves are never extrapolated. Inside the domain both ratios are positive (checked at the domain corners: capacity 0.51–1.93, power 0.67–1.50).

Returns:

(capacity_ratio, power_ratio) relative to the rated point.

Return type:

tuple[float, float]

tmhp.cop.calc_GSHP_COP(T_a_iu_in_K, T_f_out_K, dV_a_ratio, mode)[source]

Calculate COP for a Ground Source Heat Pump.

Uses the EnergyPlus Coil:*:WaterToAir:EquationFit model (Equation-Fit Method), COP = COP_ref · CAP_ratio / PWR_ratio.

References

EnergyPlus Engineering Reference, Ch. 16.5.10.2 (Eq. 16.412–16.418, Tang 2005). Dataset: TCH072_GLHP (ClimateMaster 6-ton, Ground Loop HP), source: EnergyPlus/datasets/WaterToAirHeatPumps.idf.

Rated conditions (from IDF comment, 15% methanol antifreeze):

  • Cooling: 70.29 kBtu/h @ 77 °F (25 °C) entering water, EER = 14.35

  • Heating: 56.14 kBtu/h @ 32 °F (0 °C) entering water, COP = 3.42

Parameters:
  • T_a_iu_in_K (float) – Indoor air inlet dry-bulb temperature [K] (= T_a_room). For cooling, internally converted to wet-bulb (T_wb) via CoolProp assuming RH = 50%.

  • T_f_out_K (float) – Source-side inlet water temperature [K] — water returning from the borehole to the heat pump (T_w,in in EnergyPlus notation).

  • dV_a_ratio (float) – Air flow ratio while the compressor runs, V_a / V_a,rated [-] (fitted range 0.75–1.25). It is not a part-load ratio: the curve describes full-load operation and a part load is met by cycling.

  • mode (str) – “cooling” or “heating”

Returns:

Full-load COP (dimensionless), always positive inside the fitted domain; 0.0 for any other mode.

Return type:

float

Raises:

EquationFitRangeError – (a ValueError) when the entering-air temperature, the entering water temperature or the air-flow ratio is outside the fitted domain GSHP_EQFIT_DOMAIN. The curves are not extrapolated.

Compressor maps and scale factors

Compressor efficiency: the three quantities, the default maps and the scale factors on them.

A heat-pump model describes its compressor by three quantities, each defined from the states and flows around the compressor:

eta_v – volumetric efficiency

eta_v = m_dot / (rho_1 V N): the delivered fraction of the swept volume. It sets the mass flow.

eta_ov – overall efficiency

eta_ov = m_dot (h_2s - h_1) / E_cmp: the isentropic enthalpy rise of the flow over the electrical input at the inverter input (grid side; the drive is not modelled apart from the compressor). It sets the power.

f_loss – heat-loss share

f_loss = Q_cmp_loss / E_cmp: the share of the electrical input that leaves the compressor as heat instead of reaching the gas.

The cycle closes the compressor with these three alone (#274):

m_dot      = rho_1 V N eta_v
E_cmp      = m_dot (h_2s - h_1) / eta_ov
Q_cmp_loss = f_loss E_cmp
h_2        = h_1 + (E_cmp - Q_cmp_loss) / m_dot

so the discharge enthalpy follows from the energy balance and has no efficiency of its own (discharge_enthalpy()). No isentropic or electromechanical efficiency is defined: with heat leaving the shell, the irreversibility of the compression cannot be told apart from the mechanical and electrical losses by what is measured outside the compressor. h_2 may lie below h_2s when the heat loss is large (f_loss > 1 - eta_ov).

Default maps

Three maps of one compressor, fitted to the 134 measured points of a 46 cm3 R290 scroll (Ossorio’s thesis, Appendix 1; the same tests as Compressor A of Ossorio & Navarro-Peris 2023) with the electrical input as compressor plus inverter (#217, #218), where each quantity is computed from the measured states as defined above (h_2 from the measured discharge temperature). Each is a polynomial in the pressure ratio PR, the speed N in rev/s and, for eta_v and eta_ov, the evaporating saturation temperature T_e in degrees C, both as they are (#247):

eta_v  = c . [1, PR, PR^2, N, N^2, PR N, T_e]
f_loss = c . [1, PR, PR^2, N, N^2, PR N]
eta_ov = c . [1, l, l^2, l^3, N, N^2, l N, T_e]        l = ln PR

eta_ov is cubic in ln PR because the measured efficiency rises steeply at low pressure ratios and falls slowly at high ones; eta_v and f_loss need no logarithm. Which basis a map uses is recorded with its coefficients (MAP_TERMS). The evaporating temperature is there because the measured eta_ov and eta_v differ at one pressure ratio and speed: at PR 3 and 70 rev/s the map’s eta_ov rises from 0.62 to 0.69 between T_e = -10 and 15 degrees C. f_loss does not (a T_e term leaves its error unchanged). The same maps serve every refrigerant and every machine. The fit, its data and its scores are archived in validation/coefficients/<COEFFICIENT_VERSION>/ (README there); the constants between the GENERATED markers below are emitted from that archive by validation/compressor_maps/ossorio_te/emit.py.

Scale factors

A model does not take efficiencies of its own: the maps are the same for every machine, and a target machine is followed by scaling them (CompressorMapScale, constructor argument compressor_scale). The level factors scale each quantity; the shape factors move and stretch the eta_ov map about its peak:

eta_v'        = k_v eta_v(PR, N, T_e)
f_loss'       = k_f f_loss(PR, N)
1/eta_ov' - 1 = k_ov (1/eta_ov(PR~, N~, T_e) - 1)
N~  = N* + (N - N* - delta_N) / w_N
PR~ = PR* ((PR - delta_r) / PR*) ** (1 / w_r)

with N* = 70 rev/s and PR* = 3.79, the peak of the default eta_ov map (rounded; ETA_OV_PEAK_RPS, ETA_OV_PEAK_PR). The peak moves by delta_N in speed and by delta_r in pressure ratio (either may be negative); w_N and w_r stretch the map about the moved peak (w > 1 wider). w_r stretches the ratio to the peak, which is a uniform stretch in ln PR, the coordinate of the eta_ov map. The defaults (all level factors 1, shifts 0, widths 1) give the maps as they are.

Outside their data the maps are followed as they are – nothing is held or clamped there; the range rule below is the only bound.

Rules

  • Range (check_efficiencies()): eta_v > 0 (finite, no upper bound), 0 < eta_ov <= 1 and 0 <= f_loss < 1. A value outside makes the operating point infeasible (InvalidCompressorEfficiency); nothing is clipped.

  • Data domain: the maps carry the domain of their fitting data (MapDomain): the speeds 30-110 rev/s and the convex (PR, T_e) hull of the measured points. It feeds the efficiency_extrapolated flag of a result and nothing else (CompressorMapScale.extrapolated()); the eta_ov map is checked at its transformed coordinates.

tmhp.compressor_efficiency.QUANTITIES = ('eta_v', 'eta_ov', 'f_loss')

The three quantities, in the order CompressorEfficiencies holds them.

tmhp.compressor_efficiency.ETA_OV_PEAK_RPS = 70.0

Speed [rev/s] and pressure ratio of the peak of the default eta_ov map, rounded (the exact grid peak is PR 3.786, 70.04 rev/s, the same at every T_e because T_e enters the map as a plain additive term): the centre of the shape factors of CompressorMapScale.

exception tmhp.compressor_efficiency.InvalidCompressorEfficiency[source]

Bases: ValueError

An evaluated compressor quantity lies outside its range, or a map has no value at the point.

class tmhp.compressor_efficiency.HullDomain(vertices)[source]

Bases: object

Convex polygon in a plane, vertices counter-clockwise (used for the data domain).

Parameters:

vertices (tuple[tuple[float, float], ...])

vertices: tuple[tuple[float, float], ...]
contains(x, y, rtol=0.0)[source]

Whether (x, y) lies inside (rtol: also accept a point that far outside, relatively).

Parameters:
  • x (float)

  • y (float)

  • rtol (float)

Return type:

bool

__init__(vertices)
Parameters:

vertices (tuple[tuple[float, float], ...])

class tmhp.compressor_efficiency.MapDomain(hull_PR_Te, rps_range)[source]

Bases: object

Data domain of the default maps: a speed range and the convex (PR, T_e) hull of the measured points.

Used for the efficiency_extrapolated flag only: outside it the maps are followed as they are (no hold, no clamp).

Parameters:
  • hull_PR_Te (HullDomain)

  • rps_range (tuple[float, float])

hull_PR_Te: HullDomain
rps_range: tuple[float, float]
contains(pressure_ratio, rps, T_evap_C=None, rtol=0.0)[source]

Whether (PR, N[, T_e]) lies inside; without T_evap_C only the speed range is checked.

Parameters:
  • pressure_ratio (float)

  • rps (float)

  • T_evap_C (float | None)

  • rtol (float)

Return type:

bool

__init__(hull_PR_Te, rps_range)
Parameters:
  • hull_PR_Te (HullDomain)

  • rps_range (tuple[float, float])

tmhp.compressor_efficiency.map_eta_v(pressure_ratio, rps, T_evap_C)[source]

Volumetric efficiency m_dot / (rho_1 V N) of the default map (T_e evaporating saturation temperature [C]).

Parameters:
  • pressure_ratio (float)

  • rps (float)

  • T_evap_C (float)

Return type:

float

tmhp.compressor_efficiency.map_eta_ov(pressure_ratio, rps, T_evap_C)[source]

Overall efficiency m_dot (h_2s - h_1) / E_cmp of the default map, E_cmp the compressor + inverter input.

Parameters:
  • pressure_ratio (float)

  • rps (float)

  • T_evap_C (float)

Return type:

float

tmhp.compressor_efficiency.map_f_loss(pressure_ratio, rps)[source]

Heat-loss share Q_cmp_loss / E_cmp of the default map.

Parameters:
  • pressure_ratio (float)

  • rps (float)

Return type:

float

class tmhp.compressor_efficiency.CompressorEfficiencies(eta_v: float, eta_ov: float, f_loss: float)[source]

Bases: NamedTuple

The three compressor quantities at one operating point (QUANTITIES).

Parameters:
  • eta_v (float)

  • eta_ov (float)

  • f_loss (float)

eta_v: float

Alias for field number 0

eta_ov: float

Alias for field number 1

f_loss: float

Alias for field number 2

tmhp.compressor_efficiency.check_efficiencies(eta_v, eta_ov, f_loss)[source]

The three quantities if each lies in its range, else InvalidCompressorEfficiency.

  • eta_v > 0 and finite, with no upper bound: it is a measured ratio, m_dot / (rho_1 V N) with rho_1 at the suction port, and the measured points of the default map reach 1.01 at a low pressure ratio and a warm evaporator (the map 1.018), so a value above one is an operating point, not an error.

  • 0 < eta_ov <= 1: no flow is compressed for nothing, and the hermetic compressors the maps describe take at least the isentropic work; a value above one is a map or scale outside what the model represents.

  • 0 <= f_loss < 1: zero is an adiabatic compressor; a negative share would be heat gained through the shell, which runs hotter than its surroundings, and a share of one or more leaves nothing for the gas.

Parameters:
  • eta_v (float)

  • eta_ov (float)

  • f_loss (float)

Return type:

CompressorEfficiencies

tmhp.compressor_efficiency.discharge_enthalpy(h_suction, h_isentropic, eta_ov, f_loss)[source]

Discharge enthalpy h_2 = h_1 + (E_cmp - Q_cmp_loss) / m_dot [J/kg].

With E_cmp = m_dot (h_2s - h_1) / eta_ov and Q_cmp_loss = f_loss E_cmp this is h_1 + (1 - f_loss) (h_2s - h_1) / eta_ov; it lies below h_2s when f_loss > 1 - eta_ov.

Parameters:
  • h_suction (float)

  • h_isentropic (float)

  • eta_ov (float)

  • f_loss (float)

Return type:

float

tmhp.compressor_efficiency.compressor_power(m_dot, h_suction, h_isentropic, eta_ov)[source]

Electrical input E_cmp = m_dot (h_2s - h_1) / eta_ov [W].

Parameters:
  • m_dot (float)

  • h_suction (float)

  • h_isentropic (float)

  • eta_ov (float)

Return type:

float

tmhp.compressor_efficiency.restate_compressor_loss(result, power_key='E_cmp [W]')[source]

Set Q_cmp_loss [W] of a result row to f_loss [-] times its compressor input, in place.

For a row whose compressor input has been averaged after the cycle was solved (on/off cycling, frost and defrost): the shell loss is reported as the heat-loss share of the input the row reports. A row without the two keys, or with a non-finite share (an off row), is left as it is.

Parameters:
  • result (dict[str, Any])

  • power_key (str)

Return type:

None

class tmhp.compressor_efficiency.CompressorMapScale(k_v=1.0, k_ov=1.0, k_f=1.0, delta_N=0.0, w_N=1.0, delta_r=0.0, w_r=1.0)[source]

Bases: object

Scale factors on the default compressor maps – the only way to change a model’s compressor.

k_v, k_ov and k_f scale the level of eta_v, eta_ov and f_loss; delta_N [rev/s] and delta_r [-] move the peak of the eta_ov map (either may be negative) and w_N and w_r stretch it about the moved peak (see the module docstring for the formulas). The defaults give the maps as they are. k_v, k_ov, w_N and w_r must be positive and k_f nonnegative (ValueError otherwise); a factor that puts a quantity outside its range at an operating point makes that point infeasible (check_efficiencies()).

Parameters:
  • k_v (float)

  • k_ov (float)

  • k_f (float)

  • delta_N (float)

  • w_N (float)

  • delta_r (float)

  • w_r (float)

k_v: float = 1.0
k_ov: float = 1.0
k_f: float = 1.0
delta_N: float = 0.0
w_N: float = 1.0
delta_r: float = 0.0
w_r: float = 1.0
property is_identity: bool

Whether the scale leaves the default maps as they are.

as_dict()[source]

The seven factors by name.

Return type:

dict[str, float]

eta_ov_coordinates(pressure_ratio, rps)[source]

(PR~, N~): where the default eta_ov map is read for the point (PR, N).

Raises InvalidCompressorEfficiency when PR - delta_r <= 0.

Parameters:
  • pressure_ratio (float)

  • rps (float)

Return type:

tuple[float, float]

eta_v(pressure_ratio, rps, T_evap_C)[source]

Scaled volumetric efficiency (no range check).

Parameters:
  • pressure_ratio (float)

  • rps (float)

  • T_evap_C (float)

Return type:

float

eta_ov(pressure_ratio, rps, T_evap_C)[source]

Scaled overall efficiency (no range check).

Parameters:
  • pressure_ratio (float)

  • rps (float)

  • T_evap_C (float)

Return type:

float

f_loss(pressure_ratio, rps)[source]

Scaled heat-loss share (no range check).

Parameters:
  • pressure_ratio (float)

  • rps (float)

Return type:

float

evaluate(pressure_ratio, rps, T_evap_K)[source]

The three quantities at (PR, N, T_e), range-checked (check_efficiencies()).

Parameters:
  • pressure_ratio (float)

  • rps (float)

  • T_evap_K (float)

Return type:

CompressorEfficiencies

extrapolated(pressure_ratio, rps, T_evap_C=None, rtol=0.0)[source]

Whether any of the three maps is read outside its fitting data at (PR, N[, T_e]).

eta_v and f_loss are read at the point itself, eta_ov at its transformed coordinates (eta_ov_coordinates()). Without T_evap_C only the speed range is checked. rtol accepts a point that far outside, relatively.

Parameters:
  • pressure_ratio (float)

  • rps (float)

  • T_evap_C (float | None)

  • rtol (float)

Return type:

bool

__init__(k_v=1.0, k_ov=1.0, k_f=1.0, delta_N=0.0, w_N=1.0, delta_r=0.0, w_r=1.0)
Parameters:
  • k_v (float)

  • k_ov (float)

  • k_f (float)

  • delta_N (float)

  • w_N (float)

  • delta_r (float)

  • w_r (float)

tmhp.compressor_efficiency.IDENTITY_SCALE = CompressorMapScale(k_v=1.0, k_ov=1.0, k_f=1.0, delta_N=0.0, w_N=1.0, delta_r=0.0, w_r=1.0)

The default maps as they are.

tmhp.compressor_efficiency.resolve_scale(scale)[source]

scale, or the identity for None; TypeError for anything else, a subclass included.

Parameters:

scale (CompressorMapScale | None)

Return type:

CompressorMapScale

tmhp.compressor_efficiency.efficiency_extrapolated(scale, pressure_ratio, rps, T_evap_C=None)[source]

Whether the (scaled) maps are evaluated outside their fitting data at (PR, N[, T_e]).

For a result row use PR = P_ref_cmp_out / P_ref_cmp_in, N = cmp_rpm / 60 and T_e = T_ref_evap_sat.

Parameters:
  • scale (CompressorMapScale | None)

  • pressure_ratio (float)

  • rps (float)

  • T_evap_C (float | None)

Return type:

bool

tmhp.compressor_efficiency.reject_invalid_efficiency(function)[source]

Return an infeasible state (None) where a compressor quantity is out of range.

Parameters:

function (TypeVar(_F, bound= Callable))

Return type:

TypeVar(_F, bound= Callable)

Compressor calibration

Fit the compressor scale factors to a heat pump’s catalogue (#189).

A model’s compressor is the default maps of tmhp.compressor_efficiency under a CompressorMapScale (#274). This module finds the scale that makes a model follow a product’s published operating points, and reports which factors the catalogue actually locates:

from tmhp import AirSourceHeatPumpBoiler, calibrate_compressor

def make_model(scale):
    return AirSourceHeatPumpBoiler(ref="R32", hp_capacity=9000.0, V_cmp_ref=42e-6, compressor_scale=scale)

cal = calibrate_compressor(make_model, table_df, columns={"T0": "air_C", "T_w_out": "water_C", "Q": "Q_W", "cop": "COP"})
model = make_model(cal.scale)           # or AirSourceHeatPumpBoiler(..., compressor_scale=cal.scale)
Catalogue tables (table)
"duty"

Each row is a published duty Q [W] at an outdoor air T0 [°C] and a leaving water T_w_out [°C], with its cop. The model is solved at that duty with the EN 14511 water boundary (the water enters the standard’s rise below T_w_out, at the flow that carries Q at that rise; tmhp.standard_conditions.en14511_condenser_water()), as the validation harness and the EnergyPlus plugin do. A row the model delivers more than 1 % short of Q, or meets only as an on/off cycling mean, is infeasible for that candidate.

"max_capacity"

Each row is the unit’s maximum capacity Q at T0 / T_w_out, with its cop. The model is asked for 1.5 Q at the same water boundary and must stop at its ceiling (capacity_clamped == "max"); the delivered heat is compared with Q as well as the COP. A row at which the model meets the whole request has no ceiling below it and is infeasible for that candidate.

Optional columns: T_dis [°C], the published discharge temperature, and rps [rev/s], the published compressor speed at the row.

Residuals (one row may give several)

ln(COP_model / COP_catalogue); with T_dis, (T_dis,model - T_dis,catalogue) / discharge_scale_K; with rps, ln(N_model / N_catalogue); for a "max_capacity" table, ln(Q_model / Q_catalogue). A row a candidate cannot solve gives FAIL_RESIDUAL in each of its residuals and is counted; rows the default model itself cannot solve are left out of the fit before it starts and listed in CompressorCalibration.excluded with their reason.

Factors and what identifies them

k_ov is always free. k_v is free only when the table gives the speed (rps) or is a "max_capacity" table: at a fixed duty the volumetric efficiency changes the speed, not the COP. k_f is free only when the adapter says the table separates it from k_ov: for a boiler table that is a T_dis column (the heat-loss share moves the discharge temperature; a heating COP sees eta_ov and f_loss together). A factor that is never free stays at its identity and is reported "unidentified".

Stages (DEFAULT_STAGES, nested; each refits all its free factors)

L0 k_ov (and k_v) → L1 + k_f → M1 + delta_N → M2 + w_N → M3 + delta_r, w_r. A stage starts from the last adopted one and is judged against it. A rejected stage that adds only level factors does not end the sequence: k_ov alone may fail where k_ov with k_f passes (a discharge temperature pulls k_ov to a bound until k_f is free), and a rejected L1 that adds k_f alone fixes k_f at 1. The first rejected shape stage ends the sequence; the later stages are fitted for the record and not adopted.

Adoption rule (AdoptionRule, provisional until #272)

A stage is adopted when, against the last adopted stage, (1) its k-fold cross-validated RMSE of the residuals drops by at least min_cv_gain (relative), (2) each new factor’s interval at ci_level excludes the factor’s identity, (3) no two free factors correlate beyond max_corr, and (4) no new factor rests on its search bound. Intervals and correlations come from the linearised covariance at the optimum, s² (JᵀJ)⁻¹ with s² = Σr²/(m − p) and the Student-t quantile on m − p degrees of freedom, computed in the internal coordinates (logarithm of a factor, scaled shift) and mapped back. Read the interval as a measure of how flat the error valley is, not as a probability: the residuals of a catalogue are mostly the model’s systematic gap, not random scatter.

Diagnostics (never reject a row or a candidate)

Per row at the chosen scale: the discharge below the isentropic one (f_loss > 1 - eta_ov) with the shell loss Q_cmp_loss, the maps read outside their data (efficiency_extrapolated, eta_ov at the transformed coordinates), and per factor whether it rests on a bound.

Limitation (#275): k_ov and k_f move independently, so the shell heat loss is not tied to the overall efficiency; a calibration can reach a machine whose discharge lies below the isentropic one.

tmhp.compressor_calibration.DEFAULT_BOUNDS: dict[str, tuple[float, float]] = {'delta_N': (-35.0, 35.0), 'delta_r': (-2.0, 1.0), 'k_f': (0.2, 4.0), 'k_ov': (0.3, 3.0), 'k_v': (0.7, 1.3), 'w_N': (0.4, 2.5), 'w_r': (0.4, 2.5)}

Search bounds in factor units. k_f <= 4 keeps the default f_loss (<= 0.244) below one; delta_r <= 1 keeps PR - delta_r positive down to a pressure ratio of 1.

tmhp.compressor_calibration.DEFAULT_STAGES: tuple[tuple[str, tuple[str, ...]], ...] = (('L0', ('k_v', 'k_ov')), ('L1', ('k_v', 'k_ov', 'k_f')), ('M1', ('k_v', 'k_ov', 'k_f', 'delta_N')), ('M2', ('k_v', 'k_ov', 'k_f', 'delta_N', 'w_N')), ('M3', ('k_v', 'k_ov', 'k_f', 'delta_N', 'w_N', 'delta_r', 'w_r')))

the nested stages; a factor the table cannot identify is dropped from each.

Type:

(label, factors)

tmhp.compressor_calibration.FAIL_RESIDUAL = 0.5

Residual of each quantity of a row the candidate cannot solve (about a factor e^0.5 = 1.65 off).

tmhp.compressor_calibration.FACTORS = ('k_v', 'k_ov', 'k_f', 'delta_N', 'w_N', 'delta_r', 'w_r')

The seven factors, in the order of CompressorMapScale.

class tmhp.compressor_calibration.AdoptionRule(min_cv_gain=0.1, ci_level=0.95, max_corr=0.95, bound_tol=0.01, n_folds=5, seed=0, rmse_floor=0.0001)[source]

Bases: object

When a stage is adopted (see the module docstring); provisional until #272.

Parameters:
  • min_cv_gain (float)

  • ci_level (float)

  • max_corr (float)

  • bound_tol (float)

  • n_folds (int)

  • seed (int)

  • rmse_floor (float)

min_cv_gain: float = 0.1
ci_level: float = 0.95
max_corr: float = 0.95
bound_tol: float = 0.01

A new factor within this share of its search range (internal units) from a bound rests on it.

n_folds: int = 5
seed: int = 0
rmse_floor: float = 0.0001

Residual RMSE at or below which a stage is not improved upon (the catalogue is already met).

__init__(min_cv_gain=0.1, ci_level=0.95, max_corr=0.95, bound_tol=0.01, n_folds=5, seed=0, rmse_floor=0.0001)
Parameters:
  • min_cv_gain (float)

  • ci_level (float)

  • max_corr (float)

  • bound_tol (float)

  • n_folds (int)

  • seed (int)

  • rmse_floor (float)

class tmhp.compressor_calibration.BoilerCatalogue(name='AirSourceHeatPumpBoiler (EN 14511)')[source]

Bases: object

tmhp.AirSourceHeatPumpBoiler at an EN 14511 catalogue row (analyze_steady).

The boundary is the validation harness’s and the EnergyPlus plugin’s: the water enters the standard’s rise below the leaving temperature, at the flow that carries the published duty at that rise.

Parameters:

name (str)

name: str = 'AirSourceHeatPumpBoiler (EN 14511)'
solve(model, point, table)[source]
Parameters:
Return type:

PointOutcome

f_loss_identifiable(points)[source]
Parameters:

points (Sequence[CataloguePoint])

Return type:

bool

__init__(name='AirSourceHeatPumpBoiler (EN 14511)')
Parameters:

name (str)

exception tmhp.compressor_calibration.CalibrationVersionError[source]

Bases: ValueError

A saved calibration was fitted on other default maps than the library’s.

class tmhp.compressor_calibration.CatalogueAdapter(*args, **kwargs)[source]

Bases: Protocol

How a family of models is solved at a catalogue row (#189: boilers; #193: air-to-air).

property name: str

A label recorded with the calibration.

solve(model, point, table)[source]

The model at point for a table of kind table; never raises for an infeasible point.

Parameters:
Return type:

PointOutcome

f_loss_identifiable(points)[source]

Whether the rows separate k_f from k_ov.

Parameters:

points (Sequence[CataloguePoint])

Return type:

bool

__init__(*args, **kwargs)
class tmhp.compressor_calibration.CataloguePoint(T0, T_w_out, Q, cop, T_dis=nan, rps=nan)[source]

Bases: object

One catalogue row: outdoor air T0 [°C], leaving water T_w_out [°C], duty Q [W], cop.

T_dis [°C] and rps [rev/s] are NaN when the table does not give them.

Parameters:
  • T0 (float)

  • T_w_out (float)

  • Q (float)

  • cop (float)

  • T_dis (float)

  • rps (float)

T0: float
T_w_out: float
Q: float
cop: float
T_dis: float = nan
rps: float = nan
__init__(T0, T_w_out, Q, cop, T_dis=nan, rps=nan)
Parameters:
  • T0 (float)

  • T_w_out (float)

  • Q (float)

  • cop (float)

  • T_dis (float)

  • rps (float)

class tmhp.compressor_calibration.CompressorCalibration(scale, factors, stages, points, excluded, table, adapter, rule, coefficient_version='ossorio-r290-2026-11-30', trace=<factory>)[source]

Bases: object

The result of calibrate_compressor().

scale is what a model takes (compressor_scale=cal.scale). points has one row per catalogue row: the catalogue values, the default model’s (*_default) and the calibrated model’s (*_cal) predictions, whether each solved, and the diagnostics (below_isentropic, Q_cmp_loss, extrapolated) at the calibrated scale. excluded lists the rows left out before the fit (the default model cannot solve them) with the reason.

Parameters:
scale: CompressorMapScale
factors: dict[str, FactorEstimate]
stages: list[StageRecord]
points: DataFrame
excluded: list[dict[str, Any]]
table: str
adapter: str
rule: AdoptionRule
coefficient_version: str = 'ossorio-r290-2026-11-30'
trace: dict[str, int]
property adopted_stage: str

Label of the last adopted stage ("default" when none was).

stage_scores()[source]

The stages as tmhp.compressor_plots.StageScore (the default maps first).

plot_stages(*, title=None)[source]

tmhp.compressor_plots.plot_calibration_stages() of this calibration.

Parameters:

title (str | None)

plot_parity(*, title=None)[source]

tmhp.compressor_plots.plot_cop_parity(): default maps against the calibrated scale.

Parameters:

title (str | None)

plot_map(quantity='eta_ov', **kwargs)[source]

tmhp.compressor_plots.plot_compressor_map(): the default maps before, scale after.

Parameters:

quantity (str)

to_dict()[source]

A JSON-safe record (NaN as None); from_dict() reads it back.

Return type:

dict[str, Any]

classmethod from_dict(data)[source]

Read to_dict() back; CalibrationVersionError if the default maps have changed since.

The factors scale one set of default maps: on other maps the same numbers describe another machine, so a record of other maps is refused rather than applied.

Parameters:

data (Mapping[str, Any])

Return type:

CompressorCalibration

__init__(scale, factors, stages, points, excluded, table, adapter, rule, coefficient_version='ossorio-r290-2026-11-30', trace=<factory>)
Parameters:
class tmhp.compressor_calibration.FactorEstimate(value, status, estimate=None, ci=None, stage=None, at_bound=False)[source]

Bases: object

One factor: the value the calibrated model uses and how it was reached.

status: "adopted" (free in the adopted stage), "not_adopted" (fitted in a stage that was not adopted; the model keeps its identity) or "unidentified" (the table cannot locate it; never fitted). estimate and ci are from the last stage that fitted it, or None.

Parameters:
  • value (float)

  • status (str)

  • estimate (float | None)

  • ci (tuple[float, float] | None)

  • stage (str | None)

  • at_bound (bool)

value: float
status: str
estimate: float | None = None
ci: tuple[float, float] | None = None
stage: str | None = None
at_bound: bool = False
__init__(value, status, estimate=None, ci=None, stage=None, at_bound=False)
Parameters:
  • value (float)

  • status (str)

  • estimate (float | None)

  • ci (tuple[float, float] | None)

  • stage (str | None)

  • at_bound (bool)

class tmhp.compressor_calibration.PointOutcome(feasible, reason='none', cop=nan, Q=nan, T_dis=nan, rps=nan, pr=nan, T_evap=nan, eta_v=nan, eta_ov=nan, f_loss=nan, Q_cmp_loss=nan, extrapolated=False)[source]

Bases: object

What a model gives at one catalogue row; feasible False carries the reason.

Parameters:
  • feasible (bool)

  • reason (str)

  • cop (float)

  • Q (float)

  • T_dis (float)

  • rps (float)

  • pr (float)

  • T_evap (float)

  • eta_v (float)

  • eta_ov (float)

  • f_loss (float)

  • Q_cmp_loss (float)

  • extrapolated (bool)

feasible: bool
reason: str = 'none'
cop: float = nan
Q: float = nan
T_dis: float = nan
rps: float = nan
pr: float = nan
T_evap: float = nan
eta_v: float = nan
eta_ov: float = nan
f_loss: float = nan
Q_cmp_loss: float = nan
extrapolated: bool = False
property below_isentropic: bool

f_loss > 1 - eta_ov (#275).

Type:

Discharge enthalpy below the isentropic one

__init__(feasible, reason='none', cop=nan, Q=nan, T_dis=nan, rps=nan, pr=nan, T_evap=nan, eta_v=nan, eta_ov=nan, f_loss=nan, Q_cmp_loss=nan, extrapolated=False)
Parameters:
  • feasible (bool)

  • reason (str)

  • cop (float)

  • Q (float)

  • T_dis (float)

  • rps (float)

  • pr (float)

  • T_evap (float)

  • eta_v (float)

  • eta_ov (float)

  • f_loss (float)

  • Q_cmp_loss (float)

  • extrapolated (bool)

class tmhp.compressor_calibration.StageRecord(label, free, scale, rmse_fit, mape_fit, rmse_cv, mape_cv, cv_gain, max_corr, ci, at_bound, infeasible_rows, adopted, reason)[source]

Bases: object

One fitted stage: free factors, fitted scale, scores and the adoption decision.

Parameters:
  • label (str)

  • free (tuple[str, ...])

  • scale (dict[str, float])

  • rmse_fit (float)

  • mape_fit (float)

  • rmse_cv (float | None)

  • mape_cv (float | None)

  • cv_gain (float | None)

  • max_corr (float | None)

  • ci (dict[str, tuple[float, float]])

  • at_bound (tuple[str, ...])

  • infeasible_rows (int)

  • adopted (bool)

  • reason (str)

label: str
free: tuple[str, ...]
scale: dict[str, float]
rmse_fit: float
mape_fit: float
rmse_cv: float | None
mape_cv: float | None
cv_gain: float | None
max_corr: float | None
ci: dict[str, tuple[float, float]]
at_bound: tuple[str, ...]
infeasible_rows: int
adopted: bool
reason: str
__init__(label, free, scale, rmse_fit, mape_fit, rmse_cv, mape_cv, cv_gain, max_corr, ci, at_bound, infeasible_rows, adopted, reason)
Parameters:
  • label (str)

  • free (tuple[str, ...])

  • scale (dict[str, float])

  • rmse_fit (float)

  • mape_fit (float)

  • rmse_cv (float | None)

  • mape_cv (float | None)

  • cv_gain (float | None)

  • max_corr (float | None)

  • ci (dict[str, tuple[float, float]])

  • at_bound (tuple[str, ...])

  • infeasible_rows (int)

  • adopted (bool)

  • reason (str)

tmhp.compressor_calibration.calibrate_compressor(make_model, points, *, columns=None, table='duty', adapter=None, stages=(('L0', ('k_v', 'k_ov')), ('L1', ('k_v', 'k_ov', 'k_f')), ('M1', ('k_v', 'k_ov', 'k_f', 'delta_N')), ('M2', ('k_v', 'k_ov', 'k_f', 'delta_N', 'w_N')), ('M3', ('k_v', 'k_ov', 'k_f', 'delta_N', 'w_N', 'delta_r', 'w_r'))), rule=None, bounds=None, discharge_scale_K=50.0)[source]

Fit the scale factors of the default compressor maps to a catalogue (see the module docstring).

Parameters:
  • make_model (Callable[[CompressorMapScale], Any]) – make_model(scale) builds a NEW model with compressor_scale=scale (called once per candidate scale; a model is never changed in place).

  • points (DataFrame) – The catalogue, one row per operating point.

  • columns (Mapping[str, str] | None) – Maps the quantities T0, T_w_out, Q, cop (required) and T_dis, rps (optional) to column names of points; a quantity not mapped is read from the column of its own name.

  • table (str) – "duty" or "max_capacity".

  • adapter (CatalogueAdapter | None) – How a row is solved; BoilerCatalogue by default.

  • stages (Sequence[tuple[str, Sequence[str]]]) – (label, factors) pairs, nested; DEFAULT_STAGES.

  • rule (AdoptionRule | None) – AdoptionRule; the provisional default until #272.

  • bounds (Mapping[str, tuple[float, float]] | None) – Search bounds per factor, over DEFAULT_BOUNDS.

  • discharge_scale_K (float) – A discharge-temperature error of this many kelvin weighs like a COP off by a factor e (50 K: 1 K weighs like 2 % of COP).

Return type:

CompressorCalibration

Compressor envelope

Compressor operating envelope shared by every cycle-resolved heat-pump model.

A real compressor runs inside an envelope that its manufacturer publishes and its controller enforces. Five limits matter for the single-stage vapour compression cycle TMHP solves, and this module holds the rule for each so the five families (ASHP, GSHP, ASHPB, GSHPB, WSHPB) apply them identically.

Pressure ratio (PR_cycle_min / PR_cycle_max)

The physically primary lift limit is the pressure ratio PR = P_cond / P_evap, not a fixed temperature lift: the lift needed to reach a given PR maps non-linearly through the saturation curve and differs by refrigerant and level, so a fixed minimum lift (e.g. 20 K) over- or under-states the true limit; a PR floor is transferable. Scroll axial loading / built-in volume ratio, the oil-feed pressure difference and the collapse of compression efficiency place the floor near PR ~ 1.5 (1.3–2.0); below it the cycle is clamped onto the floor. The ceiling is the single-stage scroll’s hardware limit, about 11:1 (self-unloading of AC scrolls; Cuevas & Lebrun 2009; Bertsch & Groll 2008; Gayeski et al. 2011); above it the point is rejected (PR_ABOVE_MAX). Every family defaults to PR_CYCLE_MAX_SINGLE_STAGE. Higher ratios belong to two-stage or vapour-injection machines, which the single-stage cycle does not describe. Since the discharge-temperature limit below binds first almost everywhere, the ratio ceiling acts as a hardware sanity bound.

Discharge temperature (T_dis_max)

Lubricant breakdown and valve / motor temperature limit the gas leaving the compressor. Compressor application guides give the protection setting: Danfoss SH scrolls (R410A) “discharge gas temperature must not exceed 135 degC”; Danfoss PSH (R410A/R454B) start wet injection at 121 degC with a 135 degC maximum safety value; the external discharge-gas protection of Danfoss DSF scrolls (R32, which “leads to higher discharge temperatures than R410A”) opens at 150 degC at most. Unit controllers act earlier on the discharge pipe temperature (Daikin room units reduce frequency from about 100 degC and stop at 110–120 degC). A point whose computed discharge temperature exceeds the limit is not an operating point (DISCHARGE_TEMP_ABOVE_MAX). The defaults, one per refrigerant (DISCHARGE_TEMP_MAX_C, default_discharge_temp_max()), are the protection values – R32 150 degC, every other fluid 135 degC – not the controllers’ earlier set points: the cycle’s discharge state is the gas leaving the compression, after the shell heat loss of the compressor maps (f_loss, fitted to measured discharge temperatures, tmhp.compressor_efficiency) and with no pipe heat loss after it, which is the temperature the protection values refer to; a controller’s pipe sensor reads lower. A scale that removes the shell loss (k_f = 0, so f_loss = 0) sends every loss into the gas and gives an upper estimate of the machine’s.

Discharge-temperature control comes first (discharge_controlled(), x_suction_min). A unit whose discharge runs hot does not stop: its controller opens the expansion valve, so the suction superheat falls, and then lets the suction go wet or injects liquid. The cycle at a candidate operating point is therefore re-solved, compressor speed included, first with the suction superheat reduced from its value towards 0 K until the discharge temperature equals T_dis_max, then – if 0 K is not enough – with a two-phase suction of quality x lowered towards x_suction_min. Its default "auto" is the refrigerant’s value (X_SUCTION_MIN, default_x_suction_min(); provisionally 0.9 for every fluid), and a number given by the caller takes precedence. Wet suction is modelled as a homogeneous two-phase state at the evaporating pressure (see tmhp.refrigerant.calc_ref_state()); the evaporator outlet is then two-phase, the swept mass flow follows the homogeneous density, and the isentropic work is that of the two-phase state, so the cycle energy balance stays closed. The efficiency maps were fitted to dry suction, so applying them to wet suction is an approximation. Only a point that is still above the limit at x_suction_min is outside the envelope. x_suction_min=1 keeps the superheat stage only; None switches the control off.

Known limitation: this control is the model’s assumption, not a confirmed description of how heat pumps hold their discharge temperature. Neither the order (superheat to 0 K, then suction quality, then a smaller duty), nor stopping at the driest suction state that meets T_dis_max, nor bounding the wet suction by its quality has been confirmed against a manufacturer’s control. One patent describes a similar order (Daikin, US 6,581,397 B1, FIG. 10: wet the suction down to quality 0.85–0.75 once the discharge pipe exceeds 125–135 degC, then lower the compressor frequency) without naming the compressor type or the test. Units also hold a discharge or discharge-superheat target with the expansion valve, and compressor makers bound liquid return by the oil or shell superheat rather than by the suction quality. The per-refrigerant quality floors are placeholders until the literature collected on issue #216 is reviewed (issue #229).

How a family answers a point the control cannot bring inside the limit: the space-conditioning models (ASHP, GSHP) reject the candidate inside the operating-point search, so the search moves to a smaller lift if one carries the duty, and otherwise the existing capacity search returns the largest duty the envelope allows with capacity_clamped='max' and capacity_binding='discharge_temperature'. The boilers (fixed requested duty) check the solved operating point; analyze_steady then tries smaller duties (steady_envelope()) and returns the largest one inside the limit the same way, or the off state with failure_reason='discharge_temp_above_max' when even a small duty exceeds it. A dynamic boiler step does the same with its one cycle solve per step (reduce_duty_within_envelope()): it runs at the reduced duty, or is an off step with that reason when no duty fits. The boilers answer every limit a smaller duty cures this way – the pressure-ratio ceiling and the source heat exchanger’s range as well (duty_reduction_binding()); capacity_binding names the limit. The envelope also has a lower side: at a large lift the overall efficiency falls towards low speed, so the discharge runs hotter there (past the limit even with the control used up) – while larger duties run. A boiler’s analyze_steady answers a request refused there with the smallest duty that runs (raise_duty_within_envelope(), capacity_clamped='min'), which is then reported as the mean of on/off cycling like a request below the minimum speed; AirSourceHeatPump does the same in its own search. failure_reason='discharge_temp_above_max' is left for a condition at which no duty runs.

Condensing pressure (T_cond_max)

The top of every published envelope is a maximum condensing temperature, which is a maximum high-side pressure: the shell, the scroll set and the motor are built for it, and the unit’s high-pressure switch stops the compressor just above it. T_cond_max is that limit as the saturation temperature of the condensing pressure [degC]; the check compares pressures, P_cond > P_dew(T_cond_max) (for a zeotropic blend the envelope temperature is the dew point; the cycle’s own condensing temperature is the bubble point, lower by the glide – R407C reaches the 65 degC limit at 61.2 degC). The defaults (CONDENSING_TEMP_MAX_C, default_condensing_temp_max()) are the upper end of the high-side working range of compressors sold for each fluid:

fluid

degC

basis

R410A

65

Copeland ZP*K3E/K5E application envelope tops at about 65.5 degC (replacement guidelines C050202, fig. 2); Danfoss PSH019-039 “65 degC saturated condensing temperature”; Danfoss DSH working range to 41.7 bar(g) = 64.9 degC.

R32

65

Danfoss DSF090 working range high side to 43 bar(g) = 65.2 degC; Copeland YP (R32) is stated to cover the field of application of the R410A scrolls.

R407C

65

Danfoss HHP heat-pump scrolls: working range high side to 27.4 bar(g) = 65.0 degC dew (Copeland ZR envelope: about 67 degC).

R290

75

Copeland ZH04KCU-ZH16KCU heat-pump scrolls: high-side PS 28 bar(g) = 76.0 degC (Danfoss VZN: working range to 31.5 bar(g) = 82 degC).

R134a

80

Danfoss VZN with R513A (the R134a pressure class): working range high side to 25.9 bar(g), 81.0 degC as R134a.

R1234yf

75

no envelope published for this fluid was found; the R134a pressure class (25.9 bar(g)) would allow 83.3 degC. 75 degC is about 20 K below the critical point (94.7 degC), as for R290 (96.7 degC).

R1234ze(E)

90

Danfoss PSG605-800: working range to 25.3 bar(g) = 93.0 degC.

R600a

100

Danfoss PSG605-800: working range to 19.6 bar(g) = 102.0 degC.

R717

70

the 40 bar class of ammonia heat-pump compressors (GEA Grasso V HP, 39 bar, hot water about 70 degC); 50 and 63 bar machines reach 82-95 degC.

No default exceeds the saturation temperature at CONDENSING_PRESSURE_MAX_REDUCED (0.9) of the critical pressure, and that alone is the default of a fluid not in the table: no published envelope reaches it, and next to the critical point the condenser has almost no latent heat left (R744 gets 26.4 degC: its heat pumps are transcritical, which this subcritical cycle does not describe). A machine with a different high-pressure rating is given its own T_cond_max; None switches the check off.

A point above the limit is not an operating point (CONDENSING_TEMP_ABOVE_MAX), and it is answered like the discharge limit below, because the condensing temperature is the demand-side temperature plus the condenser approach and the approach shrinks with the duty: the space-conditioning models reject the candidate inside the operating-point search, the boilers reduce the duty (reduce_duty_within_envelope()) and report capacity_clamped='max' with capacity_binding='condensing_temperature'. The boundary duty is found by a secant on the condensing temperature (_duty_on_condensing_limit(): three cycle solves in all, instead of the ladder and bisection of the other limits), so a dynamic step that runs against the limit stays cheap. When the demand side is itself at the limit (a tank at T_cond_max) no duty runs: the off state with failure_reason='condensing_temp_above_max'.

A boiler’s thermostat is told where the envelope ends (limit_tank_setpoints_to_envelope()): an upper set point above the tank temperature at which the nameplate duty condenses on the limit (condensing_tank_cutout()) is capped there at construction, with an OperatingLimitWarning. A dynamic step solves one cycle and applies its heat over the step, so without the cap a long step overran the limit and the temperature at which the heat pump stopped depended on the step.

That is the boiler constructors’ condensing_limit_control="stop", the default: a fixed-speed unit, or one whose controller ends the charge on its high-pressure protection. "reduce_duty" is the inverter unit, which slows the compressor on the limit and keeps charging: a dynamic step then runs past the nameplate cut-out at the largest duty inside the limit, K_tank_hx (T_reach - T) (condensing_tank_reach()), which is what analyze_steady reports there. The tank approaches T_reach as a first-order lag with the time constant C_tank / K_tank_hx (about five minutes for the default 151 L tank and 15 kW unit), which the in-step thermostat follows in closed form (tmhp.dynamic_context.resolve_step_operation()): the run time and the heat of a step on this limit do not depend on the step (the tank temperature a step ends at is still one implicit solve with the loss at its end, as with "stop", so a tank that loses much heat needs short steps). The charge ends where the limit leaves less than the smallest duty the compressor runs at continuously (smallest_continuous_duty(): the speed floor, or the envelope’s lower side). That duty depends on the source, so each step applies the stop of its own conditions (smallest_duty_on_condensing_limit()); the thermostat’s cap is the stop at one stated reference source (limit_tank_setpoints_to_charge_limit()).

That treatment covers the source states in which the condensing limit is the one that governs the stretch from the nameplate cut-out to that stop. Each source state is checked once, with three cycles (condensing_stretch()). Where another limit governs somewhere on the stretch – the source fluid’s freezing limit, the pressure-ratio ceiling, a discharge-temperature ceiling, the compressor’s speed ceiling at a cold source – reduced-duty charging is withheld for the step: it is solved exactly as "stop" solves it, and the row names what withheld it (reduced_duty_withheld).

Speed (rps_min / rps_max)

rps_min is the inverter’s floor (15 rev/s). rps_max defaults to default_rps_max() of the rated speed the model solves at its rating point: RPS_MAX_ABSOLUTE (120 rev/s), or 1.5 times the rated speed where that is higher. The rated speed itself is solved over [rps_min, RATED_SPEED_SEARCH_MAX].

Efficiency domain

The compressor maps are followed as they are outside their data (speed range and (PR, T_e) hull, tmhp.compressor_efficiency); the envelope sets no limit on an efficiency. Steady results carry efficiency_extrapolated so a caller can see a point evaluated outside the data of a map (the eta_ov map at its scaled coordinates).

tmhp.compressor_envelope.check_pr_envelope(pr, pr_min, pr_max)[source]

Classify a compressor pressure ratio against the operating envelope.

Returns None when pr_min <= pr <= pr_max (feasible); otherwise PR_BELOW_MIN or PR_ABOVE_MAX.

Parameters:
  • pr (float)

  • pr_min (float)

  • pr_max (float)

Return type:

str | None

tmhp.compressor_envelope.PR_BELOW_MIN = 'pr_below_min'

pressure ratio is below PR_cycle_min (floor -> clamp).

Type:

Reason code

tmhp.compressor_envelope.PR_ABOVE_MAX = 'pr_above_max'

pressure ratio is above PR_cycle_max (ceiling -> reject).

Type:

Reason code

tmhp.compressor_envelope.PR_CYCLE_MAX_SINGLE_STAGE = 11.0

the single-stage scroll hardware limit.

Type:

Default PR_cycle_max of every family

tmhp.compressor_envelope.DISCHARGE_TEMP_ABOVE_MAX = 'discharge_temp_above_max'

every duty tried, smaller and larger, exceeds T_dis_max.

Type:

failure_reason

tmhp.compressor_envelope.DISCHARGE_TEMP_MAX_C: Mapping[str, float] = {'IsoButane': 135.0, 'R1234yf': 135.0, 'R1234ze(E)': 135.0, 'R134a': 135.0, 'R290': 135.0, 'R32': 150.0, 'R407C': 135.0, 'R410A': 135.0, 'R600a': 135.0, 'R717': 135.0}

Default discharge-temperature limit by refrigerant [degC]; see the module docstring.

Only R410A (Danfoss SH / PSH, 135 degC) and R32 (Danfoss DSF, 150 degC) rest on a protection value published for the fluid. Every other entry is the 135 degC of DISCHARGE_TEMP_MAX_DEFAULT_C, set provisionally so that each refrigerant has its own value to replace (issue #229).

tmhp.compressor_envelope.DISCHARGE_TEMP_MAX_DEFAULT_C = 135.0

Default for every refrigerant not in DISCHARGE_TEMP_MAX_C [degC].

tmhp.compressor_envelope.DISCHARGE_TOL_K = 0.01

Tolerance of every discharge-temperature comparison [K]. The control solves T_dis = T_dis_max by root finding, so the check that follows has to accept the root’s own residual (1e-5 K for the predicted closure, ~1e-3 K for the bracketing fallback); 0.01 K is far below any meaning the limit has.

tmhp.compressor_envelope.CONDENSING_TEMP_ABOVE_MAX = 'condensing_temp_above_max'

even the smallest duty tried condenses above T_cond_max.

Type:

failure_reason

tmhp.compressor_envelope.CONDENSING_TEMP_MAX_C: Mapping[str, float] = {'IsoButane': 100.0, 'R1234yf': 75.0, 'R1234ze(E)': 90.0, 'R134a': 80.0, 'R290': 75.0, 'R32': 65.0, 'R407C': 65.0, 'R410A': 65.0, 'R600a': 100.0, 'R717': 70.0}

Default maximum condensing temperature by refrigerant [degC] (saturation temperature of the highest condensing pressure; dew point for a blend). Sources in the module docstring.

tmhp.compressor_envelope.CONDENSING_PRESSURE_MAX_REDUCED = 0.9

No default condensing pressure exceeds this fraction of the critical pressure; it alone is the default of a refrigerant not in CONDENSING_TEMP_MAX_C.

tmhp.compressor_envelope.CONDENSING_TOL_K = 0.01

Tolerance of every condensing-temperature comparison [K]. The duty reduction solves T_cond = T_cond_max for the duty, so the check that follows has to accept that root’s residual (round-off for a tank whose condensing approach is Q / UA); 0.01 K is far below any meaning the limit has, and it keeps the verdict the same on every platform.

tmhp.compressor_envelope.ENVELOPE_REJECTIONS = frozenset({'condensing_temp_above_max', 'discharge_temp_above_max'})

Reasons with which the envelope rejects a candidate of the space-conditioning searches (_last_pr_event[0]); they are reported as the failure_reason.

tmhp.compressor_envelope.default_condensing_temp_max(ref)[source]

Default maximum condensing temperature for refrigerant ref [degC].

The value of CONDENSING_TEMP_MAX_C, never above the dew point at CONDENSING_PRESSURE_MAX_REDUCED of the critical pressure; that dew point alone for a refrigerant not in the table.

Parameters:

ref (str)

Return type:

float

tmhp.compressor_envelope.resolve_condensing_temp_max(value, ref)[source]

Constructor argument -> limit: "auto" the refrigerant default, None no check.

A number is the caller’s statement about the machine and is used as given; it has to lie below the critical temperature (above it the fluid has no condensing pressure to compare with).

Parameters:
  • value (Union[float, Literal['auto'], None])

  • ref (str)

Return type:

float | None

tmhp.compressor_envelope.condensing_pressure_max(ref, T_cond_max)[source]

Highest condensing pressure of the envelope [Pa]: the dew pressure at T_cond_max.

Parameters:
  • ref (str)

  • T_cond_max (float | None)

Return type:

float | None

tmhp.compressor_envelope.condensing_temp_exceeded(P_cond, T_cond_max, ref)[source]

Whether a condensing pressure [Pa] is above the dew pressure at T_cond_max.

Compared with CONDENSING_TOL_K of margin. T_cond_max=None switches the check off; a pressure that is not a finite number is not judged here (a state without one is refused elsewhere).

Parameters:
  • P_cond (object)

  • T_cond_max (float | None)

  • ref (str)

Return type:

bool

tmhp.compressor_envelope.condensing_violation(result, model)[source]

CONDENSING_TEMP_ABOVE_MAX if a solved state condenses above model.T_cond_max, else None.

The refused state’s condensing temperature (dew point of its pressure) is left on the model as _condensing_refused_C, where the duty reduction reads it (_duty_on_condensing_limit()).

Parameters:
  • result (Mapping[str, Any])

  • model (Any)

Return type:

str | None

tmhp.compressor_envelope.check_rated_condensing(model, T_cond_sat_C, standard)[source]

Why a rating point is outside the condensing limit, or None.

T_cond_sat_C is the condensing temperature the reference state solved (the cycle’s bubble point). The message names the limit and what to change; tmhp.reference_state raises it at construction.

Parameters:
  • model (Any)

  • T_cond_sat_C (float)

  • standard (str)

Return type:

str | None

tmhp.compressor_envelope.condensing_tank_reach(model)[source]

Tank temperature at which the condensing limit leaves a boiler no duty [degC].

The hottest the cycle may condense: the bubble point of the limit pressure (T_cond_max itself for a pure fluid, lower by the glide for a blend). A duty Q needs the tank Q / K_tank_hx colder than this (condensing_tank_cutout() for the nameplate duty). None without a limit.

Parameters:

model (Any)

Return type:

float | None

tmhp.compressor_envelope.condensing_tank_cutout(model)[source]

Highest tank temperature a boiler heats at its nameplate duty inside the condensing limit [degC].

The cycle condenses at the tank temperature plus the tank heat exchanger’s approach, hp_capacity / K_tank_hx at the nameplate duty (K_tank_hx: the heat the exchanger carries per kelvin above the tank water, the water entering a plate condenser), and the hottest it may condense is the bubble point of the limit pressure. None without a limit.

Parameters:

model (Any)

Return type:

float | None

tmhp.compressor_envelope.limit_tank_setpoints_to_envelope(model, what)[source]

Cap a boiler’s thermostat band at the tank temperature its compressor envelope allows.

A heat pump whose set point lies above what its compressor can reach does not charge the tank to it: the controller stops at the unit’s maximum. The thermostat has to know that temperature – a dynamic step solves one cycle and applies its heat over the step, so a cut-out the thermostat does not see is overrun inside a long step, by an amount that depends on the step. So when T_tank_w_upper_bound is above condensing_tank_cutout(), the model’s upper bound becomes that cut-out; a lower bound that is not below it is moved down to keep the width of the band. The values asked for stay in T_tank_w_setpoints_requested (lower, upper), and an OperatingLimitWarning (a UserWarning) says what was changed. Up to the cut-out the machine runs at its nameplate duty; the duty reduction of reduce_duty_within_envelope() then serves analyze_steady and the steps a tank model or a minimum run time takes past it.

This is condensing_limit_control="stop". With "reduce_duty" the band is only recorded here; the cap is the charging limit, set once the model can solve a cycle (limit_tank_setpoints_to_charge_limit()).

Parameters:
  • model (Any)

  • what (str)

Return type:

None

tmhp.compressor_envelope.CONDENSING_LIMIT_CONTROLS: tuple[str, ...] = ('stop', 'reduce_duty')

Values of the boilers’ condensing_limit_control.

tmhp.compressor_envelope.CONTROL_STOP = 'stop'

the charge ends where the nameplate duty meets the condensing limit.

Type:

condensing_limit_control

tmhp.compressor_envelope.CONTROL_REDUCE_DUTY = 'reduce_duty'

the compressor reduces its duty on the limit and keeps charging.

Type:

condensing_limit_control

tmhp.compressor_envelope.resolve_condensing_limit_control(value)[source]

Constructor argument -> one of CONDENSING_LIMIT_CONTROLS.

Parameters:

value (object)

Return type:

str

tmhp.compressor_envelope.smallest_continuous_duty(model, solve, delivered_key='Q_ref_tank [W]')[source]

Smallest duty a boiler’s compressor runs at continuously at one operating point [W].

solve(q) solves the point at duty q. The probe is the smallest duty the duty reduction itself tries, the lowest rung of its ladder at the nameplate request (0.1 hp_capacity), so the answer is the floor analyze_steady has for a nameplate request at this point:

  • the probe runs with the compressor on its speed floor: what the machine delivers there (more than the probe);

  • the probe runs as asked: the probe itself (the reduction looks no lower);

  • the envelope refuses it from below (the discharge temperature at low speed): the smallest duty that runs above it (raise_duty_within_envelope()).

None when no such duty runs (the point is beyond the condensing limit at every duty, or refused for another reason). The solves run silently.

Parameters:
  • model (Any)

  • solve (Callable[[float], Any])

  • delivered_key (str)

Return type:

float | None

tmhp.compressor_envelope.smallest_duty_on_condensing_limit(model, floor_at)[source]

Smallest continuous duty of a boiler where that duty condenses on the limit [W].

floor_at(T) is the smallest continuous duty at tank temperature T [degC] (smallest_continuous_duty() at the source of interest). The tank temperature at which it condenses on the limit is T_reach - floor / K_tank_hx (condensing_tank_reach()); the floor depends on that temperature only through the condensing pressure, weakly, so a fixed-point iteration from the nameplate cut-out closes in two or three evaluations (to _FLOOR_CLOSE_K). A trial the limit refuses is retried half-way back.

The search stays where a tank can be: no trial is above the boiling point of the stored water (tmhp.dynamic_context.T_WATER_BOIL_C, the upper end of the tank temperatures the models accept). A refrigerant whose limit lies high enough (R600a with T_cond_max above about 101 °C) meets its smallest duty above 100 °C; the duty returned is then the one at 100 °C, the tank temperature it gives (T_reach - duty / K_tank_hx) is above the boiling point, and the boiling cut-out, not the condensing limit, ends the charge.

Above the tank temperature the returned duty gives, T_reach - duty / K_tank_hx, no duty runs: the charging limit of condensing_limit_control="reduce_duty". None without a condensing limit, or when no duty below the nameplate runs at the nameplate cut-out (there is then no reduced stretch: the cut-out is the limit).

Parameters:
  • model (Any)

  • floor_at (Callable[[float], float | None])

Return type:

float | None

tmhp.compressor_envelope.steady_smallest_duty(model, **source)[source]

floor_at of smallest_duty_on_condensing_limit() from a boiler’s analyze_steady.

source are the steady call’s source arguments (T0=... or T_source=...). The probe request of smallest_continuous_duty() is solved by analyze_steady itself; a row on the speed floor carries the continuous duty in Q_min [W] (the row is the on/off mean).

Parameters:
  • model (Any)

  • source (Any)

Return type:

Callable[[float], float | None]

tmhp.compressor_envelope.limit_tank_setpoints_to_charge_limit(model, what, floor_at, reference)[source]

Cap a reduced-duty boiler’s thermostat band at its charging limit.

The counterpart of limit_tank_setpoints_to_envelope() for condensing_limit_control="reduce_duty", called at the end of construction (it solves cycles). Past the nameplate cut-out the compressor charges on at the duty the condensing limit leaves, down to its smallest continuous duty; the charging limit is the tank temperature at which that duty condenses on the limit, T_reach - Q_min / K_tank_hx (smallest_duty_on_condensing_limit() with floor_at). An upper set point above it becomes it, the lower one keeps the band’s width, the values asked for stay in T_tank_w_setpoints_requested and an OperatingLimitWarning says what was changed.

The smallest continuous duty depends on the source (a warmer source gives the compressor denser suction gas, so more duty at its lowest speed, and the limit is met at a colder tank). The cap is evaluated once, at the source floor_at solves at – reference names it in the warning – and each dynamic step applies the stop of its own source: below the cap the compressor then stops at that stop (hp_stop_reason == "condensing_limit") and, while the call stands, holds the tank there or, with a minimum rest time, rests and restarts (duty_limit of tmhp.dynamic_context.simulate_thermostat_step()). A set point at or below the nameplate cut-out needs no cycle solve and is left alone. For a blend the warning names the bubble point the tank is held below as well as T_cond_max, the dew point of the same pressure.

Parameters:
  • model (Any)

  • what (str)

  • floor_at (Callable[[float], float | None])

  • reference (str)

Return type:

None

tmhp.compressor_envelope.on_condensing_limit(model, result, request, delivered_key='Q_ref_tank [W]')[source]

Capacity keys of a cycle a dynamic step ran on the condensing limit (in place).

A step of condensing_limit_control="reduce_duty" solves the stretch it spends on the limit directly at the limit’s duty, so the duty reduction (reduce_duty_within_envelope()) has nothing to reduce and writes no keys. The row is the one that reduction lands on for the nameplate request, and gets its keys: capacity_clamped = "max", Q_max [W], Q_request [W] and capacity_binding – the condensing limit, unless the solve was itself reduced further onto another limit, which then names it. An off row is returned unchanged.

Parameters:
  • model (Any)

  • result (dict)

  • request (float)

  • delivered_key (str)

Return type:

dict

tmhp.compressor_envelope.condensing_stretch(solve, T_zero_C, K, Q_knee, min_duty, delivered_key='Q_ref_tank [W]')[source]

The stretch a reduced-duty step charges on at one source state: (Q_min, None), or (None, what withholds it).

A step of condensing_limit_control="reduce_duty" integrates the tank along the condensing limit’s duty, K (T_zero_C - T) [W] (tmhp.dynamic_context.DutyLimit), from the knee – the tank temperature at which that duty is Q_knee, the nameplate duty – to the stop, where it is Q_min, the smallest continuous duty (min_duty(): smallest_duty_on_condensing_limit() at this source; neither point above the boiling point of the stored water). That is the tank’s path only if the condensing limit is the limit that governs the whole stretch. This function checks it for one source state, with three cycles: solve(T, q) – the step’s cycle at tank temperature T [degC] asked for duty q [W], solved with the source as the step finds it – at the knee, at the middle of the stretch and at the stop, each asked for the limit’s duty there. The stretch qualifies if each of them runs, delivers that duty to tmhp.dynamic_context.DUTY_MATCH_RTOL, and names no limit but the condensing one; Q_min is then returned.

Otherwise reduced-duty charging is withheld at this source state, and the first check that fails says by what (later ones are not made; the knee comes first, before the search for Q_min, which is the costly part):

  • a cycle that does not run: its failure_reason ("source_fluid_freezing", "discharge_temp_above_max", …);

  • a cycle held at another duty, or naming another limit: its capacity_binding ("discharge_temperature", "source_fluid_freezing", …), and BINDING_COMPRESSOR for one that names none – the compressor at its speed ceiling, which a cold source leaves short of the nameplate duty at the knee;

  • no Q_min below Q_knee (None, or not smaller): WITHHELD_NO_SMALLER_DUTY.

The answer is a property of the machine and the source state: it does not depend on the step, nor on where the tank is. The boilers keep it for as long as the source state stays the same. Three points are a sample: a limit that acts only strictly between two of them is not seen. The check assumes that a limit which leaves the knee, the middle and the stop alone leaves the stretch between them alone. Where one does not, the check each step makes of its own cycles (tmhp.dynamic_context.resolve_step_operation()) withholds the steps whose cycle lands on it; which steps those are depends on the step length and the tank temperature, so the charge at that source state then depends on the step size. The solves run silently.

Parameters:
  • solve (Callable[[float, float], Any])

  • T_zero_C (float)

  • K (float)

  • Q_knee (float)

  • min_duty (Callable[[], float | None])

  • delivered_key (str)

Return type:

tuple[float | None, str | None]

tmhp.compressor_envelope.WITHHELD_NO_SMALLER_DUTY = 'no_smaller_duty'

no continuous duty below the nameplate runs on the condensing limit at this source, so there is no stretch to charge on.

Type:

condensing_stretch()

tmhp.compressor_envelope.BINDING_DISCHARGE = 'discharge_temperature'

the duty was reduced to stay within T_dis_max.

Type:

capacity_binding

tmhp.compressor_envelope.BINDING_CONDENSING = 'condensing_temperature'

the duty was reduced to stay within T_cond_max.

Type:

capacity_binding

tmhp.compressor_envelope.BINDING_PRESSURE_RATIO = 'pressure_ratio'

the duty was reduced to stay within PR_cycle_max.

Type:

capacity_binding

tmhp.compressor_envelope.BINDING_HEAT_EXCHANGER = 'source_heat_exchanger'

the duty was reduced to what the source heat exchanger carries within its flow range (ASHPB reports "outdoor_coil").

Type:

capacity_binding

tmhp.compressor_envelope.BINDING_CYCLE = 'cycle'

the next larger duty has no valid cycle, for a reason none of the above names.

Type:

capacity_binding

tmhp.compressor_envelope.BINDING_COMPRESSOR = 'compressor'

the compressor runs at its speed ceiling (rps_max).

Type:

capacity_binding

tmhp.compressor_envelope.CYCLE_KEY = '_cycle'

Key under which a candidate whose heat exchanger did not close keeps its solved cycle.

tmhp.compressor_envelope.duty_reduction_binding(result, bindings=None)[source]

The limit a failed fixed-duty result ran into, if a smaller duty may run; else None.

The value is the capacity_binding a reduced point reports. bindings lets a family rename one (the ASHPB’s heat exchanger is its outdoor coil).

Parameters:
  • result (Mapping[str, Any])

  • bindings (Mapping[str, str] | None)

Return type:

str | None

tmhp.compressor_envelope.default_discharge_temp_max(ref)[source]

Default discharge-temperature limit for refrigerant ref [degC].

Parameters:

ref (str)

Return type:

float

tmhp.compressor_envelope.resolve_discharge_temp_max(value, ref)[source]

Constructor argument -> limit: "auto" the refrigerant default, None no check.

Parameters:
  • value (Union[float, Literal['auto'], None])

  • ref (str)

Return type:

float | None

tmhp.compressor_envelope.discharge_temp_exceeded(T_dis_C, T_dis_max)[source]

Whether a discharge temperature [degC] violates T_dis_max.

A non-finite discharge temperature (no discharge state: the enthalpy left the fluid’s equation of state) counts as exceeded. T_dis_max=None switches the check off.

Parameters:
  • T_dis_C (object)

  • T_dis_max (float | None)

Return type:

bool

tmhp.compressor_envelope.discharge_violation(result, T_dis_max)[source]

DISCHARGE_TEMP_ABOVE_MAX if a solved state exceeds T_dis_max, else None.

Parameters:
  • result (Mapping[str, Any])

  • T_dis_max (float | None)

Return type:

str | None

tmhp.compressor_envelope.envelope_violation(result, model)[source]

Why a solved running state is outside the compressor envelope, or None.

CONDENSING_TEMP_ABOVE_MAX or DISCHARGE_TEMP_ABOVE_MAX (after the discharge-temperature control). The condensing pressure is judged first: it does not depend on the efficiency model or on the control, and a smaller duty always lowers it.

Parameters:
  • result (Mapping[str, Any])

  • model (Any)

Return type:

str | None

tmhp.compressor_envelope.envelope_excess(result, model)[source]

How far a solved running state is outside the envelope, as a ranking weight [W-equivalent].

0 inside. 1000 per kelvin of discharge above T_dis_max (beyond DISCHARGE_TOL_K; an undefined discharge state counts as very far) and per kelvin of condensing above T_cond_max (beyond CONDENSING_TOL_K). Used by searches to rank candidates outside the envelope among themselves.

Parameters:
  • result (Mapping[str, Any])

  • model (Any)

Return type:

float

tmhp.compressor_envelope.RPS_MAX_ABSOLUTE = 120.0

7200 rpm, the upper end of the speed ranges inverter rotary compressors of heat-pump size are specified for (see default_rps_max()) …

Type:

rps_max default [rev/s]

tmhp.compressor_envelope.RPS_MAX_MIN_PER_RATED = 1.5

… and never less than this multiple of the rated speed (catalogue maximum / rated capacity <= 1.52).

tmhp.compressor_envelope.RATED_SPEED_SEARCH_MAX = 150.0

Upper speed bound for solving the rated speed when rps_max is not given [rev/s].

tmhp.compressor_envelope.default_rps_max(rps_rated)[source]

Default upper speed bound from the rated speed [rev/s].

max(120, 1.5 * rps_rated): RPS_MAX_ABSOLUTE for every machine rated at 80 rev/s or below.

The ceiling is a property of the compressor, not of the nameplate. Manufacturer documents specify inverter rotary compressors of heat-pump size for 12–120 rev/s (8.9–21 cm3/rev), 12–110 (57.9 cm3/rev), 15–100 (44 cm3/rev class) and 10–130 (small twins); an air-to-air outdoor unit’s service manual gives 110 rev/s in heating. 120 rev/s (7200 rpm) is the upper end of that range for the 40–65 cm3/rev machines of the validation catalogues, whose own documents print no maximum speed (they limit the frequency by running current). The former bound min(2 * rps_rated, 120) tied the ceiling to the nameplate, so two units that share one compressor had different ceilings (91 and 120 rev/s for the 9 and 12 kW units on a 42 cm3/rev compressor). A machine whose compressor is known should be given its documented rps_max.

A machine whose rated speed is already high – a low-volumetric-capacity fluid with a default displacement that does not follow the refrigerant (#86) – keeps at least RPS_MAX_MIN_PER_RATED times its rated speed, so it can still reach the catalogue maximum-to-rated ratio; such a machine should be given its real V_cmp_ref.

Parameters:

rps_rated (float)

Return type:

float

tmhp.compressor_envelope.efficiency_extrapolated_at(scale, result)[source]

Whether the (scaled) compressor maps are evaluated outside their data at this state.

Pressure ratio, speed and evaporating temperature are read from the result row (P_ref_cmp_out / P_ref_cmp_in, cmp_rpm / 60 and T_ref_evap_sat); the eta_ov map is checked at its transformed coordinates (extrapolated()). False for a state that does not run.

Parameters:
Return type:

bool

tmhp.compressor_envelope.steady_envelope(duty_arg=None, delivered_key='Q_ref_tank [W]', bindings=None)[source]

Decorate an analyze_steady with the envelope’s steady-state reporting.

Every result gains efficiency_extrapolated. With duty_arg (the boilers, whose requested duty is fixed), a request that fails on a limit a smaller duty can cure (duty_reduction_binding()) is retried at smaller duties; the largest one with an operating point is returned with capacity_clamped='max', capacity_binding naming the limit, Q_max [W] and Q_request [W] (the caller’s request). If no smaller duty runs, the original off-state result stands – unless the discharge limit refused the request and a larger duty runs: the smallest such duty is then returned with capacity_clamped='min' (raise_duty_within_envelope()), for the cycling decorator outside this one to average. The trial solves run silently. bindings renames a capacity_binding for the family (duty_reduction_binding()).

Parameters:
  • duty_arg (str | None)

  • delivered_key (str)

  • bindings (Mapping[str, str] | None)

Return type:

Callable[[TypeVar(_F, bound= Callable[..., Any])], TypeVar(_F, bound= Callable[..., Any])]

tmhp.compressor_envelope.reduce_duty_within_envelope(model, result, solve, request, delivered_key='Q_ref_tank [W]', bindings=None)[source]

The largest duty with an operating point when the request has none.

result is the solve at request; solve(q) solves the same point at duty q. When result failed on a limit a smaller duty can cure (duty_reduction_binding(): the condensing limit, the discharge-temperature limit even under its control, the pressure-ratio ceiling, the source heat exchanger’s range), smaller duties are tried (_reduce_to_envelope()) and the largest that runs is returned with capacity_clamped='max', Q_max [W], Q_request [W] and capacity_binding naming the limit active at that point (_reduced_binding(): the pressure-ratio ceiling, then the speed ceiling, then the limit the next larger duty tried ran into); otherwise result is returned. The boilers use it for analyze_steady (steady_envelope()) and for each dynamic step’s cycle, so a step runs at the same reduced duty as the steady solve – its run time and step-average heat follow from that duty. The trial solves run silently.

The condensing limit is closed directly (_duty_on_condensing_limit()): the request, the lowest duty of the ladder and the duty on the limit are the three solves of a step that runs against it, and two decide that no duty runs. On a model with a condensing limit a request for which no cycle exists at all (cycle_invalid without a detail: its condensing temperature is at or above the critical point) is treated as beyond that limit: reduced onto it when a smaller duty runs, and otherwise reported with failure_reason='condensing_temp_above_max' when the lowest duty tried is refused by the limit.

Parameters:
  • model (Any)

  • result (dict)

  • solve (Callable[[float], Any])

  • request (float)

  • delivered_key (str)

  • bindings (Mapping[str, str] | None)

Return type:

dict

tmhp.compressor_envelope.raise_duty_within_envelope(model, result, solve, request, delivered_key='Q_ref_tank [W]', condition=None)[source]

The smallest duty with an operating point when the envelope refuses the request from below.

The counterpart of reduce_duty_within_envelope(). The compressor’s speed floor is not the only lower end of continuous operation. At a large lift the overall efficiency falls towards low speed, and before rps_min is reached the envelope refuses the point for the discharge temperature, which the falling efficiency drives above T_dis_max even with the discharge-temperature control used up. Every duty below the one at which that limit lets go is refused, while larger duties run. A unit does not stay off there: it runs at the smallest duty the envelope admits and switches off when the tank has had enough, exactly as it does below its minimum speed. (Variable-speed compressors are sold with that restriction: the published envelope of the lowest speeds does not reach the pressure ratios of the higher ones, and the controller holds the frequency above it.)

Why the smallest duty and not the most efficient one above it: the request just above that duty is met in continuous operation at it, so cycling at any other duty would make the result jump at the boundary – and a controller that cycles runs as long as it can, at the lowest frequency its protections allow.

result is the solve at request, refused for the discharge limit (_RAISED_OVER) after no smaller duty ran; solve(q) solves the same point at duty q. A ladder of duties above the request (_RAISE_LADDER, fractions of model.hp_capacity) is climbed past the rungs refused the same way to the first that is not; a bisection then closes on the smallest duty that runs (to _RAISE_REL_TOL). The rung that ends the climb may itself be refused – by a limit of the other side (the pressure ratio, the source heat exchanger, the condensing temperature): the duties that run, if any, then lie between it and the rung below, and the bisection goes by which side refuses the trial. The continuous row found is returned with capacity_clamped='min' and the caller’s request in its request keys: it delivers more than the request, and tmhp.cycling.steady_cycling() averages it over the on/off period like a minimum-speed row (Q_min [W] is its duty). result is returned unchanged when no duty runs: the limits of the two sides then meet, or the discharge limit refuses every duty (it also binds from above, where the lift grows with the duty). A trial at the compressor’s speed ceiling (it delivers less than its duty) bounds the search from above but is not returned. The trial solves run silently.

condition identifies the operating condition (everything but the duty); with it and inside remembering_smallest_duties() the row found is reused for every smaller request at the same condition.

Parameters:
  • model (Any)

  • result (dict)

  • solve (Callable[[float], Any])

  • request (float)

  • delivered_key (str)

  • condition (object)

Return type:

dict

tmhp.compressor_envelope.remembering_smallest_duties(model)[source]

Reuse the rows of raise_duty_within_envelope() while the block runs.

The smallest continuous duty belongs to the condition, not to the request. One analyze_steady call can solve the same condition at several duties (the frost balance of tmhp.defrost.steady_defrost()); inside the block the search runs once per condition. The memory ends with the block, because the model may be changed between calls.

Parameters:

model (Any)

Return type:

Iterator[None]

tmhp.compressor_envelope.remember_smallest_duty(function)[source]

Decorate an analyze_steady so that its trial solves share remembering_smallest_duties().

Outermost: above the frost correction, whose solves at other duties are the ones that share the search.

Parameters:

function (TypeVar(_F, bound= Callable[..., Any]))

Return type:

TypeVar(_F, bound= Callable[..., Any])

tmhp.compressor_envelope.X_SUCTION_MIN: Mapping[str, float] = {'IsoButane': 0.9, 'R1234yf': 0.9, 'R1234ze(E)': 0.9, 'R134a': 0.9, 'R290': 0.9, 'R32': 0.9, 'R407C': 0.9, 'R410A': 0.9, 'R600a': 0.9, 'R717': 0.9}

Default lowest suction vapour quality of the discharge-temperature control, by refrigerant [-].

Two-phase suction (wet compression) is one of the methods experimentally used to hold the discharge temperature of R32 compressors (Wang et al., International Compressor Engineering Conference 2014, paper 1595; Zheng et al., International Refrigeration and Air Conditioning Conference 2016, paper 1766; Seong et al., Appl. Sci. 2017), alongside liquid and two-phase injection; a lower suction quality lowers the discharge temperature but raises the risk of over-wet compression and liquid slugging.

Every value is a provisional placeholder: 0.9, the single default this table replaced, for every fluid. It has no quantitative basis and is not a reliability limit. The sources collected on issue #216 disagree: for R32, a Daikin patent rates quality 0.75 and above as reliable (US 6,581,397 B1), a 3.5 kW water-to-water unit lost refrigerant flow below 0.84–0.91 (Seong et al. 2017), and a measured efficiency relation holds above 0.9 (Cheng et al., Appl. Sci. 2023). Values based on that literature are to replace these (issue #229). A number given as the constructor argument x_suction_min takes precedence; "auto" (the default) takes the value here.

tmhp.compressor_envelope.X_SUCTION_MIN_DEFAULT = 0.9

Default for every refrigerant not in X_SUCTION_MIN [-].

tmhp.compressor_envelope.default_x_suction_min(ref)[source]

Default lowest suction quality of the discharge-temperature control for refrigerant ref [-].

Parameters:

ref (str)

Return type:

float

tmhp.compressor_envelope.resolve_x_suction_min(value, ref)[source]

Constructor argument -> lowest suction quality of the control.

"auto" takes the refrigerant’s default (default_x_suction_min()), a number given by the caller takes precedence over it, and None switches the control off.

Parameters:
  • value (Union[float, Literal['auto'], None])

  • ref (str)

Return type:

float | None

tmhp.compressor_envelope.discharge_controlled(reject)[source]

Wrap a family’s _calc_state with the discharge-temperature control.

The wrapped method evaluates one candidate operating point; it reads the suction superheat from self.dT_superheat (capped by the evaporator approach where the family caps it) and the suction quality from self._x_suction. When the running state discharges above self.T_dis_max, the same candidate is re-evaluated with the superheat reduced (root of T_dis(superheat) = T_dis_max on [0, superheat]) and, if 0 K is not enough, with the quality reduced (root on [x_suction_min, 1]). The root is predicted from the fluid properties and corrected with two or three evaluations (_control_predicted()); root finding on the evaluations themselves is the fallback (_control_bracketed()). Every running state gets SUPERHEAT_KEY, QUALITY_KEY and CONTROL_KEY.

A state still above the limit is returned as is when reject is false (the boilers check the solved operating point and reduce the duty), and is rejected – None, with self._last_pr_event naming the discharge limit – when reject is true (ASHP, GSHP: a candidate inside the search).

With reject true the condensing limit (self.T_cond_max) is applied here too, before the control: a running state above it is rejected the same way (_last_pr_event names CONDENSING_TEMP_ABOVE_MAX). The boilers judge it on the solved operating point (envelope_violation()), after the control, so that the state they judge has a discharge state.

Parameters:

reject (bool)

Return type:

Callable[[TypeVar(_F, bound= Callable[..., Any])], TypeVar(_F, bound= Callable[..., Any])]

Compressor reference state

Compressor reference state solved from nominal capacity.

Models normalise the ground heat exchanger refrigerant-side UA by a rated mass flow (m_dot_ref / m_dot_ref_rated). That denominator belongs to one physical point – the reference state – and this module computes that point from the same inputs every model already requires:

hp_capacity -> V_cmp_ref -> rating condition -> rps_rated -> m_dot_ref_rated
V_cmp_ref

Swept displacement. When the caller gives none, the air-source and ground-source space-conditioning models and the air-source boiler use tmhp.default_inputs.estimate_displacement() – the displacement an inverter twin-rotary compressor catalogue gives for that capacity and refrigerant – and record it in default_input_estimates. It is a representative compressor, not an identification of a real one.

rating condition

A standard (or manufacturer/user) rating point for the model family: mode, source- and load-side inlet temperatures, the model’s reference secondary flows and its rated UA values. It is independent of whatever operating condition is simulated afterwards.

rps_rated

The speed at which the model delivers hp_capacity at the rating condition, with the compressor maps evaluated at that actual shaft speed.

m_dot_ref_rated

The refrigerant mass flow of that same state.

Capacity-only initialization constructs a representative compressor; it does not identify the exact manufacturer compressor.

Solution method

At the rating condition the duty on the rated side (load side) is known, so the rated-side saturation temperature follows from the rated-UA heat exchanger directly. For a trial duty on the other side, the other saturation temperature follows the same way; the cycle at those two temperatures then fixes the speed through the bounded root

\[Q_{model}(rps) - Q_{rated} = 0\]

with the (scaled) compressor maps evaluated at the actual bounded shaft speed. Heating is parameterized by speed, closing source mass flow first and then the rated condenser duty; this does not assume a monotone condenser-duty curve. Variable ground-HX UA is not used here – it needs m_dot_ref_rated, which is what is being solved for – so both heat exchangers use their rated UA at their reference flow.

A rated capacity that needs a speed outside [rps_min, rps_max] – or a rating point the subcritical cycle or the rated heat exchangers cannot reach – is reported as REFERENCE_CAPACITY_INCONSISTENT instead of being clamped onto a bound: a clamped speed would deliver a different capacity and silently redefine the machine. The pressure-ratio envelope is an operating limit and is not imposed on the rating point; its pressure ratio is reported.

tmhp.reference_state.REFERENCE_CAPACITY_INCONSISTENT = 'reference_capacity_inconsistent'

the rated capacity is not reachable inside the speed envelope (or by the subcritical cycle / rated HX) at the rating condition.

Type:

Failure reason

class tmhp.reference_state.ReferenceStateMixin[source]

Bases: object

Shared reference-state initialization for compressor-based models.

A model sets _RATING_FAMILY / _RATING_DEFAULT_MODE, implements _rating_side(), and calls _initialize_reference_state() once its refrigerant, displacement, rated UA values, reference flows and speed limits are known – and before anything that needs m_dot_ref_rated (variable ground-HX UA) is configured.

ref: str
V_cmp_ref: float
hp_capacity: float
dT_superheat: float
dT_subcool: float
dT_hx_min: float
rps_min: float
rps_max: float

The rated-speed search bound until _initialize_reference_state() replaces it with default_rps_max(rps_rated) (when _rps_max_derived).

property default_input_estimates: Mapping[str, DefaultInputEstimate]

Catalogue estimates behind the inputs the caller left out, by constructor argument name.

An input the caller supplied has no entry; a model built entirely from supplied inputs gives an empty mapping. Each DefaultInputEstimate carries the value, the release and stratum it came from, the capacity range the catalogues cover, extrapolated (the capacity lies outside that range), the source documents, the assumptions, and status ("provisional", with its reason, where the evidence is weak).

tmhp.reference_state.RATING_STANDARDS: dict[str, dict[str, RatingStandard]] = {'ASHP': {'cooling': RatingStandard(source_T_C=35.0, load_T_C=27.0, standard='ISO 5151:2017 T1 cooling (outdoor 35 °C DB, indoor 27 °C DB)'), 'heating': RatingStandard(source_T_C=7.0, load_T_C=20.0, standard='ISO 5151:2017 H1 heating (outdoor 7 °C DB, indoor 20 °C DB)')}, 'ASHPB': {'heating': RatingStandard(source_T_C=7.0, load_T_C=55.0, standard='EN 14511-2:2022 A7/W55 (outdoor air 7 °C DB, water outlet 55 °C)')}, 'GSHP': {'cooling': RatingStandard(source_T_C=25.0, load_T_C=27.0, standard='ISO 13256-1:2021 ground-loop cooling (liquid entering 25 °C, indoor 27 °C DB)'), 'heating': RatingStandard(source_T_C=0.0, load_T_C=20.0, standard='ISO 13256-1:2021 ground-loop heating (liquid entering 0 °C, indoor 20 °C DB)')}, 'GSHPB': {'heating': RatingStandard(source_T_C=0.0, load_T_C=55.0, standard='EN 14511-2:2022 B0/W55 (brine inlet 0 °C, water outlet 55 °C)')}, 'WSHPB': {'heating': RatingStandard(source_T_C=10.0, load_T_C=55.0, standard='EN 14511-2:2022 W10/W55 (water inlet 10 °C, water outlet 55 °C)')}}

Standard rating points per model family and mode.

source_T_C / load_T_C are the secondary-fluid inlet temperatures. TMHP’s air coils are dry (sensible only), so wet-bulb conditions of the standards are not used. The boilers’ load_T_C is the standard’s water outlet temperature: a plate condenser with circulating water is rated with water entering at the outlet less the rise its rated flow takes at hp_capacity (tmhp.heat_exchanger.tank_hx_rating_side()); a condenser without circulating water works against a tank at the outlet temperature, the conservative end of the condenser water range.

class tmhp.reference_state.HXSide(fluid, T_in_C, UA, volume_flow=None, rho_cp=None)[source]

Bases: object

Secondary side of one refrigerant heat exchanger at the rating point.

fluid is "air" or "water" for a single-phase stream crossing a constant-saturation-temperature surface (Q = eps C dT, eps = 1 - exp(-UA / C)), or "tank" for a boiler condenser without circulating water (Q = UA dT), as in the models’ own cycles.

rho_cp is the stream’s volumetric heat capacity rho c_p [J/(m³ K)]. Left out, the stream is standard air or water (the constants of tmhp.constants). A source loop filled with an antifreeze mixture is a "water" (liquid) side that carries the mixture’s own value – SourceFluid.rho * SourceFluid.cp, what the model’s cycle uses on that side – so that the reference state and the cycle solve the rating point with one heat capacity rate. (The default 25 % ethylene glycol holds 8 % less heat per litre than water.)

Parameters:
  • fluid (Literal['air', 'water', 'tank'])

  • T_in_C (float)

  • UA (float)

  • volume_flow (float | None)

  • rho_cp (float | None)

fluid: Literal['air', 'water', 'tank']
T_in_C: float
UA: float
volume_flow: float | None = None
rho_cp: float | None = None
property conductance: float

Duty per kelvin of approach, eps C (or UA for a tank) [W/K].

__init__(fluid, T_in_C, UA, volume_flow=None, rho_cp=None)
Parameters:
  • fluid (Literal['air', 'water', 'tank'])

  • T_in_C (float)

  • UA (float)

  • volume_flow (float | None)

  • rho_cp (float | None)

class tmhp.reference_state.RatingCondition(mode, source, load, standard)[source]

Bases: object

Rating point: mode, both secondary sides and the standard it follows.

Parameters:
  • mode (Literal['heating', 'cooling'])

  • source (HXSide)

  • load (HXSide)

  • standard (str)

mode: Literal['heating', 'cooling']
source: HXSide
load: HXSide
standard: str
__init__(mode, source, load, standard)
Parameters:
  • mode (Literal['heating', 'cooling'])

  • source (HXSide)

  • load (HXSide)

  • standard (str)

class tmhp.reference_state.ReferenceState(rps_rated, m_dot_ref_rated, condition, hp_capacity, V_cmp_ref, T_evap_sat_C, T_cond_sat_C, pressure_ratio, Q_cond, Q_evap, E_cmp_ref, E_cmp, eta_v, eta_ov, f_loss, rps_rated_solved=True)[source]

Bases: object

Self-consistent compressor reference state.

Parameters:
  • rps_rated (float)

  • m_dot_ref_rated (float)

  • condition (RatingCondition)

  • hp_capacity (float)

  • V_cmp_ref (float)

  • T_evap_sat_C (float)

  • T_cond_sat_C (float)

  • pressure_ratio (float)

  • Q_cond (float)

  • Q_evap (float)

  • E_cmp_ref (float)

  • E_cmp (float)

  • eta_v (float)

  • eta_ov (float)

  • f_loss (float)

  • rps_rated_solved (bool)

rps_rated: float
m_dot_ref_rated: float
condition: RatingCondition
hp_capacity: float
V_cmp_ref: float
T_evap_sat_C: float
T_cond_sat_C: float
pressure_ratio: float
Q_cond: float
Q_evap: float
E_cmp_ref: float
E_cmp: float
eta_v: float
eta_ov: float
f_loss: float
rps_rated_solved: bool = True
property cop: float

Load-side duty over compressor electrical input at the reference state.

__init__(rps_rated, m_dot_ref_rated, condition, hp_capacity, V_cmp_ref, T_evap_sat_C, T_cond_sat_C, pressure_ratio, Q_cond, Q_evap, E_cmp_ref, E_cmp, eta_v, eta_ov, f_loss, rps_rated_solved=True)
Parameters:
  • rps_rated (float)

  • m_dot_ref_rated (float)

  • condition (RatingCondition)

  • hp_capacity (float)

  • V_cmp_ref (float)

  • T_evap_sat_C (float)

  • T_cond_sat_C (float)

  • pressure_ratio (float)

  • Q_cond (float)

  • Q_evap (float)

  • E_cmp_ref (float)

  • E_cmp (float)

  • eta_v (float)

  • eta_ov (float)

  • f_loss (float)

  • rps_rated_solved (bool)

exception tmhp.reference_state.ReferenceStateError(message)[source]

Bases: ValueError

Rated capacity cannot be reached at the rating condition.

Parameters:

message (str)

reason = 'reference_capacity_inconsistent'
__init__(message)[source]
Parameters:

message (str)

tmhp.reference_state.rating_condition(family, *, source, load, default_mode, overrides=None)[source]

Resolve a family’s rating condition, applying caller overrides.

source / load build the model’s own heat-exchanger side for a mode and an inlet temperature (rated UA, reference flow). overrides is a complete RatingCondition, or a mapping with any of mode, source_T_C, load_T_C and standard. Changing mode switches the defaults to that mode’s standard point.

Parameters:
  • family (str)

  • source (Callable[[Literal['heating', 'cooling'], float], HXSide])

  • load (Callable[[Literal['heating', 'cooling'], float], HXSide])

  • default_mode (Literal['heating', 'cooling'])

  • overrides (Mapping[str, Any] | RatingCondition | None)

Return type:

RatingCondition

tmhp.reference_state.solve_reference_state(*, ref, V_cmp_ref, hp_capacity, condition, compressor_scale, dT_superheat, dT_subcool, dT_hx_min, rps_min, rps_max, rps_rated=None, cache_key=None)[source]

Solve the reference state at condition.

With rps_rated=None the speed delivering hp_capacity is solved and becomes the rated speed. With an explicit rps_rated the same state is solved with the model’s compressor maps, so m_dot_ref_rated can still be derived; rps_rated itself is then left as supplied.

cache_key (hashable, describing the compressor maps) enables a process-wide cache, so identical constructions solve once.

Parameters:
  • ref (str)

  • V_cmp_ref (float)

  • hp_capacity (float)

  • condition (RatingCondition)

  • compressor_scale (CompressorMapScale | None)

  • dT_superheat (float)

  • dT_subcool (float)

  • dT_hx_min (float)

  • rps_min (float)

  • rps_max (float)

  • rps_rated (float | None)

  • cache_key (tuple | None)

Return type:

ReferenceState