calculate_BODF error - ValueError: need at least one array to concatenate

643 views
Skip to first unread message

Jesse Farmer

unread,
Feb 3, 2021, 8:12:37 AM2/3/21
to pypsa
I'm calling the calculate_BODF() method and getting this error.  What populates the passive_branch_components member?  I notice it is empty in my model but yet I have lines and transformers present.

Can someone help?

subnet = psanet.determine_network_topology()
psanet.sub_networks.iloc[1,2].calculate_BODF()

Error:

SubNetwork 1
---------------------------------------------------------------------------
ValueError 
 Traceback (most recent call last) 
<ipython-input-80-d59a9ddc4db2> in <module> 
#print(psanet.passive_branch_components) 
----> 9 psanet.sub_networks.iloc[1,2].calculate_BODF() 
10 #psanet.export_to_csv_folder('c:\\test\\psanet_output\\') 

~\anaconda3\lib\site-packages\pypsa\contingency.py in calculate_BODF(sub_network, skip_pre) 
68 
69 if not skip_pre:
---> 70 calculate_PTDF(sub_network) 
71 
72 num_branches = sub_network.PTDF.shape[0] 

~\anaconda3\lib\site-packages\pypsa\pf.py in calculate_PTDF(sub_network, skip_pre) 
890 
891 if not skip_pre: 
--> 892 calculate_B_H(sub_network) 
893
894 #calculate inverse of B with slack removed 

~\anaconda3\lib\site-packages\pypsa\pf.py in calculate_B_H(sub_network, skip_pre) 
850 
851 #susceptances 
--> 852 b = 1./np.concatenate([(c.df.loc[c.ind, attribute]).values \ 
853 for c in sub_network.iterate_components(network.passive_branch_components)]) 
854

<__array_function__ internals> in concatenate(*args, **kwargs) 

  ValueError: need at least one array to concatenate


Fabian Hofmann

unread,
Feb 4, 2021, 4:43:24 AM2/4/21
to py...@googlegroups.com

Did you check whether there exist branches in your sub(!)network? If psanet.sub_networks.iloc[1,2].branches() is empty, this should be the problem.

--
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.
To view this discussion on the web, visit https://groups.google.com/d/msgid/pypsa/dc3646c4-e749-49ac-b90b-243d03e981cfn%40googlegroups.com.

Jesse Farmer

unread,
Feb 4, 2021, 7:33:33 AM2/4/21
to pypsa
Yes, it is an empty DataFrame.  Only my first subnetwork (0) contains branches.  I do not understand this because I did a .consistency_check() and ran .lpf() on the network.  During the lfp, the following was displayed:

INFO:pypsa.pf:Performing linear load-flow on AC sub-network SubNetwork 0 for snapshot(s) Index(['now'], dtype='object') 
INFO:pypsa.pf:Performing linear load-flow on AC sub-network SubNetwork 1 for snapshot(s) Index(['now'], dtype='object')
 INFO:pypsa.pf:Performing linear load-flow on AC sub-network SubNetwork 2 for snapshot(s) Index(['now'], dtype='object')
 INFO:pypsa.pf:Performing linear load-flow on AC sub-network SubNetwork 3 for snapshot(s) Index(['now'], dtype='object')
 INFO:pypsa.pf:Performing linear load-flow on AC sub-network SubNetwork 4 for snapshot(s) Index(['now'], dtype='object')
 INFO:pypsa.pf:Performing linear load-flow on AC sub-network SubNetwork 5 for snapshot(s) Index(['now'], dtype='object')
 INFO:pypsa.pf:Performing linear load-flow on AC sub-network SubNetwork 6 for snapshot(s) Index(['now'], dtype='object')

According to the documentation, the sub-networks are created automatically, is this correct?  Why is the lfp generating multiple empty subnetworks?

I want to stress that my network case I am using is a real-world grid.

Fabian Hofmann

unread,
Feb 4, 2021, 7:37:24 AM2/4/21
to py...@googlegroups.com

Yes that's correct. Idk how your network looks like, but if the subnetworks has no passive branches (and probably just one bus), then you just skip it in your BODF analysis.

Jesse Farmer

unread,
Feb 4, 2021, 7:40:51 AM2/4/21
to pypsa
OK, so I ran the BODF on only the first subnetwork which has all the branches.  I am still getting two warnings:

\anaconda3\lib\site-packages\scipy\sparse\linalg\dsolve\linsolve.py:318: SparseEfficiencyWarning: splu requires CSC matrix format 

\anaconda3\lib\site-packages\pypsa\contingency.py:77: RuntimeWarning: divide by zero encountered in true_divide

I am able to print the BODF so it would seem the procedure is finishing.

Reply all
Reply to author
Forward
0 new messages