Skip to content

Commit

Permalink
Merge branch 'main' into feature/columnar-data-support-no-id-field
Browse files Browse the repository at this point in the history
  • Loading branch information
Jerry-Jinfeng-Guo authored Oct 31, 2024
2 parents e29748e + 6d10b80 commit a8ea09d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
17 changes: 17 additions & 0 deletions docs/user_manual/calculations.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,23 @@ 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}
\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` 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 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

Two types of power flow algorithms are implemented in power-grid-model; iterative algorithms (Newton-Raphson / Iterative current) and linear algorithms (Linear / Linear current).
Expand Down
6 changes: 3 additions & 3 deletions src/power_grid_model/core/buffer_handling.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)


Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit a8ea09d

Please sign in to comment.