@enervance/insight-cim-model 0.0.282 → 0.0.284

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (134) hide show
  1. package/dist/analysis/analysis-neplan/digi-ons.d.ts +2 -2
  2. package/dist/analysis/analysis-neplan/digi-ons.js +2 -2
  3. package/dist/analysis/powerflow/powerflow.util.d.ts +1 -15
  4. package/dist/analysis/powerflow/powerflow.util.js +420 -310
  5. package/dist/analysis/powerflow/powerflow.util.js.map +1 -1
  6. package/dist/constants/cim-class-names.d.ts +2 -1
  7. package/dist/constants/cim-class-names.js +2 -1
  8. package/dist/constants/cim-class-names.js.map +1 -1
  9. package/dist/constants/cim-constants.d.ts +1 -0
  10. package/dist/constants/cim-constants.js +1 -0
  11. package/dist/constants/cim-constants.js.map +1 -1
  12. package/dist/converter/integral7/converter.integral7.d.ts +6 -0
  13. package/dist/converter/integral7/converter.integral7.js +48 -7
  14. package/dist/converter/integral7/converter.integral7.js.map +1 -1
  15. package/dist/converter/integral7/interface-i7/export-frame-i7.js +0 -3
  16. package/dist/converter/integral7/interface-i7/export-frame-i7.js.map +1 -1
  17. package/dist/converter/integral7/model/interfaces.d.ts +19 -0
  18. package/dist/converter/integral7/model/interfaces.js.map +1 -1
  19. package/dist/converter/integral7/sql/integral.sql.js +7 -1
  20. package/dist/converter/integral7/sql/integral.sql.js.map +1 -1
  21. package/dist/data-structures/graph/graph-util.d.ts +1 -1
  22. package/dist/etl/etl-integral7/etl-integral7.d.ts +7 -0
  23. package/dist/etl/etl-integral7/etl-integral7.js +75 -0
  24. package/dist/etl/etl-integral7/etl-integral7.js.map +1 -1
  25. package/dist/etl/etl-integral7/interfaces.d.ts +10 -0
  26. package/dist/etl/etl-integral7/interfaces.js +3 -0
  27. package/dist/etl/etl-integral7/interfaces.js.map +1 -0
  28. package/dist/etl/etl-neplan/etl-neplan-contingency-analysis.js +3 -3
  29. package/dist/etl/etl-neplan/etl-neplan-csv.js +4 -4
  30. package/dist/etl/etl-neplan/etl-neplan-feederline.js +2 -2
  31. package/dist/etl/etl-neplan/etl-neplan-geo.js +1 -1
  32. package/dist/etl/etl-neplan/etl-neplan-util.d.ts +1 -1
  33. package/dist/etl/etl-neplan/etl-neplan-util.js +1 -1
  34. package/dist/etl/etl-neplan/etl-neplan.d.ts +1 -1
  35. package/dist/etl/etl-neplan/etl-neplan.js +1 -1
  36. package/dist/etl/etl-neplan/neplan-contingency-analysis.d.ts +1 -1
  37. package/dist/etl/etl-neplan/neplan-contingency-analysis.js +3 -3
  38. package/dist/index.d.ts +17 -14
  39. package/dist/index.js +26 -20
  40. package/dist/index.js.map +1 -1
  41. package/dist/model/assets/AnalyticScore.d.ts +1 -1
  42. package/dist/model/assets/AnalyticScore.js +2 -2
  43. package/dist/model/assets/AnalyticScore.js.map +1 -1
  44. package/dist/model/assets/Asset.d.ts +2 -0
  45. package/dist/model/assets/Asset.js +5 -2
  46. package/dist/model/assets/Asset.js.map +1 -1
  47. package/dist/model/assets/Facility.js +3 -1
  48. package/dist/model/assets/Facility.js.map +1 -1
  49. package/dist/model/core/IdentifiedObject.js +1 -2
  50. package/dist/model/core/IdentifiedObject.js.map +1 -1
  51. package/dist/model/extensions/amprion/assets/AMPRIONFacility.js +3 -2
  52. package/dist/model/extensions/amprion/assets/AMPRIONFacility.js.map +1 -1
  53. package/dist/model/extensions/amprion/core/{AMPRIONSubstation.d.ts → INTEGRALSubstation.d.ts} +1 -1
  54. package/dist/model/extensions/amprion/core/{AMPRIONSubstation.js → INTEGRALSubstation.js} +11 -13
  55. package/dist/model/extensions/amprion/core/INTEGRALSubstation.js.map +1 -0
  56. package/dist/model/extensions/enervance/assets/EVWireObject.d.ts +2 -2
  57. package/dist/model/extensions/enervance/assets/EVWireObject.js +3 -3
  58. package/dist/model/extensions/integral/equivalents/INTEGRALEquivalentInjection.js +2 -1
  59. package/dist/model/extensions/integral/equivalents/INTEGRALEquivalentInjection.js.map +1 -1
  60. package/dist/model/extensions/westnetz-integral/assets/EconimicScoreKind.d.ts +3 -0
  61. package/dist/model/extensions/westnetz-integral/assets/EconimicScoreKind.js +8 -0
  62. package/dist/model/extensions/westnetz-integral/assets/EconimicScoreKind.js.map +1 -0
  63. package/dist/model/extensions/westnetz-integral/assets/WIEconomicScore.d.ts +12 -0
  64. package/dist/model/extensions/westnetz-integral/assets/WIEconomicScore.js +55 -0
  65. package/dist/model/extensions/westnetz-integral/assets/WIEconomicScore.js.map +1 -0
  66. package/dist/model/extensions/{neplan-westnetz → westnetz-neplan}/assets/WNFacility.js.map +1 -1
  67. package/dist/model/extensions/{neplan-westnetz → westnetz-neplan}/assets/WNFacilityKind.js.map +1 -1
  68. package/dist/model/extensions/{neplan-westnetz → westnetz-neplan}/assets/WNWireInfo.js.map +1 -1
  69. package/dist/model/extensions/{neplan-westnetz → westnetz-neplan}/assets/WNZUWOHealthScore.js.map +1 -1
  70. package/dist/model/extensions/{neplan-westnetz → westnetz-neplan}/assets/WNZUWOImportanceScore.js.map +1 -1
  71. package/dist/model/extensions/{neplan-westnetz → westnetz-neplan}/assets/WNZUWOPriority.js.map +1 -1
  72. package/dist/model/extensions/{neplan-westnetz → westnetz-neplan}/assets/WNZUWOState.js.map +1 -1
  73. package/dist/model/extensions/{neplan-westnetz → westnetz-neplan}/common/WNLocation.js.map +1 -1
  74. package/dist/model/extensions/{neplan-westnetz → westnetz-neplan}/core/WNBay.js.map +1 -1
  75. package/dist/model/extensions/{neplan-westnetz → westnetz-neplan}/core/WNConnectivityNode.js.map +1 -1
  76. package/dist/model/extensions/{neplan-westnetz → westnetz-neplan}/core/WNFeeder.js.map +1 -1
  77. package/dist/model/extensions/{neplan-westnetz → westnetz-neplan}/core/WNSwitchTypeKind.js.map +1 -1
  78. package/dist/model/extensions/{neplan-westnetz → westnetz-neplan}/faults/WNFaultConnectivityNode.js.map +1 -1
  79. package/dist/model/extensions/{neplan-westnetz → westnetz-neplan}/operations/WNOutage.js.map +1 -1
  80. package/dist/model/extensions/{neplan-westnetz → westnetz-neplan}/wires/WNACLineSegment.js.map +1 -1
  81. package/dist/model/extensions/{neplan-westnetz → westnetz-neplan}/wires/WNEnergyConsumer.js.map +1 -1
  82. package/dist/model/statevariables/SvPowerFlow.d.ts +1 -0
  83. package/dist/model/statevariables/SvPowerFlow.js +3 -0
  84. package/dist/model/statevariables/SvPowerFlow.js.map +1 -1
  85. package/dist/model/wires/ExternalNetworkInjection.js +4 -0
  86. package/dist/model/wires/ExternalNetworkInjection.js.map +1 -1
  87. package/dist/model/wires/PowerTransformer.d.ts +2 -0
  88. package/dist/model/wires/PowerTransformer.js +3 -0
  89. package/dist/model/wires/PowerTransformer.js.map +1 -1
  90. package/dist/model-container/model/ModelContainer.d.ts +2 -0
  91. package/dist/model-container/model/ModelContainer.js +5 -0
  92. package/dist/model-container/model/ModelContainer.js.map +1 -1
  93. package/dist/model-container/model/WNModelContainer.d.ts +1 -1
  94. package/dist/model-container/model/WNModelContainer.js +2 -2
  95. package/dist/util/collection/util-graph2tree.d.ts +1 -1
  96. package/dist/util/collection/util-graph2tree.js +2 -2
  97. package/dist/utils2/cim.model.utils.js +17 -13
  98. package/dist/utils2/cim.model.utils.js.map +1 -1
  99. package/dist/utils2/parser.utils.d.ts +1 -1
  100. package/dist/utils2/parser.utils.js +1 -1
  101. package/package.json +1 -1
  102. package/dist/model/extensions/amprion/core/AMPRIONSubstation.js.map +0 -1
  103. /package/dist/model/extensions/{neplan-westnetz → westnetz-neplan}/assets/WNFacility.d.ts +0 -0
  104. /package/dist/model/extensions/{neplan-westnetz → westnetz-neplan}/assets/WNFacility.js +0 -0
  105. /package/dist/model/extensions/{neplan-westnetz → westnetz-neplan}/assets/WNFacilityKind.d.ts +0 -0
  106. /package/dist/model/extensions/{neplan-westnetz → westnetz-neplan}/assets/WNFacilityKind.js +0 -0
  107. /package/dist/model/extensions/{neplan-westnetz → westnetz-neplan}/assets/WNWireInfo.d.ts +0 -0
  108. /package/dist/model/extensions/{neplan-westnetz → westnetz-neplan}/assets/WNWireInfo.js +0 -0
  109. /package/dist/model/extensions/{neplan-westnetz → westnetz-neplan}/assets/WNZUWOHealthScore.d.ts +0 -0
  110. /package/dist/model/extensions/{neplan-westnetz → westnetz-neplan}/assets/WNZUWOHealthScore.js +0 -0
  111. /package/dist/model/extensions/{neplan-westnetz → westnetz-neplan}/assets/WNZUWOImportanceScore.d.ts +0 -0
  112. /package/dist/model/extensions/{neplan-westnetz → westnetz-neplan}/assets/WNZUWOImportanceScore.js +0 -0
  113. /package/dist/model/extensions/{neplan-westnetz → westnetz-neplan}/assets/WNZUWOPriority.d.ts +0 -0
  114. /package/dist/model/extensions/{neplan-westnetz → westnetz-neplan}/assets/WNZUWOPriority.js +0 -0
  115. /package/dist/model/extensions/{neplan-westnetz → westnetz-neplan}/assets/WNZUWOState.d.ts +0 -0
  116. /package/dist/model/extensions/{neplan-westnetz → westnetz-neplan}/assets/WNZUWOState.js +0 -0
  117. /package/dist/model/extensions/{neplan-westnetz → westnetz-neplan}/common/WNLocation.d.ts +0 -0
  118. /package/dist/model/extensions/{neplan-westnetz → westnetz-neplan}/common/WNLocation.js +0 -0
  119. /package/dist/model/extensions/{neplan-westnetz → westnetz-neplan}/core/WNBay.d.ts +0 -0
  120. /package/dist/model/extensions/{neplan-westnetz → westnetz-neplan}/core/WNBay.js +0 -0
  121. /package/dist/model/extensions/{neplan-westnetz → westnetz-neplan}/core/WNConnectivityNode.d.ts +0 -0
  122. /package/dist/model/extensions/{neplan-westnetz → westnetz-neplan}/core/WNConnectivityNode.js +0 -0
  123. /package/dist/model/extensions/{neplan-westnetz → westnetz-neplan}/core/WNFeeder.d.ts +0 -0
  124. /package/dist/model/extensions/{neplan-westnetz → westnetz-neplan}/core/WNFeeder.js +0 -0
  125. /package/dist/model/extensions/{neplan-westnetz → westnetz-neplan}/core/WNSwitchTypeKind.d.ts +0 -0
  126. /package/dist/model/extensions/{neplan-westnetz → westnetz-neplan}/core/WNSwitchTypeKind.js +0 -0
  127. /package/dist/model/extensions/{neplan-westnetz → westnetz-neplan}/faults/WNFaultConnectivityNode.d.ts +0 -0
  128. /package/dist/model/extensions/{neplan-westnetz → westnetz-neplan}/faults/WNFaultConnectivityNode.js +0 -0
  129. /package/dist/model/extensions/{neplan-westnetz → westnetz-neplan}/operations/WNOutage.d.ts +0 -0
  130. /package/dist/model/extensions/{neplan-westnetz → westnetz-neplan}/operations/WNOutage.js +0 -0
  131. /package/dist/model/extensions/{neplan-westnetz → westnetz-neplan}/wires/WNACLineSegment.d.ts +0 -0
  132. /package/dist/model/extensions/{neplan-westnetz → westnetz-neplan}/wires/WNACLineSegment.js +0 -0
  133. /package/dist/model/extensions/{neplan-westnetz → westnetz-neplan}/wires/WNEnergyConsumer.d.ts +0 -0
  134. /package/dist/model/extensions/{neplan-westnetz → westnetz-neplan}/wires/WNEnergyConsumer.js +0 -0
