Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 39 additions & 9 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,23 @@ coverage.xml
*.nbi
*.nbc

# Project outputs (regenerated by `python -m bdsim`)
results/inputs
results/states
results/measurements
results/setpoints
results/*.csv
results/*.html
results/*.png
!results/.gitkeep
# Project outputs (regenerated by `python -m bdsim` / gold scripts)
data/results/inputs
data/results/states
data/results/measurements
data/results/setpoints
data/results/*.csv
data/results/*.parquet
data/results/*.html
data/results/*.png
!data/results/.gitkeep
data/results_py/
# Octave gold ASCII (large; keep local / sync separately)
data/results_octave/
logs/
# Legacy root-level paths (pre-move)
results/
results_py/

docs/Fernandes2019_BDSIM.pdf
docs/manual.pdf
Expand All @@ -53,3 +61,25 @@ docs/manual.pdf

# Obsidian
.obsidian/

# Data files
data/

# Local uv cache (optional)
.uv-cache/

# >>> agents-kit (generated) >>>
# Managed by agents-kit adapters; this block is rewritten on every run.
# Local project memory and generated views. Back up .agents/memory/ yourself.
/.agents/memory/
/CLAUDE.md
/.mcp.json
/.mcp.json.agents-kit-generated
/.cursor/mcp.json
/.cursor/mcp.json.agents-kit-generated
/.cursor/rules/agents-kit-pointer.mdc
/.cursor/rules/agents-kit-python.mdc
/.cursor/rules/agents-kit-repos.mdc
/.cursor/rules/agents-kit-md-docs.mdc
/.cursor/rules/agents-kit-memory.mdc
# <<< agents-kit <<<
8 changes: 5 additions & 3 deletions ADMIN.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,17 +128,19 @@ uv run ruff check bdsim/ tests/

# 5. CLI works
uv run python -m bdsim 42 --outdir /tmp/bdsim-check --no-plots
ls /tmp/bdsim-check/ # expect 4 CSVs
ls /tmp/bdsim-check/ # expect *.parquet tables
```

## Output artifacts

`python3 -m bdsim <seed>` produces in `--outdir` (default `results/`):
`python3 -m bdsim <seed>` produces in `--outdir` (default `data/results/`):

- `inputs.csv`, `states.csv`, `measurements.csv`, `setpoints.csv` — 4 CSVs matching the upstream MATLAB column names byte-for-byte
- `inputs.parquet`, `states.parquet`, `measurements.parquet`, `setpoints.parquet` — handbook schema (`t_s`, `TR_C`, …); see `Port_execution.md` §6
- 9 Plotly HTML figures (when `--no-plots` is NOT set) — `fig01_tr_td_toil_qheat.html` through `fig09_setpoint_loop.html`
- `index.html` — combined view of all 9 figures

Gold scenarios: `python -m bdsim.scenarios S00` or `./scripts/run_gold_scenarios_cluster.sh` → `data/results_py/S##/`. See [`docs/30-engine/Gold-parity-cluster.md`](docs/30-engine/Gold-parity-cluster.md).

## Deployment context

bdsim is **not deployed** as a service. It's an installed library. The bdsim-dashboard project wraps it as a live process.
Expand Down
22 changes: 12 additions & 10 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ tests/
├── test_fouling_modes.py # five-mode fouling stepper (offline)
└── test_fouling_modes_live.py # LiveSimulator wiring + priority for fouling-mode windows

results/ # default output dir (created on first run)
data/results/ # default demo output (created on first run)
data/results_py/ # Python gold Parquet (S00–S07)
data/results_octave/ # Octave gold ASCII (gold_dataset_1w, …)
docs/ # Obsidian knowledge base (docs/Home.md); see docs/README.md
scripts/ # optional maintainer utilities (not part of the package)
NOTES.md # historical: upstream-faithful bugs we found and fixed
Expand All @@ -67,15 +69,15 @@ NOTES.md # historical: upstream-faithful bugs we found and fixed

| Profile | Construction | `sv` width | Pins (full SHA-256[:16]) |
|--------|--------------|-------------|----------------------------|
| Runtime default (1.2.0+) | `ProcessFaults()` | **30** | batch `sv=691cf51b…` `pv=baedc29f…` `uv=4e4134e4…`; live `sv=80f6f046…` |
| Legacy fingerprint | `fouling_dynamic=False`, all masters off | 21 | batch `sv=c8807b23…` `pv=77def506…` `uv=17e62051…`; live `sv=23c3c885…` |
| dynamic-fouling fingerprint | `fouling_dynamic=True`, all other masters off | 22 | batch `sv=696531c4…` `pv=3c96ca4f…` `uv=0d9a9673…` |
| dynamic-fouling + quality-latching | `fouling_dynamic=True`, `quality_state=True` (no actuator wear, no spectra) | 27 | batch `sv=d663e17d…` (quality latching review pending — see [CHANGELOG.md](CHANGELOG.md) historical notes) |
| pump-only actuator wear | `pump_wear=True`, `valve_wear=False`, `fouling_dynamic=True`, `quality_state=False` | 23 | batch `sv=7ddd7aaa…` `pv=e0dba881…` `uv=86c2704f…` |
| valve-only actuator wear | `pump_wear=False`, `valve_wear=True`, `fouling_dynamic=True`, `quality_state=False` | 23 | batch `sv=9425d007…` `pv=02296ffa…` `uv=aa146ea3…` |
| pump + valve wear | `pump_wear=True`, `valve_wear=True`, `fouling_dynamic=True`, `quality_state=False` | 24 | batch `sv=c092fe08…` `pv=2d26f03f…` `uv=4ef50b9f…` |
| external disturbances active | `fouling_dynamic=True`, `ambient_t_amplitude_k` etc. > 0 (all other masters off) | 22 | batch `sv=8865a8c3…`; live `sv=bb763a9b…` |
| cooling-water pump trip live | `LiveSimulator` cw_pump_trip mid-run override | 22 | live `sv` matches external disturbances baseline; trip is a single row-removal event |
| Runtime default (1.2.0+) | `ProcessFaults()` | **30** | batch `sv=65c8e648…` `pv=49d36bb6…` `uv=936439b7…` (updated: Octave-aligned PID `nic` tick) |
| Legacy fingerprint | `fouling_dynamic=False`, all masters off | 21 | batch `sv=ad3d55bf…` `pv=fbdcb0d4…` `uv=6c182226…` |
| dynamic-fouling fingerprint | `fouling_dynamic=True`, all other masters off | 22 | batch `sv=07c2e836…` `pv=2ebd9f02…` `uv=7fe600c7…` |
| dynamic-fouling + quality-latching | `fouling_dynamic=True`, `quality_state=True` (no actuator wear, no spectra) | 27 | (re-pin with suite after nic fix — see tests) |
| pump-only actuator wear | `pump_wear=True`, `valve_wear=False`, `fouling_dynamic=True`, `quality_state=False` | 23 | batch `sv=736a8032…` `pv=fc29a420…` `uv=6865d7d6…` |
| valve-only actuator wear | `pump_wear=False`, `valve_wear=True`, `fouling_dynamic=True`, `quality_state=False` | 23 | batch `sv=56c453e9…` `pv=3e8783ba…` `uv=bf7ff824…` |
| pump + valve wear | `pump_wear=True`, `valve_wear=True`, `fouling_dynamic=True`, `quality_state=False` | 24 | batch `sv=2290bca3…` `pv=694dab99…` `uv=8231d3c9…` |
| external disturbances active | amplitudes > 0 (legacy masters off) | 21 | batch `sv=9b102224…` `pv=1bb38dc9…` `uv=2e5a1b88…` |
| cooling-water pump trip live | `LiveSimulator` cw_pump_trip mid-run override | — | live short-horizon pins in `tests/test_cw_pump_trip.py` |

Full write-up: `docs/00-orientation/Byte-identical-contract.md`.
- **Tests run from the bdsim root:** `python3 -m pytest tests/ -q`. Full suite: ~6:40.
Expand Down
31 changes: 31 additions & 0 deletions NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,3 +135,34 @@ fig03: Tmet 46.61–53.40 °C order_lift_oil 39.62–41.93 %
```

All 14 smoke tests still pass.

## 3. Foil / oil-valve phase vs Octave gold (FIXED 2026-10-26)

### Symptom

Full-week gold parity failed on `measurements.Foil_kg_h` with RMSE ~6k
despite matching means/std and identical plateau values — correlation
≈ −0.5. Oil valve lift showed the same ~3-sample lead vs
`data/results_octave/gold_dataset_1w`.

### Root cause

Python PID tick used `(i - 1) % nic == 0` on the 0-based driver index
`i` from `for i in range(1, lt)`. Octave `inputs.m` uses
`~mod(i_m - 1, nic)` with 1-based `i_m` starting at 2, so the first
controller update is at MATLAB step 5 ≡ Python `i == nic` (4), not
`i == 1`. Python fired PID one `nic` group early → Foil/lift
square-wave phase inversion after export alignment.

Secondary: `_intermittence` used MATLAB 1-based `ind1:ind2` formulas
as 0-based Python slices (off-by-one). Gold calendars now also use
Octave `heaviside(0) = 0.5`.

### Fix

- `apply_controller_step`: tick when `i % nic == 0`
- `_intermittence`: `signal[ind1_m - 1:ind2_m]`
- Gold scenarios: `np.heaviside(x, 0.5)`
- Fingerprint pins refreshed (intentional drift from nic alignment)
- S01/S07: Foil/DP/oil-lift family gated on pre-clean window (RK45 vs
`lsode` DPclean timing remains irreducible without solver change)
Loading
Loading