Improving transmission loss approximation for DC power flow#1409
Improving transmission loss approximation for DC power flow#1409WeiAi-Energy wants to merge 4 commits intoPyPSA:masterfrom
Conversation
|
It's great that this issue is getting some attention, i wanted to work on it myself but unfortunately did not find the time. My main issue outlined in #1320 is that the value of s_nom_max affects the losses and hence the solution. The reason is that the tangents depend on s_nom_max (both slope and offset). This PR improves the situation by using s_nom_opt in suitable situations during iterative expansion modeling. However, in other situations it still relies on s_nom_max, so unfortunately i does not resolve #1320 completly. I think the losses can be made independent of s_nom_max, because the shape of the loss parabola is independent of s_nom_max. In the loss constraint s_nom_max is only really needed to provide an upper bound on the losses (and should only be relevant for the model in negative price hours, if I understand the theory right). So my suggestion is to choose the approximation independently of s_nom_max, only relying on a specified |
I believe that even if we implement the loss approximation using the idea of setting a |
|
Great, I will try to look into it soon! For now, just one question: In your image, it looks like the first tangent cuts through the red line. Shouldn't it be on the outside of the red line? |
Hi @fneum, this modification is intended to generate line segments that minimize approximation error without restricting the segments to be tangents. |
|
Hey @WeiAi-Energy, @lindnemi proposed a secant model in #1495. What do you think of that? Would you see your PR as a third mode or would you say it's unnecessary if we go forward with #1495? |
Hi @fneum, I think the error control proposed in #1495 is a great idea. My only concern is that it still requires a |
I totally agree that it's undesirable to have many inactive constraints. Using |
|
@WeiAi-Energy thanks for the pr. After tackling it partially in #1495 (as it seems), I am wondering if is makes sense to pull this in. the code changes are not a lot and don't seem to be invasive. so I am happy to give this a go and review properly. otherwise we can close this. also tagging @lindnemi |
Changes proposed in this Pull Request
Summary
This PR enhances the transmission loss constraint formulation in PyPSA by:
s_nom_optfrom the last iteration to form a tighter envelope for transmission loss approximation during iterative transmission expansionMathematical Formulation (L2 Piecewise-Linear Approximation)
We model losses with the quadratic function
Choice of$s_{\max}$
In transmission-expansion loops we initialize$s_{\max}$ with $s_{\max}$ as
s_nomin the 1st iteration and then use the previous iteration’s optimized capacitys_nom_opt. This provides a tighter approximation compared to the original implementation of settings_nom_max. Such choice also avoid the requirement of settings_nom_maxfor lines, resolving #1320.Single-segment case (N=1)
We seek the best linear function$a|s|$ over $[0,s_{\max}]$ with zero intercept:
Setting$\partial/\partial a=0$ yields
Multi-segment case (N>1)
Let$0=x_0<x_1<\dots<x_N=s_{\max}$ be uniform breakpoints. On each interval $[x_k,x_{k+1}]$ we fit
To preserve$\ell(0)=0$ , we enforce $b_1=0$ on $[x_0,x_1]$ and minimize $\int_{x_0}^{x_1}(r s^2 - a_1 s)^2 ds$ , which gives
Short Test Summary Info
FAILED test/test_network_index.py::test_get_scenario_empty_components_bug_1402 - AssertionError: assert not True
FAILED test/test_options.py::test_params_optimize - AssertionError: Solver gurobi not installed
FAILED test/test_plot_maps_static.py::test_plot_map_flow - _tkinter.TclError: Can't find a usable tk.tcl in the following directories:
FAILED test/test_statistics_plot.py::test_networks_line_plot[withdrawal] - _tkinter.TclError: Can't find a usable tk.tcl in the following directories:
4 failed, 939 passed, 414 skipped, 4 deselected, 3 warnings in 340.71s (0:05:40)
Example (N=2)
Checklist
docs.docs/release-notes.mdof the upcoming release is included.