Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Converter capacity #326

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 0 additions & 17 deletions .flake8

This file was deleted.

2 changes: 2 additions & 0 deletions src/cimsparql/data_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
import datetime as dt
from typing import Self

import pandera as pa

Check failure on line 6 in src/cimsparql/data_models.py

View workflow job for this annotation

GitHub Actions / ubuntu-latest / 3.11

Import "pandera" could not be resolved (reportMissingImports)

Check failure on line 6 in src/cimsparql/data_models.py

View workflow job for this annotation

GitHub Actions / ubuntu-latest / 3.11

Import "pandera" could not be resolved (reportMissingImports)

Check failure on line 6 in src/cimsparql/data_models.py

View workflow job for this annotation

GitHub Actions / ubuntu-latest / 3.12

Import "pandera" could not be resolved (reportMissingImports)

Check failure on line 6 in src/cimsparql/data_models.py

View workflow job for this annotation

GitHub Actions / ubuntu-latest / 3.12

Import "pandera" could not be resolved (reportMissingImports)
from pandera.api.pandas.model_config import BaseConfig

Check failure on line 7 in src/cimsparql/data_models.py

View workflow job for this annotation

GitHub Actions / ubuntu-latest / 3.11

Import "pandera.api.pandas.model_config" could not be resolved (reportMissingImports)

Check failure on line 7 in src/cimsparql/data_models.py

View workflow job for this annotation

GitHub Actions / ubuntu-latest / 3.11

Import "pandera.api.pandas.model_config" could not be resolved (reportMissingImports)

Check failure on line 7 in src/cimsparql/data_models.py

View workflow job for this annotation

GitHub Actions / ubuntu-latest / 3.12

Import "pandera.api.pandas.model_config" could not be resolved (reportMissingImports)

Check failure on line 7 in src/cimsparql/data_models.py

View workflow job for this annotation

GitHub Actions / ubuntu-latest / 3.12

Import "pandera.api.pandas.model_config" could not be resolved (reportMissingImports)
from pandera.typing import DataFrame, Index, Series

Check failure on line 8 in src/cimsparql/data_models.py

View workflow job for this annotation

GitHub Actions / ubuntu-latest / 3.11

Import "pandera.typing" could not be resolved (reportMissingImports)

Check failure on line 8 in src/cimsparql/data_models.py

View workflow job for this annotation

GitHub Actions / ubuntu-latest / 3.11

Import "pandera.typing" could not be resolved (reportMissingImports)

Check failure on line 8 in src/cimsparql/data_models.py

View workflow job for this annotation

GitHub Actions / ubuntu-latest / 3.12

Import "pandera.typing" could not be resolved (reportMissingImports)

Check failure on line 8 in src/cimsparql/data_models.py

View workflow job for this annotation

GitHub Actions / ubuntu-latest / 3.12

Import "pandera.typing" could not be resolved (reportMissingImports)


class CoercingSchema(pa.DataFrameModel):
Expand Down Expand Up @@ -163,6 +163,7 @@
class ConvertersSchema(NamedResourceSchema):
alias: Series[str] = pa.Field(nullable=True)
substation_mrid: Series[str] = pa.Field()
pole: Series[str] = pa.Field()
status: Series[bool] = pa.Field()
node: Series[str] = pa.Field()
p: Series[float] = pa.Field()
Expand All @@ -176,6 +177,7 @@
loss2: Series[float] = pa.Field()
vdcn: Series[float] = pa.Field()
un: Series[float] = pa.Field()
capacity: Series[float] = pa.Field()


