pandapower example on pypsa

264 views
Skip to first unread message

André Lisboa

unread,
Nov 4, 2022, 1:58:23 PM11/4/22
to pypsa


Hi guys,

I am new to PyPSA and was trying to run this simple pandapower example: https://github.com/e2nIEE/pandapower/blob/master/tutorials/opf_basic.ipynb, with DC OPF. Could you help me figure out whats is wrong?

Snippet:
def run_pypsa():
   
    network = pypsa.Network()

    #create buses
    network.add("Bus", name="bus1", v_nom=220,control="P",v_mag_pu_max=1.2,v_mag_pu_min=0.8,carrier="DC")
    network.add("Bus", name="bus2", v_nom=110,control="P",v_mag_pu_max=1.2,v_mag_pu_min=0.8,carrier="DC")
    network.add("Bus", name="bus3", v_nom=110,control="P",v_mag_pu_max=1.2,v_mag_pu_min=0.8,carrier="DC")
    network.add("Bus", name="bus4", v_nom=110,control="P",v_mag_pu_max=1.2,v_mag_pu_min=0.8,carrier="DC")

    #create 220/110 kV transformer
    network.add("Transformer", name="MV-LV trafo", bus0="bus1", bus1="bus2",type="100 MVA 220/110 kV")
   
    # add line
    network.add("Line", name="LV cable 1",type="149-AL1/24-ST1A 110.0",bus0="bus2", bus1="bus3",length=70)
    network.add("Line", name="LV cable 2",type="149-AL1/24-ST1A 110.0",bus0="bus3", bus1="bus4",length=50)
    network.add("Line", name="LV cable 3",type="149-AL1/24-ST1A 110.0",bus0="bus4", bus1="bus2",length=40)
 
    #add a load at bus 1
    network.add("Load", name="load1",bus="bus2",p_set=60)
    network.add("Load", name="load2",bus="bus3",p_set=70)
    network.add("Load", name="load3",bus="bus4",p_set=10)
           
    #add external grid
    network.add("Generator", name="External Grid", bus="bus1", control="Slack",marginal_cost=10)

    network.add("Generator", name="Generator1",bus="bus3",p_nom_min=0,p_nom_max=80,control="P",marginal_cost=10)
    network.add("Generator", name="Generator2",bus="bus4",p_nom_min=0,p_nom_max=100,control="P",marginal_cost=10)
    
    network.lopf()  

Max Parzen

unread,
Nov 20, 2022, 5:09:15 AM11/20/22
to pypsa
Hi Andre,

Very cool example. What is your error? Maybe the lines are reaching the limit? What is the s_nom?
Maybe also loose a bit the v_mag_pu constraints & generators constraints to see if the network would solve otherwise.

Best wishes,
Max

Paul K

unread,
Dec 6, 2022, 4:04:15 AM12/6/22
to pypsa
If you choose a line type from the library, do you have to set the s_nom as well? Thought it might be a type variable. But for my example the s_nom always seems to be 0?

best regards
Paul

Fabian Neumann

unread,
Dec 13, 2022, 9:32:46 AM12/13/22
to pypsa
Set num_parallel of the line, then hit n.calculate_dependent_values() to fill in the corresponding electrical characteristics for the given number of parallel lines.

Reply all
Reply to author
Forward
0 new messages