Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add creation of Y matrix from Network, multiphase breakout #3

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

zzink731
Copy link

Hi Nick,

Went ahead and added that Y matrix creation you alluded to. I also started to separate single-phase and multi-phase. I didn't touch single_phase_model.jl, however, even though it calls for net::Network{MultiPhase}

Cheers,
Zephyr

Copy link
Owner

@NLaws NLaws left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for doing this! Totally understand if you don't want to address the requested changes if this meets your needs. The high level summary is that the Y builder should live in CommonOPF.

@@ -0,0 +1,62 @@


function admittance_builder(net::Network{MultiPhase})
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method should live in CommonOPF (according to the design patterns I'm working within, not something I expect you to be aware of). This way there is no need to add the Graphs library to BIM.jl and the admittance_builder is available to any package that uses CommonOPF.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good! Happy to take direction on specifically where you want these things to live.

function admittance_builder(net::Network{MultiPhase})

order = bfs_order(net)
Y = zeros(ComplexF64, (3*length(order), 3*length(order)))
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be best to use a sparse matrix for Y (because it is mostly zeros and gets big for real networks).

non_zero_indices = findall(non_zero_rows) .|> x -> x[1]
Y = Y[non_zero_indices, non_zero_indices]

return Y
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how do you track the order of Y's indices? One thought I had on this would be to use an AxisArray, which can be indexed on strings (i.e. bus names) but then Y cannot be a sparse matrix. So I think that it's best to use Y like OpenDSS does, with a "node order" vector of strings as a companion to Y. Then one could index into Y like

bus_to_node = Dict(b => i for (b, i) in enumerate(node_order))
Y[bus_to_node["bus1"], bus_to_node["bus2"]]

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking that bfs order of busses does provide an unambiguous general format but wouldn't give an indication of which phases exist at each node. So, yes, I like node_order. Do you like the OpenDSS format? e.g. 650.1, 650.2, 650.3...

end

function bfs_order(net::Network{MultiPhase})
b = Graphs.bfs_tree(net.graph, 1)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is the 1 argument here?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the source vertex to make the tree from. I am assuming the source of net.graph is always at 1 but perhaps this is not the case?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's unclear because we use MetaGraphsNext to make the net.graph. I think that the following extension will meet the need:

Graphs.bfs_tree(net::Network, bus::String) = Graphs.bfs_tree(net.graph, net.graph[][:bus_int_map][bus])

I did something like this here, which is a good spot to put the bfs_tree extension.


for edge in CommonOPF.edges(net)

z_prim = CommonOPF.zij(edge[1],edge[2],net)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not use CommonOPF.yij (and skip the inverse step) ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh nice, I didn't see this in that commit you sent over and my local CommonOPF I was looking in was not current. I definitely will.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

v0.4.3 of CommonOPF was just released today (went through some issues with the OpenDSSDirect dependency).



include("single_phase_model.jl")
include("single_phase_fpl_model.jl")
include("multi_phase_fpl_model.jl")
include("utilities.jl")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need for this new file include (see comment about putting the Y builder in CommonOPF).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants