Skip to content

[codex] add per-floor building assignments#69

Draft
szvsw wants to merge 2 commits into
mainfrom
codex/per-floor-building-configs
Draft

[codex] add per-floor building assignments#69
szvsw wants to merge 2 commits into
mainfrom
codex/per-floor-building-configs

Conversation

@szvsw

@szvsw szvsw commented Jun 22, 2026

Copy link
Copy Markdown
Owner

Summary

Adds a typed, floor-first SBEM API for heterogeneous shoebox buildings:

  • introduces BuildingFlatModel, BuildingShell, ZoneTemplate, PartialZoneTemplate, FloorBand, and ZoneAssignmentResolver
  • supports per-floor and per-role overrides for loads, schedules, HVAC-related template fields, facade/window constructions, and WWR
  • applies per-zone WWR by resetting EnergyPlus fenestration on each resolved zone's exterior wall surfaces before loads/HVAC are added
  • preserves the legacy uniform Model(Zone=...) and FlatModel path, with FlatModel.to_building_model() as a compatibility adapter
  • adds zone and floor annual energy summaries with raw kWh and kWh/m2, and attaches zone_results / floor_results to assignment-backed runs

Validation

Passed:

  • pre-commit hook suite on the committed files: case/merge checks, whitespace/end-of-file fixes, pyright, ruff, ruff-format, prettier
  • uv run pytest tests/test_sbem/test_zone_assignment.py tests/test_sbem/test_floor_assignment_build.py tests/test_analysis/test_zone_energy.py -q -> 11 passed
  • manual two-floor EnergyPlus smoke simulation using BuildingFlatModel; returned exactly 2 floor rows and the high-LPD floor had higher simulated lighting kWh/m2
  • uv run pyright epinterface\sbem\zone_assignment.py epinterface\sbem\building_flat_model.py epinterface\analysis\zone_energy.py epinterface\sbem\flat_model.py epinterface\sbem\builder.py -> 0 errors

Full-suite note:

  • uv run pytest -q reached 255 passed / 8 skipped / 2 xfailed, but failed on Prisma-backed tests during fixture/database setup. The common error was RuntimeError: Error applying migrations from prisma migrate deploy, with Prisma reporting Schema engine error before the affected test bodies ran.

Design Notes

The implementation intentionally keeps roof/slab/interior boundary constructions shared from defaults. Floor/role-specific facade and glazing construction assignment is applied zone-by-zone, while WWR is handled geometrically per floor/zone via EnergyPlus fenestration reset. This keeps unsupported envelope semantics from being silently implied while satisfying the per-floor WWR requirement.

@codecov-commenter

codecov-commenter commented Jun 22, 2026

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 70.17937% with 266 lines in your changes missing coverage. Please review.
✅ Project coverage is 69.2%. Comparing base (f414ccb) to head (0b4ce6f).

Files with missing lines Patch % Lines
epinterface/sbem/builder.py 40.1% 156 Missing and 17 partials ⚠️
epinterface/analysis/zone_energy.py 70.3% 25 Missing and 13 partials ⚠️
epinterface/sbem/zone_assignment.py 88.5% 22 Missing and 9 partials ⚠️
epinterface/sbem/flat_model.py 82.9% 10 Missing and 6 partials ⚠️
epinterface/sbem/building_flat_model.py 92.3% 7 Missing and 1 partial ⚠️
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.
Additional details and impacted files
@@           Coverage Diff           @@
##            main     #69     +/-   ##
=======================================
+ Coverage   64.1%   69.2%   +5.1%     
=======================================
  Files         34      37      +3     
  Lines       5001    5750    +749     
  Branches     452     567    +115     
=======================================
+ Hits        3207    3984    +777     
+ Misses      1641    1572     -69     
- Partials     153     194     +41     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Resolve the blocking and major issues from the review of the floor-first
SBEM assignment API:

- fix FlatModel.zone_template() so the legacy -> BuildingFlatModel adapter
  no longer trips ZoneTemplate's extra="forbid" (project onto template fields)
- reject per-floor RoofRValue/SlabRValue overrides (removed from
  PartialZoneTemplate) since they are building-wide, not per-floor yet
- reject WWR overrides on core zones, which have no exterior walls
- rename zone-energy columns to make accounting explicit
  (sim_lighting_site_kwh, sim_equipment_site_kwh, sim_total_included_kwh) and
  document that DHW is excluded and HVAC is delivered thermal energy
- drop duplicate metadata in merge_assignment_and_energy so the join no longer
  produces _x/_y suffixed columns
- validate floor_results has exactly one row per above-grade floor
- warn when heterogeneous fuels make the building-level energy_and_peak
  utility mapping approximate
- make total_people/compute_dhw resolver-aware (per-zone, IDF-based) instead
  of using building-wide defaults under zone assignments
- drive ground temperature from ground-contact zones only (basement, or the
  lowest above-grade floor) instead of all floors
- default from_uniform_flat_model zoning to the source model's zoning
- report as-built actual_wwr / glazed / exterior-wall areas in the assignment
  and floor summaries, using wall-area-weighted floor WWR
- extract zone_template_to_zone_component into a pure function over
  ZoneTemplate instead of fabricating a dummy FlatModel

Add tests covering FlatModel compatibility, boundary/WWR override rejection,
attic/basement parsing and scaling, object-name uniqueness, merge stability,
floor row counts, and ground-contact ground temperature.

Co-authored-by: Cursor <cursoragent@cursor.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants