Demand & weather¶
Outdoor-air temperature utilities and domestic hot water demand profiles consumed by the dynamic simulation entry points.
Weather¶
Weather data processing and irradiance calculations.
Irradiance convention of the dynamic models¶
The I_DN_schedule / I_dH_schedule inputs of the boiler models are the
direct-normal irradiance (DNI, beam on a surface facing the sun) and the
diffuse-horizontal irradiance (DHI), step averages in W/m². A collector or
PV array turns them into the irradiance on its own plane with
plane_of_array_irradiance(), from the sun position at the step midpoint
(solar_position(), site and clock from the collector’s latitude,
longitude, utc_offset_h and start_time). Measured global-horizontal
irradiance (GHI, e.g. KMA data) is split into DNI and DHI with
decompose_ghi_to_poa(), whose result carries dni and dhi columns.
- tmhp.weather.decompose_ghi_to_poa(ghi, latitude, longitude, tilt, azimuth, altitude=0, tz='Asia/Seoul', decomposition='erbs', transposition='perez')[source]¶
Decompose GHI to POA (Plane of Array) total irradiance.
- Parameters:
ghi (
ndarray) – Global horizontal irradiance timeseries [W/m2]. Must have DatetimeIndex.latitude (
float) – Location latitude.longitude (
float) – Location longitude.tilt (
float) – Surface tilt angle [deg].azimuth (
float) – Surface azimuth [deg]. 180 is South.altitude (
float) – Location altitude [m]. Default is 0.tz (
str) – Timezone. Default is ‘Asia/Seoul’.decomposition (
str) – DNI/DHI decomposition model:'erbs'(default),'disc','dirint'or'boland'(pvlib). Any other name raisesValueError.transposition (
str) – POA transposition model (‘perez’, ‘isotropic’, etc). Default is ‘perez’.
- Returns:
DataFrame with ‘poa_global’, ‘poa_direct’, ‘poa_diffuse’ (and pvlib’s sky/ground components) plus the decomposed
'dni'and'dhi', which are theI_DN_schedule/I_dH_scheduleinputs of the dynamic models.- Return type:
DataFrame
- tmhp.weather.load_kma_T0_sol_hourly_csv(csv_path, encoding='euc-kr')[source]¶
Load KMA hourly temperature and solar irradiance CSV.
- Parameters:
csv_path (
str) – Path to CSV file.encoding (
str) – File encoding. Default is ‘euc-kr’.
- Returns:
DataFrame with datetime index, ‘T0_K’, and ‘ghi’ columns.
- Return type:
DataFrame
- tmhp.weather.load_kma_solar_csv(csv_path, encoding='euc-kr')[source]¶
Load a Korea Meteorological Administration (KMA, 기상청) 1-minute cumulative solar irradiance CSV.
- Parameters:
csv_path (
str) – Path to CSV file.encoding (
str) – File encoding. Default is ‘euc-kr’.
- Returns:
DataFrame with datetime index and ‘ghi’ column [W/m2].
- Return type:
DataFrame
- tmhp.weather.plane_of_array_irradiance(dni, dhi, *, zenith, azimuth, tilt, surface_azimuth, albedo=0.2, sky_model='perez', day_of_year=79.0)[source]¶
Irradiance on a tilted plane [W/m²] from DNI and DHI and the sun position.
Beam
DNI·cos θ(zero with the sun below the horizon or behind the plane), sky diffuse fromsky_model("perez"(default, asdecompose_ghi_to_poa()),"haydavies"or"isotropic", via pvlib) and ground-reflectedalbedo·GHI·(1 − cos β)/2withGHI = DNI·cos z + DHI. With the sun below the horizon the beam is zero and the sky diffuse is isotropic.Returns
beam,sky,ground,total,aoi[deg],ghi,zenithanddni_used(the DNI after the horizon check).- Parameters:
dni (
float)dhi (
float)zenith (
float)azimuth (
float)tilt (
float)surface_azimuth (
float)albedo (
float)sky_model (
str)day_of_year (
float)
- Return type:
dict[str,float]
- tmhp.weather.solar_position(day_of_year, *, latitude=37.57, longitude=126.98, utc_offset_h=9.0)[source]¶
Solar zenith and azimuth [deg] at a fractional day of year (local standard time).
day_of_yearcounts from 1 at 1 January 00:00 local standard time (utc_offset_hhours ahead of UTC); its fraction is the clock time. Spencer (1971) declination and equation of time with the analytical zenith/azimuth (Duffie & Beckman, Solar Engineering of Thermal Processes, 4th ed., §1.6): within 0.3° (zenith) and 0.4° (azimuth) of NREL SPA over a year at Seoul, without atmospheric refraction. Azimuth is clockwise from north (180 = south), as in pvlib.- Parameters:
day_of_year (
float)latitude (
float)longitude (
float)utc_offset_h (
float)
- Return type:
tuple[float,float]
Domestic hot water demand¶
Domestic Hot Water (DHW) load modeling.
Besides the draw-schedule helpers, this module holds the hot-water service
accounting the boiler models share: what a step was asked to deliver, what it
did not deliver (dhw_service_columns()), the totals of a run
(summarize_dhw_service()) and the end-of-run warning
(warn_if_dhw_unmet()).
- tmhp.dhw.DHW_REQUEST_KEY: str = 'Q_dhw_request [W]'¶
hot-water heat a step was asked to deliver [W].
- Type:
Result key
- tmhp.dhw.DHW_SETPOINT_TOL_K: float = 0.01¶
Width of the service set point [K].
A delivery whose shortfall is no more than the requested flow cooled by this much counts as met (
Q_dhw_unmet [W]is 0). The mixing valve of a multi-node tank is set on the outlet temperature by iteration (to 1e-3 K), and a lumped tank sitting on the set point differs between platforms in the last digits; neither is a hot-water shortfall. 0.01 K is 0.04 % of a 25 K lift.
- tmhp.dhw.DHW_UNMET_KEY: str = 'Q_dhw_unmet [W]'¶
part of
Q_dhw_request [W]a step did not deliver [W].- Type:
Result key
- exception tmhp.dhw.DHWUnmetWarning[source]¶
Bases:
OperatingLimitWarningA dynamic run delivered less hot water than its draw schedule asked for.
A
tmhp.OperatingLimitWarning(itself aUserWarning): a filter on that class covers this one together with the warnings about a compressor that did not run or ran below the request.
- tmhp.dhw.build_dhw_usage_ratio(entries, t_array)[source]¶
Build schedule ratio array from schedule entries for each timestep.
- Parameters:
entries (
list[tuple[str,str,float]]) – Schedule entry list. Each item is (start_str, end_str, frac) with times in hours, hours:minutes or hours:minutes:seconds.t_array (
ndarray) – Array of time seconds from start of day.
- Returns:
Array of fractions corresponding to
t_array.- Return type:
ndarray
- tmhp.dhw.calc_cold_water_temp(df, target_date_str, *, latitude=None)[source]¶
Mains water temperature [°C] by the EnergyPlus
Site:WaterMainsTemperaturecorrelation.The correlation of Burch & Christensen (NREL; Hendron et al. 2004) as EnergyPlus evaluates it (Engineering Reference, “Water Mains Temperatures”;
WaterMainsTempFromCorrelationinWeatherManager.cc). It is fitted in °F, so the inputs are converted to °F, the correlation is evaluated there and the result converted back:T_mains = (T_avg + 6) + ratio · (ΔT_max / 2) · sin(0.986·(day − 15 − lag) − 90) ratio = 0.4 + 0.01·(T_avg − 44) lag = 35 − 1.0·(T_avg − 44)
in °F with the sine argument in degrees,
T_avgthe annual mean outdoor temperature andΔT_maxthe spread (max − min) of the monthly mean outdoor temperatures. The result is not allowed below 32 °F (0 °C). South of the equator the seasonal term changes sign, as in EnergyPlus.References
Hendron, R., Anderson, R., Christensen, C., Eastment, M., & Reeves, P. (2004). Development of an Energy Savings Benchmark for All Residential End-Uses. SimBuild 2004, IBPSA-USA. EnergyPlus Engineering Reference, Water Systems.
- Parameters:
df (
DataFrame) – The twelve monthly mean outdoor temperatures [°C] in a column whose name containsT_avg(or기온,temp,T0,°C,℃).target_date_str (
str) – Target date string in ‘YYYY-MM-DD’ format.latitude (
float|None) – Site latitude [°]; negative flips the season.None: northern hemisphere.
- Returns:
Mains water temperature [°C].
- Return type:
float
- tmhp.dhw.calc_total_water_use_from_schedule(schedule, peak_load_m3s, info=True, info_unit='L')[source]¶
Calculate total daily water use from a schedule.
- Parameters:
schedule (
list[tuple[str,str,float]]) – Schedule list. Each item is (start_str, end_str, ratio) with times in hours, hours:minutes or hours:minutes:seconds.peak_load_m3s (
float) – Peak load water flow rate [m3/s].info (
bool) – Flag to print info. Default is True.info_unit (
str) – Unit to print info. Default is ‘L’.
- Returns:
Total daily water usage [m3].
- Return type:
float
- tmhp.dhw.dhw_service_columns(dV_request, dV_delivered, T_delivered_K, T_set_K, T_sup_w_K)[source]¶
Hot-water heat a step was asked for and the part it did not deliver.
The request is the scheduled mixed-water flow at the service set point, counted from the mains temperature:
Q_dhw_request = rho·c · dV_request · (T_set − T_sup_w)The delivery is the mixed water that actually left the valve at the temperature it left at,
rho·c · dV_delivered · (T_delivered − T_sup_w), andQ_dhw_unmet = Q_dhw_request − delivery(never negative). Two things make it positive:the tank is colder than the set point, so the mixing valve passes tank water unmixed and the water arrives below the set point;
a tank whose level varies stopped the draw at its lowest level, so less water was delivered (
dV_mix_w_out_unmet [m3/s]).
Both are step averages like every other rate in a dynamic result:
Q_dhw_unmet·dtis the step’s shortfall in joules. A shortfall withinDHW_SETPOINT_TOL_Kof the set point is reported as 0.- Parameters:
dV_request (
float) – Mixed-water flow the draw schedule asks for [m³/s].dV_delivered (
float) – Mixed-water flow that left the mixing valve [m³/s].T_delivered_K (
float) – Temperature of the delivered water [K]; unused when nothing was delivered.T_set_K (
float) – Service set point of the mixing valve [K].T_sup_w_K (
float) – Mains water temperature [K].
- Returns:
{"Q_dhw_request [W]": ..., "Q_dhw_unmet [W]": ...}. Both are 0 on a step without a draw, and when the mains water is already at the set point (nothing to heat).- Return type:
dict[str,float]
- tmhp.dhw.make_dhw_schedule_from_Annex_42_profile(flow_rate_array, df_time_step, simulation_time_step)[source]¶
Generate DHW schedule list from flow profile data.
Treat each input rate as constant over its sample interval. Each output fraction is the time-weighted mean rate over the interval divided by the profile peak. The last interval ends at midnight, even for a step that does not divide the day.
- Parameters:
flow_rate_array (
ndarray) – One day of finite, nonnegative flow rates [L/min].df_time_step (
int) – Time step of the inputflow_rate_array[min].simulation_time_step (
int) – Positive whole-second time step for the simulation schedule [s].
- Returns:
Nonzero intervals as tuples (start_time, end_time, fraction). Times include seconds for boundaries that do not fall on a whole minute.
- Return type:
list[tuple[str,str,float]]- Raises:
ValueError – If the profile is not a day of finite, nonnegative rates or the target step is not a positive whole number of seconds.
- tmhp.dhw.summarize_dhw_service(df, dt_s)[source]¶
Hot-water service totals of a dynamic result.
- Parameters:
df (
DataFrame) – Result of a boileranalyze_dynamic(or rows ofstep) carryingQ_dhw_request [W]andQ_dhw_unmet [W].dt_s (
float) – Time step of the result [s].
- Returns:
Q_dhw_request [kWh]: heat the draw schedule asked for;Q_dhw_delivered [kWh]: heat delivered (request less unmet);Q_dhw_unmet [kWh]: heat not delivered;dhw_unmet_fraction [-]: unmet / request (0 without a request);dhw_draw_steps [-]: steps with a draw request;dhw_unmet_steps [-]: steps withQ_dhw_unmet [W] > 0;T_mix_w_out_min [°C]: lowest delivered temperature on a step with a draw (NaN without a draw or without the column).
- Return type:
dict[str,float]- Raises:
KeyError – If
dfdoes not carry the two hot-water columns.
- tmhp.dhw.warn_if_dhw_unmet(df, dt_s, who, T_set_C)[source]¶
Warn once (
DHWUnmetWarning) if a run left hot-water demand unmet.Called at the end of each boiler
analyze_dynamic. Silent when every draw was delivered at the set point, and on frames without the hot-water columns.- Parameters:
df (
DataFrame)dt_s (
float)who (
str)T_set_C (
float)
- Return type:
None