Air-source heat pump boiler (ASHPB)¶
The ASHPB family pairs the shared refrigerant cycle with an
outdoor-coil source side and a DHW tank sink side. This is the
validated reference example used by the Getting Started flow.
Overview¶
ASHPB solves the closed refrigerant cycle every step against an
outdoor coil (ε-NTU air-side) and a tank-coupled condenser. The
class is tmhp.AirSourceHeatPumpBoiler. Three composed
variants extend it with subsystems:
tmhp.ASHPB_STC_preheat— STC heats the mains feed before it reaches the tank.tmhp.ASHPB_STC_tank— a pumped collector loop charges the tank, with a storage high limit.tmhp.ASHPB_PV_ESS— PV generation + battery storage routes electricity to the compressor and auxiliaries before drawing grid.
Reference ASHPB instantiation. This physical wiring view is useful for the validated air-source DHW case, while the shared compressor / expander / heat-exchanger cycle core is reused by the other TMHP source and demand-side families.¶
Base usage¶
from tmhp import AirSourceHeatPumpBoiler
ashpb = AirSourceHeatPumpBoiler(ref="R32")
# Steady-state snapshot
result = ashpb.analyze_steady(
T_tank_w=55.0, # tank water [°C]
T0=7.0, # outdoor air [°C]
Q_ref_tank=8_000, # target condenser duty [W]
)
# Time-stepping dynamic run — see Getting Started for full schedule
# construction.
# df = ashpb.analyze_dynamic(...)
In a dynamic run the compressor cycles between T_tank_w_lower_bound
and T_tank_w_upper_bound (60 / 65 °C). The thermostat is followed
inside each step, so a step reports the fraction of it the compressor ran
(runtime_fraction [-]), its starts (hp_starts [-]) and heat and
power averaged over the step; min_on_time_s / min_off_time_s
(default 0) hold the compressor to a minimum run and rest time. See
Time step and the thermostat.
The upper set point has to lie inside the compressor envelope of the
refrigerant: the cycle condenses at the tank temperature plus the condenser
approach, and the envelope ends at T_cond_max (R134a 80 °C, R290 75 °C;
R410A, R32 and R407C 65 °C, which reach about 60 °C in the tank; see
Reference points and operating limits). A band above that is capped at
construction with a UserWarning – the default 60–65 °C becomes
55–60 °C with R32 or R410A – and the thermostat stops the heat pump at the
cap. analyze_steady against a hotter tank returns a reduced duty
(capacity_binding == "condensing_temperature") or the off state with
failure_reason == "condensing_temp_above_max".
That cap is the envelope stop (T_cond_max − hp_capacity / K_tank_hx at
the condensing-limit pressure), and the in-step thermostat stops the
compressor there whatever min_on_time_s says, as in Ground-source heat pump boiler (GSHPB) and
Water-source heat pump boiler (WSHPB): a protection stop outranks the minimum run time. The step is a
normal one (failure_reason == "none") with hp_stop_reason ==
"condensing_limit"; hp_stop_reason is on every dynamic row and None
elsewhere. Before, a minimum run time carried the tank past the stop by an
amount that depended on the step, and the run ended in a
condensing_temp_above_max step: R32 with min_on_time_s=1800 peaked at
62.6 °C with 60 s steps and at 65.1 °C with 600 s steps (1.51 against
1.95 kWh of heat in 2 h); it now stops at 60.0 °C with both (1.055 kWh).
Runs without a minimum run time are unchanged. ASHPB_PV_ESS,
ASHPB_STC_preheat and ASHPB_STC_tank inherit the step and behave the
same (a collector may still heat the tank beyond the stop, up to its own
storage limit).
Charging past the cut-out at reduced duty¶
Stopping where the nameplate duty meets the condensing limit is the
behaviour of a fixed-speed unit, or of one whose controller ends the charge on
its high-pressure protection. An inverter unit slows its compressor there and
keeps charging, which is what analyze_steady reports against a hotter tank.
condensing_limit_control chooses between the two:
value |
a dynamic run |
|---|---|
|
ends the charge at the envelope stop above; the set points are capped there. Results are those of every release so far. |
|
runs on past the envelope stop at the largest duty inside the limit,
|
Past the envelope stop the tank approaches T_reach as a first-order lag
with the time constant C_tank / K_tank_hx (295 s for the default tank and
a 15 kW unit), far shorter than an hourly step. The in-step thermostat follows
it in closed form, so the charge below comes out the same at any step; see
the operating-limits reference for the method,
its error, and where that stops holding (a tank that loses much of the
compressor’s heat) or does not apply (another limit than the condensing one
on the way, below). A row of such a run
has reduced_duty_fraction [-] (the part of the step run on the limit), and
a step that ran there reports capacity_clamped == "max" and
capacity_binding == "condensing_temperature", as the steady solve does.
R32, 15 kW, set points 60–62 °C, 15 °C outdoor, one hour from 50 °C without a draw:
|
|
|
|---|---|---|
thermostat band |
55.99–57.99 °C (capped, warning) |
60–62 °C (as asked) |
highest tank temperature of the hour (where the charge ends; 60 s steps) |
57.99 °C |
62.00 °C |
tank at the end of the hour (the tank cools after the charge) |
57.77 °C |
61.77 °C |
compressor run time |
337 s |
589 s (252 s on the limit) |
heat / electricity |
1.405 / 0.449 kWh (COP 3.13) |
2.111 / 0.693 kWh (COP 3.05) |
With 60 s, 600 s and 3600 s steps the "reduce_duty" run ends the hour
within 0.006 K, 0.005 % of heat and 0.11 % of electricity of one another. That is
this tank (loss coefficient 1.15 W/K) and this limit. A tank that loses heat
fast depends on the step with either option, because a step’s tank
temperature is one implicit solve with the loss at its end: 0.02 K and 0.02 %
of heat at 4.6 W/K, 0.2 K and 1.8 % at 76.65 W/K, against a fine-step
reference (0.1 K and 0.3 % with "stop").
The smallest continuous duty depends on the outdoor air: warmer air gives the
compressor denser suction gas, so more duty at its lowest speed, and the limit
is met at a colder tank (63.1 °C at 7 °C outdoor, 61.3 °C at 35 °C for the
machine above). The thermostat’s cap is evaluated once, at the outdoor
temperature of the rating point (charge_limit_reference_C); each step
applies the stop of its own outdoor state, and where that lies below the set
point the compressor stops there (hp_stop_reason == "condensing_limit";
"boiling_limit" where the stop that acted was 100 °C, which a refrigerant
with a limit above about 101 °C reaches first). While the call stands it then
holds the tank at the stop – a mean of on/off cycling reported as one run:
one start, runtime_fraction [-] the share of the time it is on, and a
carried state that says “running” since that start – or, with a minimum rest
time (min_off_time_s), rests for that time and restarts, each restart a
counted start. A tank that is above the stop of its step (warmer air has
lowered the stop, or the run starts there) cools to it first and is held from
then on, as one start (the R32 unit with set points of 62–65 °C, from 61.8 °C
at 35 °C outdoor: the stop is 61.30 °C, and the run has one start with 60 s,
600 s and 3600 s steps). With a frosting coil the limit binds the frost-free cycle and
the heat delivered is its mean over frosting and defrost.
All of this covers the outdoor states in which the condensing limit is the
limit that governs the stretch from the envelope stop to the charging limit.
Each outdoor state is checked for it once, with three cycles: at the envelope
stop, at the middle of the stretch and at its end, each asked for the duty
the condensing limit leaves there. If one of them does not run, delivers
another duty (by more than 0.1 %) or names another limit, reduced-duty
charging is withheld in that outdoor state: the step is solved exactly as
"stop" solves it, ending the charge at the envelope stop, with
reduced_duty_fraction [-] 0 and reduced_duty_withheld naming what
withheld it on the rows in which the envelope stop acted. The thermostat band
is not capped again, so the call above the envelope stop stands. The three
cycles are a sample of the stretch. Each step that charges on the limit also
checks its own cycles the same way, at the mean of its own stretch, and is
withheld alone if one fails (reduced_duty_withheld == "cycle", a value
that names no limit and is written in other situations too; the reference
lists them). So the
verdict of an outdoor state does not depend on the step, but where another
limit acts only between the three sampled tank temperatures, which steps are
withheld does: the charge then depends on the step size (the
reference has a constructed case: 4.8 % of
the heat between 60 s and 600 s steps). None of the default machines’
charges measured does this. Cold air does
this through the pressure-ratio ceiling, which then leaves less than the
nameplate duty at the envelope stop ("pressure_ratio", and
"outdoor_coil" in the degree above it, where the coil at its largest
airflow is what holds the cycle: the 15 kW R290 unit at −13 °C and below, the
R32 unit at −14 °C and below; they qualify from −12 °C and −13 °C up),
through a low discharge-temperature limit ("discharge_temperature"), and
through the compressor’s speed ceiling ("compressor") where that is lower
than the default 120 rev/s, which the envelope stop does not need down to
those temperatures (the R290 unit with rps_max=100: −5 °C and below).
R32, 15 kW, −15 °C outdoor, set points 60–62 °C, one hour from 57.5 °C:
57.99 °C, 0.1296 kWh of heat and 0.0816 kWh of electricity with 60 s, 600 s
and 3600 s steps alike, the rows of "stop" with
reduced_duty_withheld == "pressure_ratio" (the
reference has the rule, the table of source
states and the other cases).
analyze_steady is not changed by the option. For this family it keeps
returning a running point for up to a kelvin above the charging limit (to
63.3 °C at 7 °C outdoor, 62.2 °C at 35 °C): its duty search finds
states at the speed floor that deliver less than the minimum-speed duty by
widening the outdoor coil’s approach. The dynamic run does not use those; its
floor is the minimum-speed duty analyze_steady itself reports as
Q_min [W].
Which control each option stands for, and the default (#227). The two options are two kinds of control found in manufacturers’ manuals:
"reduce_duty"is an inverter compressor’s high-pressure limiting. Above a set condensing pressure the controller lowers the compressor’s frequency limit in steps and releases it when the pressure falls (Daikin ERQ service manual: above 3.04 MPa; Mitsubishi City Multi: the frequency is lowered every 30 s while the high pressure is above its limit). The option follows that as a continuous duty. It starts where the nameplate duty condenses onT_cond_max(57.99 °C for the R32 unit above, whatever the outdoor air), lowers the duty byK_tank_hx(2.14 kW) per kelvin of tank, and ends where the duty at the compressor’s speed floor condenses on the limit (63.63 / 62.64 / 61.30 °C at −7 / 15 / 35 °C outdoor) or at the set point."stop"is a fixed-speed unit, which its high-pressure switch stops, or a domestic-hot-water controller whose highest heat-pump tank temperature (the “HP MAX” setting of Daikin Altherma controllers, for one) is the nameplate cut-out.Real units heat a tank above the heat pump’s reach with an electric booster heater. The boilers have none, so a set point above the end of the charge is capped (with a warning), and the heat a booster would add is not in the results.
The start and the end are kept as they are (co-author decision on #227, 2026-11-22). The start is the protection limit itself: no data was found on the margin between the pressure at which a controller starts limiting and the pressure of its high-pressure switch. The end is the duty at the speed floor; it is to be checked against the manufacturers’ published envelopes (the highest leaving water temperature by outdoor temperature).
The default stays "stop". It changes to "reduce_duty" once all of
these hold:
The withheld outdoor states no longer break the charge, or the annual effect of the break has been measured and accepted. The break: the 15 kW R290 unit with set points of 70–72 °C, one hour from 60 °C, reaches 72.00 °C with 2.114 kWh at −12 °C but stops at 67.99 °C with 1.456 kWh at −13 °C (
reduced_duty_withheld == "outdoor_coil").The cost of a year with hourly outdoor states is acceptable. A week of hourly steps of the R32 unit (set points 60–62 °C) takes 17.6 s against 2.7 s with
"stop".The per-refrigerant limits of #229 are settled; they move the start and the end.
GroundSourceHeatPumpBoilerwith a stratified or hybrid tank, which refuses"reduce_duty", gets a default that depends on the tank model.
Figures of the R32 example (the hour, the two cycles on a T-h diagram, and
the start and end by outdoor temperature) are in
validation/reduced_duty_charge/.
Steady state below the minimum capacity¶
A request below what the compressor delivers at rps_min is met by
switching it on and off, and analyze_steady reports that point
(capacity_clamped == "min") as the mean over the cycling period — the
convention of Air-source heat pump (ASHP — space conditioning), with the EN 14825 form for a unit delivering to
water (Steady state below the minimum capacity has the formula and a table):
Q_ref_tank [W]equals the request andPLR_delivered [-]follows it;Q_min [W]is the duty of the running machine andcapacity_ratio [-]the request divided by it.runtime_fraction [-]equals the capacity ratio. Heat and flow rates (Q_ref_tank,Q_ref_ou,Q_ou_a,m_dot_ref,dV_ou_a) are the running values times it, as in a dynamic step.E_cmp,E_ou_fanandE_totare the running values timesCR + (1 − Cc)(1 − CR): the unit keeps drawing1 − Ccof its running input while the compressor is off. Both COPs are the continuous ones timespart_load_factor [-];E_cycling_loss [W]is the off-state part.Temperatures, pressures and speed are those of the running machine.
On the speed floor the outdoor fan still has a range to choose from, and each
airflow is a machine that delivers a different heat, all above the request.
The running machine of the row is the most efficient of them (the least
E_tot per unit of heat delivered), at any tank temperature. A tank within
0.5 K of T_tank_w_upper_bound, or above it, used to be ranked on total
power instead, which at the floor is nearly flat in the outdoor approach and
returned a starved coil. R290 at 45 °C air against a 65 °C tank: the least
total power on the floor is at 22 K of outdoor approach with the fan at its
lowest flow, a running-machine COP of 3.83 where the floor offers 5.26 at
7.7 K (on the default compressor maps, ossorio-r290-te-2026-11-21; with
the compressor defaults when the ranking was replaced, 16 K, 4.27 and 5.29).
The minimum speed is not always the lower end of continuous operation. At a
large lift the compressor efficiency falls towards low speed, and the
compressor envelope (Reference points and operating limits) can
refuse the point before rps_min is reached, for the discharge
temperature, which the falling efficiency drives above T_dis_max even
with the discharge-temperature control used up. The default 15 kW unit with
R32 at −20 °C outdoors against a 60 °C tank runs down to about 2.2 kW
(16 rev/s, suction quality 0.9 at the 150 °C limit) and no further. At −15 °C
against 60 °C, and with R290 at −7 °C against 55 or 65 °C, R134a at −7 °C
against 55 °C and R410A at −15 °C against 55 °C, it reaches its minimum speed
first (2.4 to 2.9 kW). A request below that duty was answered
with the unit switched off (failure_reason == "discharge_temp_above_max")
while a larger one ran. It is met the same way as one below the minimum speed,
and as Air-source heat pump (ASHP — space conditioning) does: the unit cycles at the smallest duty the envelope
admits. The row has capacity_clamped == "min", Q_min [W] is that duty
(found by bisection on the duty, to 0.5 %; the same for every request below
it), and the compressor speed of the row is above rps_min. The mean
carries the EN 14825 degradation like any other cycling row
(runtime_fraction [-], E_cycling_loss [W]), so its COP is never above
that of the continuous point it cycles at. With Cd_cycling=None the row is
that continuous point, which delivers more than the request.
The smallest duty is used, not a more efficient larger one: the request just
above it is met in continuous operation there, so the result has no step at
the boundary, and a unit that cycles runs as long as its protections let it.
Where that duty is a large share of the nameplate the unit is off for most of
the time at small loads (2.1 kW, 14 % of the nameplate, in the R32 case
above); runtime_fraction [-] says how much.
The reason remains where no duty runs at all: the limits that refuse the duty from above (the pressure ratio, the outdoor coil, the condensing temperature, the discharge temperature itself at a larger lift) meet the one from below. The default 15 kW unit with R32 against a 55 °C tank is such a case at −25 °C outdoors: the discharge limit refuses the smallest duties and the pressure-ratio ceiling every larger one, so there is no duty to cycle at (at −24 °C it still runs, at up to 2.9 kW, held by the pressure ratio). A dynamic step is not affected: its thermostat runs the compressor at the nameplate duty.
Cd_cycling is the coefficient Cc: 0.9 by default (the standard’s value
for an untested unit), 1 − P_off / P_on for a unit with a measured standby
power, 1.0 for loss-free cycling, and None for the continuous
minimum-speed point, which delivers more than the request. An 8 kW R32 unit
at 7 °C air and a 35 °C tank delivers 1.9 kW at its minimum speed: a 400 W
request now returns 400 W at 154 W (system COP 2.59 against 3.55 for the
running machine). Before the cycling model it returned the minimum-speed duty
itself (with the defaults of then 3.7 kW at 822 W of input).
Note
The declared COP of an EN 14825 part-load condition belongs to the
declared capacity at that condition — the unit running at its lowest step
when the load is below it — and the standard applies the degradation
afterwards, in the bin calculation. Compare a certified part-load COP with
the running machine: build the model with Cd_cycling=None, or divide
cop_sys [-] by part_load_factor [-].
A dynamic run is not affected: the tank thermostat already switches the
compressor, which runs at hp_capacity for runtime_fraction [-] of a
step.
Frost and defrost¶
Below 5 °C outdoor the coil frosts and the unit stops heating from time to
time to melt it; a catalogue figure at A2 or A−7 is the mean over both. The
boiler applies the adjustment Air-source heat pump (ASHP — space conditioning) applies (tmhp.defrost: the
EnergyPlus DX heating-coil model with on-demand reverse-cycle defrost, its
constants unchanged, growing from nothing at 5 °C to its full size at 2 °C),
on by default, in analyze_steady and in the cycle of every dynamic step:
The request is met by the mean, so the frost-free cycle is solved at the larger duty
(Q_ref_tank + Q_defrost) / frost_capacity_factorand the row is then averaged.Q_ref_tank [W]is the mean heat that reaches the tank: the request, unless that larger duty runs into the compressor’s speed ceiling or the operating envelope (capacity_clamped == "max").E_cmp [W]is the frost-free compressor power timesfrost_power_factor + defrost_fraction(heating, then defrosting — the compressor is taken to draw the same power while it defrosts);E_defrost [W]is the defrosting part.E_ou_fan [W]is multiplied byfrost_power_factor [-].Q_defrost [W]is the heat a reverse-cycle defrost takes back from the tank water. A unit cycling below its minimum capacity defrosts only while it runs, so that heat isruntime_fraction [-]of the continuous figure.Heat and flow rates (
Q_ref_ou,Q_ou_a,m_dot_ref,dV_ou_a) are scaled with the delivered heat; temperatures, pressures, speed and efficiencies are those of the frost-free cycle, whose duty and input areQ_ref_tank_frost_free [W]andE_tot_frost_free [W].Q_min [W]of a cycling row is the frost-free duty at the minimum speed.In a dynamic step the thermostat asks for
hp_capacityand the running cycle is that mean;E_defrost [W]andQ_defrost [W]are step averages like the other rates.
from tmhp import AirSourceHeatPumpBoiler
from tmhp.defrost import DefrostModel
AirSourceHeatPumpBoiler() # frost and defrost, 84 % RH
AirSourceHeatPumpBoiler(defrost=False) # the frost-free steady state
AirSourceHeatPumpBoiler(defrost=DefrostModel(RH_out=0.70)) # another default humidity
AirSourceHeatPumpBoiler(defrost=DefrostModel(frost_point_band_K=None)) # EnergyPlus in dry air too
# Humidity per call, per step, or as a schedule (fraction, 0-1):
# model.analyze_steady(T_tank_w=45.0, T0=0.0, Q_ref_tank=8000.0, RH_out=0.9)
# model.analyze_dynamic(..., RH_out_schedule=rh) # one value per step
# model.step(state, {..., "RH_out": 0.9}, dt_s)
Dry air. Air whose frost point is at or below the coil of the correlation
leaves no frost and is not corrected; the fixed losses grow to their full
size as the frost point rises 3 K above it (dry air).
At −5 °C and 50 % relative humidity the default 15 kW unit delivering 10 kW
to a 40 °C tank draws 3,391 W, the frost-free figure, where the EnergyPlus
multipliers (frost_point_band_K=None) give 3,734 W; at 60 % it draws
3,556 W against 3,781 W, and at the rating humidity, 84 %, 4,017 W either
way.
Part load. The correction is that of the load the coil carries
(frost at part load): the coil sits r (0.18 T_out + 8.589) below the
air, with r the frost-free duty over the capacity the correlation’s unit
has at that outdoor temperature (hp_capacity at 7 °C, 0.6 of it at
−15 °C), at most 1. At r = 1 it is the rated-load correction unchanged;
below, the deposition and the fixed losses shrink with the frost drive that is
left, to nothing once the coil is at the air’s frost point.
DefrostModel(load_weighted=False) applies the full correction at every
load.
The default 15 kW unit delivering 8 kW to a 45 °C tank, system COP
(defrost=False is what every version before returned):
Outdoor air |
7 °C |
4 °C |
2 °C |
0 °C |
−7 °C |
−15 °C |
|---|---|---|---|---|---|---|
Frost-free |
3.51 |
3.29 |
3.15 |
3.01 |
2.59 |
2.21 |
With frost and defrost |
3.51 |
3.22 |
2.75 |
2.63 |
2.30 |
1.97 |
Load ratio |
— |
0.58 |
0.69 |
0.72 |
0.84 |
1.00 |
|
0 |
0.012 |
0.065 |
0.061 |
0.036 |
0.018 |
|
3.51 |
3.07 |
2.54 |
2.47 |
2.24 |
1.97 |
At 4 kW the same unit hardly frosts (r 0.3: 3.17 at 2 °C against 3.21
frost-free). Frost also lowers what the unit can deliver: at A2 against a
35 °C tank the default unit reaches its speed ceiling at a frost-free 25.4 kW,
a mean of 20.0 kW – what a 25 kW request receives. The frost of a request the
unit cannot meet is that of the duty it runs at its ceiling, not of the
request (the ceiling the envelope search reports varies by a few per cent
with the request, where the search starts; the correction is that of the
duty each row reports). In a dynamic
run the thermostat asks for hp_capacity, so a running step is at
r = 1 – unless the envelope holds its cycle below the capacity of the
correlation’s unit (a hot tank in very cold air: at −20 °C the pressure-ratio
ceiling leaves about 6.3 kW frost-free against a 65 °C tank, where that unit
delivers 7.6 kW), where r is that of the duty it runs. The stretch a condensing_limit_control="reduce_duty" step charges on
the condensing limit keeps r = 1 all along (the duty of that stretch is a
straight line in the tank temperature only with one frost state): exact where
the stretch begins, and it can overstate the frost once the duty falls below
the capacity of the correlation’s unit.
Note
The multipliers come from air-to-air DX coils and depend on the outdoor temperature, the humidity and the load ratio, not on the coil the model solves; the condenser approach, the discharge temperature and the envelope checks are those of the frost-free cycle at the larger duty, not of a coil with frost on it. The load term takes the air flow as independent of the load, and it inherits the EnergyPlus fixed loss in air too dry to frost (Air-source heat pump (ASHP — space conditioning), Frost and defrost). See Scope and limits.
Default compressor efficiencies¶
A bare AirSourceHeatPumpBoiler takes its compressor from the default maps
of tmhp.compressor_efficiency (coefficient set
ossorio-r290-2026-11-30): the volumetric efficiency eta_v sets the
mass flow, the overall efficiency eta_ov the electrical input
E_cmp = m_dot (h_2s - h_1) / eta_ov, and the heat-loss share f_loss
the heat the shell gives off, Q_cmp_loss = f_loss E_cmp; the discharge
enthalpy follows from the energy balance (#274). Every family takes the same
maps, whatever its refrigerant and compressor: they are fitted to 134
measured points of one 46 cm³/rev R290 scroll, not to heat-pump catalogues,
and are evaluated at the pressure ratio, the shaft speed in rev/s and the
evaporating saturation temperature. They are fitted on the power of
compressor and inverter together, so E_cmp [W] is the inverter input;
there is no separate drive model. The maps, their data and their limits are
described in Where the defaults come from and in the coefficient archive
validation/coefficients/ossorio-r290-2026-11-30/ (its README).
Warning
The data of the maps span 30–110 rev/s and a hull in pressure ratio and
evaporating temperature. The model’s operating range (rps_min =
15 rev/s, rps_max = max(120, 1.5 × rps_rated), PR_cycle_max =
11) reaches outside it, and outside it the maps are followed as they are
– nothing is held – with efficiency_extrapolated set on steady
results. That is the case at every speed below 30 rev/s and above
110 rev/s. Applied without calibration, the defaults run low against the
catalogues of Validation (COP bias −5.9 % for the
air-to-water units). With R32 the default 15 kW unit runs at pressure
ratios 8.3 and 10.9 at A−7/W65 and A−15/W65 and has an uncontrolled
discharge of 172 and 196 °C there; the
discharge-temperature control holds T_dis_max (150 °C) by lowering
the suction superheat and then letting the suction go wet down to
x_suction_min (by default 0.9 for every refrigerant for now), and a
request it cannot hold runs at the largest
smaller duty that it can (capacity_clamped == "max"), or is refused
when there is none (see Reference points and operating limits).
A model takes no efficiencies of its own. The maps are followed for a target
machine by scaling them: compressor_scale takes a
CompressorMapScale with level factors for
the three quantities (k_v, k_ov, k_f) and shape factors that move
and stretch the eta_ov map about its peak (delta_N, w_N,
delta_r, w_r); model.plot_compressor_map() draws the scaled map
against the default. The earlier default models – the semi-empirical models
of 2026-11-15, the quadratic map of 2026-10-06 and the correlations before it
– are no longer in the library; their archives are kept in
validation/coefficients/ (README.md).
Calibrating the compressor to a catalogue¶
tmhp.calibrate_compressor() finds the scale that makes a model follow a
product’s published operating points (#189). Give it a function that builds
the model for a scale, and the catalogue as a table:
import pandas as pd
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)
table = pd.read_csv("catalogue.csv") # outdoor air, leaving water, heating duty [W], COP
cal = calibrate_compressor(make_model, table, columns={"T0": "air_C", "T_w_out": "water_C", "Q": "Q_W", "cop": "COP"})
model = make_model(cal.scale) # the calibrated machine
print(cal.adopted_stage, cal.scale)
cal.plot_parity(); cal.plot_stages(); cal.plot_map("eta_ov")
Each row is solved with analyze_steady at the EN 14511 water boundary –
the water enters the standard’s rise below the leaving temperature, at the
flow that carries the published duty – as the validation harness and the
EnergyPlus plugin do. table="duty" (the default) reads rows at a published
duty; table="max_capacity" reads a maximum-capacity table, whose rows the
model must reach at its ceiling. A published discharge temperature
(T_dis) and compressor speed (rps) are used when the table has them.
The factors are fitted in nested stages, each refitting all its free factors and judged against the last adopted one:
Stage |
Free factors |
Free only when |
|---|---|---|
L0 |
|
|
L1 |
|
the table gives the discharge temperature (a heating COP sees
|
M1, M2 |
|
|
M3 |
|
A stage is adopted when its 5-fold cross-validated RMSE of
ln(COP_model / COP_catalogue) drops by at least 10 % against the last
adopted stage, each new factor’s 95 % interval excludes its identity, no two
free factors correlate beyond |rho| = 0.95, and no new factor rests on its
search bound (AdoptionRule). The rule
is provisional until the adoption rule of #272 is settled. The interval is
the linearised one at the optimum (Student t on the residual degrees of
freedom); read it as how flat the error valley is, not as a probability,
since a catalogue’s residuals are mostly the model’s systematic gap. A factor
the table cannot locate stays at its identity and is reported
"unidentified"; one fitted in a stage that was not adopted is reported
"not_adopted" with its estimate. Rows the default model cannot solve (a
duty above its ceiling, a duty it meets only by cycling) are left out before
the fit and listed in cal.excluded; a row a candidate cannot solve counts
with a fixed residual (FAIL_RESIDUAL).
Diagnostics – a discharge below the isentropic one with the shell loss it
implies, maps read outside their data – are reported per row and never
reject a row or a candidate.
cal.to_dict() is a JSON-safe record and
from_dict() reads it
back; a record fitted on other default maps (another
COEFFICIENT_VERSION) is refused, since the same factors on other maps
describe another machine. Limitation: k_ov and k_f move
independently, so the shell heat loss is not tied to the overall efficiency
(#275). The air-to-air models (Air-source heat pump (ASHP — space conditioning)) have no catalogue adapter yet
(#193). The calibrated parity of the air-to-water catalogues is in
Calibrated parity.
Source-side mechanics¶
ASHPB models its outdoor coil as a variable-speed fan coupled to an
ε-NTU heat exchanger. Fan electrical power follows an ASHRAE
90.1-style cubic-with-speed curve; coil ε is recomputed each step
from the resolved refrigerant mass flow. At the rated flow the fan draws
E_fan_rated: the flow times dP_fan_rated over eta_fan_rated
(60 Pa and 0.6), or a catalogue fan power given as E_fan_rated itself
(the two ways together are refused).
The coil exchanges heat with the mass of air the fan moves:
dV_ou_a is a volume at the outdoor temperature T0, and the air mass
flow is air_density(T0) * dV_ou_a with the density of dry air at one
standard atmosphere (tmhp.air_properties.air_density(); 1.42 kg/m³ at
−25 °C, 1.26 at 7 °C, 1.15 at 35 °C). NTU_ou [-], the outlet temperature
T_ou_a_out (fan heat included) and the air exergy flows use that one mass
flow, so c_a * rho(T0) * dV_ou_a * (T_ou_a_out - T0) = E_ou_fan - Q_ref_ou
within a row. Against the 15 °C standard air of earlier releases the COP at
nameplate capacity is 0.2 % higher at A7/W35 and 0.2 to 0.7 % higher at −7 °C;
from 25 to 45 °C outdoors it is typically 0.2 to 0.5 % lower. See Air density for what is left on
the volume flow and what is left out.
Sink-side mechanics¶
The sink is a single-node DHW tank (with optional stratification on
the _STC_tank variant). The tank energy balance is solved
implicitly per step with fsolve, jointly with the refrigerant
cycle.
By default the tank stays full: mains water replaces each litre drawn.
With tank_always_full=False the level varies instead. The draw lowers
it, and a make-up valve opens when the level reaches
tank_level_lower_bound (0.5) and admits dV_tank_w_in_refill
(1 L/s) until the level is back at tank_level_upper_bound (1.0). The
valve is followed inside each step, so a step can refill part of its
length. prevent_simultaneous_flow admits make-up only while nothing
is drawn. A draw that would replace the whole tank in less than 10 s
(tmhp._validation.DHW_TANK_TURNOVER_MIN_S: 15 L/s for the 151 L default
tank) is refused as a unit slip – the schedule is in m³/s, and a value in
L/s or L/min lands far above it; the same check applies to GSHPB, WSHPB and
step(). Either way the step balances the water and its energy
together,
with the draw at the end-of-step temperature. The envelope loss
UA_tank_wall does not depend on the level. The tank never drains
below TANK_LEVEL_MIN (0.1 % of its volume): a draw beyond what it
holds plus its make-up is cut, and the cut is reported as
dV_mix_w_out_unmet [m3/s]. A run of a level-varying tank starts with
tank_level_init of at least TANK_LEVEL_MIN.
Every step reports the hot-water service: Q_dhw_request [W] is the
scheduled draw at the set point T_mix_w_out counted from the mains
temperature, Q_dhw_unmet [W] the part not delivered — the tank was
colder than the set point, so the water arrived cold, or a level-varying
tank cut the draw. analyze_dynamic warns once
(tmhp.dhw.DHWUnmetWarning) when a run leaves demand unmet; see
Was the hot water delivered? for the run totals.
A step on which the thermostat called but the compressor could not run (an
off row with a failure_reason), or ran below the nameplate duty
(capacity_clamped == "max"), is not reported while the run goes on.
analyze_dynamic ends with one tmhp.OperatingLimitWarning that counts
such steps by limit and says what they did to the tank, and the same totals
are in df.attrs["operating_limits"]; analyze_steady warns once about a
point that does not run or runs reduced (Being told: OperatingLimitWarning).
Composed variants¶
The standalone ASHPB: outdoor coil ε-NTU evaporator, R32 cycle, DHW tank charge.
from tmhp import AirSourceHeatPumpBoiler
ashpb = AirSourceHeatPumpBoiler(ref="R32")
result = ashpb.analyze_steady(
T_tank_w=55.0,
T0=7.0,
Q_ref_tank=8_000,
)
Adds a flat-plate STC that preheats mains water entering the tank. Reduces the tank-charge duty the heat pump has to deliver.
from tmhp import ASHPB_STC_preheat
from tmhp.subsystems import SolarThermalCollector
stc = SolarThermalCollector(A_stc=4.0, stc_tilt=35.0, stc_azimuth=180.0)
model = ASHPB_STC_preheat(stc=stc, ref="R32")
A pumped collector loop draws tank water, heats it and returns it,
under a differential controller with a storage high limit
(T_stc_tank_max, 85 °C).
from tmhp import ASHPB_STC_tank
from tmhp.subsystems import SolarThermalCollector
stc = SolarThermalCollector(A_stc=4.0, stc_tilt=35.0, stc_azimuth=180.0)
model = ASHPB_STC_tank(stc=stc, ref="R32")
Photovoltaic generation + ESS preferentially feeds the compressor and auxiliaries.
from tmhp import ASHPB_PV_ESS
from tmhp.subsystems import EnergyStorageSystem, PhotovoltaicSystem
model = ASHPB_PV_ESS(
pv=PhotovoltaicSystem(),
ess=EnergyStorageSystem(),
ref="R32",
)
Solar inputs and the collector model¶
Irradiance inputs. I_DN_schedule is the direct-normal
irradiance (beam on a surface facing the sun) and I_dH_schedule the
diffuse-horizontal irradiance, step averages in W/m². They are not
added: the collector (and the PV array) transposes them to its own plane —
beam I_DN·cos θ, sky diffuse (Perez by default) and ground reflection
(albedo 0.2) — with the sun position of the step. For measured
global-horizontal data (e.g. KMA hourly GHI) split it first with
tmhp.weather.decompose_ghi_to_poa(), whose dni / dhi columns
are these two schedules.
Site and clock. The sun position needs where and when:
latitude / longitude (default Seoul, 37.57 °N 126.98 °E),
utc_offset_h (default 9, KST) and start_time, the local standard
time of simulation second 0 (default 00:00 on 20 March, a year-average sun
path). Set start_time to the first timestamp of your weather data,
at local midnight so that the boiler’s clock schedules agree. A beam given
while the sun is below the horizon for a whole step is dropped with a
warning: it means the site or the clock does not match the data.
Collector. SolarThermalCollector uses the
ISO 9806 / EN 12975 quasi-steady efficiency on the mean fluid temperature,
Q_u = A·[η0·(K_b·G_b + K_d·G_d) − a1·ΔT_m − a2·ΔT_m²], with the ASHRAE
incidence-angle modifier K_b = 1 − b0·(1/cos θ − 1). A_stc is the
area the coefficients refer to. The defaults are a representative
single-glazed flat plate (eta0_stc 0.78, a1_stc 3.6 W/(m²·K),
a2_stc 0.015 W/(m²·K²), b0_stc 0.10; stagnation about 170 °C at
1000 W/m²); take them from a datasheet for a given product. The pumped
loops circulate the ISO test flow, 0.02 kg/(s·m²) of collector, unless
dV_stc_w is set. The former construction parameters (A_stc_pipe,
alpha_stc, h_o_stc …) are accepted with a DeprecationWarning.
Loop control. A pumped loop is run by a differential controller. A
stopped pump starts when the idle collector is dT_stc_on (6 K) above the
sink, provided the run would hold; a running pump runs on while its outlet
stays dT_stc_off (2 K) above the sink. The gain must exceed the pump
power and the outlet stay below T_stc_boil (100 °C). Charging the tank
stops at T_stc_tank_max (85 °C) within the step, and so does circulation
once the outlet reaches T_stc_boil as the tank warms:
stc_runtime_fraction [-] is the share of the step the loop ran, and the
flow, pump power and delivered heat are step averages. After the tank has
reached its limit the loop starts again only once the tank is 2 K below it.
Every step closes Q_sol_stc = (Q_stc_w_out − Q_stc_w_in) + Q_l_stc with
Q_stc_w_out − Q_stc_w_in = Q_solar_tank.
With the default flow (the ISO test flow) the running outlet is only a few
kelvin above the inlet, so the 2 K stop threshold decides in both directions;
the start threshold matters for low-flow loops (dV_stc_w).
Freeze protection. The collector carries water (tank water or mains
water), so the system is a drain-back one: while the idle collector is below
T_stc_freeze (4 °C) the loop does not run and the collector is drained.
stc_freeze_protected [-] marks those steps (winter nights, and dull
winter days). T_stc_freeze=None declares a loop filled with antifreeze
and switches the protection off; a separate antifreeze loop with a heat
exchanger is not modelled.
Stagnation lock-out. When the tank is at its limit the loop stops and the
collector idles at its stagnation temperature (T_stc_stag [°C], 130–160 °C
on a clear day). Pumping tank water into an absorber that hot makes steam,
so a loop that a protection holds off while its idle collector is at or above
T_stc_lockout (130 °C) is locked out: it is not started again, even if a
draw cools the tank, until the collector has cooled 10 K below the lock-out
temperature. stc_stagnation_lockout [-] marks those steps. On a clear
day that fills the tank before noon the loop therefore collects nothing in
the afternoon; T_stc_lockout=None switches the lock-out off. The
collector has no heat capacity in the model, so its idle temperature is the
equilibrium one of the step.
The pump latch, the limit hold and the lock-out are state of the run: they
travel in DynamicState.subsystem_state between step() calls, and a
run starts with all of them cleared.
STC preheat¶
A SolarThermalCollector sits in the mains line
that feeds the tank: mains → collector → tank make-up inlet, while the
mixing valve’s cold side takes mains water directly. Only the water that
enters the tank passes the collector, so its flow is the tank’s make-up
flow; it is solved together with the tank temperature and the preheated
inflow is the reported T_tank_w_in [°C]. The collector is bypassed
outside the preheat_start_hour–preheat_end_hour window, without a
draw and when it would cool the feed; when its outlet reaches
T_stc_tank_max at the flow the end-of-step tank draws, it is bypassed for
the rest of the step. The mains pressure drives it: no pump power. The
freeze protection applies (bypassed and drained below T_stc_freeze); the
stagnation lock-out does not, there being no pump to hold off. Between draws
the collector has no flow, so on a clear day it idles far above 100 °C
(T_stc_stag [°C]) and the next draw passes through it: check that column
before relying on this placement where draws are rare.
import numpy as np
import pandas as pd
import pvlib
from tmhp import ASHPB_STC_preheat
from tmhp.subsystems import SolarThermalCollector
stc = SolarThermalCollector(
A_stc=4.0, # 4 m² collector area
stc_tilt=35.0,
stc_azimuth=180.0,
start_time="2026-03-20", # local time of second 0 (Seoul by default)
)
model = ASHPB_STC_preheat(stc=stc, ref="R32")
Drive it the same way as base ASHPB, adding irradiance schedules
(I_DN_schedule, I_dH_schedule) — direct-normal and
diffuse-horizontal, both in W/m² per step:
dt_s = 60
n_steps = 24 * 3600 // dt_s
# Clear-sky DNI / DHI for Seoul on the start day (step midpoints).
site = pvlib.location.Location(37.57, 126.98, "Asia/Seoul")
times = pd.date_range("2026-03-20", periods=n_steps, freq=f"{dt_s}s", tz="Asia/Seoul")
sky = site.get_clearsky(times + pd.Timedelta(seconds=dt_s / 2))
I_DN = sky["dni"].to_numpy()
I_dH = sky["dhi"].to_numpy()
T0 = np.full(n_steps, 5.0)
dhw = np.zeros(n_steps)
df = model.analyze_dynamic(
simulation_period_sec = n_steps * dt_s,
dt_s = dt_s,
T_tank_w_init_C = 50.0,
dhw_usage_schedule = dhw,
T0_schedule = T0,
I_DN_schedule = I_DN,
I_dH_schedule = I_dH,
)
To quantify the contribution, run the same schedules through a base
AirSourceHeatPumpBoiler and difference the daily compressor
energy:
from tmhp import AirSourceHeatPumpBoiler
base = AirSourceHeatPumpBoiler(ref="R32").analyze_dynamic(
simulation_period_sec = n_steps * dt_s,
dt_s = dt_s,
T_tank_w_init_C = 50.0,
dhw_usage_schedule = dhw,
T0_schedule = T0,
)
def daily_kwh(s, dt_s=dt_s):
return float(s.sum()) * dt_s / 3.6e6
saving = daily_kwh(base["E_cmp [W]"]) - daily_kwh(df["E_cmp [W]"])
print(f"STC preheat saving: {saving:.2f} kWh/day")
- class tmhp.ASHPB_STC_preheat(*, stc, **kwargs)[source]
Bases:
STCPreheat,AirSourceHeatPumpBoilerAirSourceHeatPumpBoiler+SolarThermalCollectorin mains preheat placement.The behaviour and energy columns are those of
tmhp._stc_scenarios.STCPreheat: the collector runs at the tank’s make-up flow andQ_stc_w_out - Q_stc_w_in = Q_solar_tankis the heat the preheated inflow brings into the tank.- Parameters:
stc (
SolarThermalCollector) – Collector, site and clock (its pump power is set to 0 on a copy: the mains pressure drives the flow).**kwargs (
Any) – Forwarded toAirSourceHeatPumpBoiler.
- Raises:
TypeError – If stc is not a
SolarThermalCollectorinstance.
STC tank loop¶
- class tmhp.ASHPB_STC_tank(*, stc, **kwargs)[source]
Bases:
STCTankLoop,AirSourceHeatPumpBoilerAirSourceHeatPumpBoiler+SolarThermalCollectorin tank-loop placement.The behaviour and energy columns are those of
tmhp._stc_scenarios.STCTankLoop: per stepQ_sol_stc = (Q_stc_w_out - Q_stc_w_in) + Q_l_stcandQ_stc_w_out - Q_stc_w_in = Q_solar_tank;E_totincludesE_stc_pump.- Parameters:
stc (
SolarThermalCollector) – Collector, loop pump and controller settings, site and clock.**kwargs (
Any) – Forwarded toAirSourceHeatPumpBoiler.
- Raises:
TypeError – If stc is not a
SolarThermalCollectorinstance.
UV lamp¶
A UVLamp (uv= on the base boilers and the PV +
ESS variants) switches on num_switching times per period_sec for
exposure_sec each. Each step reports the lamp’s step-average power
E_uv [W] (the schedule integrated over the step, so a 12 s exposure is
12 s of lamp energy at any dt_s) and the heat it gives the tank water,
Q_uv_tank = heat_to_water_fraction · E_uv. The default fraction 0.9
assumes the lamp in a quartz sleeve inside the tank (its UV, light and heat
all end in the water) and its ballast (about 90 % efficient) in the control
box outside; set 1.0 when both are inside the tank boundary.
E_tot [W] includes the lamp: E_tot = E_cmp + E_ou_fan + E_uv on the
base boiler (E_pmp in place of the fan on the ground- and water-source
boilers). The PV + ESS variants route that E_tot, so the lamp is counted
once. COP columns (cop_ref, cop_sys) describe the heat-pump cycle and
do not include the lamp.
PV + ESS¶
PhotovoltaicSystem generation feeds the
compressor and auxiliaries; an EnergyStorageSystem
buffers midday surplus for evening load; grid import covers
whatever the two cannot supply.
No grid export. DC power that neither the heat pump nor the battery can
take is discarded and reported as E_dump [W]; nothing is sold to the grid
(a large array on a small load dumps a large share of its output).
Where the efficiencies act. The charge controller (eta_ctrl) sits between
the array output E_pv_out and E_ctrl_out; the battery efficiencies
(eta_ess_chg, eta_ess_dis) act inside the battery; the inverter
(eta_inv, 0 < eta_inv <= 1) acts on the DC power that reaches it, i.e.
PV direct plus battery discharge. Every loss is a result column, so each step
closes (all in W):
E_pv_out = Q_l_ctrl + E_pv_to_inv + E_ess_chg + E_dump
E_tot = E_inv_out + E_grid_import
E_inv_out = eta_inv * (E_pv_to_inv + E_ess_dis), Q_l_inv = (1 - eta_inv) * (E_pv_to_inv + E_ess_dis)
E_ess_chg - E_ess_dis = C_ess_max * dSOC_ess/dt + Q_l_ess
E_tot is the whole electric draw of the system: compressor, E_ou_fan
(outdoor fan) and the UV lamp E_uv when one is attached. E_inv_out is the
AC power out of the inverter only (it excludes E_grid_import). cop_grid is
Q_tank_w_out / E_grid_import and is NaN while the import is at most 1 mW
(tmhp.subsystems.GRID_IMPORT_FLOOR_W): without a grid draw there is no
meaningful ratio.
The battery state of charge belongs to the run: every analyze_dynamic starts
from ess.SOC_init again, so the same model run twice gives the same result.
from tmhp import ASHPB_PV_ESS
from tmhp.subsystems import EnergyStorageSystem, PhotovoltaicSystem
model = ASHPB_PV_ESS(
pv = PhotovoltaicSystem(),
ess = EnergyStorageSystem(),
ref = "R32",
)
# Pass I_DN_schedule + I_dH_schedule to analyze_dynamic exactly
# as you would for ASHPB_STC_preheat.
24-hour ASHPB_PV_ESS run with a clear-sky irradiance profile
and default PhotovoltaicSystem / EnergyStorageSystem sizes.
Panel (b) makes the sizing tradeoff readable: shrinking the ESS
column on the left would push more of the right-hand bar from
“PV” to “Grid”. Generated by
scripts/visualization/pv_ess_energy_balance.py.¶
- class tmhp.ASHPB_PV_ESS(*, pv, ess=None, eta_inv=0.95, T_inv_K=313.15, **kwargs)[source]
Bases:
AirSourceHeatPumpBoilerASHPB scenario where the heat pump is supplied by PV + ESS + Grid.
The PV/ESS routing is resolved synchronously inside
_augment_resultsafter the HP compressor load is known. No 1-step lag: the PV energy is allocated to the exact HP load produced in the same timestep.The battery state of charge belongs to a run: it is restored to
ess.SOC_initwhen a run starts (make_initial_state, which bothanalyze_dynamicand an externalstep()driver call), so repeating a run on the same model reproduces it.- Parameters:
pv (
PhotovoltaicSystem) – Pure-physics PV + charge-controller model.ess (
EnergyStorageSystem|None) – Pure-physics battery model withcharge()/discharge().eta_inv (
float) – Inverter DC→AC efficiency [–],0 < eta_inv <= 1.T_inv_K (
float) – Inverter temperature for entropy calculation [K].**kwargs – Forwarded to
AirSourceHeatPumpBoiler.
- __init__(*, pv, ess=None, eta_inv=0.95, T_inv_K=313.15, **kwargs)[source]
- Parameters:
pv (
PhotovoltaicSystem)ess (
EnergyStorageSystem|None)eta_inv (
float)T_inv_K (
float)
- make_initial_state(T_tank_w_init_C, tank_level_init=1.0)[source]
Start of a run: tank state as the base class, battery back at
SOC_init.- Parameters:
T_tank_w_init_C (
float)tank_level_init (
float)
- Return type:
DynamicState
API reference¶
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 compressor with three quantities of the default maps (
tmhp.compressor_efficiency, scaled bycompressor_scale): the volumetric efficiencyeta_vsets the mass flow, the overall efficiencyeta_ovthe powerE_cmp = m_dot (h_2s - h_1) / eta_ov, and the heat-loss sharef_lossthe shell lossQ_cmp_loss = f_loss E_cmp; the discharge enthalpy follows from the energy balance.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: An external plate condenser the tank water is pumped through (circulation flow
m_dot_w_rated, conductanceUA_tank_hx); the tank temperature is the water entering it.m_dot_w_rated=0selects a coil without circulating water,UA_tank_hxworking against the tank temperature.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.
- tmhp.air_source_heat_pump_boiler.BINDING_OUTDOOR_COIL = 'outdoor_coil'¶
capacity_bindingof a duty reduced to what the outdoor coil absorbs (the family’s name for the shared"source_heat_exchanger").
- class tmhp.air_source_heat_pump_boiler.AirSourceHeatPumpBoiler(ref='R290', V_cmp_ref=None, dT_superheat=5.0, dT_subcool=5.0, UA_tank_hx=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, min_on_time_s=0.0, min_off_time_s=0.0, stc=None, pv=None, uv=None, vsd_coeffs=None, T_sur=20.0, dT_hx_min=0.5, PR_cycle_min=1.5, PR_cycle_max=11.0, rps_min=15.0, rps_max=None, V_disp_cmp=None, UA_tank=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, *, compressor_scale=None, rps_rated=None, m_dot_ref_rated=None, rated_condition=None, dT_w_rated=5.0, m_dot_w_rated=None, dV_fan_a_ref=None, dV_fan_a_min=None, dV_fan_a_max=None, E_fan_rated=None, T_dis_max='auto', x_suction_min='auto', Cd_cycling=0.9, T_cond_max='auto', defrost=True, condensing_limit_control='stop')[source]¶
Bases:
ReferenceStateMixin,CompressorMapPlotMixinAir 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: tank water entering a plate condenser at the circulation flow (constant-surface-temperature ε-NTU;
m_dot_w_ratedby default,m_dot_wof a call), or, without flow,dT_ref_tank = Q_ref_tank / UA_tank_hx. A bounded 1-D optimiser (Brent’s method) minimises total electrical input (E_cmp + E_ou_fan) over the evaporator approach.Default heat exchangers.
UA_tank_hxandUA_ou_ratedleft out are the effective conductances that reproduce the approach temperatures real air-to-water machines print at their rating point (tmhp.default_inputs.estimate_hx_UA()): the plate condenser at the rated circulation flow (hp_capacity / (c_w dT_w_rated), 5 K rise by default) and the outdoor coil as an evaporator at its rated airflow, recorded indefault_input_estimates.Unless explicitly injected, compressor efficiencies are the default maps of
tmhp.compressor_efficiency, evaluated at the pressure ratio, the shaft speed in rev/s and the evaporating temperature. A scalar or a callable given for one replaces that model.Below the minimum capacity.
analyze_steadyreports a request below what the compressor delivers atrps_minas the mean of on/off cycling (capacity_clamped == "min",tmhp.cycling):Q_ref_tank [W]equals the request,runtime_fraction [-]is the share of the time the compressor runs, and the electrical input carries the EN 14825 degradation of a unit delivering to water –Cd_cyclingis its coefficientCc(0.9: while the compressor is off the unit draws a tenth of its running input; 1.0: nothing; a tested unit hasCc = 1 - P_off / P_on).Cd_cycling=Nonereturns the continuous minimum-speed point, which delivers more than the request. Of the machines the speed floor offers (the outdoor fan still has a range there) the row is the most efficient one, whatever the tank temperature. Dynamic runs are not affected: there the tank thermostat switches the compressor, which runs athp_capacityforruntime_fraction [-]of a step.Frost and defrost. Below 5 degC outdoor the coil frosts and the unit stops heating from time to time to melt it.
analyze_steadyand the cycle of a dynamic step then report the mean over frosting and defrost (tmhp.defrost, the EnergyPlus / DOE-2.1E adjustment, in full at and below 2 degC), asAirSourceHeatPumpdoes: the request is met by the mean, so the frost-free cycle is solved at the larger duty(Q_ref_tank + Q_defrost) / frost_capacity_factor, the compressor draws its power while it defrosts too, and a reverse-cycle defrost takesQ_defrost [W]from the tank. A request the unit cannot meet under frost is delivered short (capacity_clamped == "max").defrost=False(orNone) returns the frost-free steady state;RH_out(RH_out_schedulein a dynamic run,inputs["RH_out"]instep) is the outdoor relative humidity, 0.84 when not given.Charging at the condensing limit.
condensing_limit_controlsays what a dynamic run does where the nameplate duty condenses onT_cond_max(the tank atT_cond_maxlesshp_capacity / K_tank_hx)."stop", the default, ends the charge there and caps the set points at it: a fixed-speed unit, or a controller that stops on its high-pressure protection."reduce_duty"is an inverter unit: the compressor slows down and keeps charging at the largest duty inside the limit,K_tank_hx (T_reach - T), which is the dutyanalyze_steadyreports there, down to the smallest duty it runs at continuously. The tank’s first-order approach to the limit is solved inside each step (tmhp.dynamic_context.resolve_step_operation(), which also says how far the result is independent of the step); rows carryreduced_duty_fraction [-]. That covers the outdoor states in which the condensing limit governs the whole stretch down to that duty, checked once per outdoor state with three cycles (tmhp.compressor_envelope.condensing_stretch()). Where another limit governs on it (the pressure ratio in cold air, a discharge-temperature limit, a low speed ceiling), reduced-duty charging is withheld: the step is solved exactly as"stop"solves it, andreduced_duty_withheldnames what withheld it. The set points are then capped where the smallest continuous duty meets the limit, evaluated at the rating point’s outdoor air (charge_limit_reference_C); each step applies the limit of its own source.analyze_steadyis the same with either value. With a frosting coil the limit binds the frost-free cycle and the heat delivered is its mean over frosting and defrost.- Parameters:
ref (
str)V_cmp_ref (
float|None)dT_superheat (
float)dT_subcool (
float)UA_tank_hx (
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)min_on_time_s (
float)min_off_time_s (
float)stc (
SolarThermalCollector|None)pv (
PhotovoltaicSystem|None)vsd_coeffs (
dict|None)T_sur (
float)dT_hx_min (
float)PR_cycle_min (
float)PR_cycle_max (
float)rps_min (
float)rps_max (
float|None)V_disp_cmp (
float|None)UA_tank (
float|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)compressor_scale (
CompressorMapScale|None)rps_rated (
float|None)m_dot_ref_rated (
float|None)rated_condition (
Mapping[str,Any] |RatingCondition|None)dT_w_rated (
float)m_dot_w_rated (
float|None)dV_fan_a_ref (
float|None)dV_fan_a_min (
float|None)dV_fan_a_max (
float|None)E_fan_rated (
float|None)T_dis_max (
Union[float,Literal['auto'],None])x_suction_min (
Union[float,Literal['auto'],None])Cd_cycling (
CyclingDegradation|float|None)T_cond_max (
Union[float,Literal['auto'],None])defrost (
DefrostModel|bool|None)condensing_limit_control (
str)
- __init__(ref='R290', V_cmp_ref=None, dT_superheat=5.0, dT_subcool=5.0, UA_tank_hx=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, min_on_time_s=0.0, min_off_time_s=0.0, stc=None, pv=None, uv=None, vsd_coeffs=None, T_sur=20.0, dT_hx_min=0.5, PR_cycle_min=1.5, PR_cycle_max=11.0, rps_min=15.0, rps_max=None, V_disp_cmp=None, UA_tank=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, *, compressor_scale=None, rps_rated=None, m_dot_ref_rated=None, rated_condition=None, dT_w_rated=5.0, m_dot_w_rated=None, dV_fan_a_ref=None, dV_fan_a_min=None, dV_fan_a_max=None, E_fan_rated=None, T_dis_max='auto', x_suction_min='auto', Cd_cycling=0.9, T_cond_max='auto', defrost=True, condensing_limit_control='stop')[source]¶
- Parameters:
ref (
str)V_cmp_ref (
float|None)dT_superheat (
float)dT_subcool (
float)UA_tank_hx (
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)min_on_time_s (
float)min_off_time_s (
float)stc (
SolarThermalCollector|None)pv (
PhotovoltaicSystem|None)vsd_coeffs (
dict|None)T_sur (
float)dT_hx_min (
float)PR_cycle_min (
float)PR_cycle_max (
float)rps_min (
float)rps_max (
float|None)V_disp_cmp (
float|None)UA_tank (
float|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)compressor_scale (
CompressorMapScale|None)rps_rated (
float|None)m_dot_ref_rated (
float|None)rated_condition (
Mapping[str,Any] |RatingCondition|None)dT_w_rated (
float)m_dot_w_rated (
float|None)dV_fan_a_ref (
float|None)dV_fan_a_min (
float|None)dV_fan_a_max (
float|None)E_fan_rated (
float|None)T_dis_max (
Union[float,Literal['auto'],None])x_suction_min (
Union[float,Literal['auto'],None])Cd_cycling (
CyclingDegradation|float|None)T_cond_max (
Union[float,Literal['auto'],None])defrost (
DefrostModel|bool|None)condensing_limit_control (
str)
- condensing_limit_control: str¶
- cycling: CyclingDegradation | None¶
continuous at minimum speed).
- Type:
EN 14825 cycling degradation of
analyze_steady(None
- defrost: DefrostModel | None = None¶
frost-free steady state). Set by the constructor.
- Type:
EnergyPlus / DOE-2.1E frost adjustment (None
- ref: str¶
- V_cmp_ref: float¶
- dT_superheat: float¶
- dT_subcool: float¶
- dT_hx_min: float¶
- PR_cycle_min: float¶
- PR_cycle_max: float¶
- rps_min: float¶
- rps_max: float¶
The rated-speed search bound until
_initialize_reference_state()replaces it withdefault_rps_max(rps_rated)(when_rps_max_derived).
- T_dis_max: float | None¶
- T_cond_max: float | None¶
- x_suction_min: float | None¶
- hp_capacity: float¶
- n_ou: float¶
- E_fan_rated: float¶
- dP_fan_rated: float | None¶
- eta_fan_rated: float | None¶
- vsd_coeffs: dict¶
- fan_params: dict¶
- dT_w_rated: float¶
- m_dot_w_rated: float¶
- tank_physical: dict¶
- UA_tank_wall: float¶
- T_sur_K: float¶
- V_tank_full: float¶
- C_tank: float¶
- dV_mix_w_out_max: float¶
- T_tank_w_upper_bound: float¶
- T_tank_w_lower_bound: float¶
- T_sup_w: float¶
- T_sup_w_K: float¶
- T_tank_w_in: float¶
- T_mix_w_out: float¶
- T_tank_w_in_K: float¶
- T_mix_w_out_K: 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]]¶
- min_on_time_s: float¶
- min_off_time_s: float¶
- stc: SolarThermalCollector | None¶
- pv: PhotovoltaicSystem | None¶
- dV_tank_w_in: float¶
- dV_tank_w_out: float¶
- dV_mix_sup_w_in: float¶
- dV_mix_w_out: float¶
- charge_limit_reference_C: float¶
Source temperature the thermostat’s cap was evaluated at [degC].
- property K_tank_hx: float¶
Heat the tank heat exchanger carries per kelvin of condensing temperature above the tank water [W/K].
C_w (1 - exp(-UA_tank_hx / C_w))withC_w = m_dot_w_rated c_w(the plate condenser at its rated circulation flow, the tank water entering it), orUA_tank_hxfor the no-flow form (m_dot_w_rated = 0).
- analyze_steady(T_tank_w, T0, Q_ref_tank, *, m_dot_w=None, return_dict=True, RH_out=None)[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. With circulating water (the default) it is the temperature of the water entering the condenser: the tank water the pump draws. The water leaves atT_tank_w + Q_ref_tank / (m_dot_w c_w).T0 (
float) – Dead-state / outdoor-air temperature [°C].Q_ref_tank (
float) – Target condenser heat rate [W].m_dot_w (
float|None) – Water flow through the condenser [kg/s].None(default) is the rated circulation flowm_dot_w_rated; a positive value is that flow, the condenser a constant-surface-temperature ε-NTU exchanger with the shared water specific heatc_w(tmhp.constants).0is the no-flow form:UA_tank_hxworks against the tank temperature (an immersed coil). A model built withm_dot_w_rated=0uses that form forNonetoo.return_dict (
bool) – If True return dict; else single-row DataFrame.RH_out (
float|None) – Outdoor relative humidity as a fraction (0-1), used by the frost correction. None: the frost model’s default (0.84).
- Returns:
Cycle state plus diagnostic flags.
Three 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","t_cond_below_t_in","pr_above_max","discharge_temp_above_max"(even under the discharge-temperature control the discharge exceedsT_dis_max, at the request and at every smaller and larger duty tried: a request that is only too small for the limit, refused at low speed while a larger duty runs, is a"min"point, below),"condensing_temp_above_max"(even a reduced duty condenses aboveT_cond_max: the tank is too hot),"hx_not_converged", or"optimizer_failed"."failure_detail"(str, failures only) — on"cycle_invalid", which check oftmhp.dynamic_context.unphysical_cycle_detail()rejected a solved cycle; on"hx_not_converged", which fan limit the outdoor coil fails at every approach the cycle reaches ("outdoor_coil_short_at_max_airflow","outdoor_coil_excess_at_min_airflow"or"outdoor_coil_no_band")."capacity_clamped"(str | None) —"min"when the requested duty was below what the compressor delivers atrps_minand the cycle was solved at that floor instead (or below the smallest duty the compressor envelope admits, where the discharge exceedsT_dis_maxbeforerps_minis reached: the cycle is then solved at that duty, aboverps_min),"max"for the corresponding ceiling case,Nonewhen the request was met exactly. A clamped point is converged: the request simply lay outside the machine’s deliverable band, which a real inverter unit answers by running at its limit and cycling. A"min"point is reported as that cycling mean (below); at a"max"point compare"Q_ref_tank [W]"against"Q_request [W]"for the shortfall. A"max"point carries"capacity_binding", the limit active at the point returned:"compressor"(rps_max; also for a reduced point that already runs at it), or the operating limit the request ran into when a smaller duty runs –"discharge_temperature"(T_dis_max),"condensing_temperature"(T_cond_max),"pressure_ratio"(PR_cycle_max) or"outdoor_coil"(the coil is short at the fan’s largest airflow). The largest duty that runs is then returned, with"Q_max [W]"and"Q_request [W]"; seetmhp.compressor_envelope.reduce_duty_within_envelope()."capacity_clamped","capacity_binding","Q_max [W]"and"Q_request [W]"are on every row (Noneor NaN where they do not apply;"Q_request [W]"is theQ_ref_tankasked for), and an off or failed row carries every key of a running one (NaN where it has no value): the keys do not depend on the point."T_ref_cond_sat_v [°C]"is the dew point of the condensing pressure, above"T_ref_cond_sat_l [°C]"by the glide for a zeotropic blend."runtime_fraction [-]","capacity_ratio [-]","part_load_factor [-]","Q_min [W]"and"E_cycling_loss [W]"— on every row. A request below the smallest continuous duty (capacity_clamped == "min") is reported as the mean of on/off cycling:Q_ref_tank [W]equals the request (Q_min [W]is the continuous duty), heat and refrigerant rates are the running machine’s timescapacity_ratio [-]– the compressor runs that share of the time,runtime_fraction [-]– and the electrical inputs carry the EN 14825 degradation for a unit delivering to water (Cd_cycling: the running values timescapacity_ratio / part_load_factor), so both COPs are the continuous ones times the part-load factor. Temperatures, pressures and speed are those of the running machine. WithCd_cycling=Nonethe row is the continuous minimum-speed point andQ_ref_tank [W]exceeds the request."efficiency_extrapolated"(bool) — a default efficiency model is evaluated outside its data at this point."discharge_control"(bool),"dT_ref_superheat [K]","x_ref_cmp_in [-]"— whether the discharge-temperature control heldT_dis_maxand the suction state it used (superheat reduced first, then wet suction down tox_suction_min); seetmhp.compressor_envelope."defrost_fraction [-]","frost_capacity_factor [-]","frost_power_factor [-]","E_defrost [W]","Q_defrost [W]","RH_out [-]","Q_ref_tank_frost_free [W]"and"E_tot_frost_free [W]"— on every row. Below the frost model’s outdoor limit (5 degC; the correction grows to its full size at 2 degC) a running row is the mean over frosting and defrost (tmhp.defrost):defrost_fraction [-]is the share of the runtime spent defrosting, the two factors the multipliers of the frosted coil,E_defrost [W]andQ_defrost [W]the mean power and the tank heat the defrost takes, and the last two the frost-free cycle the row was solved at (heat, flow rates andE_ou_fan [W]are its values scaled; temperatures, pressures and speed are its values).Q_ref_tank [W]is the mean heat delivered: the request, or less withcapacity_clamped == "max"when the unit cannot make up for the frost. Without frost, and withdefrost=False, the fraction is 0, the factors 1 and the last two repeatQ_ref_tank [W]andE_tot [W].
Every failure – an infeasible cycle, a solved cycle that is not an operating point, an outdoor coil that cannot carry the duty, a search that did not settle – returns the same off-mode state:
hp_is_on = False,converged = False,E_cmp = 0,Q_ref_tank = 0, NaN COP, withfailure_reason(andfailure_detailwhere there is one). A request that fails on a limit a smaller duty cures is not a failure when such a duty runs (capacity_clamped = "max"above);"cycle_invalid"with no cycle at all (a condensing temperature at or above the critical point) is not reduced.- Return type:
dict|DataFrame- Warns:
OperatingLimitWarning – Once, when the compressor was asked to run and the result is the off state (
failure_reasonother than"none") or a running point that delivers less than the request (capacity_clamped == "max"): the request, what is delivered, the limit in words and what removes it. Issued once per model and limit unless the"always"filter is set (tmhp.operating_limits).
- make_initial_state(T_tank_w_init_C, tank_level_init=1.0)[source]¶
Build the initial carried state for a
step()-driven run.A tank whose level varies (
tank_always_full=Falseorprevent_simultaneous_flow) starts with at leastTANK_LEVEL_MINof water: an empty tank has no temperature to start from.- Parameters:
T_tank_w_init_C (
float)tank_level_init (
float)
- Return type:
DynamicState
- step(state, inputs, dt_s)[source]¶
Advance one timestep from state under inputs.
Returns
(new_state, result_row). Re-entrant: every cross-step quantity is read fromstate(neverself), so an external co-simulation master (FMI/EnergyPlus) can drive the model one exchange at a time and re-run it independently.The tank thermostat is followed inside the step (
tmhp.dynamic_context.resolve_step_operation()): the compressor stops when the tank reaches the upper bound and starts when it falls to the lower bound, at any point of the step. It also stops at the envelope stop (tmhp.compressor_envelope.condensing_tank_cutout(): the tank temperature at which the nameplate duty condenses onT_cond_max) whatevermin_on_time_ssays; such a step is a normal one withhp_stop_reason == "condensing_limit"(hp_stop_reasonis on every row,Noneotherwise). Withcondensing_limit_control="reduce_duty"the compressor runs on past that temperature at the duty the limit leaves, and stops where it leaves less than its smallest continuous duty; the row then hasreduced_duty_fraction [-], the part of the step run on the limit, and its rates are the mean of the two stretches. In an outdoor state in which another limit governs on that stretch the step is the one"stop"solves, andreduced_duty_withheldnames what withheld the charging (_charge_stretch()). The heat, power and refrigerant-flow rates inresult_roware averages overdt_s(the running cycle timesruntime_fraction [-]), sorate * dt_sis the step’s energy;hp_is_onsays the compressor ran at some point of the step,hp_starts [-]how often it started, and COP and state points describe the running cycle. The per-step environment is set onselfafresh frominputseach call (transient scratch shared with the cycle/tank helpers).- Parameters:
state (
DynamicState) – Carried state frommake_initial_stateor the previousstep.inputs (
dict) – Per-step drivers:n(int),current_time_s[s],T0[°C],dV_mix_w_out[m³/s],T_sup_w[°C],T_sur[°C], and optionalI_DN/I_dH[W/m²] (default 0) andRH_out(outdoor relative humidity, 0-1, for the frost correction; default: the frost model’s 0.84).dt_s (
float) – Timestep [s].
- Return type:
tuple[DynamicState,dict]
- 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, RH_out_schedule=None)[source]¶
Run a time-stepping dynamic simulation.
Loops over
step(): implicit tank balance per step, with the thermostat followed inside each step, so heat and power are step averages and the result converges asdt_sshrinks. Below 5 degC outdoor the running cycle is the mean over frosting and defrost (defrost_fraction [-]and the other frost keys ofanalyze_steady();E_defrost [W]andQ_defrost [W]are step averages like the other rates).- 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.RH_out_schedule (array-like | None) – Outdoor relative humidity per step, as a fraction (0-1), for the frost correction. If None, the frost model’s default.
- Returns:
Per-timestep result DataFrame, one row per step:
time [s]andtime [h]at the start of the step, and the same columns whatever the run did (a key a step has no value for isNoneor NaN; a flow that does not run is 0).- Return type:
DataFrame- Warns:
OperatingLimitWarning – Once, at the end of a run in which the compressor was called but did not run on some step, or ran below the request: the steps by limit and what they left unserved. The totals are in
df.attrs["operating_limits"](tmhp.operating_limits.summarize_operating_limits()).
- 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 (
DataFrame) – Result DataFrame fromanalyze_dynamic().- Returns:
DataFrame with exergy columns appended.
- Return type:
DataFrame
- operating_range(conditions=None, *, sink_offset_K=None)[source]¶
Solve standard rating conditions and tabulate whether the heat pump runs at each.
A check to call before a simulation; it is not made at construction because it solves the cycle at every condition. One row per condition: whether the compressor runs, delivers the request or a reduced duty, or cycles on and off, its
failure_reason,cop_sys [-], and the limit in words. NoOperatingLimitWarningis issued and the model is not changed.- Parameters:
conditions (
Iterable[StandardCondition] |None) – Conditions to solve;tmhp.standard_conditions.AIR_TO_WATER(A7/W35 … A-15/W55 at the nameplate duty) when omitted. A condition names the water leaving the heat pump; it is solved with the water entering the condenser below it by the temperature rise of the rating (tmhp.standard_conditions), the table’sT_tank_w [°C].sink_offset_K (
float|None) – The water enters this far below each condition’s leaving water [K], at the rated circulation flow, instead (0: the tank water at the named temperature, a stricter point).None: the EN 14511 rise.
- Returns:
Columns
tmhp.standard_conditions.COLUMNS; seetmhp.standard_conditions.operating_range().- Return type:
DataFrame
ASHPB with a SolarThermalCollector — mains preheat placement.
The collector sits in the mains line that feeds the tank; the mixing valve’s
cold side takes mains water directly. See tmhp._stc_scenarios (shared
with the GSHPB version).
Usage¶
from tmhp import SolarThermalCollector, ASHPB_STC_preheat
stc = SolarThermalCollector(A_stc=4.0, start_time="2026-06-01")
model = ASHPB_STC_preheat(stc=stc)
df = model.analyze_dynamic(...)
- class tmhp.ashpb_stc_preheat.ASHPB_STC_preheat(*, stc, **kwargs)[source]¶
Bases:
STCPreheat,AirSourceHeatPumpBoilerAirSourceHeatPumpBoiler+SolarThermalCollectorin mains preheat placement.The behaviour and energy columns are those of
tmhp._stc_scenarios.STCPreheat: the collector runs at the tank’s make-up flow andQ_stc_w_out - Q_stc_w_in = Q_solar_tankis the heat the preheated inflow brings into the tank.- Parameters:
stc (
SolarThermalCollector) – Collector, site and clock (its pump power is set to 0 on a copy: the mains pressure drives the flow).**kwargs (
Any) – Forwarded toAirSourceHeatPumpBoiler.
- Raises:
TypeError – If stc is not a
SolarThermalCollectorinstance.
ASHPB with a SolarThermalCollector — pumped collector loop charging the tank.
The collector loop draws tank water, heats it and returns it to the tank. The
loop is run by a differential controller with a storage high limit
(T_stc_tank_max, 85 °C by default) and boiling protection; see
tmhp._stc_scenarios (shared with the GSHPB version).
Usage¶
from tmhp import SolarThermalCollector, ASHPB_STC_tank
stc = SolarThermalCollector(A_stc=4.0, start_time="2026-06-01")
model = ASHPB_STC_tank(stc=stc)
df = model.analyze_dynamic(...)
- class tmhp.ashpb_stc_tank.ASHPB_STC_tank(*, stc, **kwargs)[source]¶
Bases:
STCTankLoop,AirSourceHeatPumpBoilerAirSourceHeatPumpBoiler+SolarThermalCollectorin tank-loop placement.The behaviour and energy columns are those of
tmhp._stc_scenarios.STCTankLoop: per stepQ_sol_stc = (Q_stc_w_out - Q_stc_w_in) + Q_l_stcandQ_stc_w_out - Q_stc_w_in = Q_solar_tank;E_totincludesE_stc_pump.- Parameters:
stc (
SolarThermalCollector) – Collector, loop pump and controller settings, site and clock.**kwargs (
Any) – Forwarded toAirSourceHeatPumpBoiler.
- Raises:
TypeError – If stc is not a
SolarThermalCollectorinstance.
ASHPB Scenario: Heat Pump driven by PV + ESS with Grid/Dump integration.
Energy routing (all logic lives in tmhp.subsystems.route_pv_ess(),
the subsystems are pure physics):
PV generation →
pv.calc_performance()(array outputE_pv_out, then the charge controller:E_ctrl_out = eta_ctrl · E_pv_out)DC routing of
E_ctrl_out: - PV surplus →ess.charge(); leftover → dump - PV deficit →ess.discharge(); leftover → grid importInverter conversion loss applied to the DC supply (PV direct + battery discharge)
Grid import covers any remaining AC shortfall
There is no grid export: DC power that neither the load nor the battery can
take is discarded and reported as E_dump [W].
Per-step balances (every term is a result column, [W]):
E_pv_out = Q_l_ctrl + E_pv_to_inv + E_ess_chg + E_dump
E_tot = E_inv_out + E_grid_import (AC load)
E_inv_out = eta_inv · (E_pv_to_inv + E_ess_dis), Q_l_inv = (1-eta_inv)·(...)
E_ess_chg - E_ess_dis = C_ess_max·ΔSOC_ess/dt + Q_l_ess
E_tot is the whole electric draw: compressor + outdoor fan + UV lamp.
Note
See the project paper for the orchestration logic and energy/exergy boundaries used by hybrid (PV + ESS + HP) systems.
- class tmhp.ashpb_pv_ess.ASHPB_PV_ESS(*, pv, ess=None, eta_inv=0.95, T_inv_K=313.15, **kwargs)[source]¶
Bases:
AirSourceHeatPumpBoilerASHPB scenario where the heat pump is supplied by PV + ESS + Grid.
The PV/ESS routing is resolved synchronously inside
_augment_resultsafter the HP compressor load is known. No 1-step lag: the PV energy is allocated to the exact HP load produced in the same timestep.The battery state of charge belongs to a run: it is restored to
ess.SOC_initwhen a run starts (make_initial_state, which bothanalyze_dynamicand an externalstep()driver call), so repeating a run on the same model reproduces it.- Parameters:
pv (
PhotovoltaicSystem) – Pure-physics PV + charge-controller model.ess (
EnergyStorageSystem|None) – Pure-physics battery model withcharge()/discharge().eta_inv (
float) – Inverter DC→AC efficiency [–],0 < eta_inv <= 1.T_inv_K (
float) – Inverter temperature for entropy calculation [K].**kwargs – Forwarded to
AirSourceHeatPumpBoiler.
- __init__(*, pv, ess=None, eta_inv=0.95, T_inv_K=313.15, **kwargs)[source]¶
- Parameters:
pv (
PhotovoltaicSystem)ess (
EnergyStorageSystem|None)eta_inv (
float)T_inv_K (
float)
Validation¶
ASHPB runs in the shared catalogue parity harness together with the air-to-air ASHP: 17 manufacturer units are registered and 15 are adopted into the headline figures (the Samsung EHS Mono HT Quiet R32 14 kW unit is one of them). The earlier 15-point Samsung comparison used a dedicated parameter set and is superseded. See Validation for the parity plot, per-unit results and the held catalogues.