Calculation Note — Reporting Contract#
This page describes the full contract between a STONE YAML file and the
generated Excel Calculation Note. It covers every export: key, how
kpi_fn and figures are resolved, what figure keys are available, and
what goes into each section of the output workbook.
export: block reference#
All keys live under the top-level export: key of the STONE YAML.
Key |
Required |
Type |
Description |
|---|---|---|---|
|
No |
string |
Output Excel filename. Default: |
|
No |
string |
Report title row in the Excel header |
|
No |
string |
Report subtitle row |
|
No |
string |
Reactor class name (e.g. |
|
No |
dotted path |
Python callable for model-specific KPI extraction. Format: |
|
No |
float |
Relative tolerance of the per-node mass/energy closure gate the export enforces (default |
|
No |
list of keys |
Figure generators to call. Keys must be registered in |
|
No |
int |
Number of top species by mole fraction to include (default 8) |
|
No |
int |
Number of top species by mass fraction to include (default 6) |
|
No |
float (0–1) |
Add species until cumulative mole fraction ≥ this value (default 0.95; set to 0 to disable) |
|
No |
float (0–1) |
Same logic for mass fractions (default 0.95) |
|
No |
float (0–1) |
Add species in descending H-atom contribution until cumulative H ≥ this value (default 0.95) |
|
No |
float (0–1) |
Same logic for carbon atoms (default 0.95) |
|
No |
list of strings |
Species that must always appear in the composition tables |
Minimal export: example#
export:
calc_note: "MyProject_Calculation_Note.xlsx"
title: "Hydrogen Production Analysis"
kpi_fn: "bloc.reporting.spring_kpi:compute_spring_kpis"
How kpi_fn is resolved#
kpi_fn may be declared in the YAML or passed as a Python kwarg to
generate_calculation_note_stone.
Resolution order:
The
kpi_fnkwarg passed togenerate_calculation_note_stone(kpi_fn=...).export.kpi_fnin the YAML — parsed as"module.path:attribute"and imported at runtime usingimportlib.If neither is set, no model-specific KPI extraction is performed and the output sheet contains only generic thermodynamic outputs (T, P, X, Y per node).
YAML format:
export:
kpi_fn: "bloc.reporting.spring_kpi:compute_spring_kpis"
This is equivalent to:
from bloc.reporting.spring_kpi import compute_spring_kpis
generate_calculation_note_stone("my.yaml", kpi_fn=compute_spring_kpis)
Built-in KPI functions:
Function |
Reactor chain |
|---|---|
|
Torch → PSR → PFR (SPRING) |
|
TubeFurnace |
Figure generators#
Figure generators are registered in bloc.io.scenario.STONE_FIGURE_GENERATORS.
List the keys you want under export.figures:.
Key |
What it produces |
|---|---|
|
Graphviz network topology diagram (nodes + connections) |
|
Spatial temperature and species profiles for TubeFurnace |
|
Spatial temperature and species profiles along the PFR axis |
|
Sankey mass-flow diagram |
Example:
export:
figures:
- pfr_profile
- network
- sankey
If a figure key is not in STONE_FIGURE_GENERATORS, generate_calculation_note_stone
raises a KeyError listing the known keys.
Figures are saved as PNG files in the output_dir and embedded in the Excel
Calculation Note on a dedicated “Diagrams” sheet.
The GUI’s Cytoscape network graph (the picture under the first sheet’s
header) is captured by the browser when you export from the GUI. CLI and
batch exports render it headlessly instead, through the optional
playwright extra (pip install bloc[gui-export] then
playwright install chromium); without it the picture is simply omitted.
Pass render_network_schema=False to generate_calculation_note_stone to
skip it. The graphviz network figure on the scenario sheets is separate
and needs the dot executable, which the bloc conda env provides.
Excel workbook structure#
The generated workbook contains the following sheets:
Sheet |
Contents |
|---|---|
Summary |
One column per scenario: inputs, outputs, KPIs, and metadata |
Inputs |
Parameter table: symbol, value, unit, description, remark (from |
Outputs |
KPI table: symbol, value, unit, description |
Composition |
Per-node species table (mole and mass fractions) |
Diagrams |
Embedded PNG figures (one per figure key) |
(one sheet per scenario) |
Detailed per-scenario tabular data when multiple scenarios are present |
Generating the Calculation Note#
Single scenario#
from bloc.reporting.orchestrator_stone import generate_calculation_note_stone
path = generate_calculation_note_stone("my_stone.yaml", output_dir="Results")
print(f"Saved: {path}")
Multiple scenarios (inline sweeps / scenarios block)#
from bloc.reporting.orchestrator_stone import generate_calculation_note_stone
generate_calculation_note_stone("my_stone.yaml", output_dir="Results")
expand_scenarios is called automatically whenever the YAML declares a
top-level scenarios: and/or sweep:/sweeps: block; each entry (plus the
BASELINE unmodified base, added automatically by Boulder) becomes a column
in the Summary sheet and its own detail sheet. include_base=False skips
running the base case itself (kept only as the workbook/export template);
scenario_yamls= runs additional standalone scenario files (each with its
own complete from:-resolved definition, not deep-merged onto the base).
This is the same expansion the GUI’s Run Sweep action and the headless
bloc some.yaml --sweep --headless CLI invocation use — see
the CLI reference (“Running scenario sweeps”) for those two other
entry points into the same run-set.
Passing a custom KPI function at call time#
from bloc.reporting.orchestrator_stone import generate_calculation_note_stone
from mypackage.kpis import my_kpi_fn
generate_calculation_note_stone(
"my_stone.yaml",
kpi_fn=my_kpi_fn,
output_dir="Results",
)
See also#
Unit conventions — all units used in inputs and outputs
bloc.reporting.orchestrator_stone.generate_calculation_note_stone— Python API referencebloc.io.scenario.STONE_FIGURE_GENERATORS— figure registryARCHITECTURE.md— full pipeline description