Automated Substation Creation and Feeder Insertion in CIM18¶
This notebook builds every node-breaker substation layout in CIM-Builder around the IEEE 13 and IEEE 13 Assets feeders. For each layout it:
- loads both feeders into a fresh CIMantic Graphs model,
- builds the substation, its 115 kV VoltageLevel, buses and bus ties,
- adds a branch from the bus to a new 115 kV line node and to each feeder's
sourcebus, - links both feeders to the substation through
Feeder.NormalEnergizingSubstation, - writes the substation and feeders to one CIM XML file, then reads it back to check the substation, its switches and the total load served.
Each layout's own page walks through these steps in detail; see Substation builder for the call order they share.
Set up¶
The CIM profile and unit handling are process-wide environment variables, so set them before importing CIMantic Graphs.
import logging
import os
os.environ["CIMG_CIM_PROFILE"] = "cim18v17"
os.environ["CIMG_USE_UNITS"] = "TRUE"
os.environ["CIMG_SYSTEM_MVA_BASE"] = "100"
# The IEEE 13 files carry CIMHub extensions that cim18v17 does not have: hide the parser warnings
logging.getLogger("cimgraph").setLevel(logging.ERROR)
import cimgraph.utils as utils
import cimprofiles.cim18.cim18v17 as cim
from cimgraph.databases import XMLFile
from cimgraph.models import FeederModel
from cimtables.units import Qty
from cimbuilder.object_builder import BaseVoltageBuilder, FeederBuilder
from cimbuilder.substation_builder import (
BreakerAndHalfSubstationBuilder,
DoubleBusSingleBreakerSubstationBuilder,
MainAndTransferSubstationBuilder,
RingBusSubstationBuilder,
SectionalizedBusSubstationBuilder,
SingleBusSubstationBuilder,
)
Shared helpers¶
These load the feeders, find each feeder's head node, link the feeders, and save and check the result. The
layout sections below differ only in their builder and their add_buses / add_branch arguments.
IEEE13 = "49AD8E07-3BF9-A4E2-CB8F-C3722F837B62"
IEEE13_ASSETS = "5B816B93-7A5F-B64C-8460-47C17D6E4B0F"
FEEDER_FILES = ["../../tests/test_models/IEEE13.xml", "../../tests/test_models/IEEE13_Assets.xml"]
def load_feeders():
"""a fresh graph of both IEEE 13 feeders and a 115 kV BaseVoltage, bv_115kV, for the substation"""
network = FeederModel(
container=cim.Feeder(mRID=IEEE13), connection=XMLFile(filename=FEEDER_FILES), distributed=False
)
BaseVoltageBuilder(network, network.container).create(
mRID="bv_115kV", name="115 kV", nominalVoltage=Qty(115, "kV")
)
return network
def sourcebus(network, feeder_mRID):
"""mRID of the feeder head node, the ConnectivityNode named sourcebus in the feeder"""
for node in network.graph[cim.ConnectivityNode].values():
node_container = node.ConnectivityNodeContainer
if node.name == "sourcebus" and node_container is not None and node_container.mRID == feeder_mRID:
return node.mRID
raise ValueError(f"no sourcebus in feeder {feeder_mRID}")
def link_feeders(network, substation):
"""Feeder.NormalEnergizingSubstation of both feeders"""
feeder_builder = FeederBuilder(network, network.container)
for feeder_mRID in (IEEE13, IEEE13_ASSETS):
feeder_builder.add_connectivity(
network.find_by_mRID(feeder_mRID), NormalEnergizingSubstation=substation.mRID
)
def save_and_check(network, substation, filename):
"""writes the network to output/<filename>, reads it back and prints what came back"""
os.makedirs("output", exist_ok=True)
utils.write_xml(network, f"output/{filename}")
roundtrip = FeederModel(
container=cim.Feeder(mRID=IEEE13), connection=XMLFile(filename=f"output/{filename}"), distributed=False
)
substation = roundtrip.find_by_mRID(substation.mRID)
switches = [
equipment
for voltage_level in substation.VoltageLevels
for equipment in voltage_level.Equipments
if isinstance(equipment, (cim.Breaker, cim.Disconnector))
]
total_load = sum(float(load.p) for load in roundtrip.graph[cim.EnergyConsumer].values())
print(f"{substation.mRID}: feeders {[feeder.name for feeder in substation.NormalEnergizedFeeder]}")
print(f" {len(switches)} breakers and disconnectors in the substation")
print(f" total load served: {cim.ActivePower(total_load).to('kW'):.1f} kW")
Single bus¶
One bus. Each branch is a breaker bay off the bus. Step by step: Single bus.
network = load_feeders()
builder = SingleBusSubstationBuilder(network, network.container)
substation = builder.create(mRID="sub_single_bus", name="sub_single_bus")
substation, voltage_level = builder.add_voltage_level(substation, mRID="vl_115", BaseVoltage="bv_115kV")
voltage_level, busbars, ties = builder.add_buses(voltage_level)
builder.add_branch(voltage_level, number=1, node="line_1")
builder.add_branch(voltage_level, number=2, node=sourcebus(network, IEEE13))
builder.add_branch(voltage_level, number=3, node=sourcebus(network, IEEE13_ASSETS))
link_feeders(network, substation)
save_and_check(network, substation, "single_bus.xml")
sub_single_bus: feeders ['ieee13nodeckt', 'ieee13nodecktassets'] 9 breakers and disconnectors in the substation total load served: 6937.0 kW
Sectionalized bus¶
Two bus sections joined by a tie bay. section picks the section each branch is on. Step by step: Sectionalized bus.
network = load_feeders()
builder = SectionalizedBusSubstationBuilder(network, network.container)
substation = builder.create(mRID="sub_sectionalized", name="sub_sectionalized")
substation, voltage_level = builder.add_voltage_level(substation, mRID="vl_115", BaseVoltage="bv_115kV")
voltage_level, busbars, ties = builder.add_buses(voltage_level, sections=2)
builder.add_branch(voltage_level, section=1, number=1, node="line_1")
builder.add_branch(voltage_level, section=1, number=2, node=sourcebus(network, IEEE13))
builder.add_branch(voltage_level, section=2, number=3, node=sourcebus(network, IEEE13_ASSETS))
link_feeders(network, substation)
save_and_check(network, substation, "sectionalized_bus.xml")
sub_sectionalized: feeders ['ieee13nodeckt', 'ieee13nodecktassets'] 12 breakers and disconnectors in the substation total load served: 6937.0 kW
Main and transfer¶
A main bus and a transfer bus joined by a tie bay. Each branch also gets a normally open bypass disconnector to the transfer bus. Step by step: Main and transfer.
network = load_feeders()
builder = MainAndTransferSubstationBuilder(network, network.container)
substation = builder.create(mRID="sub_main_and_transfer", name="sub_main_and_transfer")
substation, voltage_level = builder.add_voltage_level(substation, mRID="vl_115", BaseVoltage="bv_115kV")
voltage_level, busbars, ties = builder.add_buses(voltage_level)
builder.add_branch(voltage_level, number=1, node="line_1")
builder.add_branch(voltage_level, number=2, node=sourcebus(network, IEEE13))
builder.add_branch(voltage_level, number=3, node=sourcebus(network, IEEE13_ASSETS))
link_feeders(network, substation)
save_and_check(network, substation, "main_and_transfer.xml")
sub_main_and_transfer: feeders ['ieee13nodeckt', 'ieee13nodecktassets'] 15 breakers and disconnectors in the substation total load served: 6937.0 kW
Double bus, single breaker¶
Two buses joined by a tie bay. bus picks the bus each branch normally runs on; the selector to the other bus is normally open. Step by step: Double bus, single breaker.
network = load_feeders()
builder = DoubleBusSingleBreakerSubstationBuilder(network, network.container)
substation = builder.create(mRID="sub_double_bus", name="sub_double_bus")
substation, voltage_level = builder.add_voltage_level(substation, mRID="vl_115", BaseVoltage="bv_115kV")
voltage_level, busbars, ties = builder.add_buses(voltage_level)
builder.add_branch(voltage_level, number=1, node="line_1", bus=1)
builder.add_branch(voltage_level, number=2, node=sourcebus(network, IEEE13), bus=1)
builder.add_branch(voltage_level, number=3, node=sourcebus(network, IEEE13_ASSETS), bus=2)
link_feeders(network, substation)
save_and_check(network, substation, "double_bus_single_breaker.xml")
sub_double_bus: feeders ['ieee13nodeckt', 'ieee13nodecktassets'] 15 breakers and disconnectors in the substation total load served: 6937.0 kW
network = load_feeders()
builder = RingBusSubstationBuilder(network, network.container)
substation = builder.create(mRID="sub_ring_bus", name="sub_ring_bus")
substation, voltage_level = builder.add_voltage_level(substation, mRID="vl_115", BaseVoltage="bv_115kV")
voltage_level, busbars, ring = builder.add_buses(voltage_level, sections=4)
builder.add_branch(voltage_level, section=1, node="line_1")
builder.add_branch(voltage_level, section=3, node=sourcebus(network, IEEE13))
builder.add_branch(voltage_level, section=4, node=sourcebus(network, IEEE13_ASSETS))
link_feeders(network, substation)
save_and_check(network, substation, "ring_bus.xml")
sub_ring_bus: feeders ['ieee13nodeckt', 'ieee13nodecktassets'] 15 breakers and disconnectors in the substation total load served: 6937.0 kW
Breaker and a half¶
Two buses joined by two diameters of three breaker bays each. A branch connects to one side of a diameter. Step by step: Breaker and a half.
network = load_feeders()
builder = BreakerAndHalfSubstationBuilder(network, network.container)
substation = builder.create(mRID="sub_breaker_and_half", name="sub_breaker_and_half")
substation, voltage_level = builder.add_voltage_level(substation, mRID="vl_115", BaseVoltage="bv_115kV")
voltage_level, busbars, diameters = builder.add_buses(voltage_level, diameters=2)
builder.add_branch(voltage_level, diameter=1, side=1, node="line_1")
builder.add_branch(voltage_level, diameter=1, side=2, node=sourcebus(network, IEEE13))
builder.add_branch(voltage_level, diameter=2, side=1, node=sourcebus(network, IEEE13_ASSETS))
link_feeders(network, substation)
save_and_check(network, substation, "breaker_and_half.xml")
sub_breaker_and_half: feeders ['ieee13nodeckt', 'ieee13nodecktassets'] 21 breakers and disconnectors in the substation total load served: 6937.0 kW
<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>