Site simulator: thermal plant, facility presets, and live schematic - #6
Draft
frahlg wants to merge 5 commits into
Draft
Site simulator: thermal plant, facility presets, and live schematic#6frahlg wants to merge 5 commits into
frahlg wants to merge 5 commits into
Conversation
Introduce a conserved site-node power balance (Modelica-style DAE) so automation can be more than independent sine waves, and fill the Sungrow addresses srcfl/device-drivers actually polls (serial at 4990, device type, running state, active-power limit). Scenario "physical" steps the plant and writes semantic registers. See docs/LUA_DRIVER_PLANT.md. Co-authored-by: Fredrik Ahlgren <fredrik@sourceful-labs.com>
Site physics lives in modelica/SiteEnergy.mo (Kirchhoff power connector, hybrids, house load, grid slack). The simulator talks to plant.Model so an FMI FMU can replace the Go native backend later. NativeSite already solves the same bus: self-consumption batteries share house residual, EMS units follow Lua setpoints, the site clock writes registers. Physical site scenario skips per-inverter sine generation and steps the bus from calculateAndUpdateMeter. Co-authored-by: Fredrik Ahlgren <fredrik@sourceful-labs.com>
SVG plus short notes so the site DAE is reviewable as a picture: one AC node, NativeSite/FMU plug, vendor maps, Modbus to Lua. Co-authored-by: Fredrik Ahlgren <fredrik@sourceful-labs.com>
siteplant.Open loads a Site4 FMI 2.0 co-simulation FMU when present (linux/amd64 + CGO) and falls back to the native Go DAE otherwise. make fmu runs omc against modelica/SiteEnergy.mo. Mode-0 slack stays in the Go master. Empty FMI slots are gated with u_on. Co-authored-by: Fredrik Ahlgren <fredrik@sourceful-labs.com>
…atic The dashboard can instantiate a house or apartment (ASHP or GSHP, DHW, occupancy) whose physics plant drives Sungrow and heat-pump Modbus facades on the site clock, so an EMS can talk to it as if it were a real site. Co-authored-by: Fredrik Ahlgren <fredrik@sourceful-labs.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This is now a site simulator, not only a bag of independent devices.
Pick a facility on the dashboard (house ASHP/GSHP, apartment, or PV+battery). That instantiates a physics plant and the Modbus facades an EMS (FTW/FTV) talks to. The site clock is the only integrator. Devices do not invent power; they project what the plant just solved.
The Site plant band is a live schematic: green electrical flows (Lua sign convention), orange heat, indoor/DHW temperatures, occupancy, SG Ready.
How to use it:
docs/SITE_SIMULATOR.md. Bus sketch:docs/SITE_PLANT_SKETCH.md.Facilities
house-ashphouse-gshpapartment-ashppv-batteryPOST /api/sites/{id}/facilitywith{ "preset": "house-ashp" }creates the Sungrow + heat-pump devices if needed, sets scenariophysical, and starts the clock.Operating routines (not a full FTV stack, enough that the site feels occupied): occupancy plug loads and internal heat, heating curve + night setback, DHW draws, SG Ready 0–3.
Physics / Modelica
internal/plant) is the live thermal + electrical DAE.modelica/SiteEnergy.monow has matchingBuilding,HeatPump,DHWTank,HouseFacility.Site4.fmustays the electrical FMI 2.0 slave (make fmu). A facility forces native so heat and electricity share one clock.Lua drivers still poll Modbus, not HTTP.
API (OpenAPI + MCP +
/docsupdated together)GET /api/facilitiesGET|POST /api/sites/{id}/facilityGET /api/sites/{id}/plantheat_pump(holding 1100–1103 enable/setpoint/mode/SG Ready; inputs indoor/DHW/COP/…)Wails:
GetFacilities,ApplySiteFacility,GetSitePlant.Checklist
go test ./...)openapi.json,internal/mcp/server.go,docs.htmlpatch:/minor:/major:)