From 1467817915c703b4771aa076533b8992198d2e61 Mon Sep 17 00:00:00 2001 From: Nitish Bharambe Date: Wed, 30 Oct 2024 12:12:01 +0100 Subject: [PATCH 1/8] add branch calc explaination Signed-off-by: Nitish Bharambe --- docs/user_manual/calculations.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/docs/user_manual/calculations.md b/docs/user_manual/calculations.md index 9e0ac0071..c17dfcd5c 100644 --- a/docs/user_manual/calculations.md +++ b/docs/user_manual/calculations.md @@ -125,6 +125,26 @@ Output: - Node voltage magnitude and angle - Current flowing through branches and fault. +#### Common calculations + +Power flowing through a branch is calculated by voltage and current for any type of calculations in the following way: + +$$ + \begin{eqnarray} + S_{branch-side} = \sqrt{3} \cdot U_{node-line-line-side} \cdot I_{branch-side} + \end{eqnarray} +$$ + +These quantities are in complex form. Hence, they can be constructed by PGM output attributes. + +For $U$ of nodes, `u`, `u_angle` can be used. + +For $I$ of branches, `i_side`, `p_side`, `q_side` can be used: $I = i_{side} \angle \arctan(q_{side} / p_{side})$. + +The `side` here can be `from`, `to` for `Branch`-es, `1`, `2`, `3` for `Branch3`-s. + +Also, $ U_{node-line-neural} = U_{node-line-line} / \sqrt{3}$. Check [Node Steady State Output](components.md#steady-state-output) to find out which quantity is used in your calculation. + ### Power flow algorithms Two types of power flow algorithms are implemented in power-grid-model; iterative algorithms (Newton-Raphson / Iterative current) and linear algorithms (Linear / Linear current). From 93fab49a1d70c6cb50e0732ef2cc59887fd3b4d3 Mon Sep 17 00:00:00 2001 From: Nitish Bharambe Date: Wed, 30 Oct 2024 12:19:10 +0100 Subject: [PATCH 2/8] fix i_angle Signed-off-by: Nitish Bharambe --- docs/user_manual/calculations.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/user_manual/calculations.md b/docs/user_manual/calculations.md index c17dfcd5c..3c2e37cb1 100644 --- a/docs/user_manual/calculations.md +++ b/docs/user_manual/calculations.md @@ -131,15 +131,15 @@ Power flowing through a branch is calculated by voltage and current for any type $$ \begin{eqnarray} - S_{branch-side} = \sqrt{3} \cdot U_{node-line-line-side} \cdot I_{branch-side} + \underline{S_{branch-side}} = \sqrt{3} \cdot \underline{U_{node-line-line-side}} \cdot \underline{I_{branch-side}} \end{eqnarray} $$ -These quantities are in complex form. Hence, they can be constructed by PGM output attributes. +These quantities are in complex form. Hence, they can be constructed by PGM output attributes in the following way: For $U$ of nodes, `u`, `u_angle` can be used. -For $I$ of branches, `i_side`, `p_side`, `q_side` can be used: $I = i_{side} \angle \arctan(q_{side} / p_{side})$. +For $I$ of branches, `i_side`, `p_side`, `q_side` can be used: $\underline{I} = i_{side} \angle \arctan((p_{side} + j \cdot q_{side}) / \underline{U})$. The `side` here can be `from`, `to` for `Branch`-es, `1`, `2`, `3` for `Branch3`-s. From bbb319306f372e7a2349e8e808afa4d1dad9c142 Mon Sep 17 00:00:00 2001 From: Nitish Bharambe Date: Wed, 30 Oct 2024 12:19:56 +0100 Subject: [PATCH 3/8] fix i_angle 2 Signed-off-by: Nitish Bharambe --- docs/user_manual/calculations.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/user_manual/calculations.md b/docs/user_manual/calculations.md index 3c2e37cb1..85b8e6e4c 100644 --- a/docs/user_manual/calculations.md +++ b/docs/user_manual/calculations.md @@ -137,9 +137,9 @@ $$ These quantities are in complex form. Hence, they can be constructed by PGM output attributes in the following way: -For $U$ of nodes, `u`, `u_angle` can be used. +For $\udnerline{U}$ of nodes, `u`, `u_angle` can be used. -For $I$ of branches, `i_side`, `p_side`, `q_side` can be used: $\underline{I} = i_{side} \angle \arctan((p_{side} + j \cdot q_{side}) / \underline{U})$. +For $\udnerline{I}$ of branches, `i_side`, `p_side`, `q_side` can be used: $\underline{I} = i_{side} \angle \arctan((p_{side} + j \cdot q_{side}) / \underline{U})$. The `side` here can be `from`, `to` for `Branch`-es, `1`, `2`, `3` for `Branch3`-s. From 25f98047547e27e7c3073ff249a6b183d9f6866c Mon Sep 17 00:00:00 2001 From: Nitish Bharambe Date: Wed, 30 Oct 2024 12:34:16 +0100 Subject: [PATCH 4/8] fix error msg of validator Signed-off-by: Nitish Bharambe --- src/power_grid_model/core/buffer_handling.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/power_grid_model/core/buffer_handling.py b/src/power_grid_model/core/buffer_handling.py index 9a7c7e32a..8cbe2081a 100644 --- a/src/power_grid_model/core/buffer_handling.py +++ b/src/power_grid_model/core/buffer_handling.py @@ -85,7 +85,7 @@ def _get_raw_data_view(data: np.ndarray, dtype: np.dtype) -> VoidPtr: a raw view on the data set. """ if data.dtype != dtype: - warnings.warn("Data type does not match schema. {VALIDATOR_MSG}", DeprecationWarning) + warnings.warn(f"Data type does not match schema. {VALIDATOR_MSG}", DeprecationWarning) return np.ascontiguousarray(data, dtype=dtype).ctypes.data_as(VoidPtr) @@ -170,7 +170,7 @@ def _get_uniform_buffer_properties( columns = None else: if not sub_data: - raise ValueError("Empty columnar buffer is ambiguous.{VALIDATOR_MSG}") + raise ValueError(f"Empty columnar buffer is ambiguous.{VALIDATOR_MSG}") attribute, attribute_data = next(iter(sub_data.items())) actual_ndim = attribute_data.ndim - schema.dtype[attribute].ndim shape = attribute_data.shape[:actual_ndim] @@ -237,7 +237,7 @@ def _get_sparse_buffer_properties( shape: tuple[int, ...] = contents.shape else: if not contents: - raise ValueError("Empty columnar buffer is ambiguous. {VALIDATOR_MSG}") + raise ValueError(f"Empty columnar buffer is ambiguous. {VALIDATOR_MSG}") attribute_data = next(iter(contents.values())) shape = attribute_data.shape[:ndim] columns = list(contents) From 8646fda68b1044e98f3d300d94770c56a54fd26a Mon Sep 17 00:00:00 2001 From: Nitish Bharambe Date: Wed, 30 Oct 2024 12:38:49 +0100 Subject: [PATCH 5/8] change eqn Signed-off-by: Nitish Bharambe --- docs/user_manual/calculations.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/user_manual/calculations.md b/docs/user_manual/calculations.md index 85b8e6e4c..4d1eadecd 100644 --- a/docs/user_manual/calculations.md +++ b/docs/user_manual/calculations.md @@ -137,9 +137,9 @@ $$ These quantities are in complex form. Hence, they can be constructed by PGM output attributes in the following way: -For $\udnerline{U}$ of nodes, `u`, `u_angle` can be used. +For $\underline{U}$ of nodes, `u`, `u_angle` can be used. -For $\udnerline{I}$ of branches, `i_side`, `p_side`, `q_side` can be used: $\underline{I} = i_{side} \angle \arctan((p_{side} + j \cdot q_{side}) / \underline{U})$. +For $\underline{I}$ of branches, `i_side`, `p_side`, `q_side` can be used: $\underline{I} = i_{side} \angle \arctan(((p_{side} + j \cdot q_{side}) / \underline{U})*)$. The `side` here can be `from`, `to` for `Branch`-es, `1`, `2`, `3` for `Branch3`-s. From 97e81933d4e3b06670c60dc9ddda3c38702bd3a1 Mon Sep 17 00:00:00 2001 From: Nitish Bharambe Date: Wed, 30 Oct 2024 14:02:00 +0100 Subject: [PATCH 6/8] address comments Signed-off-by: Nitish Bharambe --- docs/user_manual/calculations.md | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/docs/user_manual/calculations.md b/docs/user_manual/calculations.md index 4d1eadecd..cbdc48f2b 100644 --- a/docs/user_manual/calculations.md +++ b/docs/user_manual/calculations.md @@ -131,19 +131,16 @@ Power flowing through a branch is calculated by voltage and current for any type $$ \begin{eqnarray} - \underline{S_{branch-side}} = \sqrt{3} \cdot \underline{U_{node-line-line-side}} \cdot \underline{I_{branch-side}} + \underline{S_{branch-side}} = \sqrt{3} \cdot \underline{U_{LL-side-node}} \cdot \underline{I_{branch-side}} \end{eqnarray} $$ These quantities are in complex form. Hence, they can be constructed by PGM output attributes in the following way: -For $\underline{U}$ of nodes, `u`, `u_angle` can be used. +* For $\underline{U}$ of nodes, `u` is the magnitude and `u_angle` is the angle. Also the line to neutral voltage can be converted into line to line voltage by $ U_{LN} = U_{LL} / \sqrt{3}$. Check [Node Steady State Output](components.md#steady-state-output) to find out which quantity is relevant in your calculation. -For $\underline{I}$ of branches, `i_side`, `p_side`, `q_side` can be used: $\underline{I} = i_{side} \angle \arctan(((p_{side} + j \cdot q_{side}) / \underline{U})*)$. - -The `side` here can be `from`, `to` for `Branch`-es, `1`, `2`, `3` for `Branch3`-s. - -Also, $ U_{node-line-neural} = U_{node-line-line} / \sqrt{3}$. Check [Node Steady State Output](components.md#steady-state-output) to find out which quantity is used in your calculation. +* For $\underline{I}$ of branches, `i_side` is the maginute and angle can be found from `p_side` and `q_side` by: $\arctan(\frac{P_{side} + j \cdot Q_{side}}{\underline{U}})^{*}$. +The `side` here can be `from`, `to` for `Branch`es, `1`, `2`, `3` for `Branch3`s. ### Power flow algorithms From 07284018be92b3a76bc360be97447ef1c2d53edf Mon Sep 17 00:00:00 2001 From: Nitish Bharambe <78108900+nitbharambe@users.noreply.github.com> Date: Wed, 30 Oct 2024 14:03:34 +0100 Subject: [PATCH 7/8] Update src/power_grid_model/core/buffer_handling.py Co-authored-by: Martijn Govers Signed-off-by: Nitish Bharambe <78108900+nitbharambe@users.noreply.github.com> --- src/power_grid_model/core/buffer_handling.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/power_grid_model/core/buffer_handling.py b/src/power_grid_model/core/buffer_handling.py index 8cbe2081a..fd0c1e39b 100644 --- a/src/power_grid_model/core/buffer_handling.py +++ b/src/power_grid_model/core/buffer_handling.py @@ -170,7 +170,7 @@ def _get_uniform_buffer_properties( columns = None else: if not sub_data: - raise ValueError(f"Empty columnar buffer is ambiguous.{VALIDATOR_MSG}") + raise ValueError(f"Empty columnar buffer is ambiguous. {VALIDATOR_MSG}") attribute, attribute_data = next(iter(sub_data.items())) actual_ndim = attribute_data.ndim - schema.dtype[attribute].ndim shape = attribute_data.shape[:actual_ndim] From 8fa8629205fe1e728e16b5227e179fa26709fd26 Mon Sep 17 00:00:00 2001 From: Nitish Bharambe <78108900+nitbharambe@users.noreply.github.com> Date: Wed, 30 Oct 2024 15:09:27 +0100 Subject: [PATCH 8/8] Apply suggestions from code review Co-authored-by: Martijn Govers Signed-off-by: Nitish Bharambe <78108900+nitbharambe@users.noreply.github.com> --- docs/user_manual/calculations.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/user_manual/calculations.md b/docs/user_manual/calculations.md index cbdc48f2b..958607396 100644 --- a/docs/user_manual/calculations.md +++ b/docs/user_manual/calculations.md @@ -139,8 +139,8 @@ These quantities are in complex form. Hence, they can be constructed by PGM outp * For $\underline{U}$ of nodes, `u` is the magnitude and `u_angle` is the angle. Also the line to neutral voltage can be converted into line to line voltage by $ U_{LN} = U_{LL} / \sqrt{3}$. Check [Node Steady State Output](components.md#steady-state-output) to find out which quantity is relevant in your calculation. -* For $\underline{I}$ of branches, `i_side` is the maginute and angle can be found from `p_side` and `q_side` by: $\arctan(\frac{P_{side} + j \cdot Q_{side}}{\underline{U}})^{*}$. -The `side` here can be `from`, `to` for `Branch`es, `1`, `2`, `3` for `Branch3`s. +* For $\underline{I}$ of branches, `i_side` is the magnitude. Its angle can be found from `p_side` and `q_side` by: $\arctan(\frac{P_{side} + j \cdot Q_{side}}{\underline{U}})^{*}$. +The `side` here can be `from`, `to` for {hoverxreftooltip}`user_manual/components:Branch`es, `1`, `2`, `3` for {hoverxreftooltip}`user_manual/components:Branch3`s. ### Power flow algorithms