This is an introduction into the usage of the pandapower optimal power flow. It shows how to set the constraints and the cost factors into the pandapower element tables. 该notebook主要是介绍pandapower最优潮流计算的使用。它展示了如何将约束和成本因子设置进入pandapower的元件列表。 We use the following four bus example network for this tutorial: 我们的教程使用下图的4节点示例网络: We first create this network in pandapower: 我们首先在pandapower中创建网络: We specify the same costs for the power at the external grid and all generators to minimize the overall power feed in. This equals an overall loss minimization: 我们特别指出外部电网和所有的发电机具有相同的电能成本,并最小化总的电能供应。这相当于整体网损的最小化。 pp.create_polynomial_cost()为元件的多项式成本创建一个条目,返回已经创建的成本条目的ID We run an OPF: 我们运行一个最优潮流计算: let"s check the results: 让我们看下结果: Since all costs were specified the same, the OPF minimizes overall power generation, which is equal to a loss minimization in the network. The loads at buses 3 and 4 are supplied by generators at the same bus, the load at Bus 2 is provided by a combination of the other generators so that the power transmission leads to minimal losses. 因为所有的成本都看成相同的,最优潮流计算最小化总的发电量后的结果和网络的损失最小化结果相同。母线3和母线4的负荷由各自母线上的发电机供应,而母线2上的负荷是由其他发电机联合供应因此电能的传输达到了最小的损失。 Let"s now assign individual costs to each generator. 现在给每台发电机赋予各自的发电成本。 We assign a cost of 10 ct/kW for the external grid, 15 ct/kw for the generator g0 and 12 ct/kw for generator g1: 我们给外部电网赋予10ct/kW的成本,发电机g0赋予15ct/kW的成本以及发电机g1赋予12ct/kW的成本: And now run an OPF: 现在运行最优潮流运算: We can see that all active power is provided by the external grid. This makes sense, because the external grid has the lowest cost of all generators and we did not define any constraints. 我们可以看出所有的有功都是由外部电网提供。这是合理的,因为外部电网拥有最低的发电成本,而且我们没有定义任何的约束。 The dispatch costs are given in net.res_cost: dispatch成本可以由net.res_cost给出: Since all active power comes from the external grid and subsequently flows through the transformer, the transformer is overloaded with a loading of about 145%: 因为所有的有功功率都来自与外部电网,接着潮流流过了变压器,变压器过载运行,负载约为145%: We now limit the transformer loading to 50%: 现在设置变压器的负载约束为50%: (the max_loading_percent parameter can also be specified directly when creating the transformer) and run the OPF: (max_loading_percent参数也可以在创建变压器时直接指定) 然后运行最优潮流计算: We can see that the transformer complies with the maximum loading: 我们可以看到变压器以最大负荷运行: And power generation is now split between the external grid and generator 1 (which is the second cheapest generation unit): 现在有功功率的产生主要来自于外部电网和发电机g1(g1是发电成本第二低的发电机组) This comes of course with an increase in dispatch costs: 这样的结果就导致了dispatch成本的上升: We now look at the line loadings: 我们现在关注于线路负载: and run the OPF with a 50% loading constraint: 然后在线路50%负载水平条件下运行最优潮流计算: Now the line loading constraint is complied with: 现在线路的负载约束编译后: And all generators are involved in supplying the loads: 所有的发电机都开始供应负荷: This of course comes with a once again rising dispatch cost: 这导致了dispatch成本又一次的提升: Finally, we have a look at the bus voltage: 最后,我们在关注一下电压: and constrain it: 加以约束,并运行最优潮流计算: We can see that all voltages are within the voltage band: And all generators are once again involved in supplying the loads: 所有的发电机又一次都参与了负荷的供应: This of course comes once again with rising dispatch costs: 又一次导致了dipatch成本的提升: pandapower also provides the possibility of running a DC Optimal Power Flow: pandapower也可以提供了运行直流最优潮流计算的可能: Since voltage magnitudes are not included in the DC power flow formulation, voltage constraints canot be considered in the DC OPF: 因为直流潮流公式中不考虑电压幅值,所以在直流潮流计算中并不考虑电压约束: Line and transformer loading limits are however complied with: 线路和变压器负载限制编译后为: As are generator limits: 发电机限制为: The cost function is the same for the linearized OPF as for the non-linear one: 线性最优潮流计算和非线性潮流计算的成本函数一致: Piecewise linear cost functions The OPF also offers us piecewise linear cost functions. Let us first check the actual cost function setup: 分段线性成本函数 最优潮流九三也提供了分段线性成本函数。我们首先看一下实际的成本函数设置: An element can either have polynomial costs or piecewise linear costs at the same time. So let us first delete the polynomial costs in order to avoid confusion and errors: 一个元件的成本函数只能是多项式或者分段线性中的一种。因此,让我们首先删除多项式成本函数,以免产生困惑和错误: The results above have been produced with polynomial cost functions, that were linear. Let"s try to reproduce the results using piecewise linear cost functions. Note: The cost functions need to have the same gradient! 上面的计算结果是采用多项式成本函数计算的,是线性的。现在我们使用分段线性函数重新计算结果。 需要强调的是:成本函数需要拥有相同的梯度! What we forgot is that the piecewise linear function should be defined for the whole range of the generator. The range is determined by p_max and p_min. Let"s check: 额...错误信息是ValueError: Cost function must be defined for whole power range of the generator,让我们检查一下: We try again: 我们再试一下: An external grid usually has no operational limits, but this is a problem for the OPF: 外部电网通常没有运行限制,但这是OPF的一个问题: So we set imaginary constraints, that we can choose very broad: 因此,我们虚构一个约束,将这个约束的范围设置的很广: Let us check the results from the previous OPF again! 让我们再看一下之前的OPF运行结果: We run the same OPF now with different cost function setup. We should get the exact same results: 我们运行了相同的OPF但是采用不同的成本函数,我们应该获得完全相同的结果: