Skip to content

Commit

Permalink
Extract connectivity node
Browse files Browse the repository at this point in the history
  • Loading branch information
davidkleiven committed Jan 4, 2024
1 parent 78de08a commit 8d16675
Show file tree
Hide file tree
Showing 9 changed files with 33 additions and 11 deletions.
5 changes: 5 additions & 0 deletions cimsparql/data_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ class LoadsSchema(NamedResourceSchema):
p: Series[float] = pa.Field(nullable=True)
q: Series[float] = pa.Field(nullable=True)
station_group: Series[str] = pa.Field(nullable=True)
connectivity_node: Series[str] = pa.Field()


LoadsDataFrame = DataFrame[LoadsSchema]
Expand Down Expand Up @@ -110,6 +111,7 @@ class SynchronousMachinesSchema(NamedMarketResourceSchema):
sn: Series[float] = pa.Field()
p: Series[float] = pa.Field(nullable=True)
q: Series[float] = pa.Field(nullable=True)
connectivity_node: Series[str] = pa.Field()


SynchronousMachinesDataFrame = DataFrame[SynchronousMachinesSchema]
Expand Down Expand Up @@ -149,6 +151,7 @@ class ConvertersSchema(NamedResourceSchema):
node: Series[str] = pa.Field()
p: Series[float] = pa.Field()
q: Series[float] = pa.Field()
connectivity_node: Series[str] = pa.Field()


ConvertersDataFrame = DataFrame[ConvertersSchema]
Expand Down Expand Up @@ -185,6 +188,8 @@ class BranchComponentSchema(NamedResourceSchema):
status: Series[bool] = pa.Field()
un: Series[float] = pa.Field()
x: Series[float] = pa.Field()
connectivity_node_1: Series[str] = pa.Field()
connectivity_node_2: Series[str] = pa.Field()


