-
Notifications
You must be signed in to change notification settings - Fork 29
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
Hydraulics linearization #285
Hydraulics linearization #285
Conversation
@@ -4280,7 +4435,7 @@ def PumpCostRule(b, l1, l2): | |||
* mh.p_rhog | |||
* 1e3 # convert the kUSD/kWh to kUSD/Ws | |||
* sum( | |||
b.v_PumpHead[l1, l2, t] | |||
1609 |
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.
Please consider exploring alternative methods to linearize the pump cost function in the co-optimize approach rather than replacing the pump head with constant values. Co-optimize is designed to incorporate pump cost within the objective function, accounting for elevation changes and frictional losses. Using a constant pump head overlooks the critical impact of elevation changes and frictional losses in the network on the objective cost. Without variable pump heads, hydraulic post-processing might suffice instead of co-optimize.
Additionally, it's important to note that we cannot use a constant number from a small case study and generalize it to all other case studies.
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.
Thanks for the comment and feedback! The pricing for the variable component of pump now has the pump head variable. The linearization is now done based on the flow. Say grid size for flow is 10000 bbl/day. Then for 0<flow<10000, the flow is assumed to be constant 0, for flow 10000<flow<20000, the flow is assumed to be constant 10000, and so on.
pareto/strategic_water_management/strategic_produced_water_optimization.py
Outdated
Show resolved
Hide resolved
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #285 +/- ##
==========================================
+ Coverage 88.37% 88.64% +0.26%
==========================================
Files 23 23
Lines 5059 5203 +144
==========================================
+ Hits 4471 4612 +141
- Misses 588 591 +3 ☔ View full report in Codecov by Sentry. |
pareto/strategic_water_management/strategic_produced_water_optimization.py
Outdated
Show resolved
Hide resolved
pareto/strategic_water_management/strategic_produced_water_optimization.py
Outdated
Show resolved
Hide resolved
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.
Nice work - looks good for the most part to me, but a bit of cleanup is needed.
Also, would it be possible to develop a Jupyter notebook tutorial showing/explaining how to use the Hydraulics.co_optimize_linearized
method? That would be a nice touch if wouldn't take too long to put together.
pareto/strategic_water_management/strategic_produced_water_optimization.py
Outdated
Show resolved
Hide resolved
pareto/strategic_water_management/strategic_produced_water_optimization.py
Outdated
Show resolved
Hide resolved
pareto/strategic_water_management/strategic_produced_water_optimization.py
Outdated
Show resolved
Hide resolved
pareto/strategic_water_management/strategic_produced_water_optimization.py
Outdated
Show resolved
Hide resolved
pareto/strategic_water_management/strategic_produced_water_optimization.py
Outdated
Show resolved
Hide resolved
Co-authored-by: Travis Arnold <[email protected]>
Co-authored-by: Travis Arnold <[email protected]>
Co-authored-by: Travis Arnold <[email protected]>
…imization.py Co-authored-by: Travis Arnold <[email protected]>
…imization.py Co-authored-by: Travis Arnold <[email protected]>
…imization.py Co-authored-by: Travis Arnold <[email protected]>
Binary variable description update
error message for solver not found.
…imization.py Co-authored-by: Travis Arnold <[email protected]>
Uncommented y_BeneficialReuse fixing
Removed opt solver and made it to the solver specified by the user
Added jupyter notebook to test hydraulics co_optimize and post_process.
…lics, support all hydraulics options in report generation
…hkt/project-pareto into Hydraulics_linearization
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.
Great work!
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.
Approved. Great work!
Fixes/Addresses/Summary/Motivation:
Co-optimize method had two non-linearities: Hazen-William Rule and Pump Cost rule. These non-linearities result in a very slow computation by non-linear solvers. We make piecewise linearization of the term flow raised to the power 1.85 in the RHS of Hazen-Williams equation. In the LHS of the same equation, we model the product of pressure change and diameter selection binaries with a set of linear constraints. Finally, for the variable (electricity) component of the pump cost is modeled by compartmentalization of the volumetric flow through the pump. Thus, the formulation is completely linearized.
Changes proposed in this PR:
the term in RHS of Hazen-William equation is modeled using a piecewise linear function.
Brief idea: Consider a non-linear function of one variable with any point on the curve represented by (x, f(x)). We can fit a piecewise linear function as an approximation to f(x). Say the new point (x, y) is an approximation of the original point as shown in the figure below. Then, it is possible to model this (x, y) as a system of linear constraints. This can be done by introducing logarithmic number of binary variables as the number of sections of piecewise linear graph. Refer section 2 of https://link.springer.com/chapter/10.1007/978-1-4614-1927-3_10
For LHS of the Hazen-William equation, we have a multiplication of non-negative continuous variable(pressure drop) and binary variable(diameter choice). When we have such a product, it can be modeled using linear constraints. For example, consider a term P = Hz where H is a non-negative continuous variable with upper bound M and z is a binary variable. Then we can model P using
a) P>=0 b) P<=H c) P<=Mz d) P>= H - M(1-z)
In Pump cost rule, the variable cost is modeled using comparmentalization of flow. For example, say the section which the flow is in is 20000bbl/day to 30000bbl/day. Then the variable cost would be modeled as vρgΔH*20000
The documentation of hydraulics is updated to reflect the proposed changes in the formulation.
Node pressure rule for co_optimize method is corrected in the documentation. Earlier it had flipped sign of pump head and valve release.
Legal Acknowledgement
By contributing to this software project, I agree to the following terms and conditions for my
contribution:
at the top level of this directory.
rights to intellectual property that includes these contributions, I represent that I have
received permission to make contributions and grant the required license on behalf of that
employer.