-
Notifications
You must be signed in to change notification settings - Fork 503
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
Create lines more general approach including 3ph params #1403
base: develop
Are you sure you want to change the base?
Conversation
For single line: All params of std_type are now used, regardless of their names. Also it is now possible to pass integers to the function for from_buses and to_buses.
general aaproach now working for multiple lines too
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## develop #1403 +/- ##
===========================================
- Coverage 75.61% 75.59% -0.03%
===========================================
Files 185 185
Lines 21775 21772 -3
===========================================
- Hits 16466 16458 -8
- Misses 5309 5314 +5 ☔ View full report in Codecov by Sentry. |
more elagant solution using check_entry_in_std_type() plus codecov should be happy
@@ -1970,6 +1973,9 @@ def create_lines(net, from_buses, to_buses, length_km, std_type, name=None, inde | |||
create_line(net, "line1", from_bus=0, to_bus=1, length_km=0.1, std_type="NAYY 4x50 SE") | |||
|
|||
""" | |||
from_buses = [from_buses] if type(from_buses) == int else from_buses |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is the reason for this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
User-friedlyness: even if the user only wants to create one line (as one is also a multiple of lines) and only passes the index as an int instead of a list, the function will work.
Also this could be a way to reduce the number of functions the user has to know by possibly replacing create_line().
What do you think about it?
entries["g_us_per_km"] = lineparam["g_us_per_km"] if "g_us_per_km" in lineparam else 0. | ||
if "type" in lineparam: | ||
entries["type"] = lineparam["type"] | ||
lineparam["g_us_per_km"] = lineparam["g_us_per_km"] if "g_us_per_km" in lineparam else 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should not having this kind of logic here. If some types in pp std_type library are missing g_us_per_km, we should change it there (even if to 0).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The user should be responsible for providing the relevant parameters in std_type, I think
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree. The user should be responsible. But the parameter should also be a natural part of the std_type, so the user knows what info needs to be provided in the first place.
Is the std_type going through a similar function as create_empty_network() during creation/loading of the net? Would make sense to add the parameter there, if it's missing.
Hi @elodin , I think it is a good idea to combine functions for 1 line and multiple lines. For the second point, you are right that the std_types should be adjusted accordingly, so that we don't need to have the if-clause in line 1990. I think in this PR it should be adjusted in the std_type library and then the missing parameters should raise an exception. Roman |
This alters the behavior of create_lines() based on the discussion on #1382.
The function will now use whatever parameters are specified in the std_type(s) instead of only using those parameters directly mentioned. It works with either multiple lines and one std_type as well as multiple lines and multiple std_types. Also the bus inputs can now be int, for convenience.
Codecov is showing an error, because the function is shorter regarding the number of code-lines now, which changes the ratio of covered to uncovered lines of the file. All lines of the function are covered by tests, though.
Tests of the changes have been conducted using the following code:
---------- CODE ----------
import pandapower as pp
import pandapower.networks
#Import test network
net = pandapower.networks.mv_oberrhein("generation")
#zero seq. parameters added to only one specific std_type
net.std_types['line']['NA2XS2Y 1x185 RM/25 12/20 kV']['r0_ohm_per_km'] = 123
net.std_types['line']['NA2XS2Y 1x185 RM/25 12/20 kV']['x0_ohm_per_km'] = 321
net.std_types['line']['NA2XS2Y 1x185 RM/25 12/20 kV']['c0_nf_per_km'] = 456
net.std_types['line']['NA2XS2Y 1x185 RM/25 12/20 kV']['g0_us_per_km'] = 654
#Line copied and droped
line = net.line.loc[0]
net.line = net.line.drop(0)
#add one line based on formerly droped line
pp.create_lines(net,
from_buses=line['from_bus'],
to_buses=line['to_bus'],
length_km=line['length_km'],
std_type=line['std_type'],
name=line['name'],
df=line['df'],
parallel=line['parallel'],
in_service=line['in_service'])
#more lines copied and droped
line1 = net.line.loc[38]
net.line = net.line.drop(38)
line2 = net.line.loc[1]
net.line = net.line.drop(1)
#Add multiple lines based on formerly droped lines
pp.create_lines(net,
from_buses=[line2['from_bus'], line1['from_bus']],
to_buses=[line2['to_bus'], line1['to_bus']],
length_km=[line2['length_km'], line1['length_km']],
std_type=[line2['std_type'], line1['std_type']],
name=[line2['name'], line1['name']],
df=[line2['df'], line1['df']],
parallel=[line2['parallel'], line1['parallel']],
in_service=[line2['in_service'], line1['in_service']])
#see if powerflow runs smoothly
pp.runpp(net)
#manually check, if the lines are added correctly
check = net.line