BranchComponentDataFrame = DataFrame[BranchComponentSchema]
Expand Down
5 changes: 5 additions & 0 deletions cimsparql/sparql/ac_lines.sparql
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ select
(max(?b) as ?b)
(max(?g) as ?g)
(max(?length) as ?length)
(max(?connectivity_node_1) as ?connectivity_node_1)
(max(?connectivity_node_2) as ?connectivity_node_2)
where {
# TODO: Check if SN:Equipment.networkAnalysisEnable is on it's way into the standard
# Assume π equivalent with at least r,x and b shunt.
Expand Down Expand Up @@ -67,6 +69,7 @@ where {
# Search for acline SV status will be combined with SSH connected
optional {?acline ^cim:SvStatus.ConductingEquipment/cim:SvStatus.inService ?in_service . }
optional {?con_node cim:ConnectivityNode.TopologicalNode/cim:IdentifiedObject.mRID ?con_top_node_mrid .}
?con_node cim:IdentifiedObject.mRID ?connectivity_node .

# Find properties in TP/SV/SSH profile for each terminal.
?terminal cim:ACDCTerminal.connected ?connected .
Expand All @@ -88,6 +91,8 @@ where {
bind(if(?nr = 2, ?node, '') as ?node_2)
bind(if(?nr = 2, ?connected, False) as ?connected_2)
bind(if(?nr = 2, ?bidzone, '') as ?bidzone_2)
bind(if(?nr = 1, ?connectivity_node, '') as ?connectivity_node_1)
bind(if(?nr = 2, ?connectivity_node, '') as ?connectivity_node_2)
filter(regex(?area, '${region}'))
} group by ?acline
# Filtration rules
Expand Down
3 changes: 2 additions & 1 deletion cimsparql/sparql/converters.sparql
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
PREFIX cim:<${cim}>
PREFIX xsd:<${xsd}>
PREFIX SN:<${SN}>
select ?mrid ?name ?alias ?p ?q ?substation_mrid ?status ?node
select ?mrid ?name ?alias ?p ?q ?substation_mrid ?status ?node ?connectivity_node
where {
# Extract active and reactive power for the converter
?converter cim:ACDCConverter.p ?p;
Expand Down Expand Up @@ -32,6 +32,7 @@ where {
?terminal cim:Terminal.ConductingEquipment ?converter;
cim:Terminal.ConnectivityNode ?con_node;
cim:Terminal.sequenceNumber|cim:ACDCTerminal.sequenceNumber 1 .
?con_node cim:IdentifiedObject.mRID ?connectivity_node .
optional {?converter SN:Equipment.networkAnalysisEnable ?_analysis_enabled .}
filter regex(?area, '${region}')
bind(coalesce(?_analysis_enabled, True) as ?analysis_enabled)
Expand Down
3 changes: 2 additions & 1 deletion cimsparql/sparql/loads.sparql
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Name: Loads
PREFIX cim: <${cim}>
PREFIX SN: <${SN}>
select ?mrid ?name ?node ?substation_mrid ?bidzone ?status ?p ?q ?station_group
select ?mrid ?name ?node ?substation_mrid ?bidzone ?status ?p ?q ?station_group ?connectivity_node
where {

# Extrcact connected flag and optionally the mRID of the topological node associated with the terminal
Expand All @@ -10,6 +10,7 @@ where {

# Optionally extract the mRID of the topological node for the connectivity node associated with each terminal
optional {?con_node cim:ConnectivityNode.TopologicalNode/cim:IdentifiedObject.mRID ?con_top_node_mrid .}
?con_node cim:IdentifiedObject.mRID ?connectivity_node .

# Optionally extract in_service flag and active and reactive energy consumption for each load
optional {?load ^cim:SvStatus.ConductingEquipment/cim:SvStatus.inService ?in_service }.
Expand Down
7 changes: 6 additions & 1 deletion cimsparql/sparql/series_compensators.sparql
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ select
(coalesce(max(?in_service), max(?connected_1) && max(?connected_2)) as ?status)
(max(?un) as ?un)
(max(?x) as ?x)
(max(?connectivity_node_1) as ?connectivity_node_1)
(max(?connectivity_node_2) as ?connectivity_node_2)
where {
# Assume π equivalent with at least r,x and b shunt.
# Extract properties for series compensator
Expand All @@ -30,7 +32,8 @@ where {
# Extract terminal properties
?terminal cim:Terminal.ConnectivityNode ?con_node;
cim:ACDCTerminal.sequenceNumber ?nr .
?con_node cim:ConnectivityNode.ConnectivityNodeContainer/cim:VoltageLevel.Substation ?substation .
?con_node cim:ConnectivityNode.ConnectivityNodeContainer/cim:VoltageLevel.Substation ?substation ;
cim:IdentifiedObject.mRID ?connectivity_node .
?substation cim:Substation.Region/cim:SubGeographicalRegion.Region/cim:IdentifiedObject.name ?area .
optional {
?substation SN:Substation.MarketDeliveryPoint/SN:MarketDeliveryPoint.BiddingArea/SN:BiddingArea.marketCode ?bidzone
Expand Down Expand Up @@ -69,5 +72,7 @@ where {
bind(if(?nr = 2, ?node, '') as ?node_2)
bind(if(?nr = 2, ?connected, False) as ?connected_2)
bind(if(?nr = 2, ?bidzone, '') as ?bidzone_2)
bind(if(?nr = 1, ?connectivity_node, '') as ?connectivity_node_1)
bind(if(?nr = 2, ?connectivity_node, '') as ?connectivity_node_2)
} group by ?compensator
having ((count(*) > 1) && (max(?node_1) != max(?node_2)) && coalesce(max(?analysis_enabled), True))
3 changes: 2 additions & 1 deletion cimsparql/sparql/synchronous_machines.sparql
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
PREFIX cim: <${cim}>
PREFIX SN: <${SN}>
PREFIX xsd: <${xsd}>
select distinct ?mrid ?name ?market_code ?node ?status ?station_group ?station_group_name ?substation_mrid ?maxP ?minP ?MO ?bidzone ?sn ?p ?q
select distinct ?mrid ?name ?market_code ?node ?status ?station_group ?station_group_name ?substation_mrid ?maxP ?minP ?MO ?bidzone ?sn ?p ?q ?connectivity_node
where {
# Extract properties for synchronous machines.
?machine a cim:SynchronousMachine;
Expand All @@ -13,6 +13,7 @@ where {
cim:Equipment.EquipmentContainer/cim:VoltageLevel.Substation ?substation .
?terminal cim:Terminal.ConnectivityNode ?con_node;
cim:IdentifiedObject.mRID ?t_mrid .
?con_node cim:IdentifiedObject.mRID ?connectivity_node .

# Extract area and mrid for the substation associated with a sync machine
?substation cim:Substation.Region/cim:SubGeographicalRegion.Region/cim:IdentifiedObject.name ?area;
Expand Down
5 changes: 3 additions & 2 deletions cimsparql/sparql/three_winding.sparql
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
PREFIX cim: <${cim}>
PREFIX SN: <${SN}>
PREFIX xsd: <${xsd}>
select ?node_1 ?node_2 ?status ?name ?mrid ?un ?r ?x ?b ?g ?rate (?bidzone as ?bidzone_1) (?bidzone as ?bidzone_2) ?angle ?ratio
select ?node_1 ?node_2 ?status ?name ?mrid ?un ?r ?x ?b ?g ?rate (?bidzone as ?bidzone_1) (?bidzone as ?bidzone_2) ?angle ?ratio ?connectivity_node_1 (?node_2 as ?connectivity_node_2)
where {
# Use mrid of transformer as dummy node
?p_transformer cim:IdentifiedObject.mRID ?node_2;
Expand All @@ -25,7 +25,8 @@ where {

# Extract the connectivity node for each termina, and find the nominal voltage from the connectivity node
?terminal cim:Terminal.ConnectivityNode ?con_node .
?con_node cim:ConnectivityNode.ConnectivityNodeContainer/cim:VoltageLevel.BaseVoltage/cim:BaseVoltage.nominalVoltage ?un .
?con_node cim:ConnectivityNode.ConnectivityNodeContainer/cim:VoltageLevel.BaseVoltage/cim:BaseVoltage.nominalVoltage ?un ;
cim:IdentifiedObject.mRID ?connectivity_node_1 .

# Optionally extract bidzone for substations
optional {?Substation SN:Substation.MarketDeliveryPoint/SN:MarketDeliveryPoint.BiddingArea/SN:BiddingArea.marketCode ?bidzone} .
Expand Down
3 changes: 2 additions & 1 deletion cimsparql/sparql/three_winding_dummy_nodes.sparql
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Name: Three winding with dummy nodes
PREFIX cim:<${cim}>
PREFIX SN:<${SN}>
select ?node ?busname (?container_name as ?substation) ?un (?container_mrid as ?substation_mrid) ?bidzone ?island (False as ?is_swing_bus)
select ?node ?busname (?container_name as ?substation) ?un (?container_mrid as ?substation_mrid) ?bidzone ?island (False as ?is_swing_bus) ?connectivity_node
where
{
# Select all three winding transformerss
Expand All @@ -23,6 +23,7 @@ where
cim:PowerTransformerEnd.ratedU ?un;
cim:PowerTransformerEnd.PowerTransformer ?p_transformer;
cim:TransformerEnd.Terminal/cim:Terminal.ConnectivityNode ?con_node.
?con_node cim:IdentifiedObject.mRID ?connectivity_node .
?container cim:IdentifiedObject.mRID ?container_mrid;
cim:IdentifiedObject.name ?container_name.
service <${repo}> {
Expand Down
10 changes: 6 additions & 4 deletions cimsparql/sparql/two_winding_transformer.sparql
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ PREFIX cim: <${cim}>
PREFIX SN: <${SN}>
PREFIX xsd: <${xsd}>

select ?mrid ?name ?bidzone_1 ?bidzone_2 ?node_1 ?node_2 ?ploss_1 ?ploss_2 ?r ?rate ?status (?un_1 as ?un) ?x ?b ?g ?angle ?ratio
select ?mrid ?name ?bidzone_1 ?bidzone_2 ?node_1 ?node_2 ?ploss_1 ?ploss_2 ?r ?rate ?status (?un_1 as ?un) ?x ?b ?g ?angle ?ratio ?connectivity_node_1 ?connectivity_node_2
where
{
# Collect properties for terminal_1
Expand Down Expand Up @@ -46,7 +46,8 @@ where
cim:PowerTransformerEnd.g ?g;
cim:IdentifiedObject.mRID ?mrid .
?terminal_1 cim:Terminal.ConnectivityNode ?con_node_1.
?con_node_1 cim:ConnectivityNode.ConnectivityNodeContainer/cim:VoltageLevel.BaseVoltage/cim:BaseVoltage.nominalVoltage ?un_1 .
?con_node_1 cim:ConnectivityNode.ConnectivityNodeContainer/cim:VoltageLevel.BaseVoltage/cim:BaseVoltage.nominalVoltage ?un_1;
cim:IdentifiedObject.mRID ?connectivity_node_1 .
optional {
?p_lim cim:OperationalLimit.OperationalLimitSet/cim:OperationalLimitSet.Terminal ?terminal_1;
a cim:ActivePowerLimit;
Expand All @@ -58,8 +59,9 @@ where
cim:TransformerEnd.Terminal ?terminal_2;
cim:PowerTransformerEnd.ratedU ?ubase_2 ;
cim:TransformerEnd.endNumber 2 .
?terminal_2 cim:Terminal.ConnectivityNode ?con_node_2.
?con_node_2 cim:ConnectivityNode.ConnectivityNodeContainer/cim:VoltageLevel.BaseVoltage/cim:BaseVoltage.nominalVoltage ?un_2 .
?terminal_2 cim:Terminal.ConnectivityNode ?con_node_2 .
?con_node_2 cim:ConnectivityNode.ConnectivityNodeContainer/cim:VoltageLevel.BaseVoltage/cim:BaseVoltage.nominalVoltage ?un_2 ;
cim:IdentifiedObject.mRID ?connectivity_node_2 .
optional{
?winding_2 cim:PowerTransformerEnd.phaseAngleClock ?aclock .
}
Expand Down

0 comments on commit 8d16675

Please sign in to comment.