# Modify power flow equation in PowerModels.jl

**URL:** <https://discourse.julialang.org/t/modify-power-flow-equation-in-powermodels-jl/15807>\
**Category:** Optimization (Mathematical)\
**Created:** [October 3, 2018, 12:31am UTC](https://discourse.julialang.org/t/modify-power-flow-equation-in-powermodels-jl/15807 "2018-10-03T00:31:49Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rasoul](https://avatars.discourse-cdn.com/v4/letter/r/bb73d2/32.png) [@Rasoul](https://discourse.julialang.org/u/Rasoul)\
**Post date:** [October 3, 2018, 12:31am UTC](https://discourse.julialang.org/t/modify-power-flow-equation-in-powermodels-jl/15807/1 "2018-10-03T00:31:49Z")

</div>

I want to implement a different form of power flow equation, which is based on one trigonometric term instead of two, in PowerModels. In this connection, I have defined new envelopes for trig functions, and could easily implement those in PowerModels by forcing “do nothing” for old variables that had defined for trigonometric functions in wr.jl file. But changing power flow equations seems to be a little trickier since those equations are shared between different Abstract types in “shared.jl” file. Can you please let me know how I can implement new power flow equations for my defined Abstract type without having any effect on other Abstract types? Note that I have defined a new abstract type which is under the QCWRFORM (i.e., “abstract type QCWRTriShiftForm \<: QCWRForm end”). Thanks in advance! any help would be appreciated.

---

<div class="post-metadata">

**Author:** ![ccoffrin](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ccoffrin/32/400_2.png) [@ccoffrin](https://discourse.julialang.org/u/ccoffrin)\
**Post date:** [October 3, 2018, 2:22am UTC](https://discourse.julialang.org/t/modify-power-flow-equation-in-powermodels-jl/15807/2 "2018-10-03T02:22:53Z")

</div>

If your interest is to do rapid exploration of different power flow equations, I would recommend using the _from scratch_ JuMP models in [PowerModelsAnnex - Models](https://github.com/lanl-ansi/PowerModelsAnnex.jl/tree/master/src/model). These functions show you the model that PowerModels builds, for a few popular cases.

If your interest is to contribute a new formulation to PowerModels then we can discuss that in more detail.

Seeing that you mention one trigonometric term, I’ll note that PowerModels includes a non-convex tangent base formulation `ACTPowerModel`, which may provide a helpful example. Concerning one possible convex relaxation of that formulation, one can look to Section 4.2 of [this paper](https://arxiv.org/abs/1504.06770).

---

<div class="post-metadata">

**Author:** ![Rasoul](https://avatars.discourse-cdn.com/v4/letter/r/bb73d2/32.png) [@Rasoul](https://discourse.julialang.org/u/Rasoul)\
**Post date:** [October 3, 2018, 6:53pm UTC](https://discourse.julialang.org/t/modify-power-flow-equation-in-powermodels-jl/15807/3 "2018-10-03T18:53:59Z")

</div>

Thanks for the response! I think it is better to implement the new formulation in PowerModlsAnnex first, to see if it can improve the current approach then I can generalize it by contributing to PowerModels.
