def run_dwelling(xlbook, d, can_run_fee, can_run_der, can_run_ter): #can_run_fee=False #can_run_ter=False write_to_excel(xlbook, d) runner.run_fee(d) runner.run_der(d) epctk.appendix.appendix_t.run_ter(d) runner.run_sap(d) if can_run_der: xlbook.set_calc_type("DER") check_results(xlbook, d.der_results, "DER", True) check_result("DER", xlbook.der, d.der_results.der_rating, "DER", 0.01) xlbook.set_calc_type("SAP") check_results(xlbook, d.er_results, "SAP", True) check_result("SAP", xlbook.sap, d.er_results.sap_value, "SAP", 0.01) return False if can_run_ter: xlbook.set_calc_type("TER") check_results(xlbook, d.ter_results, "TER", False) check_result("TER", xlbook.ter, d.ter_results.ter_rating, "TER", 0.01) if can_run_fee: xlbook.set_calc_type("FEE") check_results(xlbook, d.fee_results, "FEE", False) months_with_cooling = sum(1 if x > 0 else 0 for x in d.fee_results.Q_cooling_required) if months_with_cooling != 3: logging.error("FEE is probably wrong due to cooling calculation") check_result("FEE", xlbook.fee, d.fee_results.fee_rating, "FEE", 0.01)
def check_results(xlbook, res, calctype, check_emissions): check_monthly_result(calctype, xlbook.h, res.h, "heat loss coeff") if hasattr(res, "thermal_mass_parameter"): check_result(calctype, xlbook.thermal_mass_parameter, res.thermal_mass_parameter, "thermal mass parameter", 0) check_monthly_result(calctype, xlbook.hw_heat_gain, res.heat_gains_from_hw, "water heat gain", .5) check_monthly_result(calctype, xlbook.solar_gain_winter, res.solar_gain_winter, "solar gain", .1) check_monthly_result(calctype, xlbook.full_light_gain, res.full_light_gain, "heat gain from lights", .1) check_monthly_result(calctype, xlbook.winter_heat_gains, res.winter_heat_gains, "total heat gain", .1) check_result(calctype, xlbook.heating_responsiveness, res.heating_responsiveness, "heating system responsiveness", 0) check_result(calctype, xlbook.heating_control_type, res.heating_control_type_sys1, "heating control type", 0) check_monthly_result(calctype, xlbook.Tliving, res.heat_calc_results['Tmean_living_area'], "internal temperature, living area", .01) check_monthly_result(calctype, xlbook.Tother, res.heat_calc_results['Tmean_other'], "internal temperature, rest of dwelling", .01) check_monthly_result(calctype, xlbook.Tmean, res.heat_calc_results['Tmean'], "internal temperature", .01) check_monthly_result(calctype, xlbook.Q_required, res.Q_required, "space heat required", 2) if sum(res.Q_cooling_required) > 0: check_summer_monthly_result(calctype, xlbook.solar_gain_summer, res.solar_gain_summer, "solar gain (summer)", .1) check_summer_monthly_result(calctype, xlbook.summer_heat_gains, res.summer_heat_gains, "total heat gain (summer)", .1) if not check_emissions: # Emissions results won't match for TER results due to 2009 vs # 2005 fuel factors return check_result(calctype, xlbook.space_main_heating_emissions, res.emissions_heating_main, "space heat emissions (main)", 0.5) check_result(calctype, xlbook.space_secondary_heating_emissions, res.emissions_heating_secondary, "space heat emissions (secondary)", 0.5) check_result(calctype, xlbook.water_heating_emissions, res.emissions_water, "water heat emissions", 0.5) check_result(calctype, xlbook.water_heating_emissions_summer_immersion, res.emissions_water_summer_immersion, "water heat emissions (summer immersion)", 0.5) check_result(calctype, xlbook.pump_emissions, res.emissions_fans_and_pumps + res.emissions_mech_vent_fans, "pump and fan emissions", 0.01) check_result(calctype, xlbook.lighting_emissions, res.emissions_lighting, "lighting emissions", 0.5) check_result(calctype, xlbook.cooling_emissions, res.emissions_cooling, "cooling emissions", 0.01)