Untitled
import pypowsybl as pp import pandas as pd net = pp.network.create_empty() #Substations net.create_substations(id=["S1G","S2C1","S3C2","S4C3"]) #Voltage levels voltage_levels = pd.DataFrame.from_records(index='id', data=[ {'substation_id': 'S1G', 'id': 'VLG_1', 'topology_kind': 'BUS_BREAKER', 'nominal_v': 115}, {'substation_id': 'S1G', 'id': 'VLG_2', 'topology_kind': 'BUS_BREAKER', 'nominal_v': 400}, {'substation_id': 'S1G', 'id': 'VLG_3', 'topology_kind': 'BUS_BREAKER', 'nominal_v': 400}, {'substation_id': 'S2C1', 'id': 'VLC1_1', 'topology_kind': 'BUS_BREAKER', 'nominal_v': 25}, {'substation_id': 'S2C1', 'id': 'VLC1_2', 'topology_kind': 'BUS_BREAKER', 'nominal_v': 200}, {'substation_id': 'S2C1', 'id': 'VLC1_3', 'topology_kind': 'BUS_BREAKER', 'nominal_v': 400}, {'substation_id': 'S3C2', 'id': 'VLC2_1', 'topology_kind': 'BUS_BREAKER', 'nominal_v': 25}, {'substation_id': 'S3C2', 'id': 'VLC2_2', 'topology_kind': 'BUS_BREAKER', 'nominal_v': 400}, {'substation_id': 'S4C3', 'id': 'VLC3_1', 'topology_kind': 'BUS_BREAKER', 'nominal_v': 400}, {'substation_id': 'S4C3', 'id': 'VLC3_2', 'topology_kind': 'BUS_BREAKER', 'nominal_v': 25} ]) net.create_voltage_levels(voltage_levels) #Buses net.create_buses(id=["B1","B2","B3","B4","B5","B6","B7","B8","B9","B10"], voltage_level_id=["VLG_1","VLG_2","VLG_3","VLC1_1","VLC1_2","VLC1_3","VLC2_1","VLC2_2","VLC3_1","VLC3_2"]) #Lines net.create_lines(id=["LineC1","LineC2", "LineG2", "LineC3","LineC1C3"], voltage_level1_id=["VLG_3","VLG_3","VLG_2", "VLG_3","VLC1_3"], bus1_id=["B3","B3","B2","B3","B6"], voltage_level2_id=["VLC1_3","VLC2_2","VLG_3","VLC3_1","VLC3_1"], bus2_id=["B6","B8","B3","B9","B9"], b1=[0,0,0,0,0], b2=[0,0,0,0,0], g1=[0,0,0,0,0], g2=[0,0,0,0,0], r=[0.5,0.5,0.5,0.5,0.5], x=[10,10,10,10,10]) #Transformers net.create_3_windings_transformers(id="TC1", rated_u0 = 400, voltage_level1_id="VLC1_1", bus1_id="B4", voltage_level2_id="VLC1_2", bus2_id="B5", voltage_level3_id="VLC1_3", bus3_id="B6", b1=1e-6, g1=1e-6, r1=0.5, x1=10, rated_u1=25, b2=1e-6, g2=1e-6, r2=0.5, x2=10, rated_u2=200, b3=1e-6, g3=1e-6, r3=0.5, x3=10, rated_u3=400) net.create_2_windings_transformers(id="TC3", voltage_level1_id="VLC3_1", bus1_id="B9", voltage_level2_id="VLC3_2", bus2_id="B10", b=1e-6, g=1e-6, r=0.5, x=10, rated_u1=400, rated_u2=25) net.create_2_windings_transformers(id="TC2", voltage_level1_id="VLC2_1", bus1_id="B7", voltage_level2_id="VLC2_2", bus2_id="B8", b=1e-6, g=1e-6, r=0.5, x=10, rated_u1=25, rated_u2=400) net.create_2_windings_transformers(id="TG1", voltage_level1_id="VLG_1", bus1_id="B1", voltage_level2_id="VLG_3", bus2_id="B3", b=1e-6, g=1e-6, r=0.5, x=10, rated_u1=115, rated_u2=400) #Phase tap changers #TG transformer ''' ptc_df = pd.DataFrame.from_records( index='id', columns=['id', 'target_deadband', 'regulation_mode', 'low_tap', 'tap', 'side'], data=[('TC3', 2, 'CURRENT_LIMITER', 0, 1, "THREE")]) steps_df = pd.DataFrame.from_records( index='id', columns=['id', 'b', 'g', 'r', 'x', 'rho', 'alpha'], data=[('TC3', 2, 2, 1, -1, 0.5, 2), ('TC3', 2, 2, 1, -1, 0.4, 2), ('TC3', 2, 2, 1, -1, 0.5, 2)]) net.create_phase_tap_changers(ptc_df, steps_df) ''' #TC2 transformer ''' ptc_df = pd.DataFrame.from_records(a index='id', columns=['id', 'target_deadband', 'regulation_mode', 'low_tap', 'tap'], data=[('TC2', 2, 'CURRENT_LIMITER', 0, 1)]) steps_df = pd.DataFrame.from_records( index='id', columns=['id', 'b', 'g', 'r', 'x', 'rho', 'alpha'], data=[('TC2', 2, 2, 1, 1, 0.5, 0.1), ('TC2', 2, 2, 1, 1, 0.4, 0.2), ('TC2', 2, 2, 1, 1, 0.5, 0.1)]) net.create_phase_tap_changers(ptc_df, steps_df) ''' #Generators generators = pd.DataFrame.from_records(index='id', data=[ {'id': 'Gen1S', 'voltage_level_id': 'VLG_1', 'bus_id': 'B1', 'energy_source': 'SOLAR', 'min_p': 0, 'max_p': 300, 'target_p': 200, 'voltage_regulator_on': True, 'target_v': 115}, {'id': 'Gen2W', 'voltage_level_id': 'VLG_1', 'bus_id': 'B1', 'energy_source': 'WIND', 'min_p': 0, 'max_p': 300, 'target_p': 250, 'voltage_regulator_on': True, 'target_v': 115}, {'id': 'Gen3G', 'voltage_level_id': 'VLG_2', 'bus_id': 'B2', 'energy_source': 'THERMAL', 'min_p': 0, 'max_p': 450, 'target_p': 350, 'voltage_regulator_on': True, 'target_v': 400}, {'id': 'Gen4C', 'voltage_level_id': 'VLG_2', 'bus_id': 'B2', 'energy_source': 'THERMAL', 'min_p': 600, 'max_p': 1200, 'target_p': 1000, 'voltage_regulator_on': True, 'target_v': 400} ]) net.create_generators(generators) #Loads loads = pd.DataFrame.from_records(index='id', data=[ {'id': 'Load_C1', 'voltage_level_id': 'VLC1_1', 'bus_id': 'B4', 'p0':700, 'q0':50}, {'id': 'Load_In', 'voltage_level_id': 'VLC1_2', 'bus_id': 'B5', 'p0':300, 'q0':20}, {'id': 'Load_C2', 'voltage_level_id': 'VLC2_1', 'bus_id': 'B7', 'p0':500, 'q0':40}, {'id': 'Load_C3', 'voltage_level_id': 'VLC3_2', 'bus_id': 'B10', 'p0':5, 'q0':5} ]) net.create_loads(loads) #Run a loadflow result = pp.loadflow.run_ac(net) print(result) print(net.get_substations()) print(net.get_generators()) print(net.get_loads()) print(net.get_lines()) net.write_network_area_diagram('diagram.svg')
Leave a Comment