Skip to content

Commit 0b78484

Browse files
authored
Add generation of CGMES profile class (#39)
Depends on cimgen pull request: sogno-platform/cimgen#35, which is already merged now. In my repo all workflows run successfully: tom-hg57#1 (even deploying of github-pages). Improve cimexport.py using profile URIs (from new generated CGMESProfile.py) in model description of exported cim files - Update generated python files created by cimgen - Use profile URIs (from new generated CGMESProfile.py) in model description of exported cim files - Fix "Package information not found" for EquipmentBoundary and ToplogyBoundary in cim_import() by using new generated CGMESProfile.py - Fix export for data read without profile information - Improve cim_export (activeProfileList is now optional - no activeProfileList means output to all profile files with data) - Add function cim_export_to_string_array - Fix model ID in cim_export (must be unique across all files) - Use recommended class profile from new generated classes (if data is read without profile information, or some objects are added after import) - Improve .github/workflows/test.yaml - Update documentation in cimpy/cimexport.py With the new generated python files created by cimgen the issue #23 is solved. PR #24 could be closed if this PR is merged. The same applies to issue #25 and PR #26.
2 parents 06aaeee + 4a73933 commit 0b78484

File tree

500 files changed

+28694
-27653
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

500 files changed

+28694
-27653
lines changed

.github/workflows/pre-commit.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ name: pre-commit
33
on:
44
pull_request:
55
push:
6-
branches: [main]
6+
branches:
7+
- master
78

89
jobs:
910
pre-commit:

.github/workflows/test.yaml

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,11 @@ jobs:
1414
- name: Checkout repository
1515
uses: actions/checkout@v4
1616

17-
- name: Setup python
17+
- name: Setup Python
1818
uses: actions/setup-python@v5
1919
with:
2020
python-version: 3.8
2121

22-
- name: Install Graphviz
23-
shell: bash
24-
run: |
25-
sudo apt-get -y install graphviz
26-
2722
- name: Install Python dependencies
2823
run: |
2924
pip install .[dev]
@@ -37,4 +32,4 @@ jobs:
3732
if: ${{ always() }}
3833
with:
3934
name: pytest-results
40-
path: cimpy/report.xml
35+
path: report.xml

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
__pycache__
44
.idea
55
.venv
6-
./cimpy/__pycache__
76
*.egg
87
build/
98
dist/
10-
119
*.log
10+
/.pytest_cache
11+
/report.xml
1212

1313
# VSCode
1414
.vscode/*

cimpy/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
from cimpy.cimexport import cim_export
44
from cimpy.cimimport import cim_import
5+
from cimpy.cimexport import cim_export_to_string_array
56
import cimpy.utils
67
from cimpy.cimexamples import import_example
78
from cimpy.cimexamples import export_example
Lines changed: 87 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -1,85 +1,87 @@
1-
from .ConductingEquipment import ConductingEquipment
2-
3-
4-
class ACDCConverter(ConductingEquipment):
5-
'''
6-
A unit with valves for three phases, together with unit control equipment, essential protective and switching devices, DC storage capacitors, phase reactors and auxiliaries, if any, used for conversion.
7-
8-
:baseS: Base apparent power of the converter pole. Default: 0.0
9-
:idleLoss: Active power loss in pole at no power transfer. Converter configuration data used in power flow. Default: 0.0
10-
:maxUdc: The maximum voltage on the DC side at which the converter should operate. Converter configuration data used in power flow. Default: 0.0
11-
:minUdc: Min allowed converter DC voltage. Converter configuration data used in power flow. Default: 0.0
12-
:numberOfValves: Number of valves in the converter. Used in loss calculations. Default: 0
13-
:ratedUdc: Rated converter DC voltage, also called UdN. Converter configuration data used in power flow. Default: 0.0
14-
:resistiveLoss: Converter configuration data used in power flow. Refer to poleLossP. Default: 0.0
15-
:switchingLoss: Switching losses, relative to the base apparent power `baseS`. Refer to poleLossP. Default: 0.0
16-
:valveU0: Valve threshold voltage. Forward voltage drop when the valve is conducting. Used in loss calculations, i.e. the switchLoss depend on numberOfValves * valveU0. Default: 0.0
17-
:DCTerminals: Default: "list"
18-
:PccTerminal: All converters` DC sides linked to this point of common coupling terminal. Default: None
19-
:p: Active power at the point of common coupling. Load sign convention is used, i.e. positive sign means flow out from a node. Starting value for a steady state solution in the case a simplified power flow model is used. Default: 0.0
20-
:q: Reactive power at the point of common coupling. Load sign convention is used, i.e. positive sign means flow out from a node. Starting value for a steady state solution in the case a simplified power flow model is used. Default: 0.0
21-
:targetPpcc: Real power injection target in AC grid, at point of common coupling. Default: 0.0
22-
:targetUdc: Target value for DC voltage magnitude. Default: 0.0
23-
:idc: Converter DC current, also called Id. Converter state variable, result from power flow. Default: 0.0
24-
:poleLossP: The active power loss at a DC Pole = idleLoss + switchingLoss*|Idc| + resitiveLoss*Idc^2 For lossless operation Pdc=Pac For rectifier operation with losses Pdc=Pac-lossP For inverter operation with losses Pdc=Pac+lossP Converter state variable used in power flow. Default: 0.0
25-
:uc: Converter voltage, the voltage at the AC side of the bridge. Converter state variable, result from power flow. Default: 0.0
26-
:udc: Converter voltage at the DC side, also called Ud. Converter state variable, result from power flow. Default: 0.0
27-
'''
28-
29-
cgmesProfile = ConductingEquipment.cgmesProfile
30-
31-
possibleProfileList = {'class': [cgmesProfile.EQ.value, cgmesProfile.SSH.value, cgmesProfile.SV.value, ],
32-
'baseS': [cgmesProfile.EQ.value, ],
33-
'idleLoss': [cgmesProfile.EQ.value, ],
34-
'maxUdc': [cgmesProfile.EQ.value, ],
35-
'minUdc': [cgmesProfile.EQ.value, ],
36-
'numberOfValves': [cgmesProfile.EQ.value, ],
37-
'ratedUdc': [cgmesProfile.EQ.value, ],
38-
'resistiveLoss': [cgmesProfile.EQ.value, ],
39-
'switchingLoss': [cgmesProfile.EQ.value, ],
40-
'valveU0': [cgmesProfile.EQ.value, ],
41-
'DCTerminals': [cgmesProfile.EQ.value, ],
42-
'PccTerminal': [cgmesProfile.EQ.value, ],
43-
'p': [cgmesProfile.SSH.value, ],
44-
'q': [cgmesProfile.SSH.value, ],
45-
'targetPpcc': [cgmesProfile.SSH.value, ],
46-
'targetUdc': [cgmesProfile.SSH.value, ],
47-
'idc': [cgmesProfile.SV.value, ],
48-
'poleLossP': [cgmesProfile.SV.value, ],
49-
'uc': [cgmesProfile.SV.value, ],
50-
'udc': [cgmesProfile.SV.value, ],
51-
}
52-
53-
serializationProfile = {}
54-
55-
__doc__ += '\n Documentation of parent class ConductingEquipment: \n' + ConductingEquipment.__doc__
56-
57-
def __init__(self, baseS = 0.0, idleLoss = 0.0, maxUdc = 0.0, minUdc = 0.0, numberOfValves = 0, ratedUdc = 0.0, resistiveLoss = 0.0, switchingLoss = 0.0, valveU0 = 0.0, DCTerminals = "list", PccTerminal = None, p = 0.0, q = 0.0, targetPpcc = 0.0, targetUdc = 0.0, idc = 0.0, poleLossP = 0.0, uc = 0.0, udc = 0.0, *args, **kw_args):
58-
super().__init__(*args, **kw_args)
59-
60-
self.baseS = baseS
61-
self.idleLoss = idleLoss
62-
self.maxUdc = maxUdc
63-
self.minUdc = minUdc
64-
self.numberOfValves = numberOfValves
65-
self.ratedUdc = ratedUdc
66-
self.resistiveLoss = resistiveLoss
67-
self.switchingLoss = switchingLoss
68-
self.valveU0 = valveU0
69-
self.DCTerminals = DCTerminals
70-
self.PccTerminal = PccTerminal
71-
self.p = p
72-
self.q = q
73-
self.targetPpcc = targetPpcc
74-
self.targetUdc = targetUdc
75-
self.idc = idc
76-
self.poleLossP = poleLossP
77-
self.uc = uc
78-
self.udc = udc
79-
80-
def __str__(self):
81-
str = 'class=ACDCConverter\n'
82-
attributes = self.__dict__
83-
for key in attributes.keys():
84-
str = str + key + '={}\n'.format(attributes[key])
85-
return str
1+
from .ConductingEquipment import ConductingEquipment
2+
from .CGMESProfile import Profile
3+
4+
5+
class ACDCConverter(ConductingEquipment):
6+
"""
7+
A unit with valves for three phases, together with unit control equipment, essential protective and switching devices, DC storage capacitors, phase reactors and auxiliaries, if any, used for conversion.
8+
9+
:DCTerminals: Default: "list"
10+
:PccTerminal: All converters` DC sides linked to this point of common coupling terminal. Default: None
11+
:baseS: Base apparent power of the converter pole. Default: 0.0
12+
:idc: Converter DC current, also called Id. Converter state variable, result from power flow. Default: 0.0
13+
:idleLoss: Active power loss in pole at no power transfer. Converter configuration data used in power flow. Default: 0.0
14+
:maxUdc: The maximum voltage on the DC side at which the converter should operate. Converter configuration data used in power flow. Default: 0.0
15+
:minUdc: Min allowed converter DC voltage. Converter configuration data used in power flow. Default: 0.0
16+
:numberOfValves: Number of valves in the converter. Used in loss calculations. Default: 0
17+
:p: Active power at the point of common coupling. Load sign convention is used, i.e. positive sign means flow out from a node. Starting value for a steady state solution in the case a simplified power flow model is used. Default: 0.0
18+
:poleLossP: The active power loss at a DC Pole = idleLoss + switchingLoss*|Idc| + resitiveLoss*Idc^2 For lossless operation Pdc=Pac For rectifier operation with losses Pdc=Pac-lossP For inverter operation with losses Pdc=Pac+lossP Converter state variable used in power flow. Default: 0.0
19+
:q: Reactive power at the point of common coupling. Load sign convention is used, i.e. positive sign means flow out from a node. Starting value for a steady state solution in the case a simplified power flow model is used. Default: 0.0
20+
:ratedUdc: Rated converter DC voltage, also called UdN. Converter configuration data used in power flow. Default: 0.0
21+
:resistiveLoss: Converter configuration data used in power flow. Refer to poleLossP. Default: 0.0
22+
:switchingLoss: Switching losses, relative to the base apparent power `baseS`. Refer to poleLossP. Default: 0.0
23+
:targetPpcc: Real power injection target in AC grid, at point of common coupling. Default: 0.0
24+
:targetUdc: Target value for DC voltage magnitude. Default: 0.0
25+
:uc: Converter voltage, the voltage at the AC side of the bridge. Converter state variable, result from power flow. Default: 0.0
26+
:udc: Converter voltage at the DC side, also called Ud. Converter state variable, result from power flow. Default: 0.0
27+
:valveU0: Valve threshold voltage. Forward voltage drop when the valve is conducting. Used in loss calculations, i.e. the switchLoss depend on numberOfValves * valveU0. Default: 0.0
28+
"""
29+
30+
possibleProfileList = {
31+
"class": [Profile.EQ.value, Profile.SV.value, Profile.SSH.value, ],
32+
"DCTerminals": [Profile.EQ.value, ],
33+
"PccTerminal": [Profile.EQ.value, ],
34+
"baseS": [Profile.EQ.value, ],
35+
"idc": [Profile.SV.value, ],
36+
"idleLoss": [Profile.EQ.value, ],
37+
"maxUdc": [Profile.EQ.value, ],
38+
"minUdc": [Profile.EQ.value, ],
39+
"numberOfValves": [Profile.EQ.value, ],
40+
"p": [Profile.SSH.value, ],
41+
"poleLossP": [Profile.SV.value, ],
42+
"q": [Profile.SSH.value, ],
43+
"ratedUdc": [Profile.EQ.value, ],
44+
"resistiveLoss": [Profile.EQ.value, ],
45+
"switchingLoss": [Profile.EQ.value, ],
46+
"targetPpcc": [Profile.SSH.value, ],
47+
"targetUdc": [Profile.SSH.value, ],
48+
"uc": [Profile.SV.value, ],
49+
"udc": [Profile.SV.value, ],
50+
"valveU0": [Profile.EQ.value, ],
51+
}
52+
53+
serializationProfile = {}
54+
55+
recommendedClassProfile = Profile.EQ.value
56+
57+
__doc__ += "\nDocumentation of parent class ConductingEquipment:\n" + ConductingEquipment.__doc__
58+
59+
def __init__(self, DCTerminals = "list", PccTerminal = None, baseS = 0.0, idc = 0.0, idleLoss = 0.0, maxUdc = 0.0, minUdc = 0.0, numberOfValves = 0, p = 0.0, poleLossP = 0.0, q = 0.0, ratedUdc = 0.0, resistiveLoss = 0.0, switchingLoss = 0.0, targetPpcc = 0.0, targetUdc = 0.0, uc = 0.0, udc = 0.0, valveU0 = 0.0, *args, **kw_args):
60+
super().__init__(*args, **kw_args)
61+
62+
self.DCTerminals = DCTerminals
63+
self.PccTerminal = PccTerminal
64+
self.baseS = baseS
65+
self.idc = idc
66+
self.idleLoss = idleLoss
67+
self.maxUdc = maxUdc
68+
self.minUdc = minUdc
69+
self.numberOfValves = numberOfValves
70+
self.p = p
71+
self.poleLossP = poleLossP
72+
self.q = q
73+
self.ratedUdc = ratedUdc
74+
self.resistiveLoss = resistiveLoss
75+
self.switchingLoss = switchingLoss
76+
self.targetPpcc = targetPpcc
77+
self.targetUdc = targetUdc
78+
self.uc = uc
79+
self.udc = udc
80+
self.valveU0 = valveU0
81+
82+
def __str__(self):
83+
str = "class=ACDCConverter\n"
84+
attributes = self.__dict__
85+
for key in attributes.keys():
86+
str = str + key + "={}\n".format(attributes[key])
87+
return str
Lines changed: 36 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,36 @@
1-
from .DCBaseTerminal import DCBaseTerminal
2-
3-
4-
class ACDCConverterDCTerminal(DCBaseTerminal):
5-
'''
6-
A DC electrical connection point at the AC/DC converter. The AC/DC converter is electrically connected also to the AC side. The AC connection is inherited from the AC conducting equipment in the same way as any other AC equipment. The AC/DC converter DC terminal is separate from generic DC terminal to restrict the connection with the AC side to AC/DC converter and so that no other DC conducting equipment can be connected to the AC side.
7-
8-
:DCConductingEquipment: Default: None
9-
:polarity: Represents the normal network polarity condition. Default: None
10-
'''
11-
12-
cgmesProfile = DCBaseTerminal.cgmesProfile
13-
14-
possibleProfileList = {'class': [cgmesProfile.EQ.value, cgmesProfile.SSH.value, cgmesProfile.TP.value, ],
15-
'DCConductingEquipment': [cgmesProfile.EQ.value, ],
16-
'polarity': [cgmesProfile.EQ.value, ],
17-
}
18-
19-
serializationProfile = {}
20-
21-
__doc__ += '\n Documentation of parent class DCBaseTerminal: \n' + DCBaseTerminal.__doc__
22-
23-
def __init__(self, DCConductingEquipment = None, polarity = None, *args, **kw_args):
24-
super().__init__(*args, **kw_args)
25-
26-
self.DCConductingEquipment = DCConductingEquipment
27-
self.polarity = polarity
28-
29-
def __str__(self):
30-
str = 'class=ACDCConverterDCTerminal\n'
31-
attributes = self.__dict__
32-
for key in attributes.keys():
33-
str = str + key + '={}\n'.format(attributes[key])
34-
return str
1+
from .DCBaseTerminal import DCBaseTerminal
2+
from .CGMESProfile import Profile
3+
4+
5+
class ACDCConverterDCTerminal(DCBaseTerminal):
6+
"""
7+
A DC electrical connection point at the AC/DC converter. The AC/DC converter is electrically connected also to the AC side. The AC connection is inherited from the AC conducting equipment in the same way as any other AC equipment. The AC/DC converter DC terminal is separate from generic DC terminal to restrict the connection with the AC side to AC/DC converter and so that no other DC conducting equipment can be connected to the AC side.
8+
9+
:DCConductingEquipment: Default: None
10+
:polarity: Represents the normal network polarity condition. Default: None
11+
"""
12+
13+
possibleProfileList = {
14+
"class": [Profile.EQ.value, Profile.SSH.value, Profile.TP.value, ],
15+
"DCConductingEquipment": [Profile.EQ.value, ],
16+
"polarity": [Profile.EQ.value, ],
17+
}
18+
19+
serializationProfile = {}
20+
21+
recommendedClassProfile = Profile.EQ.value
22+
23+
__doc__ += "\nDocumentation of parent class DCBaseTerminal:\n" + DCBaseTerminal.__doc__
24+
25+
def __init__(self, DCConductingEquipment = None, polarity = None, *args, **kw_args):
26+
super().__init__(*args, **kw_args)
27+
28+
self.DCConductingEquipment = DCConductingEquipment
29+
self.polarity = polarity
30+
31+
def __str__(self):
32+
str = "class=ACDCConverterDCTerminal\n"
33+
attributes = self.__dict__
34+
for key in attributes.keys():
35+
str = str + key + "={}\n".format(attributes[key])
36+
return str

0 commit comments

Comments
 (0)