Model data¶
Loading and normalising model dictionaries and JSON files, and the power flow.
model_data
¶
Loading and normalization of power system model data.
PS_MODELS_DIR
module-attribute
¶
CATEGORY_ALIASES
module-attribute
¶
DEFAULT_MODELS
module-attribute
¶
DEFAULT_MODELS = {
"lines": "Line",
"switches": "Switch",
"trafos": "Trafo",
"loads": "Load",
"shunts": "Shunt",
}
read_json
¶
Read model data from a JSON file, looking in the bundled ps_models folder if the path does not exist.
Source code in src/tops/model_data.py
load_model_data
¶
Return a normalized (shallow) copy of model data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
Dict with model data, or path to a .json file (which can also be the name of a bundled model, e.g. 'k2a.json'). |
required |
Source code in src/tops/model_data.py
find_model_class
¶
Look up a model class, first in the user model library and then in the standard one.
Returns None (with a warning) if the model is not found.
Source code in src/tops/model_data.py
is_table
¶
Check if data is a single table (list with header row and at least one entry, or a DataFrame).
read_table
¶
Convert a table given as a list (header row followed by entries) or a DataFrame to a structured array.
Source code in src/tops/model_data.py
power_flow
¶
Power flow: collects injections from models, solves, and distributes the solution back to the units.
PowerFlowResult
dataclass
¶
default_slack_bus_idx
¶
Index of the bus of the PV unit with the largest P setpoint, used as slack bus if none is specified.
Ties are resolved in favour of the first unit found.
Source code in src/tops/power_flow.py
load_flow_q_share
¶
Weights of the PV units of a model in the sharing of the reactive power at their buses.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mdl
|
A model with |
required |
Returns:
| Type | Description |
|---|---|
|
One weight per unit, in the order of |
solve_power_flow
¶
Solve the power flow.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
y_bus
|
Bus admittance matrix for the power flow. |
required | |
pq_mdls
|
Models with load_flow_pq(), returning (bus_idx, P, Q) in MW/MVAr. |
required | |
pv_mdls
|
Models with load_flow_pv(), returning (bus_idx, P setpoint, V setpoint). P is in MW with load convention, i.e. a generator producing 100 MW returns -100. |
required | |
s_n
|
System base power (MVA). |
required | |
sl_idx
|
Index of the slack bus. |
required |