@@ -15,6 +15,7 @@ const cim_constants_1 = require("../../constants/cim-constants.js");
15
15
  const Switch_1 = require("../../model/wires/Switch.js");
16
16
  const EquivalentBranch_1 = require("../../model/equivalents/EquivalentBranch.js");
17
17
  const LinearShuntCompensator_1 = require("../../model/wires/LinearShuntCompensator.js");
18
+ const INTEGRALSynchronousMachine_1 = require("../../model/extensions/integral/wires/INTEGRALSynchronousMachine.js");
18
19
  class PowerflowUtil {
19
20
  /**
20
21
  * Ermittelt alle elektrischverbundene Elemente eines Netzes
@@ -45,7 +46,6 @@ class PowerflowUtil {
45
46
  let nodesOnCurrentLevel = new Array();
46
47
  let nodesOnNextLevel = new Array(startCN);
47
48
  let terminalVisited = new Map();
48
- let counter = 0;
49
49
  while (nodesOnNextLevel.length) {
50
50
  nodesOnCurrentLevel.length = 0;
51
51
  nodesOnCurrentLevel = [...nodesOnNextLevel];
@@ -54,6 +54,12 @@ class PowerflowUtil {
54
54
  for (const currentNode of nodesOnCurrentLevel) {
55
55
  objectsFound.set(currentNode.getUUID(), currentNode);
56
56
  // nodesVisited.push(currentNode.getUUID());
57
+ /** Schaltzustände prüfen */
58
+ if (withSwitchSates && currentNode instanceof Switch_1.Switch) {
59
+ /** Wenn offen - überspringe */
60
+ if (!currentNode.isClosed())
61
+ continue;
62
+ }
57
63
  for (const terminal of currentNode.terminals.values()) {
58
64
  if (!terminal)
59
65
  continue;
@@ -119,11 +125,12 @@ class PowerflowUtil {
119
125
  // return network.find(it => (it instanceof EnergySource || it instanceof EnergyConsumer)) ? true : false;
120
126
  }
121
127
  static convertCIM2PandaPowerNetwork(network, nodeType, pandaDataFrame, defaultsConfig) {
122
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z;
128
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1;
123
129
  const uuidToIndex = new Map();
124
130
  const snMVA = pandaDataFrame._object.sn_mva;
125
131
  /** key uuid -> (Typ EnergyConsumer/EnergySource => Objekte)*/
126
132
  const tpLoadsNfeeders = new Map();
133
+ const a = ['789e9fa1-b89a-48f6-ab2a-3cbab4a691ed', 'c61073d2-b27a-410a-a81a-c6262de43319', '6c810212-0c1b-4be1-a3ec-21275181f4df'];
127
134
  /** Buselemente anlegen */
128
135
  const cimNodes = network.filter(it => it.constructor.name.includes(nodeType));
129
136
  const busData = pandaDataFrame._object.bus._object;
@@ -204,10 +211,10 @@ class PowerflowUtil {
204
211
  }
205
212
  }
206
213
  /** Ersatzleistungszahl */
207
- const krInfo = getKrInfo(tpLoadsNfeeders);
208
- const sgenData = pandaDataFrame._object.sgen._object;
214
+ const krSumme = getKrInfo(tpLoadsNfeeders);
209
215
  /** Generatoren anlegen */
210
216
  const genData = pandaDataFrame._object.gen._object;
217
+ const sgenData = pandaDataFrame._object.sgen._object;
211
218
  /** Einspeisungen anlegen */
212
219
  for (const loadsNfeeders of tpLoadsNfeeders.values()) {
213
220
  for (const entry of loadsNfeeders.entries()) {
@@ -216,8 +223,6 @@ class PowerflowUtil {
216
223
  if (key.includes('EnergySource')) {
217
224
  for (let i = 0; i < valuesArr.length; i++) {
218
225
  const energySource = valuesArr[i];
219
- if (PowerflowUtil.synchronousMachineUUIDs.includes(energySource.getUUID()))
220
- continue;
221
226
  for (const terminalValue of energySource.terminals.values()) {
222
227
  const connectedNode = terminalValue.getConnectedNode();
223
228
  const busID = uuidToIndex.get(connectedNode === null || connectedNode === void 0 ? void 0 : connectedNode.mrid);
@@ -229,37 +234,12 @@ class PowerflowUtil {
229
234
  let p = isNaN(energySource.activePower) ? 0 : energySource.activePower;
230
235
  let q = isNaN(energySource.reactivePower) ? 0 : energySource.reactivePower;
231
236
  const inServiceDate = (_a = energySource.getAsset()) === null || _a === void 0 ? void 0 : _a.getInServiceDate();
232
- const isGenerator = energySource.kr > 0;
233
- if (isGenerator) {
234
- const baseVoltage = PowerflowUtil.getBaseVoltageAsNumber(connectedNode);
235
- const slackWeight = energySource.kr / (krInfo === null || krInfo === void 0 ? void 0 : krInfo.krSum);
236
- /** name, bus, vm_pu, va_degree, slack_weight, in_service, s_sc_max_mva,s_sc_min_mva,rx_min,rx_max,r0x0_max,x0x_max,r0x0_min,x0x_min,description */
237
- const gen = [
238
- energySource.getUUID(),
239
- busID,
240
- //p < 0 ? p * -1 : p, // p_mw
241
- 0,
242
- 1,
243
- snMVA,
244
- 0,
245
- 0,
246
- 1,
247
- //genWithHighestPrio?.getUUID() === synchronousMachine.getUUID() ? true : false, // slack
248
- false,
249
- true,
250
- slackWeight ? slackWeight : 0,
251
- 'sync',
252
- energySource.key
253
- ]; // min_p_mw
254
- genData.data.push(gen);
255
- genData.index.push(genData.data.length - 1);
256
- }
257
237
  /** "name, bus, p_mw, q_mvar,sn_mva,scaling,in_service,type,current_source, in_service_date */
258
238
  const sgen = [
259
239
  energySource.mrid,
260
240
  busID,
261
241
  p, q,
262
- snMVA,
242
+ 0,
263
243
  PowerflowUtil.scalingFactorRn,
264
244
  true,
265
245
  ((_c = (_b = energySource.psrType) === null || _b === void 0 ? void 0 : _b.name) !== null && _c !== void 0 ? _c : ''),
@@ -274,65 +254,129 @@ class PowerflowUtil {
274
254
  }
275
255
  }
276
256
  }
277
- /** Slacks */
278
- const extNetData = pandaDataFrame._object.ext_grid._object;
279
- const generators = network.filter(it => it instanceof SynchronousMachine_1.SynchronousMachine);
280
- const generatorsWithoutControl = generators.filter(it => { var _a; return !((_a = it.regulatingControl) === null || _a === void 0 ? void 0 : _a.targetValue) && !it.generatingUnit; });
281
- const genWithHighestPrio = generators.reduce((highest, current) => highest.referencePriority > current.referencePriority ? highest : current);
282
- for (const synchronousMachine of krInfo.gensWithKrOnly) {
283
- const str = `${synchronousMachine.mrid} ${synchronousMachine.key}`;
284
- // TODO
285
- console.log('GensWithKrOnly ist nicht implementiert', str);
286
- }
287
- for (const synchronousMachine of krInfo.gensWithTargetVoltageKr) {
288
- const str = `${synchronousMachine.mrid}${synchronousMachine.key}`;
289
- if (PowerflowUtil.synchronousMachineUUIDs.includes(synchronousMachine.getUUID()))
290
- continue;
257
+ const generators = network.filter(it => it instanceof INTEGRALSynchronousMachine_1.INTEGRALSynchronousMachine);
258
+ for (const synchronousMachine of generators) {
291
259
  for (const terminalValue of synchronousMachine.terminals.values()) {
292
260
  const connectedNode = terminalValue.getConnectedNode();
293
261
  const busID = uuidToIndex.get(connectedNode === null || connectedNode === void 0 ? void 0 : connectedNode.mrid);
294
- if (!busID) {
295
- console.log(`${str} keine BusID`);
262
+ if (synchronousMachine.normallyInService !== true)
296
263
  continue;
297
- }
298
- const baseVoltage = PowerflowUtil.getBaseVoltageAsNumber(connectedNode);
299
- const targetValue = synchronousMachine.regulatingControl.targetValue;
300
- const targetVoltage = targetValue / baseVoltage;
301
- const p = synchronousMachine.p || 0;
302
- if (synchronousMachine.controlEnabled === false) {
303
- console.log(`${str} kein controlEnabled`);
264
+ if (!((_d = synchronousMachine.regulatingControl) === null || _d === void 0 ? void 0 : _d.targetValue))
304
265
  continue;
266
+ if (busID !== undefined) {
267
+ const baseV = PowerflowUtil.getBaseVoltageAsNumber(connectedNode);
268
+ let targetValue = baseV;
269
+ if (synchronousMachine.regulatingControl && synchronousMachine.regulatingControl.targetValue > 0) {
270
+ targetValue = synchronousMachine.regulatingControl.targetValue;
271
+ }
272
+ targetValue = !isNaN(targetValue) ? targetValue : baseV;
273
+ const baseVoltage = baseV <= 0 ? defaultsConfig.data.line.default_u : baseV;
274
+ const targetVoltage = targetValue / baseVoltage;
275
+ const p = synchronousMachine.p || 0;
276
+ const q = synchronousMachine.q || 0;
277
+ const slackWeight = (synchronousMachine === null || synchronousMachine === void 0 ? void 0 : synchronousMachine.kr) ? (synchronousMachine === null || synchronousMachine === void 0 ? void 0 : synchronousMachine.kr) / krSumme : 0;
278
+ /* if (p !== 0 || q !== 0) {
279
+ /!** "name, bus, p_mw, q_mvar, sn_mva, scaling, in_service, type, current_source, in_service_date *!/
280
+ const sgen: any[] = [
281
+ CommonUtils.generateUUID(), // name
282
+ busID, // bus
283
+ p, // p_mw
284
+ q, // q_mvar
285
+ 0, // sn_mva
286
+ 1, // scaling
287
+ true, // in_service
288
+ '', // type
289
+ false, // current_source
290
+ null // in_service_date
291
+ ];
292
+
293
+ sgenData.data.push(sgen);
294
+ sgenData.index.push(sgenData.data.length - 1);
295
+ }*/
296
+ if (synchronousMachine.controlEnabled === false)
297
+ continue;
298
+ /** name,bus,p_mw,vm_pu,sn_mva,min_q_mvar,max_q_mvar,scaling,slack,in_service,slack_weight,type*/
299
+ const gen = [
300
+ synchronousMachine.getUUID(),
301
+ busID,
302
+ p,
303
+ targetVoltage,
304
+ 0,
305
+ -3000,
306
+ 3000,
307
+ 1,
308
+ slackWeight > 0 ? true : false,
309
+ true,
310
+ slackWeight,
311
+ 'sync',
312
+ synchronousMachine['key']
313
+ ]; // min_p_mw
314
+ genData.data.push(gen);
315
+ genData.index.push(genData.data.length - 1);
305
316
  }
306
- const isSlack = (genWithHighestPrio === null || genWithHighestPrio === void 0 ? void 0 : genWithHighestPrio.getUUID()) === synchronousMachine.getUUID();
307
- const generatingUnit = synchronousMachine.generatingUnit;
308
- /** KR-Zahl => (governorSCD * nominalP ) / (100 * 50hz) */
309
- const kr = generatingUnit ? ((generatingUnit.governorSCD * generatingUnit.nominalP) / (100 * 50)) : 0;
310
- const slackWeight = kr / (krInfo === null || krInfo === void 0 ? void 0 : krInfo.krSum);
311
- if (isSlack) {
312
- if (p !== 0) {
313
- /** "name, bus, p_mw, q_mvar, sn_mva, scaling, in_service, type, current_source, in_service_date */
314
- const sgen = [
315
- common_utils_1.CommonUtils.generateUUID(),
316
- busID,
317
- p,
318
- 0,
319
- snMVA,
320
- 1,
321
- true,
322
- '',
323
- false,
324
- null // in_service_date
325
- ];
326
- sgenData.data.push(sgen);
327
- sgenData.index.push(sgenData.data.length - 1);
317
+ }
318
+ }
319
+ /** Slacks */
320
+ const extNetData = pandaDataFrame._object.ext_grid._object;
321
+ const externalNetworkInjections = network.filter(it => it instanceof ExternalNetworkInjection_1.ExternalNetworkInjection);
322
+ for (const extNetwork of externalNetworkInjections) {
323
+ if (extNetwork.getUUID() === '3dd86cf5-33a6-4676-b0c0-2783f8bb2540')
324
+ continue;
325
+ for (const terminalValue of extNetwork.terminals.values()) {
326
+ const connectedNode = terminalValue.getConnectedNode();
327
+ const busID = uuidToIndex.get(connectedNode === null || connectedNode === void 0 ? void 0 : connectedNode.mrid);
328
+ if (busID !== undefined && terminalValue.isClosed()) {
329
+ // "name","bus","vm_pu","va_degree","in_service"
330
+ // [1, 0.0, 0.0,false,true,null,21.7,12.7,1.0,null,null]
331
+ //"bus","in_service","name","va_degree","vm_pu","max_p_mw","min_p_mw","max_q_mvar","min_q_mvar"
332
+ /** name,bus,ps_mw,qs_mvar,qz_mvar,pz_mw,r_ohm,x_ohm,vm_pu,slack_weight,in_service */
333
+ const baseV = PowerflowUtil.getBaseVoltageAsNumber(connectedNode);
334
+ let targetValue = baseV;
335
+ if (extNetwork.regulatingControl && extNetwork.regulatingControl.targetValue > 0) {
336
+ targetValue = extNetwork.regulatingControl.targetValue;
328
337
  }
338
+ //TODO temp Fix
339
+ /* if (extNetwork.p !== 0 || extNetwork.q !== 0) {
340
+ const p = isNaN(extNetwork.p) ? 0 : extNetwork.p;
341
+ const q = isNaN(extNetwork.p) ? 0 : extNetwork.q;
342
+ const inServiceDate = extNetwork.getAsset()?.getInServiceDate();
343
+ /!** "name, bus, p_mw, q_mvar, sn_mva, scaling, in_service, type, current_source, in_service_date *!/
344
+ const sgen: any[] = [
345
+ CommonUtils.generateUUID(), // name
346
+ busID, // bus
347
+ p, // p_mw
348
+ 0, // q_mvar
349
+ 0, // sn_mva
350
+ 1, // scaling
351
+ true, // in_service
352
+ extNetwork.psrType?.name || '', // type
353
+ false, // current_source
354
+ inServiceDate // in_service_date
355
+ ];
356
+
357
+ sgenData.data.push(sgen);
358
+ sgenData.index.push(sgenData.data.length - 1);
359
+ }*/
360
+ if (!((_e = extNetwork.regulatingControl) === null || _e === void 0 ? void 0 : _e.targetValue))
361
+ continue;
362
+ targetValue = !isNaN(targetValue) ? targetValue : baseV;
363
+ const baseVoltage = baseV <= 0 ? defaultsConfig.data.line.default_u : baseV;
364
+ const targetVoltage = targetValue / baseVoltage;
365
+ const max_p_mw = 3000;
366
+ const min_p_mw = -3000;
367
+ const max_q_mvar = 3000;
368
+ const min_q_mvar = -3000;
369
+ // "bus","in_service","name","va_degree","vm_pu","max_p_mw","min_p_mw","max_q_mvar","min_q_mvar"
370
+ // const slack: any[] = [busID, true, extNetwork.mrid, 0, targetVoltage, max_p_mw, min_p_mw, max_q_mvar, min_q_mvar];
371
+ // extNetDataCSV.push(`${busID},${true},${extNetwork.mrid},${0},${targetVoltage},${300},${-300},${300},${-300}`);
372
+ const slackWeight = (extNetwork === null || extNetwork === void 0 ? void 0 : extNetwork.governorSCD) ? (extNetwork === null || extNetwork === void 0 ? void 0 : extNetwork.governorSCD) / krSumme : 1;
329
373
  /** name, bus, vm_pu, va_degree, slack_weight, in_service, s_sc_max_mva,s_sc_min_mva,rx_min,rx_max,r0x0_max,x0x_max,r0x0_min,x0x_min,description */
330
374
  const slack = [
331
- synchronousMachine.getUUID(),
375
+ extNetwork.getUUID(),
332
376
  busID,
333
377
  targetVoltage,
334
378
  0,
335
- slackWeight ? slackWeight : 0,
379
+ slackWeight,
336
380
  true,
337
381
  0,
338
382
  0,
@@ -343,82 +387,180 @@ class PowerflowUtil {
343
387
  0,
344
388
  0,
345
389
  '',
346
- synchronousMachine.key
390
+ extNetwork['key']
347
391
  ]; // key
348
392
  extNetData.data.push(slack);
349
393
  extNetData.index.push(extNetData.data.length - 1);
350
394
  }
351
- else {
352
- if (p !== 0) {
353
- /** "name, bus, p_mw, q_mvar, sn_mva, scaling, in_service, type, current_source, in_service_date */
354
- const sgen = [
355
- common_utils_1.CommonUtils.generateUUID(),
356
- busID,
357
- p,
358
- 0,
359
- snMVA,
360
- 1,
361
- true,
362
- '',
363
- false,
364
- null // in_service_date
365
- ];
366
- sgenData.data.push(sgen);
367
- sgenData.index.push(sgenData.data.length - 1);
368
- }
369
- /** name,bus,p_mw,vm_pu,sn_mva,min_q_mvar,max_q_mvar,scaling,slack,in_service,slack_weight,type*/
370
- const gen = [
371
- synchronousMachine.getUUID(),
372
- busID,
373
- //p < 0 ? p * -1 : p, // p_mw
374
- 0,
375
- targetVoltage,
376
- snMVA,
377
- synchronousMachine.minQ,
378
- synchronousMachine.maxQ,
379
- 1,
380
- //genWithHighestPrio?.getUUID() === synchronousMachine.getUUID() ? true : false, // slack
381
- true,
382
- true,
383
- slackWeight ? slackWeight : 0,
384
- 'sync',
385
- synchronousMachine.key
386
- ]; // min_p_mw
387
- genData.data.push(gen);
388
- genData.index.push(genData.data.length - 1);
389
- }
390
395
  }
391
396
  }
392
- for (const synchronousMachine of generatorsWithoutControl) {
393
- if (PowerflowUtil.synchronousMachineUUIDs.includes(synchronousMachine.getUUID()))
394
- continue;
395
- for (const terminalValue of synchronousMachine.terminals.values()) {
397
+ /*
398
+ const generatorsWithoutControl = generators.filter(it => !it.regulatingControl?.targetValue && !it.generatingUnit);
399
+
400
+ const genWithHighestPrio: SynchronousMachine = generators.reduce((highest, current) => highest.referencePriority > current.referencePriority ? highest : current);
401
+ */
402
+ /*
403
+ const ersatzQuerzweige = network.filter(it => it instanceof EquivalentInjection) as Array<INTEGRALEquivalentInjection>;
404
+ const injectionWithHighestPrio: EquivalentInjection = ersatzQuerzweige.reduce((highest, current) => highest.kr > current.kr ? highest : current);
405
+ */
406
+ /* for (const synchronousMachine of krInfo.gensWithKrOnly) {
407
+ const str = `${synchronousMachine.mrid} ${synchronousMachine.key}`;
408
+ // TODO
409
+ console.log('GensWithKrOnly ist nicht implementiert', str);
410
+ }*/
411
+ /* for (const synchronousMachine of krInfo.gensWithTargetVoltageKr) {
412
+ const str = `${synchronousMachine.mrid}${synchronousMachine.key}`;
413
+ if (PowerflowUtil.synchronousMachineUUIDs.includes(synchronousMachine.getUUID())) continue;
414
+ for (const terminalValue of synchronousMachine.terminals.values()) {
396
415
  const connectedNode = terminalValue.getConnectedNode();
397
- const busID = uuidToIndex.get(connectedNode === null || connectedNode === void 0 ? void 0 : connectedNode.mrid);
398
- if (busID !== undefined) {
399
- // "name","bus","p_mw","q_mvar",
400
- // "name","bus","p_mw","q_mvar","sn_mva","scaling","in_service","type","current_source", in_service_date
401
- // [1, 0.0, 0.0,false,true,null,21.7,12.7,1.0,null,null];
402
- // const sgen: any[] = [energySource.mrid, busID, p, q, 0, 1, true, (energySource.psrType?.name ?? ''), false, inServiceDate];
403
- let p = isNaN(synchronousMachine.p) ? 0 : synchronousMachine.p;
404
- let q = isNaN(synchronousMachine.q) ? 0 : synchronousMachine.q;
405
- /** "name, bus, p_mw, q_mvar,sn_mva,scaling,in_service,type,current_source, in_service_date */
406
- const sgen = [
407
- synchronousMachine.mrid,
408
- busID,
409
- p, q,
410
- snMVA,
411
- 1,
412
- true,
413
- '',
414
- false,
415
- null
416
+
417
+ const busID = uuidToIndex.get(connectedNode?.mrid);
418
+
419
+ if (!busID) {
420
+ console.log(`${str} keine BusID`);
421
+ continue;
422
+ }
423
+ const baseVoltage = PowerflowUtil.getBaseVoltageAsNumber(connectedNode);
424
+
425
+ const targetValue = synchronousMachine.regulatingControl.targetValue;
426
+
427
+ const targetVoltage = targetValue / baseVoltage;
428
+
429
+ const p = synchronousMachine.p || 0;
430
+
431
+ if (synchronousMachine.controlEnabled === false) {
432
+ console.log(`${str} kein controlEnabled`);
433
+ continue;
434
+ }
435
+
436
+ const isSlack = genWithHighestPrio?.getUUID() === synchronousMachine.getUUID();
437
+
438
+ const generatingUnit = synchronousMachine.generatingUnit;
439
+ /!** KR-Zahl => (governorSCD * nominalP ) / (100 * 50hz) *!/
440
+ const kr = generatingUnit ? ((generatingUnit.governorSCD * generatingUnit.nominalP) / (100 * 50)) : 0;
441
+ const slackWeight = kr / krInfo?.krSum;
442
+
443
+ if (isSlack) {
444
+ if (p !== 0) {
445
+ /!** "name, bus, p_mw, q_mvar, sn_mva, scaling, in_service, type, current_source, in_service_date *!/
446
+ const sgen: any[] = [
447
+ CommonUtils.generateUUID(), // name
448
+ busID, // bus
449
+ p, // p_mw
450
+ 0, // q_mvar
451
+ snMVA, // sn_mva
452
+ 1, // scaling
453
+ true, // in_service
454
+ '', // type
455
+ false, // current_source
456
+ null // in_service_date
416
457
  ];
458
+
417
459
  sgenData.data.push(sgen);
418
- sgenData.index.push(sgenData.data.length - 1);
460
+ sgenData.index.push(sgenData.data.length - 1)
461
+ }
462
+
463
+ /!** name, bus, vm_pu, va_degree, slack_weight, in_service, s_sc_max_mva,s_sc_min_mva,rx_min,rx_max,r0x0_max,x0x_max,r0x0_min,x0x_min,description *!/
464
+ const slack: any[] = [
465
+ synchronousMachine.getUUID(), //name
466
+ busID, // bus
467
+ targetVoltage,// vm_pu
468
+ 0, // va_degree
469
+ slackWeight ? slackWeight : 0, // slack_weight
470
+ true, // in_service
471
+ 0,// s_sc_max_mva
472
+ 0, // s_sc_min_mva
473
+ 0,// rx_min
474
+ 0,// rx_max
475
+ 0,// r0x0_max,
476
+ 0,// x0x_max,
477
+ 0,// r0x0_min,
478
+ 0,// x0x_min
479
+ '',
480
+ synchronousMachine.key]; // key
481
+
482
+ extNetData.data.push(slack);
483
+ extNetData.index.push(extNetData.data.length - 1);
484
+ }
485
+ else {
486
+
487
+ if (p !== 0) {
488
+ /!** "name, bus, p_mw, q_mvar, sn_mva, scaling, in_service, type, current_source, in_service_date *!/
489
+ const sgen: any[] = [
490
+ CommonUtils.generateUUID(), // name
491
+ busID, // bus
492
+ p, // p_mw
493
+ 0, // q_mvar
494
+ snMVA, // sn_mva
495
+ 1, // scaling
496
+ true, // in_service
497
+ '', // type
498
+ false, // current_source
499
+ null // in_service_date
500
+ ];
501
+
502
+ sgenData.data.push(sgen);
503
+ sgenData.index.push(sgenData.data.length - 1)
504
+ }
505
+
506
+ /!** name,bus,p_mw,vm_pu,sn_mva,min_q_mvar,max_q_mvar,scaling,slack,in_service,slack_weight,type*!/
507
+ const gen: any[] = [
508
+ synchronousMachine.getUUID(), // name
509
+ busID, // bus
510
+ //p < 0 ? p * -1 : p, // p_mw
511
+ 0,
512
+ targetVoltage, // vm_pu
513
+ snMVA, // sn_mva
514
+ synchronousMachine.minQ, // min_q_mvar
515
+ synchronousMachine.maxQ, // max_q_mvar
516
+ 1, // scaling
517
+ //genWithHighestPrio?.getUUID() === synchronousMachine.getUUID() ? true : false, // slack
518
+ true, // slack
519
+ true, // in_service
520
+ slackWeight ? slackWeight : 0, // slack_weight
521
+ 'sync', // type,
522
+ synchronousMachine.key
523
+ ]; // min_p_mw
524
+ genData.data.push(gen);
525
+ genData.index.push(genData.data.length - 1);
419
526
  }
527
+
528
+ }
420
529
  }
421
- }
530
+
531
+ for (const synchronousMachine of generatorsWithoutControl) {
532
+ if (PowerflowUtil.synchronousMachineUUIDs.includes(synchronousMachine.getUUID())) continue;
533
+ for (const terminalValue of synchronousMachine.terminals.values()) {
534
+ const connectedNode = terminalValue.getConnectedNode();
535
+ const busID = uuidToIndex.get(connectedNode?.mrid);
536
+
537
+ if (busID !== undefined) {
538
+ // "name","bus","p_mw","q_mvar",
539
+ // "name","bus","p_mw","q_mvar","sn_mva","scaling","in_service","type","current_source", in_service_date
540
+ // [1, 0.0, 0.0,false,true,null,21.7,12.7,1.0,null,null];
541
+ // const sgen: any[] = [energySource.mrid, busID, p, q, 0, 1, true, (energySource.psrType?.name ?? ''), false, inServiceDate];
542
+ let p = isNaN(synchronousMachine.p) ? 0 : synchronousMachine.p;
543
+ let q = isNaN(synchronousMachine.q) ? 0 : synchronousMachine.q;
544
+
545
+
546
+ /!** "name, bus, p_mw, q_mvar,sn_mva,scaling,in_service,type,current_source, in_service_date *!/
547
+ const sgen: any[] = [
548
+ synchronousMachine.mrid, // name
549
+ busID, // bus
550
+ p, q, // p_mw, q_mvar,
551
+ 0, // sn_mva
552
+ 1, // scaling
553
+ true, // in_service
554
+ '', // type
555
+ false, // current_source
556
+ null
557
+ ];
558
+
559
+ sgenData.data.push(sgen);
560
+ sgenData.index.push(sgenData.data.length - 1);
561
+ }
562
+ }
563
+ }*/
422
564
  /*for (const loadsNfeeders of tpLoadsNfeeders.values()) {
423
565
  for (const entry of loadsNfeeders.entries()) {
424
566
  const key = entry[0];
@@ -532,8 +674,8 @@ class PowerflowUtil {
532
674
  /** Typ des Stromkreisabschnittes. Default Freileitung
533
675
  * cs - Kabel
534
676
  * ol - Freileitung */
535
- const type = ((_d = acLineSegment.psrType) === null || _d === void 0 ? void 0 : _d.name) === cim_constants_1.CimAssetAliasNames.Cable ? 'cs' : 'ol';
536
- const baseVoltage = (_f = (_e = acLineSegment.baseVoltage) === null || _e === void 0 ? void 0 : _e.nominalVoltage) === null || _f === void 0 ? void 0 : _f.value;
677
+ const type = ((_f = acLineSegment.psrType) === null || _f === void 0 ? void 0 : _f.name) === cim_constants_1.CimAssetAliasNames.Cable ? 'cs' : 'ol';
678
+ const baseVoltage = (_h = (_g = acLineSegment.baseVoltage) === null || _g === void 0 ? void 0 : _g.nominalVoltage) === null || _h === void 0 ? void 0 : _h.value;
537
679
  const stdType = this.createPandaPowerTypeFromValues(pandaDataFrame, type, baseVoltage, ir, x, r, c);
538
680
  /** PandaPower-Line-Objekt erstellen */
539
681
  const line = [
@@ -566,93 +708,121 @@ class PowerflowUtil {
566
708
  lineData.index.push(lineData.data.length - 1);
567
709
  }
568
710
  const xwardData = pandaDataFrame._object.xward._object;
569
- /** ElementWithTargetVoltageKr -> XWard */
570
- for (const equivalentInjection of krInfo.wardsWithTargetVoltageKr) {
571
- //console.log(`${equivalentInjection.mrid};${equivalentInjection.key};${equivalentInjection.regulationStatus};${equivalentInjection.regulationTarget};${(equivalentInjection as INTEGRALEquivalentInjection)?.kr};${equivalentInjection.p};${equivalentInjection.q}`);
572
- for (const terminalValue of equivalentInjection.terminals.values()) {
711
+ /* /!** ElementWithTargetVoltageKr -> XWard *!/
712
+ for (const equivalentInjection of krInfo.wardsWithTargetVoltageKr) {
713
+ //console.log(`${equivalentInjection.mrid};${equivalentInjection.key};${equivalentInjection.regulationStatus};${equivalentInjection.regulationTarget};${(equivalentInjection as INTEGRALEquivalentInjection)?.kr};${equivalentInjection.p};${equivalentInjection.q}`);
714
+
715
+ for (const terminalValue of equivalentInjection.terminals.values()) {
573
716
  const connectedNode = terminalValue.getConnectedNode();
574
- const busID = uuidToIndex.get(connectedNode === null || connectedNode === void 0 ? void 0 : connectedNode.mrid);
717
+
718
+ const busID = uuidToIndex.get(connectedNode?.mrid);
719
+
575
720
  if (busID !== undefined) {
576
- const baseV = PowerflowUtil.getBaseVoltageAsNumber(connectedNode);
577
- let targetValue = equivalentInjection.regulationTarget;
578
- targetValue = !isNaN(targetValue) ? targetValue : baseV;
579
- const baseVoltage = baseV <= 0 ? defaultsConfig.data.line.default_u : baseV;
580
- const targetVoltage = targetValue / baseVoltage;
581
- const p = equivalentInjection.p || 0;
582
- const q = equivalentInjection.q || 0;
583
- const kr = equivalentInjection === null || equivalentInjection === void 0 ? void 0 : equivalentInjection.kr;
584
- const slackWeight = kr / (krInfo === null || krInfo === void 0 ? void 0 : krInfo.krSum);
585
- const ps_mw = equivalentInjection === null || equivalentInjection === void 0 ? void 0 : equivalentInjection.p_bel;
586
- const qs_mvar = equivalentInjection === null || equivalentInjection === void 0 ? void 0 : equivalentInjection.q_bel;
587
- const pz_mw = equivalentInjection === null || equivalentInjection === void 0 ? void 0 : equivalentInjection.p_ki;
588
- const qz_mvar = equivalentInjection === null || equivalentInjection === void 0 ? void 0 : equivalentInjection.q_ki;
589
- // const r_ohm = (equivalentInjection as INTEGRALEquivalentInjection)?.rExt;
590
- // const x_ohm = (equivalentInjection as INTEGRALEquivalentInjection)?.xExt;
591
- const r_ohm = equivalentInjection.r;
592
- const x_ohm = equivalentInjection.x;
593
- const xward = [
594
- equivalentInjection.getUUID(),
595
- busID,
596
- ps_mw,
597
- qs_mvar,
598
- qz_mvar,
599
- pz_mw,
600
- r_ohm,
601
- x_ohm,
602
- targetVoltage,
603
- slackWeight,
604
- true,
605
- equivalentInjection.key // key
606
- ];
607
- xwardData.data.push(xward);
608
- xwardData.index.push(xwardData.data.length - 1);
721
+ const baseV = PowerflowUtil.getBaseVoltageAsNumber(connectedNode);
722
+ let targetValue = equivalentInjection.regulationTarget;
723
+
724
+ targetValue = !isNaN(targetValue) ? targetValue : baseV;
725
+ const baseVoltage = baseV <= 0 ? defaultsConfig.data.line.default_u : baseV;
726
+ const targetVoltage = targetValue / baseVoltage;
727
+
728
+ const p = equivalentInjection.p || 0;
729
+ const q = equivalentInjection.q || 0;
730
+
731
+ const kr =(equivalentInjection as INTEGRALEquivalentInjection)?.kr;
732
+ const slackWeight = kr / krInfo?.krSum;
733
+
734
+ const ps_mw = (equivalentInjection as INTEGRALEquivalentInjection)?.p_bel;
735
+ const qs_mvar = (equivalentInjection as INTEGRALEquivalentInjection)?.q_bel;
736
+
737
+ const pz_mw = (equivalentInjection as INTEGRALEquivalentInjection)?.p_ki;
738
+ const qz_mvar = (equivalentInjection as INTEGRALEquivalentInjection)?.q_ki;
739
+
740
+ // const r_ohm = (equivalentInjection as INTEGRALEquivalentInjection)?.rExt;
741
+ // const x_ohm = (equivalentInjection as INTEGRALEquivalentInjection)?.xExt;
742
+
743
+ const r_ohm = equivalentInjection.r;
744
+ const x_ohm = equivalentInjection.x;
745
+
746
+
747
+ const xward: any[] = [
748
+ equivalentInjection.getUUID(), //name
749
+ busID, // bus
750
+ ps_mw, // ps_mw
751
+ qs_mvar, // qs_mvar
752
+ qz_mvar, // qz_mvar
753
+ pz_mw, // pz_mw
754
+
755
+ r_ohm, // r_ohm
756
+ x_ohm, // x_ohm
757
+
758
+ targetVoltage, // vm_pu
759
+ slackWeight, // slack_weight,
760
+ true, // in_service
761
+ equivalentInjection.key // key
762
+ ];
763
+
764
+ xwardData.data.push(xward);
765
+ xwardData.index.push(xwardData.data.length - 1);
609
766
  }
767
+ }
610
768
  }
611
- }
612
- for (const equivalentInjection of krInfo.wardsWithTargetVoltageOnly) {
613
- //console.log(`${equivalentInjection.mrid};${equivalentInjection.key};${equivalentInjection.regulationStatus};${equivalentInjection.regulationTarget};${(equivalentInjection as INTEGRALEquivalentInjection)?.kr};${equivalentInjection.p};${equivalentInjection.q}`);
614
- for (const terminalValue of equivalentInjection.terminals.values()) {
769
+
770
+ for (const equivalentInjection of krInfo.wardsWithTargetVoltageOnly) {
771
+ //console.log(`${equivalentInjection.mrid};${equivalentInjection.key};${equivalentInjection.regulationStatus};${equivalentInjection.regulationTarget};${(equivalentInjection as INTEGRALEquivalentInjection)?.kr};${equivalentInjection.p};${equivalentInjection.q}`);
772
+
773
+ for (const terminalValue of equivalentInjection.terminals.values()) {
615
774
  const connectedNode = terminalValue.getConnectedNode();
616
- const busID = uuidToIndex.get(connectedNode === null || connectedNode === void 0 ? void 0 : connectedNode.mrid);
775
+
776
+ const busID = uuidToIndex.get(connectedNode?.mrid);
777
+
617
778
  if (busID !== undefined) {
618
- const baseV = PowerflowUtil.getBaseVoltageAsNumber(connectedNode);
619
- let targetValue = equivalentInjection.regulationTarget;
620
- targetValue = !isNaN(targetValue) ? targetValue : baseV;
621
- const baseVoltage = baseV <= 0 ? defaultsConfig.data.line.default_u : baseV;
622
- const targetVoltage = targetValue / baseVoltage;
623
- const slackWeight = 0;
624
- const ps_mw = equivalentInjection === null || equivalentInjection === void 0 ? void 0 : equivalentInjection.p_bel;
625
- const qs_mvar = equivalentInjection === null || equivalentInjection === void 0 ? void 0 : equivalentInjection.q_bel;
626
- const pz_mw = equivalentInjection === null || equivalentInjection === void 0 ? void 0 : equivalentInjection.p_ki;
627
- const qz_mvar = equivalentInjection === null || equivalentInjection === void 0 ? void 0 : equivalentInjection.q_ki;
628
- const r_ohm = equivalentInjection.r;
629
- const x_ohm = equivalentInjection.x;
630
- /** name,bus,ps_mw,qs_mvar,qz_mvar,pz_mw,r_ohm,x_ohm,vm_pu,slack_weight,in_service */
631
- const xward = [
632
- equivalentInjection.getUUID(),
633
- busID,
634
- ps_mw,
635
- qs_mvar,
636
- qz_mvar,
637
- pz_mw,
638
- r_ohm,
639
- x_ohm,
640
- targetVoltage,
641
- slackWeight,
642
- true,
643
- equivalentInjection.key // key
644
- ];
645
- xwardData.data.push(xward);
646
- xwardData.index.push(xwardData.data.length - 1);
779
+ const baseV = PowerflowUtil.getBaseVoltageAsNumber(connectedNode);
780
+ let targetValue = equivalentInjection.regulationTarget;
781
+
782
+ targetValue = !isNaN(targetValue) ? targetValue : baseV;
783
+ const baseVoltage = baseV <= 0 ? defaultsConfig.data.line.default_u : baseV;
784
+ const targetVoltage = targetValue / baseVoltage;
785
+
786
+ const slackWeight = 0;
787
+
788
+ const ps_mw = (equivalentInjection as INTEGRALEquivalentInjection)?.p_bel;
789
+ const qs_mvar = (equivalentInjection as INTEGRALEquivalentInjection)?.q_bel;
790
+
791
+ const pz_mw = (equivalentInjection as INTEGRALEquivalentInjection)?.p_ki;
792
+ const qz_mvar = (equivalentInjection as INTEGRALEquivalentInjection)?.q_ki;
793
+
794
+ const r_ohm = equivalentInjection.r;
795
+ const x_ohm = equivalentInjection.x;
796
+ /!** name,bus,ps_mw,qs_mvar,qz_mvar,pz_mw,r_ohm,x_ohm,vm_pu,slack_weight,in_service *!/
797
+ const xward: any[] = [
798
+ equivalentInjection.getUUID(), //name
799
+ busID, // bus
800
+ ps_mw, // ps_mw
801
+ qs_mvar, // qs_mvar
802
+ qz_mvar, // qz_mvar
803
+ pz_mw, // pz_mw
804
+
805
+ r_ohm, // r_ohm
806
+ x_ohm, // x_ohm
807
+
808
+ targetVoltage, // vm_pu
809
+ slackWeight, // slack_weight,
810
+ true, // in_service
811
+ equivalentInjection.key // key
812
+ ];
813
+
814
+ xwardData.data.push(xward);
815
+ xwardData.index.push(xwardData.data.length - 1);
647
816
  }
817
+ }
648
818
  }
649
- }
650
- /** elementWithKrOnly -> Gen */
651
- for (const equivalentInjection of krInfo.wardsWithKrOnly) {
652
- const str = `${equivalentInjection.mrid} ${equivalentInjection.key}`;
653
- // TODO
654
- console.log('WardsWithKrOnly ist nicht implementiert', str);
655
- }
819
+
820
+ /!** elementWithKrOnly -> Gen *!/
821
+ for (const equivalentInjection of krInfo.wardsWithKrOnly) {
822
+ const str = `${equivalentInjection.mrid} ${equivalentInjection.key}`;
823
+ // TODO
824
+ console.log('WardsWithKrOnly ist nicht implementiert', str);
825
+ }*/
656
826
  /** EquivalentBranch/Ersatzlängszweige anlegen */
657
827
  const impedanceData = pandaDataFrame._object.impedance._object;
658
828
  const equivalentBranches = network.filter(it => it instanceof EquivalentBranch_1.EquivalentBranch);
@@ -673,7 +843,7 @@ class PowerflowUtil {
673
843
  const zeroR21 = equivalentBranch.r21 ? equivalentBranch.r21 : zeroR12;
674
844
  const zeroX21 = equivalentBranch.x21 ? equivalentBranch.x21 : zeroX12;
675
845
  const snMVA = pandaDataFrame._object.sn_mva;
676
- const z_base = Math.pow((_h = (_g = equivalentBranch.baseVoltage) === null || _g === void 0 ? void 0 : _g.nominalVoltage) === null || _h === void 0 ? void 0 : _h.value, 2) / snMVA;
846
+ const z_base = Math.pow((_k = (_j = equivalentBranch.baseVoltage) === null || _j === void 0 ? void 0 : _j.nominalVoltage) === null || _k === void 0 ? void 0 : _k.value, 2) / snMVA;
677
847
  const rft_pu = equivalentBranch.r / z_base;
678
848
  const xft_pu = equivalentBranch.x / z_base;
679
849
  const rtf_pu = r21 / z_base;
@@ -842,12 +1012,12 @@ class PowerflowUtil {
842
1012
  const busW1ID = uuidToIndex.get(busW1.mrid);
843
1013
  const busW2ID = uuidToIndex.get(busW2.mrid);
844
1014
  const busW3ID = uuidToIndex.get(busW3.mrid);
845
- const w1Ur = (_l = (_k = (_j = trafoW3.powerTransformerEnd[0]) === null || _j === void 0 ? void 0 : _j.baseVoltage) === null || _k === void 0 ? void 0 : _k.nominalVoltage) === null || _l === void 0 ? void 0 : _l.value;
846
- const w2Ur = (_p = (_o = (_m = trafoW3.powerTransformerEnd[1]) === null || _m === void 0 ? void 0 : _m.baseVoltage) === null || _o === void 0 ? void 0 : _o.nominalVoltage) === null || _p === void 0 ? void 0 : _p.value;
847
- const w3Ur = (_s = (_r = (_q = trafoW3.powerTransformerEnd[2]) === null || _q === void 0 ? void 0 : _q.baseVoltage) === null || _r === void 0 ? void 0 : _r.nominalVoltage) === null || _s === void 0 ? void 0 : _s.value;
848
- const w1Sr = (_t = trafoW3 === null || trafoW3 === void 0 ? void 0 : trafoW3.powerTransformerEnd[0]) === null || _t === void 0 ? void 0 : _t.ratedS;
849
- const w2Sr = (_u = trafoW3 === null || trafoW3 === void 0 ? void 0 : trafoW3.powerTransformerEnd[1]) === null || _u === void 0 ? void 0 : _u.ratedS;
850
- const w3Sr = (_v = trafoW3 === null || trafoW3 === void 0 ? void 0 : trafoW3.powerTransformerEnd[2]) === null || _v === void 0 ? void 0 : _v.ratedS;
1015
+ const w1Ur = (_o = (_m = (_l = trafoW3.powerTransformerEnd[0]) === null || _l === void 0 ? void 0 : _l.baseVoltage) === null || _m === void 0 ? void 0 : _m.nominalVoltage) === null || _o === void 0 ? void 0 : _o.value;
1016
+ const w2Ur = (_r = (_q = (_p = trafoW3.powerTransformerEnd[1]) === null || _p === void 0 ? void 0 : _p.baseVoltage) === null || _q === void 0 ? void 0 : _q.nominalVoltage) === null || _r === void 0 ? void 0 : _r.value;
1017
+ const w3Ur = (_u = (_t = (_s = trafoW3.powerTransformerEnd[2]) === null || _s === void 0 ? void 0 : _s.baseVoltage) === null || _t === void 0 ? void 0 : _t.nominalVoltage) === null || _u === void 0 ? void 0 : _u.value;
1018
+ const w1Sr = (_v = trafoW3 === null || trafoW3 === void 0 ? void 0 : trafoW3.powerTransformerEnd[0]) === null || _v === void 0 ? void 0 : _v.ratedS;
1019
+ const w2Sr = (_w = trafoW3 === null || trafoW3 === void 0 ? void 0 : trafoW3.powerTransformerEnd[1]) === null || _w === void 0 ? void 0 : _w.ratedS;
1020
+ const w3Sr = (_x = trafoW3 === null || trafoW3 === void 0 ? void 0 : trafoW3.powerTransformerEnd[2]) === null || _x === void 0 ? void 0 : _x.ratedS;
851
1021
  const minSHvMv = Math.min(w1Sr, w2Sr);
852
1022
  const minSMvLv = Math.min(w2Sr, w3Sr);
853
1023
  const minSLvHv = Math.min(w1Sr, w3Sr);
@@ -970,7 +1140,7 @@ class PowerflowUtil {
970
1140
  continue;
971
1141
  const busFromID = uuidToIndex.get(start.mrid);
972
1142
  const busToID = uuidToIndex.get(ziel.mrid);
973
- const z_base = Math.pow((_x = (_w = seriesCompensator.baseVoltage) === null || _w === void 0 ? void 0 : _w.nominalVoltage) === null || _x === void 0 ? void 0 : _x.value, 2) / snMVA;
1143
+ const z_base = Math.pow((_z = (_y = seriesCompensator.baseVoltage) === null || _y === void 0 ? void 0 : _y.nominalVoltage) === null || _z === void 0 ? void 0 : _z.value, 2) / snMVA;
974
1144
  const rft_pu = seriesCompensator.r / z_base;
975
1145
  const xft_pu = seriesCompensator.x / z_base;
976
1146
  const rtf_pu = seriesCompensator.r / z_base;
@@ -1002,11 +1172,11 @@ class PowerflowUtil {
1002
1172
  const linearShuntCompensators = network.filter(it => it instanceof LinearShuntCompensator_1.LinearShuntCompensator);
1003
1173
  for (const linearShuntCompensator of linearShuntCompensators) {
1004
1174
  /** regelbare Kompensationsanlagen */
1005
- if (!((_y = linearShuntCompensator.regulatingControl) === null || _y === void 0 ? void 0 : _y.targetValue)) {
1175
+ if (!((_0 = linearShuntCompensator.regulatingControl) === null || _0 === void 0 ? void 0 : _0.targetValue)) {
1006
1176
  // console.log(`LinearShuntCompensator ${linearShuntCompensator.getUUID()} kein targetValue`);
1007
1177
  //continue;
1008
1178
  }
1009
- const targetValue = (_z = linearShuntCompensator.regulatingControl) === null || _z === void 0 ? void 0 : _z.targetValue;
1179
+ const targetValue = (_1 = linearShuntCompensator.regulatingControl) === null || _1 === void 0 ? void 0 : _1.targetValue;
1010
1180
  /** bus, name, q_mvar, p_mw, vn_kv, step, max_step, in_service */
1011
1181
  for (const terminalValue of linearShuntCompensator.terminals.values()) {
1012
1182
  const connectedNode = terminalValue.getConnectedNode();
@@ -1359,122 +1529,62 @@ class PowerflowUtil {
1359
1529
  exports.PowerflowUtil = PowerflowUtil;
1360
1530
  PowerflowUtil.scalingFactor = 1;
1361
1531
  PowerflowUtil.scalingFactorRn = 1;
1362
- PowerflowUtil.synchronousMachineUUIDs = ["eafca6d1-4299-48bc-bf20-fe531c25871a", "720354d3-de47-4a0b-b40d-65a996668b88", "bcba52b6-8d94-4393-a6e4-cfbb5714ec78", "46b9e4e5-8a9d-4b82-8c84-428514bd397a", "b317798e-eca3-4a6d-bf26-a7e53cb09297"];
1363
1532
  function getKrInfo(tpLoadsNfeeders) {
1364
- var _a;
1365
- /** Ersatzleistungszahl */
1366
1533
  let krSum = 0;
1367
- let elementWithHighestKr;
1368
- const wardsWithKrOnly = new Array();
1369
- const wardsWithTargetVoltageOnly = new Array();
1370
- const wardsWithTargetVoltageKr = new Array();
1371
- const gensWithKrOnly = new Array();
1372
- const gensWithTargetVoltageOnly = new Array();
1373
- const gensWithTargetVoltageKr = new Array();
1374
- const sgensWithKrOnly = new Array();
1375
- const sgensWithTargetVoltageOnly = new Array();
1376
- const sgensWithTargetVoltageKr = new Array();
1377
1534
  for (const loadsNfeeders of tpLoadsNfeeders.values()) {
1378
1535
  for (const entry of loadsNfeeders.entries()) {
1379
1536
  const key = entry[0];
1380
- if (key.includes('INTEGRALEquivalentInjection')) {
1537
+ if (key.includes('EquivalentInjection')) {
1381
1538
  const valuesArr = entry[1];
1382
1539
  for (let i = 0; i < valuesArr.length; i++) {
1383
1540
  const equivalentInjection = valuesArr[i];
1384
- if (PowerflowUtil.synchronousMachineUUIDs.includes(equivalentInjection.getUUID()))
1541
+ if (!equivalentInjection.normallyInService)
1385
1542
  continue;
1386
1543
  const hasKr = !isNaN(equivalentInjection.kr);
1387
- const hasTargetVoltage = !isNaN(equivalentInjection.regulationTarget);
1388
- // Fall 1
1389
- if (hasKr && hasTargetVoltage) {
1390
- wardsWithTargetVoltageKr.push(equivalentInjection);
1391
- }
1392
- else if (hasTargetVoltage) {
1393
- wardsWithTargetVoltageOnly.push(equivalentInjection);
1394
- }
1395
- else if (hasKr) {
1396
- wardsWithKrOnly.push(equivalentInjection);
1397
- }
1398
1544
  if (!hasKr)
1399
1545
  continue;
1400
1546
  krSum += equivalentInjection.kr;
1401
- if (!elementWithHighestKr) {
1402
- elementWithHighestKr = equivalentInjection;
1403
- }
1404
- else if (elementWithHighestKr.kr < equivalentInjection.kr) {
1405
- elementWithHighestKr = equivalentInjection;
1406
- }
1407
1547
  }
1408
1548
  }
1409
1549
  else if (key.includes('SynchronousMachine')) {
1410
1550
  const valuesArr = entry[1];
1411
1551
  for (let i = 0; i < valuesArr.length; i++) {
1412
1552
  const synchronousMachine = valuesArr[i];
1413
- if (PowerflowUtil.synchronousMachineUUIDs.includes(synchronousMachine.getUUID()))
1414
- continue;
1415
1553
  if (synchronousMachine.normallyInService !== true)
1416
1554
  continue;
1417
- const generatingUnit = synchronousMachine.generatingUnit;
1418
- /** KR-Zahl => (governorSCD * nominalP ) / (100 * 50hz) */
1419
- // const kr = generatingUnit ? ((generatingUnit.governorSCD * generatingUnit.nominalP) / (100 * 50)) : 0;
1420
1555
  const hasKr = !isNaN(synchronousMachine.kr);
1421
- const hasTargetVoltage = !isNaN((_a = synchronousMachine.regulatingControl) === null || _a === void 0 ? void 0 : _a.targetValue);
1422
- // Fall 1
1423
- if (hasKr && hasTargetVoltage) {
1424
- gensWithTargetVoltageKr.push(synchronousMachine);
1425
- }
1426
- else if (hasTargetVoltage) {
1427
- gensWithTargetVoltageOnly.push(synchronousMachine);
1428
- }
1429
- else if (hasKr) {
1430
- gensWithKrOnly.push(synchronousMachine);
1431
- }
1432
1556
  if (!hasKr)
1433
1557
  continue;
1434
1558
  krSum += synchronousMachine.kr;
1435
- if (!elementWithHighestKr) {
1436
- elementWithHighestKr = synchronousMachine;
1437
- }
1438
- else if (elementWithHighestKr.kr < synchronousMachine.kr) {
1439
- elementWithHighestKr = synchronousMachine;
1440
- }
1441
1559
  }
1442
1560
  }
1443
1561
  else if (key.includes('EnergySource')) {
1444
1562
  const valuesArr = entry[1];
1445
1563
  for (let i = 0; i < valuesArr.length; i++) {
1446
1564
  const energySource = valuesArr[i];
1447
- if (PowerflowUtil.synchronousMachineUUIDs.includes(energySource.getUUID()))
1448
- continue;
1449
1565
  if (energySource.normallyInService !== true)
1450
1566
  continue;
1451
- /** KR-Zahl => (governorSCD * nominalP ) / (100 * 50hz) */
1452
1567
  const hasKr = !isNaN(energySource.kr);
1453
1568
  if (!hasKr)
1454
1569
  continue;
1455
- sgensWithKrOnly.push(energySource);
1456
1570
  krSum += energySource.kr;
1457
- if (!elementWithHighestKr) {
1458
- elementWithHighestKr = energySource;
1459
- }
1460
- else if (elementWithHighestKr.kr < energySource.kr) {
1461
- elementWithHighestKr = energySource;
1462
- }
1571
+ }
1572
+ }
1573
+ else if (key.includes('ExternalNetworkInjection')) {
1574
+ const valuesArr = entry[1];
1575
+ for (let i = 0; i < valuesArr.length; i++) {
1576
+ const extNetwork = valuesArr[i];
1577
+ if (extNetwork.normallyInService !== true)
1578
+ continue;
1579
+ const hasKr = !isNaN(extNetwork.governorSCD);
1580
+ if (!hasKr)
1581
+ continue;
1582
+ krSum += extNetwork.governorSCD;
1463
1583
  }
1464
1584
  }
1465
1585
  }
1466
1586
  }
1467
- return {
1468
- krSum,
1469
- elementWithHighestKr,
1470
- wardsWithKrOnly,
1471
- wardsWithTargetVoltageOnly,
1472
- wardsWithTargetVoltageKr,
1473
- gensWithKrOnly,
1474
- gensWithTargetVoltageOnly,
1475
- gensWithTargetVoltageKr,
1476
- sgensWithKrOnly
1477
- };
1587
+ return krSum;
1478
1588
  }
1479
1589
  exports.getKrInfo = getKrInfo;
1480
1590
  //# sourceMappingURL=powerflow.util.js.map