BODF

233 views
Skip to first unread message

Elias Althoff

unread,
Jan 13, 2022, 5:04:07 AM1/13/22
to pypsa
Dear all,

I am having trouble with the BODF function. Are there by any chance any examples on that? So far I am followin these  explications: https://pypsa.readthedocs.io/en/latest/contingency_analysis.html

I am running my initial LOPF so that I have my power flow solution. After that, I add these lines, as described in the readthedocs:

network.determine_network_topology()
a = pypsa.SubNetwork(network)
a.calculate_BODF()
print(a.BODF)

It does start the function, but it breaks while finding the slack bus:

line 774, in find_slack_bus
    sub_network.slack_bus = sub_network.buses_i()[0]
with the error: IndexError: index 0 is out of bounds for axis 0 with size 0

Do I have to manually set the slack bus somehow? I dont see any input parameters for that function, so I dont really know what I could do differently. When I check the output of the Power Flow, the Slack buses are defined correctly.

As always, help is much appreciated :)

Best wishes,
Elias

 

Elias Althoff

unread,
Jan 13, 2022, 5:56:06 AM1/13/22
to pypsa
I think I can answer my own question... I dont need this part:  network.determine_network_topology()

When Im not using it I still get an error (RuntimeError: Factor is exactly singular), which is probably caused by the fact that some nodes in my network are connected to only one other node, so that a failure of the connecting line would result in an error.

So I would have to delete all my nodes, that are connected to only one other node, to check the BODF. Can somebody confirm this?

Fabian Neumann

unread,
Jan 13, 2022, 8:51:24 AM1/13/22
to py...@googlegroups.com
Hi Elias,

no, the n.determine_network_topology() is sensible to have executed. It
will do that within n.lopf() as well.

You will have to calculate the BODF for each SubNetwork separately:

n.determine_network_topology()
for sn in network.sub_networks.obj:
sn.calculate_BODF()
print(sn.BODF) # or store it somewhere.

You can exclude line outages (if you do SCLOPF) e.g. for the cases you
describe with the branch_outages argument:

https://pypsa.readthedocs.io/en/latest/api_reference.html#pypsa.Network.sclopf

No need, to delete anything.

Best wishes,

Fabian N

On 13.01.22 11:56, Elias Althoff wrote:
> I think I can answer my own question... I dont need this part:
> network.determine_network_topology()
>
> When Im not using it I still get an error (RuntimeError: Factor is
> exactly singular), which is probably caused by the fact that some nodes
> in my network are connected to only one other node, so that a failure of
> the connecting line would result in an error.
>
> So I would have to delete all my nodes, that are connected to only one
> other node, to check the BODF. Can somebody confirm this?
>
> Elias Althoff schrieb am Donnerstag, 13. Januar 2022 um 11:04:07 UTC+1:
>
> Dear all,
>
> I am having trouble with the BODF function. Are there by any chance
> any examples on that? So far I am followin these  explications:
> https://pypsa.readthedocs.io/en/latest/contingency_analysis.html
> <https://pypsa.readthedocs.io/en/latest/contingency_analysis.html>
> https://pypsa.readthedocs.io/en/latest/api_reference.html#pypsa.SubNetwork.calculate_BODF
> <https://pypsa.readthedocs.io/en/latest/api_reference.html#pypsa.SubNetwork.calculate_BODF>
>
> I am running my initial LOPF so that I have my power flow solution.
> After that, I add these lines, as described in the readthedocs:
>
> network.determine_network_topology()
> a = pypsa.SubNetwork(network)
> a.calculate_BODF()
> print(a.BODF)
>
> It does start the function, but it breaks while finding the slack bus:
>
> line 774, in find_slack_bus
>     sub_network.slack_bus = sub_network.buses_i()[0]
> with the error: IndexError: index 0 is out of bounds for axis 0 with
> size 0
>
> Do I have to manually set the slack bus somehow? I dont see any
> input parameters for that function, so I dont really know what I
> could do differently. When I check the output of the Power Flow, the
> Slack buses are defined correctly.
>
> As always, help is much appreciated :)
>
> Best wishes,
> Elias
>
> --
> You received this message because you are subscribed to the Google
> Groups "pypsa" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to pypsa+un...@googlegroups.com
> <mailto:pypsa+un...@googlegroups.com>.
> To view this discussion on the web, visit
> https://groups.google.com/d/msgid/pypsa/821fdd67-73a0-45fe-b6d9-f481e6024c7fn%40googlegroups.com
> <https://groups.google.com/d/msgid/pypsa/821fdd67-73a0-45fe-b6d9-f481e6024c7fn%40googlegroups.com?utm_medium=email&utm_source=footer>.

--
Dr.-Ing.
Fabian Neumann (he/him)
Postdoctoral Researcher

Department of Digital Transformation in Energy Systems
Institute of Energy Technology
Technische Universität Berlin

Group website: https://tub-ensys.github.io
Personal website: https://neumann.fyi

Zoom: https://tu-berlin.zoom.us/my/fneum
Schedule Meeting: https://calendly.com/fneum

Visitor Address:
Einsteinufer 25 (TA 8)
10587 Berlin

My working hours may not be your working hours. Do not feel pressure to
reply to this email outside your working hours.

Elias Althoff

unread,
Jan 13, 2022, 9:45:56 AM1/13/22
to pypsa
Hi Fabian, thank you for your answer. I am one step closer.

