Implement pressure loss calculation via pandapipes - #181
Draft
jnettels wants to merge 3 commits into
Draft
Conversation
As an alternative to the existing internal pressure loss calculation, the pandapipes module can be used to calculate the pressure loss in a pipe
Coverage reportClick to see where and how coverage changed
This report was generated by python-coverage-comment-action |
||||||||||||||||||||||||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I have added a new argument
calculationtodelta_p()and the functions which call it (v_max_secant(),v_max_bisection()) which allows using apandapipessimulation to calculate pressure losses in a pipe as an alternative to the existing internal implementation.Update documentationFixes #162
Context
dhnx includes the
precalc_hydraulicmodule which allows converting the resulting capacity of each pipe into norm diameters.For this, a pressure loss calculation is needed, for which
precalc_hydraulicprovides an internal solution.In my workflows, I design a network with dhnx and then run a simulation of temperature and pressure distribution with pandapipes to check if the network is valid in terms of pressure drops and velocities. In some rare edge cases I noticed differences where dhnx was supposed to only give e.g. a maximum of 100 Pa/m pressure losses in any given pipe segment but pandapipes showed slightly larger values.
Implementing a new function
delta_p_pandapipes()inprecalc_hydraulicsolved the issue because it synchronizes the precalculation and post-processing. It allows calculating the pressure loss with pandapipes instead of using the internal implementation.Independently, in #162 another user describes issues with the internal implementation. Instead of trying to fix/improve the internal pressure loss equations I think it is the best approach to use external modules that have already put more resources into this problem. (Nevertheless: pandapipes itself offers different friction models, and judging by the issues there, not all of them are perfect, either.)
Considerations / feedback
pandapipesis significantly slower than the internal method. But in the context of a long optimization procedure that is fineprecalc_hydraulicis briefly mentioned in the documentation, but not actually documented. Thus there was no documentation to updatepandapipesto the deps in testenv intox.ini. But I am unsure if this is the best way and I need feedback. I guess I could create a new entry of optional dependencies inpyproject.tomlinstead, but that feels like overkill to me. If a user knows they want to use pandapipes alongside dhnx, they can just install it.pandapipesrequirespandapower, which is currently still restricted topandas<3.0. Thus with this change all of our tests here will run withpandas 2.x, which is not ideal, I think. But I see no way around that. Thoughts?