ConvertersDataFrame = DataFrame[ConvertersSchema]
Expand Down
34 changes: 21 additions & 13 deletions src/cimsparql/sparql/converters.sparql
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,34 @@ PREFIX cim:<${cim}>
PREFIX xsd:<${xsd}>
PREFIX SN:<${SN}>
PREFIX ALG:<${ALG}>
select ?mrid ?name ?alias ?p ?q ?substation_mrid ?status ?node ?connectivity_node ?controller ?controller_factor ?pole_loss ?loss0 ?loss1 ?loss2 ?vdcn ?un
select ?mrid ?name ?alias ?p ?q ?substation_mrid (?pole_mrid as ?pole) ?status ?node ?connectivity_node ?controller ?controller_factor ?pole_loss ?loss0 ?loss1 ?loss2 ?vdcn ?un ?capacity
where {
{
select * where {
?_eq_subject <http://entsoe.eu/CIM/EquipmentCore/3/1> ?eq_repo .
service ?eq_repo {
# Extract mrid, name, substation and optionally aliasName of the converter
# Extract converter data
?converter cim:IdentifiedObject.mRID ?mrid;
cim:IdentifiedObject.name ?name;
ALG:VoltageSourceConverter.DCPole|ALG:DCConverter.DCPole ?pole.
cim:IdentifiedObject.name ?name;
ALG:VoltageSourceConverter.DCPole|ALG:DCConverter.DCPole ?_pole;
ALG:VoltageSourceConverter.DCPole/cim:IdentifiedObject.mRID|ALG:DCConverter.DCPole/cim:IdentifiedObject.mRID ?pole_mrid;
ALG:VoltageSourceConverter.bridgeNominalVoltage|ALG:DCConverter.bridgeNominalVoltage ?ur;
ALG:VoltageSourceConverter.ratedIAC|ALG:DCConverter.currentRating ?ir.

?pole ALG:DCPole.DCController/cim:IdentifiedObject.mRID ?controller.
?_pole ALG:DCPole.DCController/cim:IdentifiedObject.mRID ?controller.
{
select ?pole (max(xsd:float(str(?controller_factor))) / count(*) as ?controller_factor)
select ?_pole (max(xsd:float(str(?controller_factor))) / count(*) as ?controller_factor)
{
?converter ALG:VoltageSourceConverter.DCPole|ALG:DCConverter.DCPole ?pole.
?pole ALG:DCPole.participationFactor ?controller_factor.
} group by ?pole
?converter ALG:VoltageSourceConverter.DCPole|ALG:DCConverter.DCPole ?_pole.
?_pole ALG:DCPole.participationFactor ?controller_factor.
} group by ?_pole
}

optional {?converter cim:IdentifiedObject.aliasName ?alias .}
optional{
?converter cim:IdentifiedObject.aliasName ?alias ;
ALG:VoltageSourceConverter.bridges ?bridges
}

# Extract properties for the terminals for the converter
?terminal cim:Terminal.ConductingEquipment ?converter;
cim:Terminal.ConnectivityNode ?con_node;
Expand All @@ -39,14 +46,15 @@ where {
?converter ALG:VoltageSourceConverter.loss0 ?_loss0;
ALG:VoltageSourceConverter.loss1 ?_loss1;
ALG:VoltageSourceConverter.loss2 ?_loss2.
?pole cim:ConductingEquipment.BaseVoltage/cim:BaseVoltage.nominalVoltage ?_vdcn;
?_pole cim:ConductingEquipment.BaseVoltage/cim:BaseVoltage.nominalVoltage ?_vdcn;
}
bind(coalesce(?_analysis_enabled, True) as ?analysis_enabled)
bind(coalesce(?_analysis_enabled, True) as ?analysis_enabled)
bind(coalesce(?_loss0, 0.0) as ?loss0)
bind(coalesce(?_loss1, 0.0) as ?loss1)
bind(coalesce(?_loss2, 0.0) as ?loss2)
bind(coalesce(?_vdcn, 0.0) as ?vdcn)
filter(?analysis_enabled)
bind((xsd:float(?ir) * xsd:float(?ur) * xsd:float(coalesce(?bridges, 1))/1000) as ?capacity)
filter(?analysis_enabled)
}
}
}
Expand Down
Loading