Skip to content

feat(gold): mirror extended scenarios S08-S15 + comparison tool - #25

Open
EugeniuStrelet wants to merge 8 commits into
mainfrom
feat/port-extended-scenarios
Open

EugeniuStrelet wants to merge 8 commits into
mainfrom
feat/port-extended-scenarios

Conversation

@EugeniuStrelet

Copy link
Copy Markdown
Collaborator

What

Extends the Octave-gold mirror (bdsim/scenarios/gold.py) from S00-S07 to S08-S15,
one-for-one with the extended scenario set added to the Octave repo
(EugeniuStrelet/BDSIM PRs #9 #10: coverage audit + new scenarios S08-S15).

Id Gap Horizon dt / nic Fault under test
S08 G1 1 week 30 s / 1 sensor noise on all 5 sensors
S09 G2 1 week 30 s / 1 ARMAX load disturbance + Foil loop MANUAL (oil order 40->45->40)
S10 G3 1 week 30 s / 1 setpoint steps TR/TD/hH
S11 G4 1 month 60 s / 1 fouling pins Qheat at the 40 kW bound (day ~23 of 30)
S12 G5 1 week 30 s / 1 stiction: oil pure deadband + H-valve no-offset slip
S13 G7 1 week 30 s / 1 intermittence masks on 3 (sensor, fault) pairs
S14 G6 1 month 60 s / 1 ~14 cleanings with new-filter variability (filter_std=6e10)
S15 G8 6 months 300 s / 1 degradation accumulation: ~79 cleanings, Qheat pinned, catalyst 0.9; Foil loop MANUAL
  • Per-scenario time base in SCENARIO_TIMEBASE (tf/dt/nic); run_gold_scenario
    resolves defaults from it; explicit tf/dt still override (SMOKE).
  • Runner scripts + CLI cover S00-S15; BD_DT forwarded only when set.
  • scripts/compare_gold.py: per-column RMSE / max|err| / bias report vs Octave
    gold ASCII; flags RNG-dependent scenarios (S06/S08/S13/S14, fingerprint-level
    per Port_execution.md §5).

Note on nic (finding F0)

At the golden time base (dt=30, nic=4, PID period 120 s) the Foil flow loop is
discretely unstable (poles |z|~1.49; Octave gold S00 itself contains a 0 <-> 7348
kg/h bang-bang from ~1 h). The extended scenarios therefore use nic=1 (stable) and
S15 removes loop 4 via MANUAL at dt=300 s. The golden S00-S07 mirrors are untouched.

Validation

  • SMOKE + full-horizon Python runs for all 16 scenarios completed
    (data/results_py/S00-S15); pytest tests/test_gold_parity.py -k "not slow" passes.
  • Extended-scenario Python fingerprints: S11 Qheat pinned at 40000 W (last 23% of
    the month), TD drifting +1.5 K by day 30; S14 14 cleanings with jittered
    post-cleaning DP levels; S09 manual pass-through exact (Foil 2997.9 -> 3367.1
    kg/h); S15 79 cleanings at 2.27 d period, Qheat pinned at 40 kW.
  • Octave gold for the extended scenarios (full-horizon S08-S15 runs) lands in
    data/results_octave/gold_dataset_ext/; comparison tables land in
    docs/30-engine/Extended-scenarios-S08-S15.md (updated in this PR).

Adds a new entry for the 'data/' directory to the .gitignore file to prevent tracking of data files in the repository.
This commit introduces a new module for handling Parquet I/O, allowing simulation results to be saved in Parquet format instead of CSV. Key changes include:
- Addition of `bdsim/io_parquet.py` for Parquet file handling.
- Updates to the CLI to reflect the new output format.
- Modifications to the simulation and controller logic to accommodate the new data structure.
- Inclusion of gold scenario execution with Parquet output.
- Updates to documentation and README to guide users on the new output format.

This enhances data handling capabilities and aligns with modern data processing practices.
This commit modifies the output directory structure for simulation results, moving from the `results/` directory to a new `data/results/` hierarchy. Key changes include:
- Updated `.gitignore` to reflect the new paths for generated data files.
- Adjustments in documentation and scripts to point to the new output locations.
- Changes in the CLI and I/O functions to default to the new `data/results/` directory for output.
- Removal of the legacy `results/` directory from tracking.

These changes enhance organization and clarity in the project's data management practices.
This commit introduces a series of Jupyter notebooks for comparing simulation results between Octave and Python across various gold scenarios (S00–S07). Key changes include:
- New notebooks in `notebooks/gold/` for each scenario, showcasing side-by-side visualizations of original BDsim figures.
- Helper scripts (`_compare.py` and `_gen_notebooks.py`) to facilitate data loading and notebook generation.
- Updates to `pyproject.toml` to include new dependencies (`ipykernel` and `nbformat`) for notebook execution.
- Modifications to `uv.lock` to reflect the addition of new packages and their versions.

These enhancements improve the project's capability for visual validation of simulation results and ensure a consistent environment for running the notebooks.
- bdsim/scenarios/gold.py: SCENARIO_TIMEBASE (per-scenario tf/dt/nic), S08-S15
  override blocks mirroring the Octave scenario files one-for-one; S09/S15 take
  loop 4 to MANUAL with the oil order on the ARMAX exogenous channel; nic=1
  everywhere in the extended set (Foil-loop discrete instability at nic=4 —
  finding F0 in the Octave repo's docs/scenario_coverage.md).
- run_gold_scenario resolves tf/dt from the per-scenario time base; explicit
  values still override (SMOKE etc).
- CLI and both runner scripts: S00-S15 lists; BD_DT forwarded only when set
  (it would otherwise override the 60 s / 300 s scenarios).
- scripts/compare_gold.py: per-table/column RMSE, max|err|, bias, gold-scale
  report tool; flags the RNG-dependent scenarios (S06/S08/S13/S14).
- docs/30-engine/Extended-scenarios-S08-S15.md: mapping, RNG policy, results.

Python suite over all 16 scenarios completed (data/results_py; SMOKE + full);
test_gold_parity (non-slow) passes.
The golden defaults zero the whole ARMAX row; u2 (Tmet) / u3 (Fmet) are pure
loads computed as u = eta*d, so eta = 0 starves the reactor of methanol and the
composition collapses to pure TG within a week (finding F1 in the Octave
repo's docs/scenario_coverage.md). Extended scenarios now pass the constant
exogenous d through for the load channels: eta = [0,1,1,0,0,0] (S08, S10-S14),
[1,1,1,0,0,0] (S09, S15 — slot 1 also passes the manual oil order).

Verified after fix: S11 Qheat pins at 40 kW on day 13.38 (as modeled from
Rf > 0.693), TD drifts to 53.5 C by day 30; S15 pins on day 27.4, 79 cleanings,
TD -> 57.3 C, xR_E 0.4302 -> 0.4146 (healthy, no collapse); loads fed
(Fmet = 657 kg/h, Tmet = 50 C) in every extended scenario.
@EugeniuStrelet

Copy link
Copy Markdown
Collaborator Author

Update (finding F1, 2026-11-16): the golden suite feeds no methanol (Fmet = 0, Tmet = 0 K) because the golden refactor zeroed the whole ARMAX row while u2/u3 are pure loads (u = eta*d). The composition collapses to pure TG within a week in every golden scenario — the stored Octave gold the parity tests use contains this degenerate plant. Documented in the Octave repo's docs/scenario_coverage.md §4ter (PR #9).

This PR now includes commit 803b132: the extended scenarios set armax.eta = [0,1,1,0,0,0] (S08, S10-S14) / [1,1,1,0,0,0] (S09/S15) so the constant loads pass through, and the Python suite for S08-S15 was re-run. After the fix: S11 pins Qheat at 40 kW on day 13.38 (matching the analytic model Rf > 0.693), S15 pins on day 27.4 with 79 cleanings and xR_E staying ~0.43. Octave gold for the extended set is being regenerated (full-horizon runs); comparison via scripts/compare_gold.py will be appended.

…enarios

S08 (noise PV statistics), S13 (mask duty), S14 (cleaning-event statistics)
and the S12 stiction stem channels (zero-cross rate / amplitude) are compared
on statistics, not sample-wise RMSE: Octave legacy RNG differs from NumPy at
the same seed and stick-slip phase drifts under solver differences
(Port_execution.md §5).
S15: 79/79 cleanings with identical event times over 6 months, Qheat pin day
27.4 both, TD RMSE 0.0097 K, xR_E end 0.4146 both, lifto bit-exact.
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