Repository navigation
Simulate > OpenStudio Simulation: minimal OpenStudio/EnergyPlus run from SAM_UI (#229) - #237
Merged
michaldengusiak merged 11 commits intoOct 18, 2026
Merged
Conversation
Adds Simulate > OpenStudio Simulation. The open model is frozen to a snapshot JSON and SAM_OpenStudio's existing ToOpenStudio pipeline runs on the copy read back from it (in process; EnergyPlus runs out of process under SAM_OpenStudio's job object). Results are attached with SAM_OpenStudio's AddResults plus the model-level result, to a copy with every earlier result removed, and saved as <model>_OpenStudio.json in a new run folder together with the OSM/OSW, run outputs, the weather used and an openstudio-run.json manifest (status, SHA-256 of snapshot and weather, CLI, error counts, diagnostics). The run is on a worker thread with the existing ProgressWindowHost for progress and cancel. The open model and the Tas workflow are not changed. Build: SAM.Analytical.UI.WPF references SAM_OpenStudio\build (OpenStudio.dll is IL-only, so no x64 platform change) and copies the x64 native files; CI clones and builds SAM_SQLite and SAM_OpenStudio (x64) before SAM_UI. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Fgbs3ko6Xix9Ut15onTY7R
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Fgbs3ko6Xix9Ut15onTY7R
The platform-override edit cut the "# Convert build order -> solution paths (robust: ...)" comment, leaving "(robust: ...)" after a closing brace; pwsh rejected the script before any build ran. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Fgbs3ko6Xix9Ut15onTY7R
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Fgbs3ko6Xix9Ut15onTY7R
SAM_UI's own SAM.Analytical.UI.AnalyticalModelParameter shadows SAM.Analytical.AnalyticalModelParameter inside SAM.Analytical.UI.WPF, so the hosted build failed with CS0117 (no WeatherData). Qualified as Modify/Simulate.cs already does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Fgbs3ko6Xix9Ut15onTY7R
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Fgbs3ko6Xix9Ut15onTY7R
JsonArray.Add(string) binds to the generic Add<T>, whose value cannot be written with ToJson's JsonSerializerOptions (no TypeInfoResolver), so a run with any diagnostic threw InvalidOperationException while writing openstudio-run.json - from a finally on the worker thread, i.e. a real run with a warning would have failed or crashed SAM_UI. Values are now added with JsonValue.Create, and the manifest write can no longer throw. Regression test: a manifest with diagnostics and an error (fails before, passes after). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Fgbs3ko6Xix9Ut15onTY7R
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Fgbs3ko6Xix9Ut15onTY7R
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.
Owner acceptance and authorized merge - 2026-10-18
The owner has accepted the documented explicit-EPW numerical residuals for G1 integration and authorized merging #237 followed by #238 after passing checks. This supersedes all earlier HOLD wording below. No GitHub approval review is fabricated and no repository protection is bypassed.
This is a one-time acceptance of the prescribed two-cell/Boston evidence, not a change to comparator tolerances or a claim of bit identity. Maximum energy residual is 3.134337021037936e-7 kWh, maximum peak residual 2.735980331181054e-10 kW; maximum relative residual about 1.9433e-11. CLI-only repeats also vary and all 163 normalized IDF objects have matching engineering fields. The precise source of run-to-run variation is not claimed proven.
Real native cancellation/process cleanup, concurrent-edit isolation, the 608/608 exact persisted Tas baseline comparison and the actually executed real-run test are PASS. Evidence and limitations are committed in documentation/OpenStudio-Simulation-PR229.md and documentation/evidence/g1-20261018/. No new simulation or local broad suite was run for this acceptance-only update; earlier local/full-suite/engine results remain attributed to their tested content.
Current documentation-only final candidate:
9abfc03469bb46c29e46b2dd3feb1961e09f8a5b. Final-head CI pending. #237 merges first; #238 stays draft until dependency and final gates pass. Numerical engine disagreement, HungaryHouse Tas crash, missing input manifests and producer deployment remain separate follow-ups.Earlier implementation and acceptance history follows.
Closes #229 (part of #227; tracker SAM-BIM/SAM#206).
Behavior
Adds Simulate > OpenStudio Simulation beside Energy Simulation. The run freezes a deep copy, uses SAM_OpenStudio's existing conversion/results pipeline, and writes a separate result model, manifest, weather, OSM/OSW and SQL. The open model and existing Tas workflow are preserved. #238 adds the unified selector and comparison workflow after this PR.
Current acceptance: HOLD - 2026-10-18
Owner authorization covers focused testing, evidence-only final heads and later merging after all gates pass. No additional pin approval is needed solely for these evidence commits. The required explicit-EPW equality gate remains unmet; no acceptance waiver or numerical tolerance has been introduced.
Final evidence-only head:
b4c5ad9279c58b0a5db0874333db2a696106b145. Freshly tested UI source:b7483443f53dd53a4d16f159d6bc327c901a7770; same-dependency pre-PR Q4 baseline:ebe5e09b30b95e43e5d047b3aef2d8c5f01110e9. Both Release builds succeeded. Final diff is documentation/evidence only;git diff b7483443 b4c5ad92 --checkpasses. No product fix was made.Standalone/benchmark stored values and deltas:
A second CLI-only run also varies (heating delta -6.598711479455233e-7 kWh versus CLI 1). All three generated IDFs have identical engineering fields after matching generated aperture/frame names and object order: 163 objects, normalized SHA-256
3b0dbe8f96a18c8b99b311811b2cccdc15c7b34046a549a0981a385cdf0da397, without rounding or dropping physical fields. This supports existing same-engine conversion/order reproducibility rather than a newly established UI mapping defect, but does not meet literal identity. No physics, units, tolerances, comparison arithmetic or deployment changed.Exact pins, commands, input hashes, assertions, screenshots and limitations: PR record, section Windows G1 acceptance execution; portable evidence. Full machine-local runs/builds/logs/TRX:
C:\TasOut\pr237-g1-20261018(must be copied/provisioned on another machine). Original fixtures preserved; only disposable HungaryHouse copy renamed.All 14 dependency source pins were held fixed on
sow/2026-Q4; eight engine/core/interop DLL hashes match across the two UI builds. Important pins: SAM618db819300df8b698b3bbe5174a203244134738, SAM_OpenStudiod4216f3525c01ca762c1b3e9b6d099733d037f54, SAM_Tasa34a298dde2803de514081a0ed72ac3ff790997b, SAM_Validation68eded0060047af714853a02a152fb9c960bfeb1, containing #15 merge912ae94ef68af20b437fc92ec7e8891fd1cb640f. Runtime OpenStudio 3.10 / EnergyPlus 25.1 / Tas 9.5.7 / Windows x64.SAM_COMMIT=618db819300df8b698b3bbe5174a203244134738supplied for benchmark provenance.Historical successful Both/partial, saved box equality, 2835/2835 suite and presentation evidence were inspected, not rerun. These do not waive the failed explicit-EPW requirement. The final-head hosted workflow builds but does not run WPF tests.
Final-head CI and merge gates
Build 39113785793 PASS; SPDX 39113785833 PASS, at final head
b4c5ad9279c58b0a5db0874333db2a696106b145. Completed build log inspected: all 14 dependencies selectsow/2026-Q4, including SAM_Validation, SAM_SQLite, SAM_OpenStudio and SAM_Tas. No Validation feature branch is selected. Log preserved atC:\TasOut\pr237-g1-20261018\logs\pr237-final-build-39113785793.log.Live metadata: OPEN, non-draft, no submitted reviews or review threads; base
sow/2026-Q4. Owner merge authorization does not bypass acceptance/protection. #238 is held dependent on this PR. No UI merge, PROJECT_PROGRESS closeout or task-branch cleanup has occurred; checkouts clean, evidence committed and pushed.Next: owner/domain review of the strict identical-value specification, or a separately reviewed deterministic-conversion fix if bit identity is required. Do not merge either UI PR until that acceptance decision is resolved. Numerical Tas/OpenStudio disagreement, HungaryHouse Tas crash, unavailable input manifests and producer deployment remain separate follow-ups.
The original G1 procedure below is retained as the acceptance source; its step-12 identity requirement has not been relaxed. Current results are above and in the dated committed record.
Manual G1 acceptance (owner, Windows x64)
Prerequisites
OpenStudio 3.10.0 installed. In a new terminal,
openstudio --versionshould print3.10.0. If it is not on PATH, the default installC:\openstudio-3.10.0\binis also found.Build this branch with the usual sibling layout. Either:
Platform=x64before SAM_UI; orSAM,SAM_SQLite,SAM_OpenStudiowith/p:Platform=x64, the other dependencies, thenSAM_UI(claude/openstudio-mcp-server-1jmjlo).The SAM_UI build fails early with a clear message if the native OpenStudio DLLs are missing.
Check the deployed folder. After the build,
%APPDATA%\SAM(or wherever you launchSAM Analytical.exefrom) must contain:openstudiolib.dll,openstudio_csharp.dll,openstudio_model_csharp.dll,openstudio_translators_csharp.dll;OpenStudio.dll,SAM.Analytical.OpenStudio.dll,System.Data.SQLite.dll;runtimes\win-x64\native\SQLite.Interop.dll.A. Real run with embedded weather
4. Copy
SAM_OpenStudio\tests\resources\models\rawModel-WindowsWeatherDataDDYAdiabaticAirPanel.samto a scratch folder, open it in SAM Analytical, and Save it. Note the file's SHA-256 withcertutil -hashfile <file> SHA256.5. Run Simulate > OpenStudio Simulation. Pick the scratch folder, then answer Yes (use the model's weather data). The progress window should step through: Freezing/converting, Saving OSM, Writing OSW, Running OpenStudio/EnergyPlus, Reading results. Check that the main window stays responsive while it runs.
6. Expected summary: finished, a run folder
<model>_OpenStudio_<timestamp>_<id>, a result model with N results,Weather: Embedded, andEnergyPlus: exit code 0, … 0 severe, 0 fatal.7. In the run folder, check that these exist:
snapshot.json,weather.epw,<model>.osm,<model>.osw;run\eplusout.sql,run\eplusout.err;<model>_OpenStudio.json,openstudio-run.json.In
openstudio-run.json,statusshould beSucceeded,engine.fatalCountshould be0, andengine.cliPathshould be your 3.10openstudio.exe. ReportsevereCountandwarningCount.8. Original model preserved:
<model>_OpenStudio.jsonin SAM Analytical. Space results show forCell 1andCell 2.… - SAM.Analytical.OpenStudioentries, with no Tas results.B. Explicit EPW, compared with the benchmark CLI (same code path)
10. Repeat step 5 but answer No and pick
SAM_OpenStudio\tests\resources\weather\USA_MA_Boston-Logan.Intl.AP.725090_TMYx.2004-2018.epw. The summary should sayWeather: File.11. Run
benchmark-openstudio --model <fixture>.sam --weather <same epw> --out bench.json. The exe is underSAM_OpenStudio\benchmark\SAM.Analytical.OpenStudio.Benchmark\bin\.12. Compare
bench.jsonmodel.consumptionHeating/consumptionCooling/peakHeatingLoad/peakCoolingLoadwith the result model's Analytical Model Simulation Result. They should be identical: same pipeline, same inputs.C. Cancel and isolation
13. Start another run, then press Cancel while it shows Running OpenStudio/EnergyPlus. Expected:
openstudio.exeandenergyplus.exedisappear in Task Manager;statusisCancelled;<model>_OpenStudio.json.snapshot.jsonand result model have the old name, and the open model keeps your edit.D. Tas unchanged
15. On the same model, run Simulate > Energy Simulation (Tas) with your usual settings, once with this build and once with a
sow/2026-Q4build. The dialog and workflow should be identical, and the results equal within Tas run-to-run reproducibility.E. Failure reporting
16. (Optional) Temporarily rename the OpenStudio install so
openstudio.exeis not found, then run. Expected: the summary says failed with "openstudio.exe was not found …" and SAM_UI does not crash. Restore the install afterwards.17. Run
dotnet test WPF/SAM.Analytical.UI.WPF.Tests -c Release. The full suite should pass.OpenStudioSimulationTests.RealRun_…must not printNOT RUN.