Skip to content

Commit b00c7c0

Browse files
committed
Merge branch 'main' into feature/Cleanup-import-statements2
2 parents ebeddc7 + 9cf8afb commit b00c7c0

File tree

101 files changed

+2805
-175
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

101 files changed

+2805
-175
lines changed

code_generation/data/attribute_classes/input.json

+45
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,51 @@
127127
}
128128
]
129129
},
130+
{
131+
"name": "AsymLineInput",
132+
"base": "BranchInput",
133+
"attributes": [
134+
{
135+
"data_type": "double",
136+
"names": [
137+
"r_aa",
138+
"r_ba",
139+
"r_bb",
140+
"r_ca",
141+
"r_cb",
142+
"r_cc",
143+
"r_na",
144+
"r_nb",
145+
"r_nc",
146+
"r_nn",
147+
"x_aa",
148+
"x_ba",
149+
"x_bb",
150+
"x_ca",
151+
"x_cb",
152+
"x_cc",
153+
"x_na",
154+
"x_nb",
155+
"x_nc",
156+
"x_nn",
157+
"c_aa",
158+
"c_ba",
159+
"c_bb",
160+
"c_ca",
161+
"c_cb",
162+
"c_cc",
163+
"c0",
164+
"c1"
165+
],
166+
"description": "Lower triangle matrix values for R, X and C matrices"
167+
},
168+
{
169+
"data_type": "double",
170+
"names": "i_n",
171+
"description": "rated current"
172+
}
173+
]
174+
},
130175
{
131176
"name": "GenericBranchInput",
132177
"base": "BranchInput",

code_generation/data/dataset_class_maps/dataset_definitions.json

+10-2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
"names": ["line"],
1313
"class_name": "LineInput"
1414
},
15+
{
16+
"names": ["asym_line"],
17+
"class_name": "AsymLineInput"
18+
},
1519
{
1620
"names": ["link"],
1721
"class_name": "LinkInput"
@@ -71,7 +75,7 @@
7175
"class_name": "NodeOutput"
7276
},
7377
{
74-
"names": ["line", "link", "transformer", "generic_branch"],
78+
"names": ["line", "link", "transformer", "generic_branch", "asym_line"],
7579
"class_name": "BranchOutput"
7680
},
7781
{
@@ -116,6 +120,10 @@
116120
"names": ["line"],
117121
"class_name": "BranchUpdate"
118122
},
123+
{
124+
"names": ["asym_line"],
125+
"class_name": "BranchUpdate"
126+
},
119127
{
120128
"names": ["link"],
121129
"class_name": "BranchUpdate"
@@ -171,7 +179,7 @@
171179
"class_name": "NodeShortCircuitOutput"
172180
},
173181
{
174-
"names": ["line", "link", "transformer"],
182+
"names": ["line", "link", "transformer", "asym_line"],
175183
"class_name": "BranchShortCircuitOutput"
176184
},
177185
{

docs/advanced_documentation/build-guide.md

+6-1
Original file line numberDiff line numberDiff line change
@@ -477,11 +477,16 @@ The `pip install .` part of the command installs the complete package from scrat
477477
478478
The C API documentation is generated using [Doxygen](https://www.doxygen.nl). If you do not have Doxygen installed, it can also be temporarily bypassed by commenting out the `breathe` settings in `docs/conf.py`.
479479
480-
The documentation can be built with the following commands, resulting in html files of the webpages which can be found in `docs/_build/html` directory.
480+
The documentation can be built with the following commands, resulting in HTML files of the webpages which can be found in `docs/_build/html` directory.
481481
482482
```shell
483483
cd docs/doxygen
484484
doxygen
485485
cd ..
486486
sphinx-build -b html . _build/html
487487
```
488+
489+
```{note}
490+
The user documentation generated by [Sphinx](https://github.com/sphinx-doc/sphinx) only contains the C API documentation.
491+
Doxygen, however, also builds the documentation for the Power Grid Model core implementation, which can be accessed after building the documentation locally via `docs/_build/html/index.html`.
492+
```

docs/advanced_documentation/core-design.md

+5
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,8 @@ graph TD
4848
4949
ComponentsOutput -->|Output| Output(Output data)
5050
```
51+
52+
## Detailed Power Grid Model core design
53+
54+
The sheer size and complexity of the Power Grid Model core implementation makes it hard to generate an up-to-date and comprehensive graph of its design.
55+
For a full overview of the core, it is recommended to build and access the Power Grid Model core documentation by following the steps in the [build guide](./build-guide.md#documentation).
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
<!--
2+
SPDX-FileCopyrightText: Contributors to the Power Grid Model project <powergridmodel@lfenergy.org>
3+
4+
SPDX-License-Identifier: MPL-2.0
5+
-->
6+
7+
# High-level design
8+
9+
The power-grid-model follows a typical dynamic/shared library approach, in which the user
10+
interface is separated from the core implementation using a strict system boundary. Depending
11+
on the use case and programming language used by the user to call the interface, the user can
12+
opt to interface with the C API in different ways.
13+
14+
## Layers of abstraction
15+
16+
For the sake of explanation, we consider the
17+
following layers of abstraction, in increasing order of ease-of-use and abstraction.
18+
19+
* Raw system interface
20+
* System symbols only
21+
* Everything is handled by the user, including which symbols are supported
22+
* Exposition-only
23+
* Exposes the supported symbols in a language supported by the user
24+
* Memory management and error handling is the responsibility of the user
25+
* Simple wrapper
26+
* Wraps the interface in a language supported by the user
27+
* Handles memory management, basic error handling and type conversions
28+
* Contains no additional features except maybe some basic utility tools
29+
* The feature-rich layer
30+
* Extensive wrapper around the interface with easy functionality exposure and utility functions
31+
* Extensive type checks
32+
33+
## Existing library interfaces
34+
35+
The following library interfaces are currently included in the power-grid-model.
36+
37+
| Interface type | Status | Layer | Explanation | Supported by |
38+
| -------------- | ------------ | ------------------ | --------------------------------------------------------------- | --------------------------------------------------- |
39+
| C API | Stable | Raw interface | Shared object / DLL that contains the core implementation | All programming languages with dynamic load support |
40+
| C headers | Stable | Exposition-only | Exposition-only library using dynamic linking | C and C++ |
41+
| C++ headers | Experimental | Wrapper | Handles memory management and basic error handling | C++ |
42+
| Python library | Stable | Feature-rich layer | Library with useful functions, conversions and extensive checks | Python |
43+
44+
Note that the Python library in turn also follows the pattern of a feature-rich library that uses a
45+
module-internal wrapper layer core module, that wraps the exposition-only core module, that exposes
46+
the raw interface.
47+
48+
This can be visualized graphically as follows.
49+
50+
```{mermaid}
51+
:title: Full design
52+
53+
flowchart TD
54+
classDef user_node fill:#9f6,stroke:#333,stroke-width:2px
55+
classDef public_interface fill:#69f,stroke:#333,stroke-width:2px
56+
classDef experimental_interface fill:#99b,stroke:#333,stroke-width:2px
57+
classDef private_interface fill:#999,stroke:#333,stroke-width:2px
58+
classDef inclusion_method fill:#ddd,stroke:#fff,stroke-width:2px
59+
60+
subgraph User
61+
any_language_user(["Any language user"]):::user_node
62+
c_user(["C user"]):::user_node
63+
cpp_user(["C++ user"]):::user_node
64+
python_user(["Python user"]):::user_node
65+
end
66+
67+
dynamic_loading{ }:::inclusion_method
68+
c_includes{ }:::inclusion_method
69+
70+
subgraph Raw interface
71+
power_grid_model_c_dll("power_grid_model_c<br>(shared library)"):::public_interface
72+
end
73+
74+
subgraph Exposition
75+
power_grid_model_c("power_grid_model_c<br>(C library)"):::public_interface
76+
power_grid_core_python("power_grid_model._core<br>.power_grid_core.py<br>(exposition-only<br>Python module)"):::private_interface
77+
end
78+
79+
subgraph Wrapper
80+
power_grid_model_cpp("power_grid_model_cpp<br>(experimental,<br>C++ library)"):::experimental_interface
81+
power_grid_model_core_python("power_grid_model._core<br>(Python wrapper library)"):::private_interface
82+
end
83+
84+
subgraph Feature-rich library
85+
power_grid_model_python("power_grid_model<br>(Python library)"):::public_interface
86+
end
87+
88+
any_language_user --> dynamic_loading
89+
c_includes --> dynamic_loading
90+
dynamic_loading -->|dynamic loading| power_grid_model_c_dll
91+
c_user --> c_includes
92+
cpp_user --> c_includes
93+
c_includes -->|links +<br>includes| power_grid_model_c -->|dynamic linking| power_grid_model_c_dll
94+
cpp_user -->|experimental<br>links +<br>includes| power_grid_model_cpp -->|links +<br>includes| power_grid_model_c
95+
python_user -->|import| power_grid_model_python -->|internal import| power_grid_model_core_python -->|internal import| power_grid_core_python -->|"CDLL<br>(dynamic loading)"| power_grid_model_c_dll
96+
```
97+
98+
## Creating a custom library or interface
99+
100+
We seek to provide an optimal user experience, but with the sheer amount of programming languages and
101+
features, it would be impossible to provide a full feature-rich library for every single one. We,
102+
being a {{ "[community-driven]({}/GOVERNANCE.md)".format(pgm_project_contribution) }} project strongly in
103+
favor of modern software engineering practices, therefore encourage people to create their own
104+
libraries and interfaces to improve their own experience. There are several possible reasons a user
105+
may want to create their own library or interface, e.g.:
106+
107+
* Support for a new programming language
108+
* Extending library support for a specific programming language
109+
* A custom wrapper that provides extra features or useful commands for specific custom requirements
110+
111+
In all cases, it is recommended that the user determines their own desired
112+
[layer of abstraction](#layers-of-abstraction) and then creates internal wrappers for all
113+
lower-level ones, following the same pattern as the power-grid-model
114+
[uses internally](#existing-library-interfaces) for the custom interfaces.
115+
116+
### Hosting a custom library or interface
117+
118+
The Power Grid Model organization supports people creating and hosting custom libraries and
119+
interfaces. If you are doing so and are willing to notify us, please create an item on our
120+
[discussion board](https://github.com/orgs/PowerGridModel/discussions) on GitHub. The Power Grid
121+
Model organization will review your item and we may decide to mention your custom library on our
122+
project website and documentation.
123+
124+
### Contributing a custom library or interface
125+
126+
When a custom library or interface becomes mature enough and the circumstances allow making it
127+
publicly available, please consider contributing it to the Power Grid Model organization. If you are
128+
considering contributing your custom library or interface, please read and follow our
129+
{{ "[contributing guidelines]({}/CONTRIBUTING.md)".format(pgm_project_contribution) }} and open an
130+
item on our [discussion board](https://github.com/orgs/PowerGridModel/discussions) on GitHub. The
131+
Power Grid Model organization will review your item and contact you accordingly.

docs/conf.py

+6
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,13 @@
2525
commit_version = git.Repo(search_parent_directories=True).head.object.hexsha
2626
link_head_gh_blob = link_head_gh + "blob/" + commit_version
2727
link_head_gh_tree = link_head_gh + "tree/" + commit_version
28+
pgm_project_root = ""
29+
pgm_project_contribution = pgm_project_root + "/contribution"
2830
else:
2931
link_head_gh_blob = ""
3032
link_head_gh_tree = ""
33+
pgm_project_root = "https://github.com/PowerGridModel/.github/blob/main"
34+
pgm_project_contribution = pgm_project_root
3135

3236

3337
# -- General configuration ---------------------------------------------------
@@ -78,6 +82,8 @@
7882
myst_substitutions = {
7983
"gh_link_head_blob": link_head_gh_blob,
8084
"gh_link_head_tree": link_head_gh_tree,
85+
"pgm_project_root": pgm_project_root,
86+
"pgm_project_contribution": pgm_project_contribution,
8187
}
8288

8389

docs/doxygen/Doxyfile

+9-9
Original file line numberDiff line numberDiff line change
@@ -495,25 +495,25 @@ EXTRACT_ALL = YES
495495
# be included in the documentation.
496496
# The default value is: NO.
497497

498-
EXTRACT_PRIVATE = NO
498+
EXTRACT_PRIVATE = YES
499499

500500
# If the EXTRACT_PRIV_VIRTUAL tag is set to YES, documented private virtual
501501
# methods of a class will be included in the documentation.
502502
# The default value is: NO.
503503

504-
EXTRACT_PRIV_VIRTUAL = NO
504+
EXTRACT_PRIV_VIRTUAL = YES
505505

506506
# If the EXTRACT_PACKAGE tag is set to YES, all members with package or internal
507507
# scope will be included in the documentation.
508508
# The default value is: NO.
509509

510-
EXTRACT_PACKAGE = NO
510+
EXTRACT_PACKAGE = YES
511511

512512
# If the EXTRACT_STATIC tag is set to YES, all static members of a file will be
513513
# included in the documentation.
514514
# The default value is: NO.
515515

516-
EXTRACT_STATIC = NO
516+
EXTRACT_STATIC = YES
517517

518518
# If the EXTRACT_LOCAL_CLASSES tag is set to YES, classes (and structs) defined
519519
# locally in source files will be included in the documentation. If set to NO,
@@ -529,7 +529,7 @@ EXTRACT_LOCAL_CLASSES = YES
529529
# included.
530530
# The default value is: NO.
531531

532-
EXTRACT_LOCAL_METHODS = NO
532+
EXTRACT_LOCAL_METHODS = YES
533533

534534
# If this flag is set to YES, the members of anonymous namespaces will be
535535
# extracted and appear in the documentation as a namespace called
@@ -538,7 +538,7 @@ EXTRACT_LOCAL_METHODS = NO
538538
# are hidden.
539539
# The default value is: NO.
540540

541-
EXTRACT_ANON_NSPACES = NO
541+
EXTRACT_ANON_NSPACES = YES
542542

543543
# If this flag is set to YES, the name of an unnamed parameter in a declaration
544544
# will be determined by the corresponding definition. By default unnamed
@@ -868,7 +868,7 @@ WARN_LOGFILE =
868868
# spaces. See also FILE_PATTERNS and EXTENSION_MAPPING
869869
# Note: If this tag is empty the current directory is searched.
870870

871-
INPUT = ../../power_grid_model_c/power_grid_model_c/include
871+
INPUT = "../../power_grid_model_c/" "../../src/" "../../tests/"
872872

873873
# This tag can be used to specify the character encoding of the source files
874874
# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses
@@ -897,7 +897,7 @@ INPUT_ENCODING = UTF-8
897897
# *.py, *.pyw, *.f90, *.f95, *.f03, *.f08, *.f18, *.f, *.for, *.vhd, *.vhdl,
898898
# *.ucf, *.qsf and *.ice.
899899

900-
FILE_PATTERNS = *.h
900+
FILE_PATTERNS =
901901

902902
# The RECURSIVE tag can be used to specify whether or not subdirectories should
903903
# be searched for input files as well.
@@ -2314,7 +2314,7 @@ HIDE_UNDOC_RELATIONS = YES
23142314
# set to NO
23152315
# The default value is: YES.
23162316

2317-
HAVE_DOT = NO
2317+
HAVE_DOT = YES
23182318

23192319
# The DOT_NUM_THREADS specifies the number of dot invocations doxygen is allowed
23202320
# to run in parallel. When set to 0 doxygen will base this on the number of

docs/index.md

+1
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ algorithms/lu-solver
108108
advanced_documentation/native-data-interface
109109
advanced_documentation/build-guide
110110
advanced_documentation/c-api
111+
advanced_documentation/high-level-design
111112
advanced_documentation/core-design
112113
advanced_documentation/python-wrapper-design
113114
```

docs/user_manual/calculations.md

+10
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,11 @@ also of importance, i.e., the measurements should be topologically independent.
9696
Global angle current measurements require at least one voltage angle measurement to make sense. See also the [current sensor component documentation](./components.md#global-angle-current-sensors).
9797
```
9898

99+
```{note}
100+
It is not possible to add both a [power sensor](./components.md#generic-current-sensor) and a [current sensor](#./components.mdgeneric-current-sensor) to the same terminal of the same component.
101+
It is, however, allowed to have both a power sensor and a current sensor on the same branch if they are on different terminals.
102+
```
103+
99104
```{warning}
100105
The [iterative linear](#iterative-linear-state-estimation) and [Newton-Raphson](#newton-raphson-state-estimation) state estimation algorithms will assume angles to be zero by default (see the details about voltage sensors).
101106
In observable systems this helps better outputting correct results. On the other hand with unobservable systems, exceptions raised from calculations due to faulty results will be prevented.
@@ -462,6 +467,11 @@ $$
462467

463468
Where $S_k$ and $\sigma_{P,k}$ and $\sigma_{Q,k}$ are the measured value and the standard deviation of the individual appliances.
464469

470+
```{note}
471+
It is not possible to add both a [power sensor](./components.md#generic-current-sensor) and a [current sensor](#./components.mdgeneric-current-sensor) to the same terminal of the same component.
472+
It is, however, allowed to have both a power sensor and a current sensor on the same branch if they are on different terminals.
473+
```
474+
465475
#### State estimate sensor transformations
466476

467477
Sometimes, measurements need to be transformed between coordinate spaces. For example, current measurements are in polar coordinates (magnitude and angle), but it is beneficial to transform them to separate real and imaginary components per phase, with each their own variances.

0 commit comments

Comments
 (0)