-
Notifications
You must be signed in to change notification settings - Fork 1
/
sincal2PF.py
120 lines (106 loc) · 7.12 KB
/
sincal2PF.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
import importlib
pf_profiles = {'DY': ['http://entsoe.eu/CIM/Dynamics/3/1'], 'EQ': ['http://entsoe.eu/CIM/EquipmentCore/3/1',
'http://entsoe.eu/CIM/EquipmentOperation/3/1', 'http://entsoe.eu/CIM/EquipmentShortCircuit/3/1'],
'GL': ['http://entsoe.eu/CIM/GeographicalLocation/2/1'], 'SSH': ['http://entsoe.eu/CIM/SteadyStateHypothesis/1/1'],
'TP': ['http://entsoe.eu/CIM/Topology/4/1'], 'DL': ['http://entsoe.eu/CIM/DiagramLayout/3/1'],
'SV': ['http://entsoe.eu/CIM/StateVariables/4/1']} # Profiles accepted by PF
def sincal_Pf(import_result):
import_result['meta_info']['namespaces'] = adjust_namespaces(
import_result['meta_info']['namespaces'])
import_result["meta_info"]['profiles'] = adjust_profiles(
import_result["meta_info"]['profiles'], pf_profiles)
add_dependentOn(import_result)
add_missingProperties(import_result)
return import_result
def add_missingProperties(import_result, ):
for mRID, value in import_result['topology'].items():
####################################EnergySource to ExternalNetworkInjection#############################
if "EnergySource" == import_result["topology"][mRID].__class__.__name__:
mRID = mRID
EquipmentContainer = import_result["topology"][mRID].__dict__[
"EquipmentContainer"]
name = import_result["topology"][mRID].__dict__["name"]
shortName = import_result["topology"][mRID].__dict__["shortName"]
description = import_result["topology"][mRID].__dict__[
"description"]
ExternalNetworkInjection_module = importlib.import_module(
'cimpy.cgmes_v2_4_15.'+'ExternalNetworkInjection')
ExternalNetworkInjection_class = getattr(
ExternalNetworkInjection_module, 'ExternalNetworkInjection')
ExternalNetworkInjection_class.serializationProfile = {
'class': 'EQ', 'p': 'SSH', 'q': 'SSH',
'referencePriority': 'SSH', 'controlEnabled': 'SSH',
'EquipmentContainer': 'EQ', 'governorSCD': 'EQ',
'maxP': 'EQ', 'maxQ': 'EQ',
'maxR0ToX0Ratio': 'EQ', 'maxR1ToX1Ratio': 'EQ',
'maxZ0ToZ1Ratio': 'EQ', 'minInitialSymShCCurrent': 'EQ',
'minP': 'EQ', 'minQ': 'EQ', 'minR0ToX0Ratio': 'EQ',
'minR1ToX1Ratio': 'EQ', 'minZ0ToZ1Ratio': 'EQ',
'name': 'EQ', 'RegulatingControl': 'EQ'}
import_result["topology"][mRID] = ExternalNetworkInjection_class(mRID=mRID,
name=name,
EquipmentContainer=EquipmentContainer, shortName=shortName, description=description,
maxP=10.0, maxQ=20.0)
####################################Add properties to synch machines####################################
if "SynchronousMachineTimeConstantReactance" == import_result['topology'][mRID].__class__.__name__:
if "modelType" in import_result['topology'][mRID].__dict__.keys().__str__() and import_result['topology'][mRID].__dict__["modelType"] is None:
import_result['topology'][mRID].__dict__[
'modelType'] = "%URL%http://iec.ch/TC57/2013/CIM-schema-cim16#SynchronousMachineModelKind.subtransient"
if "rotorType" in import_result['topology'][mRID].__dict__.keys().__str__() and import_result['topology'][mRID].__dict__["rotorType"] is None:
import_result['topology'][mRID].__dict__[
'rotorType'] = "%URL%http://iec.ch/TC57/2013/CIM-schema-cim16#RotorKind.roundRotor"
if import_result['topology'][mRID].__dict__['inertia'] == 0:
import_result['topology'][mRID].__dict__['inertia'] = 4
# add names to properties
elif "ControlAreaGeneratingUnit" in import_result['topology'][mRID].__class__.__name__:
import_result['topology'][mRID].__dict__['name'] = "CAGU"+mRID[:5]
elif "TapChangerControl" in import_result['topology'][mRID].__class__.__name__:
import_result['topology'][mRID].__dict__['name'] = "TCC"+mRID[:5]
# filter out
elif "PowerTransformer" == import_result['topology'][mRID].__class__.__name__:
if import_result['topology'][mRID].__dict__['beforeShortCircuitAnglePf'] == 0.0:
import_result['topology'][mRID].__dict__[
'beforeShortCircuitAnglePf'] = None
if import_result['topology'][mRID].__dict__['highSideMinOperatingU'] == 0:
import_result['topology'][mRID].__dict__[
'highSideMinOperatingU'] = None
if import_result['topology'][mRID].__dict__['beforeShCircuitHighestOperatingCurrent'] == 0.0:
import_result['topology'][mRID].__dict__[
'beforeShCircuitHighestOperatingCurrent'] = None
if import_result['topology'][mRID].__dict__['beforeShCircuitHighestOperatingVoltage'] == 0:
import_result['topology'][mRID].__dict__[
'beforeShCircuitHighestOperatingVoltage'] = None
def op_limittType_mRID(import_result): # get the mRID for "OperationalLimitType"
ls = []
for mRID, value in import_result['topology'].items():
if value.__class__.__name__ == "OperationalLimitType":
ls.append(value.__dict__["mRID"])
return ls
def adjust_profiles(profiles, pf_profile): # adding PF accepted namespaces
newprofile = {}
for profile in profiles.keys():
for pfprofile in pf_profile.keys():
if profile == pfprofile:
newprofile[pfprofile] = pf_profile[pfprofile]
return newprofile
def adjust_namespaces(namespaces_dict): # Adjust namespace to PF
namespaces = {}
namespaces_PF = ["rdf", "entsoe", "cim", "md"]
for key, value in namespaces_dict.items():
if key in namespaces_PF:
namespaces[key] = value
return namespaces
def add_dependentOn(import_result): # TO DO
profiledepON = {"TP": ["EQ"], "SV": ["TP", "SSH"], "SSH": ["EQ"], "DY": [
"EQ"], "DL": ["EQ", "TP"], "GL": ["TP", "EQ"]} # which profile depends on which
if "DependentOn" not in import_result['meta_info']['profile_about'].keys():
import_result['meta_info']['profile_about']["DependentOn"] = {}
for key, value in profiledepON.items():
if key not in import_result['meta_info']['profile_about']['DependentOn'] and key in import_result['meta_info']['profile_about'].keys():
import_result['meta_info']['profile_about']['DependentOn'][key] = {}
import_result['meta_info']['profile_about']['DependentOn'][key]["resource"] = [
]
for v in value:
if v in import_result['meta_info']['profile_about'].keys():
import_result['meta_info']['profile_about']['DependentOn'][key]["resource"].append(
import_result["meta_info"]["profile_about"][v])