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

NonReturnValveController created, test in pipeflow_internals added and docu updated #118

Open
wants to merge 6 commits into
base: develop
Choose a base branch
from

Conversation

ttrummel
Copy link
Contributor

No description provided.

@codecov
Copy link

codecov bot commented Aug 13, 2020

Codecov Report

Merging #118 (f00af59) into develop (c6e90a7) will increase coverage by 0.21%.
The diff coverage is 95.34%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop     #118      +/-   ##
===========================================
+ Coverage    91.22%   91.43%   +0.21%     
===========================================
  Files           62       61       -1     
  Lines         3303     3294       -9     
===========================================
- Hits          3013     3012       -1     
+ Misses         290      282       -8     
Impacted Files Coverage Δ
.../control/controller/non_return_valve_controller.py 95.23% <95.23%> (ø)
pandapipes/control/__init__.py 100.00% <100.00%> (ø)
...nent_models/abstract_models/node_element_models.py 76.92% <0.00%> (-11.97%) ⬇️
pandapipes/toolbox.py 74.69% <0.00%> (-9.36%) ⬇️
...es/component_models/abstract_models/node_models.py 73.33% <0.00%> (-8.49%) ⬇️
pandapipes/plotting/generic_geodata.py 85.00% <0.00%> (-8.34%) ⬇️
pandapipes/io/io_utils.py 78.08% <0.00%> (-8.13%) ⬇️
pandapipes/io/file_io.py 82.35% <0.00%> (-3.70%) ⬇️
pandapipes/create.py 97.60% <0.00%> (-1.44%) ⬇️
pandapipes/pipeflow.py 90.42% <0.00%> (-0.54%) ⬇️
... and 27 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c6e90a7...f0c7877. Read the comment docs.

Comment on lines 83 to 90
j = 0
for i in self.element_index:
self.v_m_per_s.append(self.net.res_valve.loc[i, "v_mean_m_per_s"])

if self.net.valve.loc[i, "opened"] and self.v_m_per_s[j] < 0:
# use the element indices, where opened = True, otherwise NaN would be in self.v_m_per_s
self.net.valve.loc[i, "opened"] = False
j += 1
Copy link
Collaborator

Choose a reason for hiding this comment

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

This could be solved without a loop which would make it much more performant! Should me something like:
rel_valve = self.net.valve.loc[self.element_index, :]
rel_valve.loc[rel_valve["opened] and rel_valve['v_mean_m_per_s']<0, 'opened] = False

Furthermore, I think, in the initial step you should only do one thing: Open all non return valves. Following reason: Right now I don't think the controller acts the way it should. Imagine following thing. Right now you only consider the valves which are open. But if you run it once, you close all valves which have a v_mean <0. Now you change something in your grid and run it again. Now, the valves you closed in the first run are not considered anymore. However, I think they still should. I would rather do it like this: All valves covered in the element_index should be considered.

Comment on lines 98 to 100
for i in range(len(self.element_index)):
if self.net.valve.loc[self.element_index[i], "opened"] and self.v_m_per_s[i] < 0:
return False
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same as above: converged = np.all(self.net.valve.loc[self.element_index, 'v_mean_m_per_s')>=0)

Comment on lines 111 to 118
j = 0
for i in self.element_index:
self.v_m_per_s.append(self.net.res_valve.loc[i, "v_mean_m_per_s"])

if self.net.valve.loc[i, "opened"] and self.v_m_per_s[j] < 0:
# use the element indices, where opened = True, otherwise NaN would be in self.v_m_per_s
self.net.valve.loc[i, "opened"] = False
j += 1
Copy link
Collaborator

Choose a reason for hiding this comment

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

see above

Copy link
Collaborator

Choose a reason for hiding this comment

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

Another thing what I was thinking about: I would return to the initial state, meaning all valves should have the same values before you used the controller. Meaning, if the user set some non return valves on open and you closed the now, I would in a finalizing step return to a open valve, as only if you really want to use the controller the controller should also have an effect.

# just calling init of the parent
super().__init__(net, in_service=in_service, recycle=recycle, order=order, level=level,
drop_same_existing_ctrl=drop_same_existing_ctrl,
matching_params=matching_params, initial_powerflow=initial_pipeflow,
Copy link
Collaborator

Choose a reason for hiding this comment

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

we changed the attribute from initial_powerflow to initial_run. Please update your pandapower and pandapipes version!

Comment on lines 69 to 71
if set_q_from_cosphi:
logger.error("Parameter set_q_from_cosphi deprecated!")
raise ValueError
Copy link
Collaborator

Choose a reason for hiding this comment

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

We don't have q-values in pandapipes. Q-values stands for reactive power.

Saving the user-defined values, determine valves with negative flow velocities,
set opened to False for these.
"""
pp.pipeflow(self.net, self.kwargs)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Don't do a pipeflow within a controller. Do it with the flag initial_run

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.

3 participants