I get through the first loop of that for loop and I can save the results. But when it comes to the second SubNetwork, it breaks when solving "line 852, in calculate_B_H
 b = 1./np.concatenate([(c.df.loc[c.ind, attribute]).values" with the error: "ValueError: need at least one array to concatenate"

This is the same error I am getting when trying to use the sclopf, which is also on my to-do list.

Do you have an Idea what the problem might be?

I was thinking that it might be based in the fact that I did not specify any DC buses. So the AC-SubNetwork can be solved, but the DC-SubNetwork is causing problems. Is that a realistic approach? I did specify DC-Links connecting AC-Buses..

Fabian Neumann

unread,
Jan 13, 2022, 12:44:11 PM1/13/22
to py...@googlegroups.com
Maybe a one node sub_network?

Never tested contingency analysis on DC sub_networks.

But connecting DC links to AC buses (when they are not meshed) is ok.
> <https://groups.google.com/d/msgid/pypsa/821fdd67-73a0-45fe-b6d9-f481e6024c7fn%40googlegroups.com?utm_medium=email&utm_source=footer
> <https://groups.google.com/d/msgid/pypsa/821fdd67-73a0-45fe-b6d9-f481e6024c7fn%40googlegroups.com?utm_medium=email&utm_source=footer>>.
>
>
> --
> Dr.-Ing.
> Fabian Neumann (he/him)
> Postdoctoral Researcher
>
> Department of Digital Transformation in Energy Systems
> Institute of Energy Technology
> Technische Universität Berlin
>
> Group website: https://tub-ensys.github.io
> <https://tub-ensys.github.io>
> Personal website: https://neumann.fyi <https://neumann.fyi>
>
> Zoom: https://tu-berlin.zoom.us/my/fneum
> <https://tu-berlin.zoom.us/my/fneum>
> Schedule Meeting: https://calendly.com/fneum
> <https://calendly.com/fneum>
>
> Visitor Address:
> Einsteinufer 25 (TA 8)
> 10587 Berlin
>
> My working hours may not be your working hours. Do not feel pressure to
> reply to this email outside your working hours.
>
> --
> You received this message because you are subscribed to the Google
> Groups "pypsa" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to pypsa+un...@googlegroups.com
> <mailto:pypsa+un...@googlegroups.com>.
> To view this discussion on the web, visit
> https://groups.google.com/d/msgid/pypsa/778ddde6-0c15-4233-8922-f5ee9978584an%40googlegroups.com
> <https://groups.google.com/d/msgid/pypsa/778ddde6-0c15-4233-8922-f5ee9978584an%40googlegroups.com?utm_medium=email&utm_source=footer>.

Elias Althoff

unread,
Jan 13, 2022, 1:18:11 PM1/13/22
to pypsa
ahhhh yes. Its the two nodes in sweden and norway which I added and connected via a simple DC-Link to simulate import. Somehow the system doesnt really like my DC-Links. I added them in a csv file name links, connected the buses and added p_nom, p_min_pu and p_max_pu. That should be enough, right? The Power Flow works fine. Maybe I need to add them as normal AC-Lines to get the sclopf to work... Or do you have an Idea how to make the system see it as only one network instead of 3 subnetworks?

Thanks for the continuous help!

Fabian Neumann

unread,
Jan 17, 2022, 4:15:52 AM1/17/22
to Elias Althoff, pypsa
Hi Elias,

yes, definitely enough information for the links. Wouldn't necessarily
add as AC lines. But if that line connects an otherwise isolated bus
then this can work (no KVL, just KCL). Just be sure to exclude this line
from the outage lines (otherwise infeasible).

Best wishes,

Fabian
> <https://groups.google.com/d/msgid/pypsa/778ddde6-0c15-4233-8922-f5ee9978584an%40googlegroups.com?utm_medium=email&utm_source=footer
> <https://groups.google.com/d/msgid/pypsa/778ddde6-0c15-4233-8922-f5ee9978584an%40googlegroups.com?utm_medium=email&utm_source=footer>>.
>
>
> --
> Dr.-Ing.
> Fabian Neumann (he/him)
> Postdoctoral Researcher
>
> Department of Digital Transformation in Energy Systems
> Institute of Energy Technology
> Technische Universität Berlin
>
> Group website: https://tub-ensys.github.io
> <https://tub-ensys.github.io>
> Personal website: https://neumann.fyi <https://neumann.fyi>
>
> Zoom: https://tu-berlin.zoom.us/my/fneum
> <https://tu-berlin.zoom.us/my/fneum>
> Schedule Meeting: https://calendly.com/fneum
> <https://calendly.com/fneum>
>
> Visitor Address:
> Einsteinufer 25 (TA 8)
> 10587 Berlin
>
> My working hours may not be your working hours. Do not feel pressure to
> reply to this email outside your working hours.
>
> --
> You received this message because you are subscribed to the Google
> Groups "pypsa" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to pypsa+un...@googlegroups.com
> <mailto:pypsa+un...@googlegroups.com>.
> To view this discussion on the web, visit
> https://groups.google.com/d/msgid/pypsa/37e27863-ce47-4a62-b445-bc2f35b49a68n%40googlegroups.com
> <https://groups.google.com/d/msgid/pypsa/37e27863-ce47-4a62-b445-bc2f35b49a68n%40googlegroups.com?utm_medium=email&utm_source=footer>.
Reply all
Reply to author
Forward
0 new messages