From 6656d8dec203e548778b628ac8853cc5cd9ab77f Mon Sep 17 00:00:00 2001 From: Khalim Conn-Kowlessar Date: Fri, 3 Jul 2026 12:05:04 +0000 Subject: [PATCH] =?UTF-8?q?A=20full-SAP=20export-capable=20PV=20cert=20rep?= =?UTF-8?q?roduces=20its=20lodged=20SAP=2010.2=20score=20=F0=9F=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 4.8 --- .../uprn_10094615101/epc.json | 507 ++++++++++++++++++ .../test_real_cert_sap_accuracy.py | 23 + 2 files changed, 530 insertions(+) create mode 100644 backend/epc_api/json_samples/real_life_examples/SAP-Schema-19.1.0/uprn_10094615101/epc.json diff --git a/backend/epc_api/json_samples/real_life_examples/SAP-Schema-19.1.0/uprn_10094615101/epc.json b/backend/epc_api/json_samples/real_life_examples/SAP-Schema-19.1.0/uprn_10094615101/epc.json new file mode 100644 index 000000000..187b4a17a --- /dev/null +++ b/backend/epc_api/json_samples/real_life_examples/SAP-Schema-19.1.0/uprn_10094615101/epc.json @@ -0,0 +1,507 @@ +{ + "der": 3.23, + "ter": 13.27, + "dfee": 35.2, + "dper": 41.21, + "tfee": 36.7, + "tper": 70.27, + "uprn": 10094615101, + "roofs": [ + { + "description": { + "value": "Average thermal transmittance 0.09 W/m\u00b2K", + "language": "1" + }, + "energy_efficiency_rating": 5, + "environmental_efficiency_rating": 5 + } + ], + "walls": [ + { + "description": { + "value": "Average thermal transmittance 0.19 W/m\u00b2K", + "language": "1" + }, + "energy_efficiency_rating": 5, + "environmental_efficiency_rating": 5 + } + ], + "floors": [ + { + "description": { + "value": "(other premises below)", + "language": "1" + }, + "energy_efficiency_rating": 0, + "environmental_efficiency_rating": 0 + } + ], + "status": "entered", + "tenure": "ND", + "windows": { + "description": { + "value": "High performance glazing", + "language": "1" + }, + "energy_efficiency_rating": 5, + "environmental_efficiency_rating": 5 + }, + "lighting": { + "description": { + "value": "Good lighting efficiency", + "language": "1" + }, + "energy_efficiency_rating": 4, + "environmental_efficiency_rating": 4 + }, + "postcode": "TN37 7GF", + "data_type": 2, + "hot_water": { + "description": { + "value": "From main system, waste water heat recovery", + "language": "1" + }, + "energy_efficiency_rating": 5, + "environmental_efficiency_rating": 5 + }, + "post_town": "ST LEONARDS-ON-SEA", + "built_form": 1, + "created_at": "2025-03-04 11:13:23", + "living_area": 28.88, + "orientation": 2, + "region_code": 14, + "report_type": 3, + "sap_heating": { + "number_baths": 1, + "thermal_store": 1, + "shower_outlets": [ + { + "shower_wwhrs": 2, + "shower_flow_rate": 8, + "shower_outlet_type": 3 + } + ], + "water_fuel_type": 39, + "water_heating_code": 914, + "instantaneous_wwhrs": { + "wwhrs_index_number1": 80140 + }, + "main_heating_details": [ + { + "has_fghrs": "false", + "main_fuel_type": 39, + "storage_heaters": [ + { + "index_number": 230003, + "number_of_heaters": 4, + "high_heat_retention": "true" + } + ], + "main_heating_code": 409, + "main_heating_number": 1, + "is_condensing_boiler": "false", + "main_heating_control": 2404, + "main_heating_category": 7, + "main_heating_fraction": 1, + "main_heating_data_source": 3, + "is_oil_pump_in_heated_space": "false", + "is_main_heating_hetas_approved": "false" + }, + { + "has_fghrs": "false", + "main_fuel_type": 39, + "main_heating_number": 2, + "main_heating_control": 2100, + "main_heating_category": 4, + "main_heating_fraction": 0, + "main_heating_data_source": 1, + "main_heating_index_number": 104014, + "is_oil_pump_in_heated_space": "false", + "is_main_heating_hetas_approved": "false" + } + ], + "has_hot_water_cylinder": "false", + "has_cylinder_thermostat": "true", + "has_fixed_air_conditioning": "false", + "secondary_heating_category": 1, + "is_immersion_for_summer_use": "false", + "is_heat_pump_installed_to_mis": "false", + "is_hot_water_separately_timed": "true", + "main_heating_systems_interaction": 2, + "is_heat_pump_assisted_by_immersion": "false" + }, + "sap_version": 10.2, + "schema_type": "SAP-Schema-19.1.0", + "uprn_source": "Address Matched", + "country_code": "ENG", + "main_heating": [ + { + "description": { + "value": "Electric storage heaters", + "language": "1" + }, + "energy_efficiency_rating": 3, + "environmental_efficiency_rating": 5 + } + ], + "sap_lighting": [ + [ + { + "lighting_power": 10, + "lighting_outlets": 18, + "lighting_efficacy": 90 + } + ] + ], + "terrain_type": 2, + "air_tightness": { + "description": { + "value": "Air permeability [AP50] = 4.7 m\u00b3/h.m\u00b2 (as tested)", + "language": "1" + }, + "energy_efficiency_rating": 4, + "environmental_efficiency_rating": 4 + }, + "dwelling_type": "Top-floor flat", + "language_code": 1, + "property_type": 2, + "pv_connection": 2, + "address_line_1": "7 Tyler House", + "address_line_2": "51 Potter Street", + "assessment_date": "2025-03-04", + "assessment_type": "SAP", + "completion_date": "2025-03-04", + "inspection_date": "2025-03-04", + "sap_ventilation": { + "psv_count": 0, + "wall_type": 1, + "pressure_test": 1, + "wet_rooms_count": 1, + "air_permeability": 4.65, + "open_flues_count": 0, + "ventilation_type": 8, + "has_draught_lobby": "false", + "other_flues_count": 0, + "closed_flues_count": 0, + "extract_fans_count": 0, + "boilers_flues_count": 0, + "open_chimneys_count": 0, + "sheltered_sides_count": 1, + "blocked_chimneys_count": 0, + "flueless_gas_fires_count": 0, + "mechanical_vent_duct_type": 2, + "mechanical_vent_duct_placement": 1, + "mechanical_ventilation_data_source": 1, + "mechanical_vent_system_index_number": 500298, + "mechanical_vent_duct_insulation_level": 2, + "is_mechanical_vent_approved_installer_scheme": "false" + }, + "design_water_use": 1, + "sap_data_version": 10.2, + "sap_flat_details": { + "level": 3, + "storeys": 4 + }, + "total_floor_area": 76, + "transaction_type": 6, + "cold_water_source": 1, + "conservatory_type": 1, + "registration_date": "2025-03-04", + "sap_energy_source": { + "pv_arrays": [ + { + "pitch": 1, + "peak_power": 1.26, + "orientation": 8, + "overshading": 1 + } + ], + "electricity_tariff": 2 + }, + "sap_opening_types": [ + { + "name": "Window", + "type": 4, + "u_value": 1.2, + "data_source": 2, + "frame_factor": 0.7, + "glazing_type": 7, + "isargonfilled": "false", + "solar_transmittance": 0.52 + }, + { + "name": "Apt door", + "type": 1, + "u_value": 0.71, + "data_source": 2, + "glazing_type": 1, + "isargonfilled": "false" + } + ], + "secondary_heating": { + "description": { + "value": "None", + "language": "1" + }, + "energy_efficiency_rating": 0, + "environmental_efficiency_rating": 0 + }, + "lowest_storey_area": 75.94, + "lzc_energy_sources": [ + 11 + ], + "sap_building_parts": [ + { + "sap_roofs": [ + { + "name": "Roof (1)", + "u_value": 0.09, + "roof_type": 2, + "total_roof_area": 75.94 + }, + { + "name": "Party roof 1", + "u_value": 0, + "roof_type": 4, + "total_roof_area": 20 + } + ], + "sap_walls": [ + { + "name": "Walls (1)", + "u_value": 0.21, + "wall_type": 2, + "total_wall_area": 61.26, + "is_curtain_walling": "false" + }, + { + "name": "Walls (2)", + "u_value": 0.14, + "wall_type": 2, + "total_wall_area": 24.82, + "is_curtain_walling": "false" + } + ], + "sap_openings": [ + { + "name": "Opening 1", + "type": "Window", + "width": 8.28, + "height": 1, + "location": "Walls (1)", + "orientation": 2 + }, + { + "name": "Opening 2", + "type": "Window", + "width": 3.2, + "height": 1, + "location": "Walls (1)", + "orientation": 4 + }, + { + "name": "Opening 4", + "type": "Apt door", + "width": 2.12, + "height": 1, + "location": "Walls (2)", + "orientation": 5 + }, + { + "name": "Opening 3", + "type": "Window", + "width": 2.56, + "height": 1, + "location": "Walls (1)", + "orientation": 8 + } + ], + "construction_year": 2023, + "sap_thermal_bridges": { + "thermal_bridges": [ + { + "length": 10.1, + "psi_value": 0.08, + "psi_value_source": 1, + "thermal_bridge_type": "E2" + }, + { + "length": 5.91, + "psi_value": 0.063, + "psi_value_source": 1, + "thermal_bridge_type": "E3" + }, + { + "length": 24.94, + "psi_value": 0.06, + "psi_value_source": 1, + "thermal_bridge_type": "E4" + }, + { + "length": 0, + "psi_value": 0.107, + "psi_value_source": 1, + "thermal_bridge_type": "E5" + }, + { + "length": 0, + "psi_value": 0.076, + "psi_value_source": 1, + "thermal_bridge_type": "E5" + }, + { + "length": 25.74, + "psi_value": 0.037, + "psi_value_source": 1, + "thermal_bridge_type": "E7" + }, + { + "length": 10.43, + "psi_value": 0.026, + "psi_value_source": 1, + "thermal_bridge_type": "E7" + }, + { + "length": 11.9, + "psi_value": 0.043, + "psi_value_source": 1, + "thermal_bridge_type": "E16" + }, + { + "length": 0, + "psi_value": 0.12, + "psi_value_source": 1, + "thermal_bridge_type": "E25" + }, + { + "length": 0, + "psi_value": 0.045, + "psi_value_source": 1, + "thermal_bridge_type": "P1" + }, + { + "length": 2.38, + "psi_value": -0.044, + "psi_value_source": 1, + "thermal_bridge_type": "E17" + }, + { + "length": 15.34, + "psi_value": 0.064, + "psi_value_source": 1, + "thermal_bridge_type": "E10" + }, + { + "length": 10.4, + "psi_value": 0.053, + "psi_value_source": 1, + "thermal_bridge_type": "E12" + }, + { + "length": 10.43, + "psi_value": 0.038, + "psi_value_source": 1, + "thermal_bridge_type": "E12" + }, + { + "length": 0, + "psi_value": 0.05, + "psi_value_source": 1, + "thermal_bridge_type": "E18" + }, + { + "length": 0, + "psi_value": 0.15, + "psi_value_source": 4, + "thermal_bridge_type": "E11" + }, + { + "length": 0, + "psi_value": 0.012, + "psi_value_source": 1, + "thermal_bridge_type": "E13" + }, + { + "length": 0, + "psi_value": 0.24, + "psi_value_source": 1, + "thermal_bridge_type": "P5" + } + ], + "thermal_bridge_code": 5 + }, + "building_part_number": 1, + "sap_floor_dimensions": [ + { + "storey": 1, + "u_value": 0, + "floor_type": 4, + "storey_height": 2.38, + "heat_loss_area": 0, + "total_floor_area": 75.94 + } + ] + } + ], + "user_interface_name": "Design SAP 10", + "windows_overshading": 2, + "heating_cost_current": { + "value": 269, + "currency": "GBP" + }, + "co2_emissions_current": 0.2, + "energy_rating_average": 60, + "energy_rating_current": 92, + "lighting_cost_current": { + "value": 51, + "currency": "GBP" + }, + "main_heating_controls": [ + { + "description": { + "value": "Controls for high heat retention storage heaters", + "language": "1" + }, + "energy_efficiency_rating": 4, + "environmental_efficiency_rating": 4 + } + ], + "has_hot_water_cylinder": "false", + "heating_cost_potential": { + "value": 269, + "currency": "GBP" + }, + "hot_water_cost_current": { + "value": 94, + "currency": "GBP" + }, + "thermal_mass_parameter": 64, + "user_interface_version": "2.21.9", + "co2_emissions_potential": 0.2, + "energy_rating_potential": 92, + "gas_smart_meter_present": "false", + "lighting_cost_potential": { + "value": 51, + "currency": "GBP" + }, + "schema_version_original": "SAP-Schema-19.1.0", + "hot_water_cost_potential": { + "value": 94, + "currency": "GBP" + }, + "is_in_smoke_control_area": "unknown", + "seller_commission_report": "Y", + "energy_consumption_current": 35, + "has_fixed_air_conditioning": "false", + "is_dwelling_export_capable": "true", + "multiple_glazed_percentage": 100, + "calculation_software_version": "2.21.9", + "energy_consumption_potential": 35, + "environmental_impact_current": 97, + "current_energy_efficiency_band": "A", + "environmental_impact_potential": 97, + "electricity_smart_meter_present": "true", + "has_heated_separate_conservatory": "false", + "potential_energy_efficiency_band": "A", + "co2_emissions_current_per_floor_area": 2.6 +} \ No newline at end of file diff --git a/tests/domain/sap10_calculator/test_real_cert_sap_accuracy.py b/tests/domain/sap10_calculator/test_real_cert_sap_accuracy.py index 2bce02247..5604b8015 100644 --- a/tests/domain/sap10_calculator/test_real_cert_sap_accuracy.py +++ b/tests/domain/sap10_calculator/test_real_cert_sap_accuracy.py @@ -309,6 +309,29 @@ _EXPECTATIONS: Final[tuple[RealCertExpectation, ...]] = ( cert_num="0390-3321-6060-2405-7985", sap_score=84, ), + # UPRN 10094615101 → cert 0380-3044-6070-2305-5925. SAP-Schema-19.1.0 — a + # FULL-SAP TOP-FLOOR FLAT (2023 new build, St Leonards-on-Sea, TFA 76 m², + # PRD #1435 WS3 evidence property 741840): PCDB HHRSH (230003 ×4) on an + # off-peak tariff, hot-water heat pump (code 914) + WWHRS, MEV (PCDB + # 500298), measured AP50 4.65, calculated per-junction thermal bridges, and + # a 1.26 kWp EXPORT-CAPABLE PV array (`is_dwelling_export_capable: true`, + # pv_connection 2). Lodged under SAP 10.2 itself (Design SAP 10 2.21.9), so + # the lodged 92 is the same-spec accredited ground truth — no Elmhurst + # rebuild needed. The engine produced 89 until the full-SAP export-capable + # mapping landed: `from_sap_schema_17_1` hardcoded + # `is_dwelling_export_capable=False` (the flag and `pv_connection` are + # top-level full-SAP fields the schema dataclass never parsed), so SAP 10.2 + # Appendix M1 zeroed the PV export credit (~460 kWh × 13.19p ≈ £61/yr). + # Carrying the lodged flag restores the credit and the engine reproduces + # the lodged 92 EXACTLY. Residual CO2/PE deltas (~252 vs ~200 kg CO2/yr; + # PE 41.7 vs 35) are demand-side follow-ups (lodged TMP 64 vs default 250, + # WWHRS, MEV PCDB fan power) — within SAP tolerance, tracked separately. + RealCertExpectation( + schema="SAP-Schema-19.1.0", + sample="uprn_10094615101", + cert_num="0380-3044-6070-2305-5925", + sap_score=92, + ), # UPRN 44012843 → cert 0775-2898-6628-9594-8005. SAP-Schema-16.3 — a # reduced-field (RdSAP-shaped) ground-floor FLAT, band K (2007-2011), cavity # insulated, mains-gas REGULAR boiler (PCDB 9895 Ideal icos HE15) + cylinder,