-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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.
- Loading branch information
Showing
500 changed files
with
28,694 additions
and
27,653 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,8 @@ name: pre-commit | |
on: | ||
pull_request: | ||
push: | ||
branches: [main] | ||
branches: | ||
- master | ||
|
||
jobs: | ||
pre-commit: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,85 +1,87 @@ | ||
from .ConductingEquipment import ConductingEquipment | ||
|
||
|
||
class ACDCConverter(ConductingEquipment): | ||
''' | ||
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. | ||
:baseS: Base apparent power of the converter pole. Default: 0.0 | ||
:idleLoss: Active power loss in pole at no power transfer. Converter configuration data used in power flow. Default: 0.0 | ||
:maxUdc: The maximum voltage on the DC side at which the converter should operate. Converter configuration data used in power flow. Default: 0.0 | ||
:minUdc: Min allowed converter DC voltage. Converter configuration data used in power flow. Default: 0.0 | ||
:numberOfValves: Number of valves in the converter. Used in loss calculations. Default: 0 | ||
:ratedUdc: Rated converter DC voltage, also called UdN. Converter configuration data used in power flow. Default: 0.0 | ||
:resistiveLoss: Converter configuration data used in power flow. Refer to poleLossP. Default: 0.0 | ||
:switchingLoss: Switching losses, relative to the base apparent power `baseS`. Refer to poleLossP. Default: 0.0 | ||
: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 | ||
:DCTerminals: Default: "list" | ||
:PccTerminal: All converters` DC sides linked to this point of common coupling terminal. Default: None | ||
: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 | ||
: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 | ||
:targetPpcc: Real power injection target in AC grid, at point of common coupling. Default: 0.0 | ||
:targetUdc: Target value for DC voltage magnitude. Default: 0.0 | ||
:idc: Converter DC current, also called Id. Converter state variable, result from power flow. Default: 0.0 | ||
: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 | ||
:uc: Converter voltage, the voltage at the AC side of the bridge. Converter state variable, result from power flow. Default: 0.0 | ||
:udc: Converter voltage at the DC side, also called Ud. Converter state variable, result from power flow. Default: 0.0 | ||
''' | ||
|
||
cgmesProfile = ConductingEquipment.cgmesProfile | ||
|
||
possibleProfileList = {'class': [cgmesProfile.EQ.value, cgmesProfile.SSH.value, cgmesProfile.SV.value, ], | ||
'baseS': [cgmesProfile.EQ.value, ], | ||
'idleLoss': [cgmesProfile.EQ.value, ], | ||
'maxUdc': [cgmesProfile.EQ.value, ], | ||
'minUdc': [cgmesProfile.EQ.value, ], | ||
'numberOfValves': [cgmesProfile.EQ.value, ], | ||
'ratedUdc': [cgmesProfile.EQ.value, ], | ||
'resistiveLoss': [cgmesProfile.EQ.value, ], | ||
'switchingLoss': [cgmesProfile.EQ.value, ], | ||
'valveU0': [cgmesProfile.EQ.value, ], | ||
'DCTerminals': [cgmesProfile.EQ.value, ], | ||
'PccTerminal': [cgmesProfile.EQ.value, ], | ||
'p': [cgmesProfile.SSH.value, ], | ||
'q': [cgmesProfile.SSH.value, ], | ||
'targetPpcc': [cgmesProfile.SSH.value, ], | ||
'targetUdc': [cgmesProfile.SSH.value, ], | ||
'idc': [cgmesProfile.SV.value, ], | ||
'poleLossP': [cgmesProfile.SV.value, ], | ||
'uc': [cgmesProfile.SV.value, ], | ||
'udc': [cgmesProfile.SV.value, ], | ||
} | ||
|
||
serializationProfile = {} | ||
|
||
__doc__ += '\n Documentation of parent class ConductingEquipment: \n' + ConductingEquipment.__doc__ | ||
|
||
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): | ||
super().__init__(*args, **kw_args) | ||
|
||
self.baseS = baseS | ||
self.idleLoss = idleLoss | ||
self.maxUdc = maxUdc | ||
self.minUdc = minUdc | ||
self.numberOfValves = numberOfValves | ||
self.ratedUdc = ratedUdc | ||
self.resistiveLoss = resistiveLoss | ||
self.switchingLoss = switchingLoss | ||
self.valveU0 = valveU0 | ||
self.DCTerminals = DCTerminals | ||
self.PccTerminal = PccTerminal | ||
self.p = p | ||
self.q = q | ||
self.targetPpcc = targetPpcc | ||
self.targetUdc = targetUdc | ||
self.idc = idc | ||
self.poleLossP = poleLossP | ||
self.uc = uc | ||
self.udc = udc | ||
|
||
def __str__(self): | ||
str = 'class=ACDCConverter\n' | ||
attributes = self.__dict__ | ||
for key in attributes.keys(): | ||
str = str + key + '={}\n'.format(attributes[key]) | ||
return str | ||
from .ConductingEquipment import ConductingEquipment | ||
from .CGMESProfile import Profile | ||
|
||
|
||
class ACDCConverter(ConductingEquipment): | ||
""" | ||
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. | ||
:DCTerminals: Default: "list" | ||
:PccTerminal: All converters` DC sides linked to this point of common coupling terminal. Default: None | ||
:baseS: Base apparent power of the converter pole. Default: 0.0 | ||
:idc: Converter DC current, also called Id. Converter state variable, result from power flow. Default: 0.0 | ||
:idleLoss: Active power loss in pole at no power transfer. Converter configuration data used in power flow. Default: 0.0 | ||
:maxUdc: The maximum voltage on the DC side at which the converter should operate. Converter configuration data used in power flow. Default: 0.0 | ||
:minUdc: Min allowed converter DC voltage. Converter configuration data used in power flow. Default: 0.0 | ||
:numberOfValves: Number of valves in the converter. Used in loss calculations. Default: 0 | ||
: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 | ||
: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 | ||
: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 | ||
:ratedUdc: Rated converter DC voltage, also called UdN. Converter configuration data used in power flow. Default: 0.0 | ||
:resistiveLoss: Converter configuration data used in power flow. Refer to poleLossP. Default: 0.0 | ||
:switchingLoss: Switching losses, relative to the base apparent power `baseS`. Refer to poleLossP. Default: 0.0 | ||
:targetPpcc: Real power injection target in AC grid, at point of common coupling. Default: 0.0 | ||
:targetUdc: Target value for DC voltage magnitude. Default: 0.0 | ||
:uc: Converter voltage, the voltage at the AC side of the bridge. Converter state variable, result from power flow. Default: 0.0 | ||
:udc: Converter voltage at the DC side, also called Ud. Converter state variable, result from power flow. Default: 0.0 | ||
: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 | ||
""" | ||
|
||
possibleProfileList = { | ||
"class": [Profile.EQ.value, Profile.SV.value, Profile.SSH.value, ], | ||
"DCTerminals": [Profile.EQ.value, ], | ||
"PccTerminal": [Profile.EQ.value, ], | ||
"baseS": [Profile.EQ.value, ], | ||
"idc": [Profile.SV.value, ], | ||
"idleLoss": [Profile.EQ.value, ], | ||
"maxUdc": [Profile.EQ.value, ], | ||
"minUdc": [Profile.EQ.value, ], | ||
"numberOfValves": [Profile.EQ.value, ], | ||
"p": [Profile.SSH.value, ], | ||
"poleLossP": [Profile.SV.value, ], | ||
"q": [Profile.SSH.value, ], | ||
"ratedUdc": [Profile.EQ.value, ], | ||
"resistiveLoss": [Profile.EQ.value, ], | ||
"switchingLoss": [Profile.EQ.value, ], | ||
"targetPpcc": [Profile.SSH.value, ], | ||
"targetUdc": [Profile.SSH.value, ], | ||
"uc": [Profile.SV.value, ], | ||
"udc": [Profile.SV.value, ], | ||
"valveU0": [Profile.EQ.value, ], | ||
} | ||
|
||
serializationProfile = {} | ||
|
||
recommendedClassProfile = Profile.EQ.value | ||
|
||
__doc__ += "\nDocumentation of parent class ConductingEquipment:\n" + ConductingEquipment.__doc__ | ||
|
||
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): | ||
super().__init__(*args, **kw_args) | ||
|
||
self.DCTerminals = DCTerminals | ||
self.PccTerminal = PccTerminal | ||
self.baseS = baseS | ||
self.idc = idc | ||
self.idleLoss = idleLoss | ||
self.maxUdc = maxUdc | ||
self.minUdc = minUdc | ||
self.numberOfValves = numberOfValves | ||
self.p = p | ||
self.poleLossP = poleLossP | ||
self.q = q | ||
self.ratedUdc = ratedUdc | ||
self.resistiveLoss = resistiveLoss | ||
self.switchingLoss = switchingLoss | ||
self.targetPpcc = targetPpcc | ||
self.targetUdc = targetUdc | ||
self.uc = uc | ||
self.udc = udc | ||
self.valveU0 = valveU0 | ||
|
||
def __str__(self): | ||
str = "class=ACDCConverter\n" | ||
attributes = self.__dict__ | ||
for key in attributes.keys(): | ||
str = str + key + "={}\n".format(attributes[key]) | ||
return str |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,36 @@ | ||
from .DCBaseTerminal import DCBaseTerminal | ||
|
||
|
||
class ACDCConverterDCTerminal(DCBaseTerminal): | ||
''' | ||
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. | ||
:DCConductingEquipment: Default: None | ||
:polarity: Represents the normal network polarity condition. Default: None | ||
''' | ||
|
||
cgmesProfile = DCBaseTerminal.cgmesProfile | ||
|
||
possibleProfileList = {'class': [cgmesProfile.EQ.value, cgmesProfile.SSH.value, cgmesProfile.TP.value, ], | ||
'DCConductingEquipment': [cgmesProfile.EQ.value, ], | ||
'polarity': [cgmesProfile.EQ.value, ], | ||
} | ||
|
||
serializationProfile = {} | ||
|
||
__doc__ += '\n Documentation of parent class DCBaseTerminal: \n' + DCBaseTerminal.__doc__ | ||
|
||
def __init__(self, DCConductingEquipment = None, polarity = None, *args, **kw_args): | ||
super().__init__(*args, **kw_args) | ||
|
||
self.DCConductingEquipment = DCConductingEquipment | ||
self.polarity = polarity | ||
|
||
def __str__(self): | ||
str = 'class=ACDCConverterDCTerminal\n' | ||
attributes = self.__dict__ | ||
for key in attributes.keys(): | ||
str = str + key + '={}\n'.format(attributes[key]) | ||
return str | ||
from .DCBaseTerminal import DCBaseTerminal | ||
from .CGMESProfile import Profile | ||
|
||
|
||
class ACDCConverterDCTerminal(DCBaseTerminal): | ||
""" | ||
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. | ||
:DCConductingEquipment: Default: None | ||
:polarity: Represents the normal network polarity condition. Default: None | ||
""" | ||
|
||
possibleProfileList = { | ||
"class": [Profile.EQ.value, Profile.SSH.value, Profile.TP.value, ], | ||
"DCConductingEquipment": [Profile.EQ.value, ], | ||
"polarity": [Profile.EQ.value, ], | ||
} | ||
|
||
serializationProfile = {} | ||
|
||
recommendedClassProfile = Profile.EQ.value | ||
|
||
__doc__ += "\nDocumentation of parent class DCBaseTerminal:\n" + DCBaseTerminal.__doc__ | ||
|
||
def __init__(self, DCConductingEquipment = None, polarity = None, *args, **kw_args): | ||
super().__init__(*args, **kw_args) | ||
|
||
self.DCConductingEquipment = DCConductingEquipment | ||
self.polarity = polarity | ||
|
||
def __str__(self): | ||
str = "class=ACDCConverterDCTerminal\n" | ||
attributes = self.__dict__ | ||
for key in attributes.keys(): | ||
str = str + key + "={}\n".format(attributes[key]) | ||
return str |
Oops, something went wrong.