Repository navigation
The Domain Model
James Dunkerley edited this page Nov 20, 2026
·
2 revisions
In short
- The domain model lives in
tz_ps_modelsand depends only on numpy and pydantic. - A network is a named collection of components on one shared time axis, and each component holds its attributes as constants, series or curves.
- A framework declares the component types and their attributes, and also holds the registry of installed frameworks.
-
Project,NetworkandComponentHandleintz_ps_conductorare the Python API over the model. The Python API describes them.
tz_ps_models holds plain pydantic models and no I/O. The diagram shows the core types and how the Python API wraps them. Each class lists only its main members.
classDiagram
direction LR
class Framework {
<<Protocol>>
+name
+component_types
+build_component(data)
}
class ComponentType {
+name
+url_token
+parameter_types
}
class ParameterType {
+name
+value_type
+kind
}
class NetworkModel {
+name
+framework_name
+timesteps
+components
}
class ComponentModel {
+name
+component_type
+parameters
}
class Parameter {
+attribute
+value_kind
+values
}
class Network {
+add_component()
+save()
+solve()
}
class Project {
+get_network(name)
+save_network(network)
+list_versions(name)
}
class ComponentHandle {
+set()
+clear()
}
Framework "1" o-- "*" ComponentType
ComponentType "1" *-- "*" ParameterType
NetworkModel "1" *-- "*" ComponentModel
ComponentModel "1" *-- "*" Parameter
NetworkModel ..> Framework : framework_name
ComponentModel ..> ComponentType : component_type
Network o-- NetworkModel
Network ..> Project : saves through
ComponentHandle o-- ComponentModel
- A
NetworkModelis a named collection of components, unique byComponentKey(component type and name). - It has one shared
timestepsaxis. -
componentsis a computed, sorted view. -
timestepsand series values are positional and are never sorted.
- A component holds each attribute as a
Parameterwith aValueKind:- a constant: one value;
- a series: one value per timestep;
- a curve: values at breakpoints in
x_values.
- Values are numpy float arrays (
FloatArray), so a large series never becomes a list of Python floats. - A component does not know the timesteps. The check that a series has one value per timestep runs at the network boundary, in
NetworkModel.validate_values(), which a save and a solve call.
-
Frameworkis the contract a framework package implements. - It also holds the registry of installed frameworks (
Framework.register,Framework.get). - A framework declares its
ComponentTypes. Each hasParameterTypes that say:- the value type;
- whether the attribute takes a series or a curve;
- whether it is an input or an output;
- what it references.
-
tz_ps_modelsloads no entry points itself. The composition root installs discovery withFramework.set_discovery.
-
Built:
Network(name, framework)and an import refuse a framework nothing registers, withUnknownFrameworkError. -
Loaded: a stored network loads on whatever framework it names.
get_framework_or_fallbackanswers a generic framework, and its components become plainComponentModels. - So a saved network stays readable on a host without its framework.
| Type | What it is |
|---|---|
VersionId |
A str subclass for a stored version's id, with the sentinel VersionId.LATEST. Compare with ==. |
VersionInfo |
A version's number, title, parent, and what authored it: a run, an import, a restore, a copy or a workflow step. |
NetworkRef |
Project, network name and an optional version. A run's input names one. |
SeriesIdentity |
Component type, component name and attribute: the one name for a series everywhere. |
ObjectKey |
A validated str subclass for an object store key. |
- A network carries
constraints. ACustomConstraintis a name and an expression. - A network carries
derived_values. ADerivedValueis a name, an expression and a unit label. - The glossary calls a derived value a custom statistic, and a measure a built-in statistic.
- Measures are declared in the shared catalogue,
tz_ps_expressions/measures.py, where eachMeasurenames the frameworks that provide it. -
Framework.measure_keysdeclares the fields a run's measures may be grouped and filtered by. - A solve stores measures in the run values table described by
tz_ps_models/run_values.py. - Snapshot weightings are a mapping from a weighting name to one number per timestep.
A solve's outputs are values on a network version, with the objective in NetworkModel.metadata.
Using the app
Architecture
- Overview
- Python API
- Domain model
- Backend core
- Composition root and config
- Expression language internals
- Storage
- Execution
- Imports and exports
- Workflow engine
- HTTP API and contracts
- Frontend and desktop
- Build, CI and release
Contributing