Bus-Branch Transmission Modeling¶
Bus-branch models are the planning view of a transmission network (as in PSS/E or MATPOWER cases): each bus is a single node, and the substation switching detail is not represented. In CIM, a bus is a ConnectivityNode, branches are ACLineSegment and PowerTransformer objects, and loads, generators and shunts connect to the buses through their Terminal objects. The CIMantic Graphs BusBranchModel class gives access to these models.
Creating a BusBranchModel¶
This page uses the IEEE 118 bus test model, read with the XMLFile parser. Import the CIM profile, set the matching environment variable and the BusBranchModel class.
The test file also contains dynamics classes (e.g. ExcitationSystem) that are not in the cim17v40 profile. Setting CIMG_VALIDATION_LOG_LEVEL to DEBUG logs the messages about them at debug level, so they are not printed:
import os
os.environ['CIMG_CIM_PROFILE'] = 'cim17v40' # import and env var must match
os.environ['CIMG_VALIDATION_LOG_LEVEL'] = 'DEBUG'
import cimprofiles.cim17.cim17v40 as cim
from cimgraph.databases import XMLFile
from cimgraph.models import BusBranchModel
Create the CIM ConnectivityNodeContainer that holds the model, and load the model:
file = XMLFile(filename='../../tests/test_models/IEEE118_CIM.xml')
model_mrid = '1783D2A8-1204-4781-A0B4-7A73A2FA6038' # IEEE 118 Bus
container = cim.ConnectivityNodeContainer(mRID=model_mrid)
network = BusBranchModel(connection=file, container=container)
for cim_class in [cim.ConnectivityNode, cim.ACLineSegment, cim.PowerTransformer,
cim.EnergyConsumer, cim.SynchronousMachine, cim.LinearShuntCompensator]:
print(cim_class.__name__, len(network.list_by_class(cim_class)))
ConnectivityNode 193 ACLineSegment 170 PowerTransformer 84 EnergyConsumer 99 SynchronousMachine 56 LinearShuntCompensator 14
Equipment at a Bus¶
Each bus lists the terminals connected to it, and each terminal its equipment:
bus = network.first(cim.ConnectivityNode)
print('bus', bus.name)
for terminal in bus.Terminals:
equipment = terminal.ConductingEquipment
print(' ', equipment.__class__.__name__, equipment.name)
bus 17
ACLineSegment 15_17_1
ACLineSegment 16_17_1
ACLineSegment 17_18_1
ACLineSegment 17_31_1
ACLineSegment 17_113_1
EnergyConsumer 17_1
PowerTransformer 30_17_0_1
Branch Impedances¶
Impedances are stored in ohms. To convert them to per unit, divide by the base impedance z_base = V_base² / S_base, using the model's system base network.base_power (100 MVA here) and the nominal voltage of the line:
base_power_va = network.base_power.to('VA')
for line in network.list_by_class(cim.ACLineSegment)[:5]:
base_voltage_v = line.BaseVoltage.nominalVoltage.to('V')
z_base = base_voltage_v ** 2 / base_power_va
r_pu = line.r.to('ohm') / z_base
x_pu = line.x.to('ohm') / z_base
nominal_kv = line.BaseVoltage.nominalVoltage.to('kV')
print(f'{line.name}: {nominal_kv} kV, r = {r_pu:.5f} pu, x = {x_pu:.5f} pu')
64_65_1: 345.0 kV, r = 0.00269 pu, x = 0.03020 pu 63_64_1: 345.0 kV, r = 0.00172 pu, x = 0.02000 pu 109_110_1: 138.0 kV, r = 0.02780 pu, x = 0.07620 pu 2_12_1: 138.0 kV, r = 0.01870 pu, x = 0.06160 pu 21_22_1: 138.0 kV, r = 0.02090 pu, x = 0.09700 pu
Loads by Voltage Level¶
Each BaseVoltage lists the equipment at that voltage. Converting the load values with .to() gives the total load per voltage level in MW and MVAr:
for base_voltage in network.list_by_class(cim.BaseVoltage):
loads = [equipment for equipment in base_voltage.ConductingEquipment
if isinstance(equipment, cim.EnergyConsumer)]
total_p = sum(load.p.to('MW') for load in loads)
total_q = sum(load.q.to('MVAr') for load in loads)
print(f'{base_voltage.name}: {len(loads)} loads, {total_p:.1f} MW, {total_q:.1f} MVAr')
BV_13.80: 0 loads, 0.0 MW, 0.0 MVAr BV_345.00: 2 loads, 212.0 MW, 0.0 MVAr BV_138.00: 97 loads, 4030.0 MW, 1438.0 MVAr
Loading a BusBranchModel from a Database¶
With a database, pass its connection instead of the XMLFile. The example below needs a running Blazegraph database with the IEEE 118 model loaded and the sparql extra (pip install cim-graph[sparql]), so it is not run here. Database models are loaded with only the identifiers of the equipment, nodes and terminals; .get_all_edges() reads the attributes of a class:
os.environ['CIMG_URL'] = 'http://localhost:8889/bigdata/namespace/kb/sparql'
from cimgraph.databases import BlazegraphConnection
database = BlazegraphConnection()
network = BusBranchModel(connection=database, container=container)
network.get_all_edges(cim.ACLineSegment)
network.pprint(cim.ACLineSegment)
Distributed Modeling¶
BusBranchModel(..., distributed=True) is not implemented yet and builds an empty graph. Use the centralized model.
<style>
['pre { line-height: 125%; }\ntd.linenos .normal { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }\nspan.linenos { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }\ntd.linenos .special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }\nspan.linenos.special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }\n.highlight-ipynb .hll { background-color: var(--jp-cell-editor-active-background) }\n.highlight-ipynb { background: var(--jp-cell-editor-background); color: var(--jp-mirror-editor-variable-color) }\n.highlight-ipynb .c { color: var(--jp-mirror-editor-comment-color); font-style: italic } /* Comment */\n.highlight-ipynb .err { color: var(--jp-mirror-editor-error-color) } /* Error */\n.highlight-ipynb .k { color: var(--jp-mirror-editor-keyword-color); font-weight: bold } /* Keyword */\n.highlight-ipynb .o { color: var(--jp-mirror-editor-operator-color); font-weight: bold } /* Operator */\n.highlight-ipynb .p { color: var(--jp-mirror-editor-punctuation-color) } /* Punctuation */\n.highlight-ipynb .ch { color: var(--jp-mirror-editor-comment-color); font-style: italic } /* Comment.Hashbang */\n.highlight-ipynb .cm { color: var(--jp-mirror-editor-comment-color); font-style: italic } /* Comment.Multiline */\n.highlight-ipynb .cp { color: var(--jp-mirror-editor-comment-color); font-style: italic } /* Comment.Preproc */\n.highlight-ipynb .cpf { color: var(--jp-mirror-editor-comment-color); font-style: italic } /* Comment.PreprocFile */\n.highlight-ipynb .c1 { color: var(--jp-mirror-editor-comment-color); font-style: italic } /* Comment.Single */\n.highlight-ipynb .cs { color: var(--jp-mirror-editor-comment-color); font-style: italic } /* Comment.Special */\n.highlight-ipynb .kc { color: var(--jp-mirror-editor-keyword-color); font-weight: bold } /* Keyword.Constant */\n.highlight-ipynb .kd { color: var(--jp-mirror-editor-keyword-color); font-weight: bold } /* Keyword.Declaration */\n.highlight-ipynb .kn { color: var(--jp-mirror-editor-keyword-color); font-weight: bold } /* Keyword.Namespace */\n.highlight-ipynb .kp { color: var(--jp-mirror-editor-keyword-color); font-weight: bold } /* Keyword.Pseudo */\n.highlight-ipynb .kr { color: var(--jp-mirror-editor-keyword-color); font-weight: bold } /* Keyword.Reserved */\n.highlight-ipynb .kt { color: var(--jp-mirror-editor-keyword-color); font-weight: bold } /* Keyword.Type */\n.highlight-ipynb .m { color: var(--jp-mirror-editor-number-color) } /* Literal.Number */\n.highlight-ipynb .s { color: var(--jp-mirror-editor-string-color) } /* Literal.String */\n.highlight-ipynb .ow { color: var(--jp-mirror-editor-operator-color); font-weight: bold } /* Operator.Word */\n.highlight-ipynb .pm { color: var(--jp-mirror-editor-punctuation-color) } /* Punctuation.Marker */\n.highlight-ipynb .w { color: var(--jp-mirror-editor-variable-color) } /* Text.Whitespace */\n.highlight-ipynb .mb { color: var(--jp-mirror-editor-number-color) } /* Literal.Number.Bin */\n.highlight-ipynb .mf { color: var(--jp-mirror-editor-number-color) } /* Literal.Number.Float */\n.highlight-ipynb .mh { color: var(--jp-mirror-editor-number-color) } /* Literal.Number.Hex */\n.highlight-ipynb .mi { color: var(--jp-mirror-editor-number-color) } /* Literal.Number.Integer */\n.highlight-ipynb .mo { color: var(--jp-mirror-editor-number-color) } /* Literal.Number.Oct */\n.highlight-ipynb .sa { color: var(--jp-mirror-editor-string-color) } /* Literal.String.Affix */\n.highlight-ipynb .sb { color: var(--jp-mirror-editor-string-color) } /* Literal.String.Backtick */\n.highlight-ipynb .sc { color: var(--jp-mirror-editor-string-color) } /* Literal.String.Char */\n.highlight-ipynb .dl { color: var(--jp-mirror-editor-string-color) } /* Literal.String.Delimiter */\n.highlight-ipynb .sd { color: var(--jp-mirror-editor-string-color) } /* Literal.String.Doc */\n.highlight-ipynb .s2 { color: var(--jp-mirror-editor-string-color) } /* Literal.String.Double */\n.highlight-ipynb .se { color: var(--jp-mirror-editor-string-color) } /* Literal.String.Escape */\n.highlight-ipynb .sh { color: var(--jp-mirror-editor-string-color) } /* Literal.String.Heredoc */\n.highlight-ipynb .si { color: var(--jp-mirror-editor-string-color) } /* Literal.String.Interpol */\n.highlight-ipynb .sx { color: var(--jp-mirror-editor-string-color) } /* Literal.String.Other */\n.highlight-ipynb .sr { color: var(--jp-mirror-editor-string-color) } /* Literal.String.Regex */\n.highlight-ipynb .s1 { color: var(--jp-mirror-editor-string-color) } /* Literal.String.Single */\n.highlight-ipynb .ss { color: var(--jp-mirror-editor-string-color) } /* Literal.String.Symbol */\n.highlight-ipynb .il { color: var(--jp-mirror-editor-number-color) } /* Literal.Number.Integer.Long */']
</style>