Hi Gorazd, Thanks again for your work on this and for offering to contribute to MATPOWER.
There are several possible levels of integration with MATPOWER, two in particular that make sense to me. One is, as you appear to be suggesting, adding a new function that calls runpf() as a subroutine that takes additional inputs as you defined. The other option is to integrate it more tightly by implementing tap-changing and phase-shifter control as an option to runpf(). While this may be more intuitive for the user, it does require updating the MATPOWER case format to include the necessary data (control modes and regulation targets etc.) and it requires more work on your part. So, I agree we go with the first approach at least for now. We may consider the tighter integration at some point in the future. Below are some specific comments, questions, and responses to your questions: Have you thought of a name for the function? How about something like runpf_w_taps()? I think what you propose for the tap changer and phase shifter input data seems fine for a very basic implementation. You may also want to include upper and lower limits on the tap ratio and phase shift angles. You might also want the number of tap positions, if you are considering discrete tap change values, though let’s limit it now to what you need for what you’ve implemented. I think you do want to allow the user to pass in a MATPOWER options struct too. Simply returning the power flow results struct should be fine. So, something like … results = runpf_w_taps(mpc, tap_changer_data, phase_shifter_data, mpopt); We should avoid unnecessary code duplication, so yes, it would make sense to adapt things to work with MATPOWER’s own code for building Ybus and Jacobian matrices. Feel free to set up your initial pull request with what you have now, but we will want to adapt it to use the MATPOWER versions before the pull request is merged. The pull request just gives us a place to discuss concrete changes to the code. And, yes, for robustness, all functions that access the columns of the bus, branch, etc. matrices, should always use the constants defined by idx_bus, idx_branch, etc, rather than the literal column numbers. Thanks again, Ray > On May 31, 2017, at 4:37 AM, Bone, Gorazd <gorazd.b...@fe.uni-lj.si> wrote: > > Hi. > > The transformer calculation is finished and I want to discuss what the flow > of the function should be like (inputs and outputs, etc.) and how the > function is constructed. > > Firstly, I should elaborate what the method does. It calculates the values > for the taps and the phases of transformers according to the desired values > for their regulation (taps control nodal voltage of some desired node, while > phaseshifters control line power through their line). The transformers are > connected at the first node of the line in the data. Calculations are carried > out externally to the load flow calculation; the method looks at the results, > calculates the first order sensitivity and minimizes the missmatch by Newton > search. Unless I have made some mistakes the routine should work with correct > first order sensitivities even when a tap changer and phase shifter are being > calculated in the same branch. > > So, I have made it so that the case must be defined (e.g. case118) and the > desired regulated tap and phase changers are then calculated(the ones that > are not specifically marked as "to be calculated" will remain fixed). I was > thinking to have the input in the form of (casedata_name_of_file , > tap_changer_data, phase_shifter_data). Where the phase_shifter_data has the > form [branches_of_transformers , controlled_nodes , desired_voltages] and the > phase_shifter_data has the form [branches_of_phaseshifters , desired_power > flows]. > > The output I think may be only the struct results, since the taps and phases > are readily accessible in results.branch. > > The routine uses several additional functions, some of them are probably > already present in the MatPower as it is (e.g. I calculated my own Ybus and > my own Jacobian for power-missmatch-LoadFlow). I wonder if it I should adapt > to work with provided MatPower capabilities or can I keep it the way it is. > > I also read the dev guide > https://github.com/MATPOWER/matpower/blob/master/docs/MATPOWER-dev-guide.md > <https://github.com/MATPOWER/matpower/blob/master/docs/MATPOWER-dev-guide.md> > and it recommends to work with idx_branch and idx_bus etc. I wonder if all > the functions must follow that form? > Also, should the inputs and outputs be in some other form? > > Regards, Gorazd > > > > > Od: bounce-121560494-78535...@list.cornell.edu > <mailto:bounce-121560494-78535...@list.cornell.edu> > [bounce-121560494-78535...@list.cornell.edu > <mailto:bounce-121560494-78535...@list.cornell.edu>] v imenu Ray Zimmerman > [r...@cornell.edu <mailto:r...@cornell.edu>] > Poslano: 25. maj 2017 22:08 > Za: MATPOWER Developer List > Zadeva: Re: Calculation of Taps and Phases of Transformers > > Hi Gorzad, > > Sorry for my slow response, swamped with other things, as usual … and thanks > for your offer to contribute your work. > > The best way to contribute this is to follow the instructions > <https://github.com/MATPOWER/matpower/blob/master/CONTRIBUTING.md#submitting-additions-or-modifications-to-the-code> > from the MATPOWER Contributors Guide > <https://github.com/MATPOWER/matpower/blob/master/CONTRIBUTING.md> on GitHub. > This gives us a simple way for us to review your code, suggest or offer > changes to it, and finally merge it into MATPOWER when it is ready. > > Please let me know if you need any help with getting things set up to make > your pull request. > > By the way, for those of you considering having your contributions included > in MATPOWER, it is always a good idea to discuss the idea here on the > MATPOWER-DEV-L list early on in the process so that it can benefit from early > feedback. It’s not problem if you don’t, it just has the potential of saving > some effort on your part in the long run. > > Thanks again, > > Ray > > > >> On May 22, 2017, at 3:22 AM, Bone, Gorazd <gorazd.b...@fe.uni-lj.si >> <mailto:gorazd.b...@fe.uni-lj.si>> wrote: >> >> Hi all, >> >> We're finishing up a routine that can calculate the Taps and Phases of >> Transformers in an OPF - like manner and would like to inquire what are the >> policies regarding contributions to MatPower. >> >> regards, Gorazd