EnergyPlus Python Plugin¶
TMHP’s current EnergyPlus adapter exposes
AirSourceHeatPumpBoiler as a
PlantComponent:UserDefined surrogate. EnergyPlus still owns the
plant loop, timestep, load dispatch, and storage-tank objects; TMHP
answers each plant-solver call with a refrigerant-cycle-resolved steady
state through analyze_steady().
Use this path when you have an EnergyPlus model and want the heat pump to be more physical than an empirical catalogue curve fit, without moving the whole building simulation out of EnergyPlus. This page is specific to the ASHPB reference adapter that exists today; it should not be read as a limit on TMHP’s shared refrigerant-cycle core.
What EnergyPlus Python Plugins are¶
EnergyPlus Python Plugins are user-defined Python classes that inherit
from EnergyPlus’s EnergyPlusPlugin base class and override named
methods for specific simulation calling points. In plugin mode,
EnergyPlus is still launched as a normal EnergyPlus simulation; it
starts an embedded Python interpreter and calls the plugin when the IDF
declares the relevant plugin instance and calling manager (EnergyPlus
Python Plugin documentation).
The broader EnergyPlus Python API exposes functional, runtime, and data exchange interfaces. The data exchange API is the part TMHP uses here: it reads plant-loop values and writes actuators or plugin globals during runtime callback methods (EnergyPlus Python API).
For TMHP, this is a narrow and useful boundary. EnergyPlus keeps the IDF, weather file, schedules, plant loop iteration, storage tank, sizing, and reporting. The current ASHPB adapter only replaces the heat-pump component response with a cycle-resolved steady solve, then returns outlet temperature, mass-flow request, electricity, and diagnostics to EnergyPlus.
Runtime contract¶
EnergyPlus Python Plugins run inside EnergyPlus’s embedded CPython.
That means pyenergyplus comes from the EnergyPlus installation, not
from PyPI, and TMHP plus its native dependencies must be importable by
that embedded interpreter.
EnergyPlus plant solver
-> PythonPlugin:SearchPaths
-> tmhp.integrations.energyplus_plugin
-> AirSourceHeatPumpBoiler.analyze_steady()
Practical setup:
Install TMHP into an environment compatible with the EnergyPlus embedded Python ABI.
Add that environment or package path with
PythonPlugin:SearchPaths.Verify an import-only smoke plugin first. A wrong-ABI native wheel such as CoolProp can fail before the plant callback reaches useful logging.
What this enables¶
Workflow |
Why the adapter matters |
|---|---|
Replace a catalogue curve |
Keep the same EnergyPlus plant model, but substitute a refrigerant-cycle TMHP solve for an empirical heat-pump performance curve. |
Compare refrigerants in context |
Run the same building and plant dispatch against different CoolProp-supported refrigerants without re-fitting component curves for every candidate. |
Preserve EnergyPlus reporting |
Leave EnergyPlus responsible for meters, schedules, plant loop iteration, and custom output variables while TMHP exposes compressor energy, power, convergence, and failure diagnostics. |
The payoff is concrete: the whole EnergyPlus building stays exactly as it is, and the empirical catalogue curve in the plant slot is replaced by the current ASHPB refrigerant-cycle solve — so you can compare refrigerants in the same building and dispatch without re-fitting a performance curve for each candidate.
How one plant call works¶
EnergyPlus owns the plant loop, the storage tank, and the timestep. On each plant-solver call it hands the plugin the loop boundary values, and the plugin answers with a single steady cycle solve. (A one-shot sizing call runs once before the simulation to size the plant connection.) Walk through one call step by step:
The plugin memoizes the solve on rounded inputs, because the plant solver
re-calls it with identical inputs many times per timestep. Humidity is rounded
to the nearest 0.01 percentage point for both the cache key and the model input.
The plugin converts the heat put into the loop into the outlet-temperature actuator with
T_out = T_in + q_loop / (mdot * cp) (see
Metered electricity and delivered heat for how q_loop and the metered electricity follow
from the solved cycle).
IDF wiring¶
The adapter expects one PlantComponent:UserDefined component and two
Python plugin managers:
EnergyPlus object |
TMHP binding |
|---|---|
|
Default name |
Initialization program-calling manager |
|
Simulation program-calling manager |
|
|
Declare |
Declare the two weather variables as Output:Variable objects so the
EnergyPlus CLI exposes their handles to the plugin. The plugin requests both
variables on its first pass and sends weather-file humidity to the frost
correction automatically.
Output:Variable, Environment, Site Outdoor Air Drybulb Temperature, Hourly;
Output:Variable, Environment, Site Outdoor Air Relative Humidity, Hourly;
Input / output boundary¶
The plugin reads only finite EnergyPlus boundary values before calling
TMHP. Invalid required inputs are reported through issue_severe(), the plant
component is driven to a safe off state, and the callback returns a
non-zero status. The EPW format accepts relative humidity up to 110%, and
EnergyPlus passes such readings on unclipped; the plugin uses a reading from
100 to 110% as 100% (saturated air). A missing humidity handle, a read flagged
by EnergyPlus, or any other humidity value (negative, above 110%, not finite)
triggers one warning per plugin instance. The solve then uses the model’s
default humidity (84% for the standard frost correction). The
TMHP_PLUGIN_LOG file counts the zone timesteps with a heating dispatch
(warmup days excluded) solved with the weather humidity, with a reading used
as 100%, and with the default, so a run shows how much of it fell back to
84%.
Direction |
Field |
Meaning |
|---|---|---|
EnergyPlus -> TMHP |
Inlet temperature |
Plant Connection 1 inlet water temperature. |
EnergyPlus -> TMHP |
Inlet mass flow rate |
Current loop-side flow available to the user-defined component. |
EnergyPlus -> TMHP |
Inlet specific heat |
Loop fluid heat capacity used to convert heat rate to outlet temperature. |
EnergyPlus -> TMHP |
Load request |
Positive heating load request for the plant component. |
EnergyPlus -> TMHP |
Outdoor drybulb temperature |
Source-side air temperature |
EnergyPlus -> TMHP |
Outdoor relative humidity |
|
TMHP -> EnergyPlus |
Outlet temperature actuator |
Inlet temperature plus the heat put into the loop ( |
TMHP -> EnergyPlus |
Mass-flow actuator |
Requests design flow when load is present and EnergyPlus has not yet provided loop flow. |
TMHP -> EnergyPlus |
|
Timestep electricity of the whole system (compressor and outdoor
fan, |
TMHP -> EnergyPlus |
|
Optional instantaneous system electricity ( |
Configuration¶
The adapter reads its configuration once at import from environment variables:
Variable |
Meaning |
|---|---|
|
Refrigerant name. Default |
|
Nominal heat-pump capacity in watts. Default |
|
|
|
Design loop volume flow in |
|
Plugin global receiving the timestep system electricity ( |
|
Optional plugin global receiving the instantaneous system electricity
in watts. Default |
|
Optional path for per-call and convergence-tally logging. Each logged
solve reports the humidity used by the model, or |
Metered electricity and delivered heat¶
The metered power is the system total E_tot of the solved cycle,
compressor plus outdoor fan. The heat handed to the plant loop and the metered
power always belong to the same operating state:
q_loop = min(Q_cycle, load request, m_dot * cp * (TOUT_MAX - T_in))
E_meter = E_tot * q_loop / Q_cycle
Q_cycle and E_tot are the heat and electricity of the solved, continuously
running cycle; q_loop / Q_cycle is the share of the timestep it runs.
Minimum-speed clamp. A variable-speed machine cannot deliver less than its minimum-speed capacity. At a small part load the solved cycle can deliver several times the request (e.g. 6.8 kW for 1.5 kW). EnergyPlus documents
Load Request for Plant Connection Nas the desired operating capacity of a connection that meets the loop load, and the loop outlet temperature fixes the heat the loop receives, so deliveringQ_cyclewould overheat the loop and its storage tank. The plugin therefore treats the clamp as on/off cycling: the time-averaged heat equals the request and the electricity is scaled by the same duty fraction.analyze_steadynow reports such a point as that cycling mean itself (Steady state below the minimum capacity): the heat of the row is the request and its electrical input carries the EN 14825 degradation for a unit delivering to water (Cc = 0.9unless the model is built with anotherCd_cycling), so the plugin’s own scaling leaves the row as it is and the metered electricity includes that degradation. A model built withCd_cycling=Nonereturns the continuous point and is scaled by the plugin as before, without a penalty.Outlet limit. Heat that would push the outlet above
TOUT_MAXis not delivered, and the electricity that would have produced it is not metered.
Why this uses analyze_steady()¶
EnergyPlus is already the dynamic simulation environment. It owns the plant loop iteration, the storage tank, and the timestep integration. The plugin therefore asks TMHP for a steady component response:
result = hp.analyze_steady(
T_tank_w=t_in,
T0=t0,
Q_ref_tank=q_target,
m_dot_w=m_dot,
RH_out=rh_out,
)
The FMU adapter uses step() instead
because the FMU owns its own dynamic state. Keeping those seams separate
prevents EnergyPlus tank state and FMU tank state from being mixed.
API reference¶
The implementation API is documented at
tmhp.integrations.energyplus_plugin.