Skip to content

Commit 6eb2e4d

Browse files
Merge pull request #133 from alliander-opensource/feature/auto-api-doc
Auto documentation generation
2 parents 1bc7d4c + 3fdc5d6 commit 6eb2e4d

34 files changed

+972
-960
lines changed

.readthedocs.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# SPDX-FileCopyrightText: 2022 Contributors to the Power Grid Model project <[email protected]>
2+
#
3+
# SPDX-License-Identifier: MPL-2.0
4+
5+
version: 2
6+
7+
# Build from the docs/ directory with Sphinx
8+
sphinx:
9+
configuration: docs/conf.py
10+
11+
build:
12+
os: "ubuntu-20.04"
13+
tools:
14+
python: "3.9"
15+
jobs:
16+
post_install:
17+
# Build package with doc requirements from pyproject.optional-dependencies
18+
- pip install --verbose --editable .[doc]

CONTRIBUTING.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,21 @@ We recognize different levels of contributions as shown below in increasing orde
2323
1. Develop new mathematical algorithms
2424
1. Improve or add new features into the C++ codebase
2525

26+
## Folder Structure
27+
28+
The repository folder structure is as follows. The `examples`, `docs` and `scripts` folders are self-explanatory.
29+
30+
- The C++ calculation core is inside [include/power-grid-model](include/power-grid-model).
31+
- The python interface code is in [src/power_grid_model](src/power_grid_model)
32+
- The code for validation of input data is in [validation](src/power_grid_model/validation) folder.
33+
- The [tests](tests) folder is divided in the following way:
34+
- `cpp_unit_tests` contains the tests for the C++ calculation core.
35+
- `benchmark_cpp` contains a benchmark test case generator in C++.
36+
- `unit` folder contains tests for the python code.
37+
- `data` contains validation test cases designed for every component and algorithm. Some sample network types are also included.
38+
The validation is either against popular power system analysis software or hand calculation.
39+
40+
2641
## Filing bugs and change requests
2742

