Skip to content

Commit

Permalink
Replace container name with substation name
Browse files Browse the repository at this point in the history
  • Loading branch information
leifwar committed Oct 2, 2023
1 parent 3e33520 commit 12b111d
Show file tree
Hide file tree
Showing 5 changed files with 234 additions and 118 deletions.
4 changes: 2 additions & 2 deletions cimsparql/data_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@ class MarketDatesSchema(NamedResourceSchema):

class BusDataSchema(JsonSchemaOut):
node: Index[str] = pa.Field(unique=True)
name: Series[str] = pa.Field()
busname: Series[str] = pa.Field()
substation: Series[str] = pa.Field()
un: Series[float] = pa.Field()
station: Series[str] = pa.Field()
substation_mrid: Series[str] = pa.Field()
bidzone: Series[str] = pa.Field(nullable=True)
sv_voltage: Series[float] = pa.Field(nullable=True)
island: Series[str] = pa.Field()
Expand Down
20 changes: 10 additions & 10 deletions cimsparql/sparql/bus.sparql
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# Name: Bus
PREFIX cim:<${cim}>
PREFIX SN:<${SN}>
select ?node ?name ?busname ?un ?station ?bidzone ?sv_voltage ?island ?is_swing_bus
select (?mrid as ?node) ?busname (?substation_name as ?substation) ?un ?substation_mrid ?bidzone ?sv_voltage ?island ?is_swing_bus
where {
# Extract propertoes from the TP/SV/SSH profile for each topological node
service <${repo}> {
?top_node cim:TopologicalNode.BaseVoltage ?base_voltage;
cim:TopologicalNode.ConnectivityNodeContainer ?container;
cim:IdentifiedObject.mRID ?node;
cim:IdentifiedObject.name ?busname;
^cim:SvVoltage.TopologicalNode/cim:SvVoltage.v ?sv_voltage .
cim:TopologicalNode.ConnectivityNodeContainer ?container;
cim:IdentifiedObject.mRID ?mrid;
cim:IdentifiedObject.name ?busname;
^cim:SvVoltage.TopologicalNode/cim:SvVoltage.v ?sv_voltage .
optional{?top_node ^cim:TopologicalIsland.TopologicalNodes/cim:IdentifiedObject.name ?island_name .}
optional{?top_node ^cim:TopologicalIsland.AngleRefTopoligicalNode ?angle_ref .}
bind(if(bound(?angle_ref), True, False) as ?is_swing_bus)
Expand All @@ -20,14 +20,14 @@ where {
?base_voltage cim:BaseVoltage.nominalVoltage ?un .

# Extract properties from the connectivity node container associated with each topoligical node
?container cim:IdentifiedObject.name ?name;
cim:VoltageLevel.Substation ?substation .
?container cim:VoltageLevel.Substation ?_substation .

# Extract information about the substation associated with the connectivity node container
?substation cim:IdentifiedObject.mRID ?station;
cim:Substation.Region/cim:SubGeographicalRegion.Region/cim:IdentifiedObject.name ?area .
?_substation cim:IdentifiedObject.mRID ?substation_mrid;
cim:IdentifiedObject.name ?substation_name;
cim:Substation.Region/cim:SubGeographicalRegion.Region/cim:IdentifiedObject.name ?area .

# Extract the bidzone of each substation if it exists
optional {?substation SN:Substation.MarketDeliveryPoint/SN:MarketDeliveryPoint.BiddingArea/SN:BiddingArea.marketCode ?bidzone} .
optional {?_substation SN:Substation.MarketDeliveryPoint/SN:MarketDeliveryPoint.BiddingArea/SN:BiddingArea.marketCode ?bidzone} .
FILTER regex(?area, '${region}')
}
21 changes: 11 additions & 10 deletions cimsparql/sparql/three_winding_dummy_nodes.sparql
Original file line number Diff line number Diff line change
@@ -1,37 +1,38 @@
# Name: Three winding with dummy nodes
PREFIX cim:<${cim}>
PREFIX SN:<${SN}>
select ?node ?name (?name as ?busname) ?un ?station ?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)
where
{
# Select all three winding transformerss
{
select ?p_transformer
where {
?p_transformer a cim:PowerTransformer;
cim:Equipment.EquipmentContainer/cim:Substation.Region/cim:SubGeographicalRegion.Region/cim:IdentifiedObject.name ?area;
^cim:PowerTransformerEnd.PowerTransformer/cim:TransformerEnd.endNumber ?nr.
cim:Equipment.EquipmentContainer/cim:Substation.Region/cim:SubGeographicalRegion.Region/cim:IdentifiedObject.name ?area;
^cim:PowerTransformerEnd.PowerTransformer/cim:TransformerEnd.endNumber ?nr.
filter(regex(?area, '${region}'))
}
group by ?p_transformer
having (count(*) > 2)
} .
?p_transformer cim:IdentifiedObject.mRID ?node;
cim:IdentifiedObject.name ?name;
cim:Equipment.EquipmentContainer ?substation .
cim:IdentifiedObject.name ?busname;
cim:Equipment.EquipmentContainer ?container.
?winding cim:TransformerEnd.endNumber 1;
cim:PowerTransformerEnd.ratedU ?un;
cim:PowerTransformerEnd.PowerTransformer ?p_transformer ;
cim:TransformerEnd.Terminal/cim:Terminal.ConnectivityNode ?con_node .
?substation cim:IdentifiedObject.mRID ?station .
cim:PowerTransformerEnd.ratedU ?un;
cim:PowerTransformerEnd.PowerTransformer ?p_transformer;
cim:TransformerEnd.Terminal/cim:Terminal.ConnectivityNode ?con_node.
?container cim:IdentifiedObject.mRID ?container_mrid;
cim:IdentifiedObject.name ?container_name.
service <${repo}> {
optional{
?con_node cim:ConnectivityNode.TopologicalNode ?top_node .
?top_node ^cim:TopologicalIsland.TopologicalNodes/cim:IdentifiedObject.name ?island_name
}.
bind(coalesce(?island_name, "Unknown") as ?island)
}
optional {?substation SN:Substation.MarketDeliveryPoint/SN:MarketDeliveryPoint.BiddingArea/SN:BiddingArea.marketCode ?bidzone}
optional {?container SN:Substation.MarketDeliveryPoint/SN:MarketDeliveryPoint.BiddingArea/SN:BiddingArea.marketCode ?bidzone}
optional {?p_transformer SN:Equipment.networkAnalysisEnable ?_network_analysis}
filter(?network_analysis)
bind(coalesce(?_network_analysis, True) as ?network_analysis)
Expand Down
Loading

0 comments on commit 12b111d

Please sign in to comment.