fluxopt.validation
¶
System-level structural validation, shared by every entry path.
:func:validate_system is the single source of truth for "is this set of
elements a coherent system": unique ids, resolvable carrier and effect
references, and node membership. FlowSystem runs it at construction
(including the objective), and ModelData.build runs it before
materializing — so the declarative and the programmatic path reject the
same mistakes with the same messages.
Functions:
| Name | Description |
|---|---|
check_unique |
Raise if ids contains duplicates. |
validate_system |
Fail fast on duplicate ids and undeclared references. |
reject_varying_contribution_into_lump |
Refuse a time-varying |
check_unique
¶
Raise if ids contains duplicates.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
list[str]
|
Identifiers to check. |
required |
|
str
|
Human label used in the error (e.g. |
required |
Source code in src/fluxopt/validation.py
validate_system
¶
validate_system(
*,
carriers: list[Carrier],
effects: list[Effect],
ports: list[Port],
converters: list[Converter],
storages: list[Storage],
objective: str | dict[str, float] | None = None,
) -> None
Fail fast on duplicate ids and undeclared references.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
list[Carrier]
|
Declared carriers. |
required |
|
list[Effect]
|
Declared effects (the built-in penalty effect is always accepted as a reference target, declared or not). |
required |
|
list[Port]
|
Port components. |
required |
|
list[Converter]
|
Converter components. |
required |
|
list[Storage]
|
Storage components. |
required |
|
str | dict[str, float] | None
|
Effect name or |
None
|
Source code in src/fluxopt/validation.py
reject_varying_contribution_into_lump
¶
Refuse a time-varying contribution_from into a lump-bearing effect.
A per-timestep factor has no meaning for a one-time quantity, so the mean is only ever a safe reading where the source effect's lump share is structurally zero. Checked on the data rather than while building, because it is a fact about the model and both lanes have to refuse it alike.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
ModelData
|
The model data to check. |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
Naming each |