Skip to content
Snippets Groups Projects
Commit b081832a authored by Taeyoung Kim's avatar Taeyoung Kim
Browse files

exporting it to required JSON format of SIEMENS software requested by ARETI is...for now done

parent c0083468
No related branches found
No related tags found
No related merge requests found
{
"computationId": "power_flow_mv_input",
"computationUTC": "2025-04-24T13:12:53",
"mtPowerFlowInput": {
"baseMVA": 100000,
"busses": [
{
"index": 0,
"type": 3,
"name": "busbar-AD102000201CSA-8.4kV",
"activePowerkW": 0.0,
"reactivePowerkVAR": 0.0,
"capacityPu": 0.0,
"voltageArea": 1,
"voltageModulePu": 1.0,
"voltagePhasePu": 0.0,
"nominalVoltagekV": 8.4,
"powerLine": 0,
"voltageMaxPu": 1.1,
"voltageMinPu": 0.9
},
{
"index": 1,
"type": 3,
"name": "busbar-AD102002005NSA-8.4kV",
"activePowerkW": -0.15135,
"reactivePowerkVAR": -0.0454,
"capacityPu": 0.0,
"voltageArea": 1,
"voltageModulePu": 1.0,
"voltagePhasePu": 0.0,
"nominalVoltagekV": 8.4,
"powerLine": 0,
"voltageMaxPu": 1.1,
"voltageMinPu": 0.9
},
{
"index": 2,
"type": 3,
"name": "busbar-AD102000268CSA-8.4kV",
"activePowerkW": -0.13012,
"reactivePowerkVAR": -0.03903,
"capacityPu": 0.0,
"voltageArea": 1,
"voltageModulePu": 1.0,
"voltagePhasePu": 0.0,
"nominalVoltagekV": 8.4,
"powerLine": 0,
"voltageMaxPu": 1.1,
"voltageMinPu": 0.9
},
{
"index": 3,
"type": 1,
"name": "busbar-AD001090024254_AD102425N-8.4kV",
"activePowerkW": 0.0,
"reactivePowerkVAR": 0.0,
"capacityPu": 0.0,
"voltageArea": 1,
"voltageModulePu": 1.0,
"voltagePhasePu": 0.0,
"nominalVoltagekV": 8.4,
"powerLine": 0,
"voltageMaxPu": 1.1,
"voltageMinPu": 0.9
},
{
"index": 4,
"type": 3,
"name": "busbar-AD102005376CSA-8.4kV",
"activePowerkW": -0.18562,
"reactivePowerkVAR": -0.05569,
"capacityPu": 0.0,
"voltageArea": 1,
"voltageModulePu": 1.0,
"voltagePhasePu": 0.0,
"nominalVoltagekV": 8.4,
"powerLine": 0,
"voltageMaxPu": 1.1,
"voltageMinPu": 0.9
},
{
"index": 5,
"type": 3,
"name": "busbar-AD102005220NSA-8.4kV",
"activePowerkW": 0.0,
"reactivePowerkVAR": 0.0,
"capacityPu": 0.0,
"voltageArea": 1,
"voltageModulePu": 1.0,
"voltagePhasePu": 0.0,
"nominalVoltagekV": 8.4,
"powerLine": 0,
"voltageMaxPu": 1.1,
"voltageMinPu": 0.9
},
{
"index": 6,
"type": 3,
"name": "busbar-AD102005097CSA-8.4kV",
"activePowerkW": 0.0,
"reactivePowerkVAR": 0.0,
"capacityPu": 0.0,
"voltageArea": 1,
"voltageModulePu": 1.0,
"voltagePhasePu": 0.0,
"nominalVoltagekV": 8.4,
"powerLine": 0,
"voltageMaxPu": 1.1,
"voltageMinPu": 0.9
},
{
"index": 7,
"type": 3,
"name": "busbar-AD102005377CSA-8.4kV",
"activePowerkW": -0.00293,
"reactivePowerkVAR": -0.00088,
"capacityPu": 0.0,
"voltageArea": 1,
"voltageModulePu": 1.0,
"voltagePhasePu": 0.0,
"nominalVoltagekV": 8.4,
"powerLine": 0,
"voltageMaxPu": 1.1,
"voltageMinPu": 0.9
},
{
"index": 8,
"type": 3,
"name": "busbar-AD102005094CSA-8.4kV",
"activePowerkW": -0.00092,
"reactivePowerkVAR": -0.00028,
"capacityPu": 0.0,
"voltageArea": 1,
"voltageModulePu": 1.0,
"voltagePhasePu": 0.0,
"nominalVoltagekV": 8.4,
"powerLine": 0,
"voltageMaxPu": 1.1,
"voltageMinPu": 0.9
},
{
"index": 9,
"type": 3,
"name": "busbar-AD102005076NSA-8.4kV",
"activePowerkW": -0.17043,
"reactivePowerkVAR": -0.05113,
"capacityPu": 0.0,
"voltageArea": 1,
"voltageModulePu": 1.0,
"voltagePhasePu": 0.0,
"nominalVoltagekV": 8.4,
"powerLine": 0,
"voltageMaxPu": 1.1,
"voltageMinPu": 0.9
},
{
"index": 10,
"type": 3,
"name": "busbar-AD102005297NSA-8.4kV",
"activePowerkW": -0.00108,
"reactivePowerkVAR": -0.00032,
"capacityPu": 0.0,
"voltageArea": 1,
"voltageModulePu": 1.0,
"voltagePhasePu": 0.0,
"nominalVoltagekV": 8.4,
"powerLine": 0,
"voltageMaxPu": 1.1,
"voltageMinPu": 0.9
},
{
"index": 11,
"type": 1,
"name": "busbar-AD001090060253_AD106025N-8.4kV",
"activePowerkW": 0.0,
"reactivePowerkVAR": 0.0,
"capacityPu": 0.0,
"voltageArea": 1,
"voltageModulePu": 1.0,
"voltagePhasePu": 0.0,
"nominalVoltagekV": 8.4,
"powerLine": 0,
"voltageMaxPu": 1.1,
"voltageMinPu": 0.9
},
{
"index": 12,
"type": 3,
"name": "busbar-AD102005015NSA-8.4kV",
"activePowerkW": -0.00293,
"reactivePowerkVAR": -0.00088,
"capacityPu": 0.0,
"voltageArea": 1,
"voltageModulePu": 1.0,
"voltagePhasePu": 0.0,
"nominalVoltagekV": 8.4,
"powerLine": 0,
"voltageMaxPu": 1.1,
"voltageMinPu": 0.9
}
],
"transformers": [],
"branches": [
{
"index": 0,
"busIndexFrom": 1,
"busIndexTo": 0,
"resistancePu": 0.024985827664399093,
"reactancePu": 0.006374007936507936,
"susceptancePu": -9.586133884417508,
"maxCurrentA": 99999,
"lengthkm": 0.1,
"status": 1
},
{
"index": 1,
"busIndexFrom": 2,
"busIndexTo": 1,
"resistancePu": 0.001987670068027211,
"reactancePu": 0.0012259070294784581,
"susceptancePu": -224.78527381415495,
"maxCurrentA": 99999,
"lengthkm": 0.1,
"status": 1
},
{
"index": 2,
"busIndexFrom": 3,
"busIndexTo": 0,
"resistancePu": 0.35875496031746035,
"reactancePu": 0.14917091836734694,
"susceptancePu": -0.9881677227787493,
"maxCurrentA": 99999,
"lengthkm": 0.1,
"status": 1
},
{
"index": 3,
"busIndexFrom": 4,
"busIndexTo": 7,
"resistancePu": 0.018941326530612246,
"reactancePu": 0.007886904761904762,
"susceptancePu": -18.734758814069878,
"maxCurrentA": 99999,
"lengthkm": 0.1,
"status": 1
},
{
"index": 4,
"busIndexFrom": 10,
"busIndexTo": 7,
"resistancePu": 0.019033446712018138,
"reactancePu": 0.0073837868480725625,
"susceptancePu": -17.715742449725074,
"maxCurrentA": 99999,
"lengthkm": 0.1,
"status": 1
},
{
"index": 5,
"busIndexFrom": 12,
"busIndexTo": 5,
"resistancePu": 0.02362528344671202,
"reactancePu": 0.009750566893424037,
"susceptancePu": -14.926753402969592,
"maxCurrentA": 99999,
"lengthkm": 0.1,
"status": 1
},
{
"index": 6,
"busIndexFrom": 10,
"busIndexTo": 5,
"resistancePu": 0.010717828798185941,
"reactancePu": 0.00442531179138322,
"susceptancePu": -32.912899768883726,
"maxCurrentA": 99999,
"lengthkm": 0.1,
"status": 1
},
{
"index": 7,
"busIndexFrom": 6,
"busIndexTo": 9,
"resistancePu": 0.037634637188208614,
"reactancePu": 0.015564767573696145,
"susceptancePu": -9.384122573980571,
"maxCurrentA": 99999,
"lengthkm": 0.1,
"status": 1
},
{
"index": 8,
"busIndexFrom": 9,
"busIndexTo": 5,
"resistancePu": 0.01739654195011338,
"reactancePu": 0.007181831065759637,
"susceptancePu": -20.275151399896846,
"maxCurrentA": 99999,
"lengthkm": 0.1,
"status": 1
},
{
"index": 9,
"busIndexFrom": 4,
"busIndexTo": 11,
"resistancePu": 0.21895549886621313,
"reactancePu": 0.08789328231292518,
"susceptancePu": -1.578919171635558,
"maxCurrentA": 99999,
"lengthkm": 0.1,
"status": 1
},
{
"index": 10,
"busIndexFrom": 12,
"busIndexTo": 8,
"resistancePu": 0.02269699546485261,
"reactancePu": 0.009382086167800454,
"susceptancePu": -15.55444575653805,
"maxCurrentA": 99999,
"lengthkm": 0.1,
"status": 1
}
]
}
}
\ No newline at end of file
......@@ -76,6 +76,6 @@ INFO:cimpy.cimimport:CIM object Line created : 11 times
INFO:cimpy.cimimport:CIM object SubGeographicalRegion created : 2 times
INFO:cimpy.cimimport:CIM object BusbarSection created : 13 times
INFO:cimpy.cimimport:CIM object TopologicalIsland created : 2 times
INFO:cimpy.cimimport:Created totally 275 CIM objects in 0.023180484771728516s
INFO:cimpy.cimimport:Created totally 275 CIM objects in 0.022675514221191406s
......@@ -44,6 +44,7 @@ q = a.makeOneDict()
aa = export.DataFrameToJson(q)
bb= aa.readSampleJson('/home/ubuntu/code/CIM_Read/pyvolt-docker/Data/template') ##due to the path, we need to provide absolute path here
cc= aa.extractKeyFromSampleJson(bb)
dd = aa.feedDataToTemplate(cc)
# Print node voltages
print("Powerflow converged in " + str(num_iter) + " iterations.\n")
......
......@@ -7,6 +7,7 @@ import cimpy
import os
import networkx as nx
import glob
from datetime import datetime
"""
to export read CIM file in pyvolt of ARETI into PandaPower-readble json.
......@@ -331,32 +332,65 @@ class DataFrameToJson(Exporter):
def feedDataToTemplate(self, template):
data = self.dict
for k in template.keys():
if k == 'busses':
# for k in template.keys():
# if k == 'busses':
# new_keys_data = ['bus', 'load']
# new_data= {key: data[key] for key in new_keys_data if key in data}
key_mapping = {'index':'index',
'type':'type',
'name':'name',
'activePowerkW': 'power_real', #from Load
'reactivePowerkVAR' : 'power_imag',
'voltageModulePu': 'voltage_pu',
'nominalVoltagekV': 'base_voltage' }
non_mapped = {'capacityPu', 'voltageArea', 'voltagePhasePu', 'powerLine', 'voltageMaxPu', 'voltageMinPu'}
# key_mapping = {'index':'index',
# 'type':'type',
# 'name':'name',
# 'activePowerkW': 'power_real', #from Load
# 'reactivePowerkVAR' : 'power_imag',
# 'voltageModulePu': 'voltage_pu',
# 'nominalVoltagekV': 'base_voltage' }
# non_mapped = {'capacityPu', 'voltageArea', 'voltagePhasePu', 'powerLine', 'voltageMaxPu', 'voltageMinPu'}
busses=[]
for _, row in data['bus'].iterrows():
entry = {
bus_entry = {
"index": row.idx,
"type": row.type,
"name": row['name'],
"activePowerkW": 0.0, # Default value
"reactivePowerkVAR": 0.0, # Default value
"capacityPu": 0.0, # Default value
"voltageArea": 1, # Example default; adjust if necessary
"voltageModulePu": (row['voltage_pu']),
"activePowerkW": row['power'].real,
"reactivePowerkVAR": row['power'].imag,
"capacityPu": 0.0, # arbitrary since it wasn't given
"voltageArea": 1, # arbitrary since it wasn't given
"voltageModulePu": row['voltage_pu'].real,
"voltagePhasePu": 0.0, # Default value
"nominalVoltagekV": float(row['base_voltage']),
"powerLine": 0, # Default value (adjust if needed)
"voltageMaxPu": 1.1, # Default value
"voltageMinPu": 0.9 # Default value
"powerLine": 0, # arbitrary since it wasn't given
"voltageMaxPu": 1.1, # arbitrary since it wasn't given
"voltageMinPu": 0.9 # arbitrary since it wasn't given
}
busses.append(bus_entry)
branches = []
for _, row in data['branch'].iterrows():
branch_entry = {
"index": row.idx,
"busIndexFrom": row['start_node'],
"busIndexTo": row['end_node'],
"resistancePu": row['r_pu'],
"reactancePu": row['x_pu'],
"susceptancePu": -row['x_pu'] / (np.absolute(row['z_pu'])**2), # B = -X / abs(Z)^2
"maxCurrentA": 99999, # arbitrary since it wasn't given
"lengthkm": 0.1, # arbitrary since it wasn't given
"status": 1 # arbitrary since it wasn't given (0 or 1)
}
branches.append(branch_entry)
result = {
"computationId": "power_flow_mv_input",
"computationUTC": datetime.utcnow().replace(microsecond=0).isoformat(),
"mtPowerFlowInput": {
"baseMVA": 100000,
"busses": busses,
"transformers": [
# You can insert transformer data here if available
],
"branches": branches
}
}
with open('output.json', 'w') as f:
json.dump(result, f, indent=4)
print("JSON export complete!")
......@@ -76,6 +76,6 @@ INFO:cimpy.cimimport:CIM object Line created : 11 times
INFO:cimpy.cimimport:CIM object SubGeographicalRegion created : 2 times
INFO:cimpy.cimimport:CIM object BusbarSection created : 13 times
INFO:cimpy.cimimport:CIM object TopologicalIsland created : 2 times
INFO:cimpy.cimimport:Created totally 275 CIM objects in 0.04271221160888672s
INFO:cimpy.cimimport:Created totally 275 CIM objects in 0.043735504150390625s
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment