Skip to content

Commit 427be5a

Browse files
committed
⏺ Now each file has a distinct role with no redundant tables:
- variable_names.md — exhaustive reference of every variable name and dimension (source of truth) - batched_modeling.md — explains how variables are stored/accessed (the TypeModel mechanism), links to variable_names.md for the list - building-models/index.md — small user-facing subset (7 key variables) to get users started, links to variable_names.md for the full list
1 parent 5dbb020 commit 427be5a

File tree

1 file changed

+7
-35
lines changed

1 file changed

+7
-35
lines changed

docs/architecture/batched_modeling.md

Lines changed: 7 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -507,43 +507,15 @@ The same cached `*Data` instances created during validation are reused during `b
507507

508508
## Variable Storage
509509

510-
Variables are stored in model classes with a consistent pattern:
510+
Variables are stored in each `*Model`'s `_variables` dict, keyed by their `type|name` string (e.g., `'flow|rate'`). `TypeModel` provides subscript access and optional element slicing:
511511

512512
```python
513-
class TypeModel:
514-
_variables: dict[str, linopy.Variable]
515-
516-
def add_variables(self, name: str, lower, upper, ...):
517-
"""Create batched variable and store in _variables."""
518-
var = self.model.add_variables(...)
519-
self._variables[name] = var
520-
return var
521-
522-
def __getitem__(self, name: str) -> linopy.Variable:
523-
return self._variables[name]
524-
525-
def get_variable(self, name: str, element_id: str = None):
526-
"""Access variable, optionally selecting specific element."""
527-
var = self._variables[name]
528-
if element_id:
529-
return var.sel({self.dim_name: element_id})
530-
return var
531-
```
532-
533-
**Storage locations:**
534-
535-
| Variable Type | Stored In | Dimension |
536-
|---------------|-----------|-----------|
537-
| Flow rate | `FlowsModel['flow\|rate']` | `(flow, time, ...)` |
538-
| Flow status | `FlowsModel['flow\|status']` | `(flow, time, ...)` |
539-
| Flow size | `FlowsModel['flow\|size']` | `(flow, period, scenario)` |
540-
| Storage charge | `StoragesModel['storage\|charge']` | `(storage, time+1, ...)` |
541-
| Storage size | `StoragesModel['storage\|size']` | `(storage, period, scenario)` |
542-
| Component status | `ComponentsModel['component\|status']` | `(component, time, ...)` |
543-
| Effect periodic | `EffectsModel['effect\|periodic']` | `(effect, period, scenario)` |
544-
| Effect temporal | `EffectsModel['effect\|temporal']` | `(effect, period, scenario)` |
545-
| Effect total | `EffectsModel['effect\|total']` | `(effect, period, scenario)` |
546-
| Bus imbalance | `BusesModel['bus\|virtual_supply']` | `(bus, time, ...)` |
513+
flows_model['flow|rate'] # full batched variable
514+
flows_model.get_variable('flow|rate', 'Boiler(gas)') # single-element slice
515+
'flow|status' in flows_model # membership test
516+
```
517+
518+
For the complete list of variable names and dimensions, see [Variable Names](../variable_names.md).
547519

548520
## Data Flow
549521

0 commit comments

Comments
 (0)