Untitled

mail@pastecode.io avatar
unknown
python
a month ago
1.2 kB
3
Indexable
Never
import pypowsybl as pp
import pandas as pd

net = pp.network.create_empty()

net.create_substations(id="S1")

voltage_levels = pd.DataFrame.from_records(index='id', data=[
    {'substation_id': 'S1', 'id': 'VL1', 'topology_kind': 'BUS_BREAKER', 'nominal_v': 400},
    {'substation_id': 'S1', 'id': 'VL2', 'topology_kind': 'BUS_BREAKER', 'nominal_v': 25}])
net.create_voltage_levels(voltage_levels)

net.create_buses(id=["B1","B2"], voltage_level_id=["VL1","VL2"])

net.create_2_windings_transformers(id="T1", voltage_level1_id="VL1", bus1_id="B1",
                                             voltage_level2_id="VL2", bus2_id="B2",
                                             b=1e-6, g=1e-6, r=0.5, x=10, rated_u1=400, rated_u2=25)

net.create_generators(id="Gen1", voltage_level_id="VL1", bus_id="B1", min_p=0, max_p=100,
                      target_p=10, voltage_regulator_on=True, target_v=400)

net.create_loads(id="Load1", voltage_level_id="VL2", bus_id="B2", p0=10, q0=0)

result = pp.loadflow.run_ac(net)
print(result)
print(net.get_substations())
print(net.get_generators())
print(net.get_loads())

net.write_network_area_diagram('net2_diagram.svg')
Leave a Comment