Skip to content

feat: store an edited building as its BuEM blocks - #117

Merged
jravani merged 3 commits into
mainfrom
feat/store-edited-building
Sep 28, 2026
Merged

jravani merged 3 commits into
mainfrom
feat/store-edited-building

Conversation

@jravani

@jravani jravani commented Sep 28, 2026

Copy link
Copy Markdown
Member

A host that lets users edit a building in the 3D view can now store the edited building and reopen it with the same state.

What changes

  • toBuem(state) (new export) returns { building, solver }: the BuEM blocks a run of that building sends. Store it, and reopen by passing it as properties.buem of a Feature to adaptBuemFeature.
  • The air change rates, c_m, thermal mass class, attached-neighbours code and MILP choice now survive onExit (withEdits) and reopening (adaptBuemFeature). They used to reset to defaults with no error.
  • Building and surface names go into the block and come back on reopen.
  • BuemBuildingRunRequest gains solver: { use_milp }. Until now the MILP toggle never reached BuEM. A host transport must forward solver to BuEM.
  • Version 0.6.0.

PV arrays and the battery are not part of either BuEM block. A host keeps technologyState beside them; docs/installing.md shows how.

Tests

src/app/lib/buemRun.test.ts checks that toBuem equals what a run sends, that the run request carries the solver, and that storing and reopening gives back the same parameters, surfaces and blocks. npm test 88/88, npm run typecheck clean.

A host that keeps a building edited in the 3D view needs to write it
back to its saved model and reopen it later with the same state. The
package gave it no way to do that without losing edits.

withEdits folded only type, year, country, floor area, room height and
storeys back into the BuildingState that onExit returns. The air
change rates, c_m, thermal mass class and attached-neighbours code
were dropped, so a host serialising that state reset them to defaults
without any error. Going the other way, adaptBuemFeature read none of
those fields, and surface names were replaced by generated labels.

- toBuemBuilding(state) returns the BuEM building block a run of that
  building sends. runIdentity is shared with the run and the download,
  so the two cannot drift.
- BuildingState gains an optional parameters field. withEdits writes
  it and adaptBuemFeature reads it from building.thermal and
  building.neighbour_status.
- generalFrom seeds the editor from a BuildingState. It replaces the
  two copies in useBuildingModel, one of which ignored the building
  name when a new building loaded.
- The serialiser writes building.name. The reader takes it as the
  label, and takes an envelope element's name as that surface's label.

PV arrays and the battery are not part of the building block. A host
keeps technologyState beside it; docs/installing.md says how.
The MILP toggle (general.use_milp) never reached BuEM. The building
run request had no solver field, so every run used BuEM's default
sparse solver whatever the user picked, and a stored building could
not say how it had been simulated.

- BuemBuildingRunRequest gains solver: { use_milp }, filled from the
  serialised properties.buem.solver. A host transport forwards it to
  BuEM's properties.buem.solver.
- toBuemBuilding becomes toBuem and returns { building, solver }, the
  properties.buem shape a host stores and hands back to
  adaptBuemFeature.
- BuildingParameters gains use_milp. withEdits writes it and
  adaptBuemFeature reads it from properties.buem.solver.use_milp.
Adds toBuem for storing an edited building as its BuEM building and
solver blocks, reopened with adaptBuemFeature, and sends the solver
choice with each building run.
@jravani
jravani merged commit c74f307 into main Sep 28, 2026
3 checks passed
@jravani
jravani deleted the feat/store-edited-building branch September 28, 2026 10:13
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.

1 participant