2843
You can file bugs against and change request for the project via GitHub issues. Consult [GitHub Help](https://docs.github.com/en/free-pro-team@latest/github/managing-your-work-on-github/creating-an-issue) for more

README.md

Lines changed: 8 additions & 141 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ SPDX-License-Identifier: MPL-2.0
88
[![Build and Test C++ and Python](https://github.com/alliander-opensource/power-grid-model/actions/workflows/main.yml/badge.svg)](https://github.com/alliander-opensource/power-grid-model/actions/workflows/main.yml)
99
[![Check Code Quality](https://github.com/alliander-opensource/power-grid-model/actions/workflows/check-code-quality.yml/badge.svg)](https://github.com/alliander-opensource/power-grid-model/actions/workflows/check-code-quality.yml)
1010
[![REUSE Compliance Check](https://github.com/alliander-opensource/power-grid-model/actions/workflows/reuse-compliance.yml/badge.svg)](https://github.com/alliander-opensource/power-grid-model/actions/workflows/reuse-compliance.yml)
11+
[![docs](https://readthedocs.org/projects/power-grid-model/badge/)](https://power-grid-model.readthedocs.io/en/stable/)
1112

1213
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=alliander-opensource_power-grid-model&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=alliander-opensource_power-grid-model)
1314
[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=alliander-opensource_power-grid-model&metric=coverage)](https://sonarcloud.io/summary/new_code?id=alliander-opensource_power-grid-model)
@@ -16,17 +17,20 @@ SPDX-License-Identifier: MPL-2.0
1617
[![Security Rating](https://sonarcloud.io/api/project_badges/measure?project=alliander-opensource_power-grid-model&metric=security_rating)](https://sonarcloud.io/summary/new_code?id=alliander-opensource_power-grid-model)
1718
[![Vulnerabilities](https://sonarcloud.io/api/project_badges/measure?project=alliander-opensource_power-grid-model&metric=vulnerabilities)](https://sonarcloud.io/summary/new_code?id=alliander-opensource_power-grid-model)
1819

19-
20+
<img src="docs\images\pgm-logo-color.svg" alt="Power Grid Model logo" width="100"/>
2021

2122
# Power Grid Model
2223

2324
`power-grid-model` is a Python library for steady-state distribution power system analysis.
2425
The core of the library is written in C++.
2526
Currently, it supports the following calculations:
2627

27-
* Symmetric and asymmetric power flow calculation with Newton-Raphson method and linear method
28+
* Symmetric and asymmetric power flow calculation with Newton-Raphson method, iterative current method and linear method
2829
* Symmetric and asymmetric state estimation with iterative linear method
2930

31+
See the [power-grid-model documentation](https://power-grid-model.readthedocs.io/en/stable/) for more information.
32+
For various conversions to the power-grid-model, refer to the [power-grid-model-io](https://github.com/alliander-opensource/power-grid-model-io) repository.
33+
3034
# Installation
3135

3236
## Install from PyPI
@@ -41,146 +45,9 @@ pip install power-grid-model
4145

4246
To install the library from source, refer to the [Build Guide](docs/build-guide.md).
4347

44-
# Quick Start
45-
46-
In this quick start a simple 10kV network as below is calculated.
47-
A line connects two nodes. One node has a source. One node has a symmetric load.
48-
The code in the quick start is in [quick_example.py](scripts/quick_example.py).
49-
50-
```
51-
node_1 ---line_3--- node_2
52-
| |
53-
source_5 sym_load_4
54-
```
55-
56-
The library uses a graph data model to represent the physical components and their attributes,
57-
see [Graph Data Model](docs/graph-data-model.md).
58-
59-
Firstly, import the main model class
60-
as well as some helper functions for enumerations and meta data.
61-
62-
```python
63-
from power_grid_model import LoadGenType
64-
from power_grid_model import PowerGridModel
65-
from power_grid_model import initialize_array
66-
```
67-
68-
## Input Data
69-
70-
The library uses dictionary of
71-
[numpy structured arrays](https://numpy.org/doc/stable/user/basics.rec.html)
72-
as the main (input and output) data exchange format between Python and C++ core.
73-
The documentation [Native Data Interface](docs/native-data-interface.md)
74-
explains the detailed design of this interface.
75-
76-
The helper function `initialize_array` can be used to
77-
easily generate an array of the correct format.
78-
79-
```python
80-
# node
81-
node = initialize_array('input', 'node', 2)
82-
node['id'] = [1, 2]
83-
node['u_rated'] = [10.5e3, 10.5e3]
84-
```
85-
86-
The code above generates a node input array with two nodes,
87-
and assigns the attributes of the nodes to the array.
88-
Similarly, we can create input arrays for line, load, and generation.
89-
90-
```python
91-
# line
92-
line = initialize_array('input', 'line', 1)
93-
line['id'] = [3]
94-
line['from_node'] = [1]
95-
line['to_node'] = [2]
96-
line['from_status'] = [1]
97-
line['to_status'] = [1]
98-
line['r1'] = [0.25]
99-
line['x1'] = [0.2]
100-
line['c1'] = [10e-6]
101-
line['tan1'] = [0.0]
102-
line['i_n'] = [1000]
103-
# load
104-
sym_load = initialize_array('input', 'sym_load', 1)
105-
sym_load['id'] = [4]
106-
sym_load['node'] = [2]
107-
sym_load['status'] = [1]
108-
sym_load['type'] = [LoadGenType.const_power]
109-
sym_load['p_specified'] = [2e6]
110-
sym_load['q_specified'] = [0.5e6]
111-
# source
112-
source = initialize_array('input', 'source', 1)
113-
source['id'] = [5]
114-
source['node'] = [1]
115-
source['status'] = [1]
116-
source['u_ref'] = [1.0]
117-
# all
118-
input_data = {
119-
'node': node,
120-
'line': line,
121-
'sym_load': sym_load,
122-
'source': source
123-
}
124-
```
125-
126-
## Instantiate Model
127-
128-
We can instantiate the model by calling the constructor of `PowerGridModel`
129-
130-
```python
131-
model = PowerGridModel(input_data, system_frequency=50.0)
132-
```
133-
134-
## Power Flow Calculation
135-
136-
To calculate power flow, call the method `calculate_power_flow`.
137-
This method has many optional arguments, see [Python API Reference](docs/python-api-reference.md)
138-
for a detailed explanation.
139-
140-
```python
141-
result = model.calculate_power_flow()
142-
```
143-
144-
Both input and output data are dictionaries of structured `numpy` arrays.
145-
We can use `pandas` to convert them to data frames and print them.
146-
147-
```python
148-
print('Node Input')
149-
print(pd.DataFrame(input_data['node']))
150-
print('Node Result')
151-
print(pd.DataFrame(result['node']))
152-
```
153-
154-
You can print the data in tables.
155-
156-
```
157-
Node Input
158-
id u_rated
159-
0 1 10500.0
160-
1 2 10500.0
161-
Node Result
162-
id energized u_pu u u_angle
163-
0 1 1 0.999964 10499.619561 -0.000198
164-
1 2 1 0.994801 10445.415523 -0.003096
165-
```
166-
167-
# Folder Structure
168-
169-
The repository folder structure is as follows. The `examples`, `docs` and `scripts` are self-explanatory.
170-
171-
- The C++ calculation core is inside [include/power-grid-model](include/power-grid-model).
172-
- The python interface code is in [src/power_grid_model](src/power_grid_model)
173-
- The code for validation of input data is in [validation](src/power_grid_model/validation) folder.
174-
- The [tests](tests) folder is divided in the following way:
175-
- `cpp_unit_tests` contains the tests for the C++ calculation core.
176-
- `benchmark_cpp` contains a benchmark test case generator in C++.
177-
- `unit` folder contains tests for the python code.
178-
- `data` contains validation test cases designed for every component and algorithm. Some sample network types are also included.
179-
The validation is either against popular power system analysis software or hand calculation.
180-
18148
# Examples
18249

183-
Please refer to [Examples](examples) for more detailed examples for power flow and state estimation.
50+
Please refer to [Examples](docs/examples) for more detailed examples for power flow and state estimation.
18451
Notebooks for validating the input data and exporting input/output data are also included.
18552

18653
# License
@@ -190,7 +57,7 @@ This project is licensed under the Mozilla Public License, version 2.0 - see [LI
19057
This project includes third-party libraries,
19158
which are licensed under their own respective Open-Source licenses.
19259
SPDX-License-Identifier headers are used to show which license is applicable.
193-
The concerning license files can be found in the LICENSES directory.
60+
The concerning license files can be found in the [LICENSES](LICENSES) directory.
19461

19562
# Contributing
19663
Please read [CODE_OF_CONDUCT](CODE_OF_CONDUCT.md) and [CONTRIBUTING](CONTRIBUTING.md) for details on the process

SUPPORT.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,12 @@ The various issue templates will guide you on making an effective report.
2929

3030
In many cases the problem is in the input data.
3131
We have an extensive input data validity check to help you with this.
32-
Pleas refer to this [notebook](examples/Validation%20Examples.ipynb).
32+
Please refer to this [notebook](docs/examples/Validation%20Examples.ipynb).
3333

3434
### Dump input/output data
3535

3636
To effectively report an issue we need a data dump of input and output.
37-
Please refer to this [notebook](examples/Make%20Test%20Dataset.ipynb) on how to do it.
37+
Please refer to this [notebook](docs/examples/Make%20Test%20Dataset.ipynb) on how to do it.
3838

3939
## How to report a security vulnerability
4040

0 commit comments

Comments
 (0)