From 91bcff7216a4925054ae387a24f349d82f2235e2 Mon Sep 17 00:00:00 2001 From: omicron Date: Sat, 13 Jun 2026 09:43:37 +0200 Subject: [PATCH] Add report functionality to output the calculation results --- report.py | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 report.py diff --git a/report.py b/report.py new file mode 100644 index 0000000..1399050 --- /dev/null +++ b/report.py @@ -0,0 +1,77 @@ +from coefficients import RHO_CP_AIR +from ventilation import Room +from interfaces import Interface, Surface + + +def infiltration_losses(area, v50, reduction_factor=20): + # TODO: review factor 20 vs factor 25 reduction. I think factor 20 is used for + # dimensioning the required input and 25 for average use calculations + + # Infiltration losses + flow_rate = (v50 / reduction_factor) * area / 3600 # m^3 / s + HV_inf = RHO_CP_AIR * flow_rate + return HV_inf + + +def ventilation_losses(rooms: list[Room], eta) -> float: + sum_wet = 0 + sum_dry = 0 + + for room in rooms: + if room.is_wet: + sum_wet += room.flow_rate + else: + sum_dry += room.flow_rate + flow_rate = max(sum_dry, sum_wet) / 3600 # m^3 / s + HV_act = RHO_CP_AIR * flow_rate * (1 - eta) + return HV_act + + +def transmission_losses(interfaces: list[Interface]) -> float: + print(" - Transmission loss contribution by part:") + for interface in interfaces: + if isinstance(interface, Surface): + print( + f" - {interface.name:16s} U = {interface.U:4.2f} W/m²K HT = {interface.HT:4.1f} W/K" + ) + HT = sum(interface.HT for interface in interfaces) + return HT + + +def report(situation) -> None: + name = situation["name"] + rooms = situation["ventilation_rooms"] + eta_vent = situation["ventilation_eta"] + infiltration_area = situation["ventilation_v50_area"] + infiltration_v50 = situation["ventilation_v50_value"] + + interfaces = situation["transmission_interfaces"] + + delta_t_worst = situation["environment_delta_t_worst"] + delta_t_typical = situation["environment_delta_t_typical"] + + print(f"Report for situation: {name}") + + HV_inf_worst = infiltration_losses(infiltration_area, infiltration_v50) + HV_inf_typical = infiltration_losses( + infiltration_area, infiltration_v50, reduction_factor=25 + ) + HV_act = ventilation_losses(rooms, eta_vent) + print(" - Ventilation loss contribution by part:") + HV_tot = HV_inf_worst + HV_act + HV_tot_typical = HV_act + HV_inf_typical + print(f" - Infiltration HV = {HV_inf_worst:4.1f} W/K") + print(f" - Active ventilation HV = {HV_act:4.1f} W/K") + + HT = transmission_losses(interfaces) + + P_worst = (HV_tot + HT) * delta_t_worst + # FIXME: hacky way to do a less dramatic worst case to consider + P_worst2 = (HV_tot + HT) * 23 + P_typical = (HV_tot_typical + HT) * delta_t_typical + + print(f" - HV = {HV_tot:7.1f} W/K") + print(f" - HT = {HT:7.1f} W/K") + print(f" - P worst = {P_worst:5.0f} W") + print(f" - P worst2 = {P_worst2:5.0f} W") + print(f" - P typical = {P_typical:5.0f} W")