enex_analysis.air_source_heat_pump_boiler¶
Integrated System Model: Air Source Heat Pump Boiler (ASHPB).
This system class orchestrates the dynamic interaction between distinct thermodynamic sub-components to simulate the overall heating performance. While implemented as an integrated model, its physical calculations represent the behavior of:
Refrigerant Cycle (Vapor-Compression): Evaluates thermodynamic states using CoolProp, enforcing superheat/subcool margins.
Heat Pump Compressor: Models the compression process using isentropic and volumetric efficiencies to compute the actual discharge enthalpy and mass flow rate. The compressor power is determined from the enthalpy difference and the mass flow rate.
Expansion Valve: Modeled as an isenthalpic expansion device (constant enthalpy) that throttles the refrigerant from the condensing pressure down to the evaporating pressure.
Heat Exchangers (Condenser & Evaporator):
Condenser: Placed inside the tank (hydronic), utilizing a static overall heat transfer coefficient (UA_tank).
Evaporator: Air-coupled outdoor unit, utilizing a dynamic overall heat transfer coefficient (UA_ou) that scales non-linearly with fan airflow (Colburn j-factor analogy).
Thermal Storage Tank: Modeled with lumped-capacitance and DHW mixing logic.
At each time step, the model finds the minimum-power operating point (compressor + fan) via bounded 1-D optimisation (Brent’s method) over the evaporator approach temperature difference.
Note
See the project paper (KJACR 2025) for the underlying refrigerant-cycle theory and component-level modelling assumptions of this system.
Optional sub-components (injected via constructor):
- SolarThermalCollector — tank-circuit or mains-preheat placement
- (future) PVPanel — photovoltaic integration
Tank-level management and UV disinfection are built-in features configured through constructor parameters.
Classes
|
Air source heat pump boiler with outdoor-air evaporator. |
- class enex_analysis.tmhp.air_source_heat_pump_boiler.AirSourceHeatPumpBoiler(ref='R134a', V_cmp_ref=None, eta_cmp_isen=None, eta_cmp_vol=None, eta_cmp=None, dT_superheat=5.0, dT_subcool=5.0, UA_tank=None, UA_ou_rated=None, n_ou=0.65, dV_fan_a_rated=None, dP_fan_rated=None, A_cross=None, eta_fan_rated=None, T_tank_w_upper_bound=65.0, T_tank_w_lower_bound=60.0, T_mix_w_out=40.0, T_sup_w=15.0, hp_capacity=15000.0, dV_mix_w_out_max=0.0045, r0=0.2, H=1.2, x_shell=0.005, x_ins=0.05, k_shell=25, k_ins=0.03, h_o=15, tank_always_full=True, tank_level_lower_bound=0.5, tank_level_upper_bound=1.0, dV_tank_w_in_refill=0.001, prevent_simultaneous_flow=False, hp_on_schedule=None, stc=None, pv=None, uv=None, vsd_coeffs=None, T_sur=20.0, dT_cycle_min=20.0, dT_hx_min=0.5, PR_cycle_min=1.5, PR_cycle_max=10.0, rps_min=10.0, rps_max=150.0, V_disp_cmp=None, eta_cmp_electro_mech=None, UA_cond_design=None, UA_evap_design=None, dV_ou_fan_a_design=None, dP_ou_fan_design=None, A_cross_ou=None, eta_ou_fan_design=None, vsd_coeffs_ou=None)[source]¶
Air source heat pump boiler with outdoor-air evaporator.
The refrigerant cycle is resolved via CoolProp with user-specified superheat / subcool margins. The condenser approach temperature is determined analytically (
dT_ref_tank = Q_ref_tank / UA_tank), and a bounded 1-D optimiser (Brent’s method) minimises total electrical input (E_cmp + E_ou_fan) over the evaporator approach.- Parameters:
ref (
str)V_cmp_ref (
float|None)eta_cmp_isen (
float|Callable|None)eta_cmp_vol (
float|Callable|None)eta_cmp (
float|Callable|None)dT_superheat (
float)dT_subcool (
float)UA_tank (
float|None)UA_ou_rated (
float|None)n_ou (
float)dV_fan_a_rated (
float|None)dP_fan_rated (
float|None)A_cross (
float|None)eta_fan_rated (
float|None)T_tank_w_upper_bound (
float)T_tank_w_lower_bound (
float)T_mix_w_out (
float)T_sup_w (
float)hp_capacity (
float)dV_mix_w_out_max (
float)r0 (
float)H (
float)x_shell (
float)x_ins (
float)k_shell (
float)k_ins (
float)h_o (
float)tank_always_full (
bool)tank_level_lower_bound (
float)tank_level_upper_bound (
float)dV_tank_w_in_refill (
float)prevent_simultaneous_flow (
bool)hp_on_schedule (
list[tuple[float,float]] |None)stc (
SolarThermalCollector|None)pv (
PhotovoltaicSystem|None)vsd_coeffs (
dict|None)T_sur (
float)dT_cycle_min (
float|None)dT_hx_min (
float)PR_cycle_min (
float)PR_cycle_max (
float)rps_min (
float)rps_max (
float)V_disp_cmp (
float|None)eta_cmp_electro_mech (
float|Callable|None)UA_cond_design (
float|None)UA_evap_design (
float|None)dV_ou_fan_a_design (
float|None)dP_ou_fan_design (
float|None)A_cross_ou (
float|None)eta_ou_fan_design (
float|None)vsd_coeffs_ou (
dict|None)
- __init__(ref='R134a', V_cmp_ref=None, eta_cmp_isen=None, eta_cmp_vol=None, eta_cmp=None, dT_superheat=5.0, dT_subcool=5.0, UA_tank=None, UA_ou_rated=None, n_ou=0.65, dV_fan_a_rated=None, dP_fan_rated=None, A_cross=None, eta_fan_rated=None, T_tank_w_upper_bound=65.0, T_tank_w_lower_bound=60.0, T_mix_w_out=40.0, T_sup_w=15.0, hp_capacity=15000.0, dV_mix_w_out_max=0.0045, r0=0.2, H=1.2, x_shell=0.005, x_ins=0.05, k_shell=25, k_ins=0.03, h_o=15, tank_always_full=True, tank_level_lower_bound=0.5, tank_level_upper_bound=1.0, dV_tank_w_in_refill=0.001, prevent_simultaneous_flow=False, hp_on_schedule=None, stc=None, pv=None, uv=None, vsd_coeffs=None, T_sur=20.0, dT_cycle_min=20.0, dT_hx_min=0.5, PR_cycle_min=1.5, PR_cycle_max=10.0, rps_min=10.0, rps_max=150.0, V_disp_cmp=None, eta_cmp_electro_mech=None, UA_cond_design=None, UA_evap_design=None, dV_ou_fan_a_design=None, dP_ou_fan_design=None, A_cross_ou=None, eta_ou_fan_design=None, vsd_coeffs_ou=None)[source]¶
- Parameters:
ref (
str)V_cmp_ref (
float|None)eta_cmp_isen (
float|Callable|None)eta_cmp_vol (
float|Callable|None)eta_cmp (
float|Callable|None)dT_superheat (
float)dT_subcool (
float)UA_tank (
float|None)UA_ou_rated (
float|None)n_ou (
float)dV_fan_a_rated (
float|None)dP_fan_rated (
float|None)A_cross (
float|None)eta_fan_rated (
float|None)T_tank_w_upper_bound (
float)T_tank_w_lower_bound (
float)T_mix_w_out (
float)T_sup_w (
float)hp_capacity (
float)dV_mix_w_out_max (
float)r0 (
float)H (
float)x_shell (
float)x_ins (
float)k_shell (
float)k_ins (
float)h_o (
float)tank_always_full (
bool)tank_level_lower_bound (
float)tank_level_upper_bound (
float)dV_tank_w_in_refill (
float)prevent_simultaneous_flow (
bool)hp_on_schedule (
list[tuple[float,float]] |None)stc (
SolarThermalCollector|None)pv (
PhotovoltaicSystem|None)vsd_coeffs (
dict|None)T_sur (
float)dT_cycle_min (
float|None)dT_hx_min (
float)PR_cycle_min (
float)PR_cycle_max (
float)rps_min (
float)rps_max (
float)V_disp_cmp (
float|None)eta_cmp_electro_mech (
float|Callable|None)UA_cond_design (
float|None)UA_evap_design (
float|None)dV_ou_fan_a_design (
float|None)dP_ou_fan_design (
float|None)A_cross_ou (
float|None)eta_ou_fan_design (
float|None)vsd_coeffs_ou (
dict|None)
- analyze_steady(T_tank_w, T0, Q_ref_tank, *, return_dict=True)[source]¶
Run a steady-state performance snapshot.
Evaluates the refrigerant cycle at a given operating point (T_tank_w, T0, Q_ref_tank) without solving the tank energy balance or tracking dynamic flows.
- Parameters:
T_tank_w (float) – Tank water temperature [°C] — treated as a given input.
T0 (float) – Dead-state / outdoor-air temperature [°C].
Q_ref_tank (float) – Target condenser heat rate [W].
return_dict (bool) – If True return dict; else single-row DataFrame.
- Returns:
Cycle state plus diagnostic flags.
Two keys are useful for branching:
"converged"(bool) — True only when the HX optimisation and the SciPy optimiser both succeeded."failure_reason"(str) — one of"none","cycle_invalid","hx_not_converged", or"optimizer_failed".
ASHPB returns the cycle numbers (
E_cmp,Q_ref_tank, …) whenever_calc_stateproduced a dict at all. Afailure_reasonof"hx_not_converged"therefore does not invalidate the result: it only means the HX residual exceeded tolerance and the converged flag is False. Off-mode fallback (E_cmp=0) only occurs when the cycle itself was infeasible.- Return type:
dict | pd.DataFrame
- analyze_dynamic(simulation_period_sec, dt_s, T_tank_w_init_C, dhw_usage_schedule, T0_schedule, I_DN_schedule=None, I_dH_schedule=None, T_sup_w_schedule=None, tank_level_init=1.0, result_save_csv_path=None, T_sur_schedule=None)[source]¶
Run a time-stepping dynamic simulation.
Fully implicit scheme:
fsolvesolves for[T_next, level_next]each timestep.- Parameters:
simulation_period_sec (int) – Total simulation duration [s].
dt_s (int) – Time step size [s].
T_tank_w_init_C (float) – Initial tank temperature [°C].
dhw_usage_schedule (np.ndarray) – DHW volumetric flow rate per step [m³/s].
T0_schedule (array-like) – Outdoor temperature per step [°C].
I_DN_schedule (array-like | None) – Direct-normal irradiance per step [W/m²].
I_dH_schedule (array-like | None) – Diffuse-horizontal irradiance [W/m²].
T_sup_w_schedule (array-like | None) – Mains water supply temperature per step [°C]. If
None, the constructor valueT_sup_wis used for every step (backward-compatible).tank_level_init (float) – Initial fractional tank level (0–1).
result_save_csv_path (str | None) – Optional CSV output path.
- Returns:
Per-timestep result DataFrame.
- Return type:
pd.DataFrame
- postprocess_exergy(df)[source]¶
Compute ASHP-specific exergy variables.
Owns the full HP exergy topology:
Refrigerant state-point exergy (CoolProp)
Electricity = exergy (compressor, OU fan, UV)
Air exergy (outdoor unit)
Heat exchanger Carnot exergy (condenser, evaporator)
Water exergy (tank inlet/outlet, mixing valve)
Heat loss exergy, tank stored exergy
Subsystem exergy via
calc_exergy()protocolComponent-level exergy destruction
Exergetic efficiency metrics
- Parameters:
df (pd.DataFrame) – Result DataFrame from
analyze_dynamic().- Returns:
DataFrame with exergy columns appended.
- Return type:
pd.DataFrame