Skip to content

Commit 6d78884

Browse files
authored
Merge pull request #1 from SOPTIM/feature/initial-commit
Add initial codebase
2 parents eb64725 + d0e5299 commit 6d78884

Some content is hidden

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

58 files changed

+7374
-0
lines changed

.gitattributes

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
*.sh text eol=lf
2+
*.py text eol=lf
3+
*.yaml text eol=lf
4+
*.txt text eol=lf
5+
*.md text eol=lf
6+
*.ini text eol=lf
7+
*.json text eol=lf
8+
*.puml text eol=lf
9+
*.git* text eol=lf
10+
*.toml text eol=lf
11+
tdb* text eol=lf
12+
Docker* text eol=lf

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
---
2+
name: Bug report
3+
about: Create a report to help us improve
4+
title: "[BUG] Bug-Title"
5+
labels: bug
6+
assignees: ''
7+
8+
---
9+
10+
**Describe the bug**
11+
A clear and concise description of what the bug is.
12+
13+
**To Reproduce**
14+
Steps to reproduce the behavior:
15+
16+
1. ...
17+
2. ...
18+
19+
**Expected behavior**
20+
A clear and concise description of what you expected to happen.
21+
22+
**Actual Behavior**
23+
If applicable, add outputs, logs or traces to help explain your problem.
24+
25+
**Desktop (please complete the following information):**
26+
27+
- Version [e.g. 0.1.0]
28+
- OS: [e.g. Ubuntu 24.04]
29+
- Python version: [e.g. 3.10.4]
30+
31+
**Additional context**
32+
Anything else that might be useful — configuration files, recent changes, or links to related issues.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
name: Feature request
3+
about: Suggest an idea for this project
4+
title: "[FEATURE] Feature title"
5+
labels: enhancement
6+
assignees: ''
7+
8+
---
9+
10+
**Describe the solution you'd like**
11+
A clear and concise description of what you want to happen.
12+
13+
**Additional context**
14+
Add any other context about the feature request here.

.gitignore

Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
# result data
2+
result/
3+
temp/
4+
5+
# Byte-compiled / optimized / DLL files
6+
__pycache__/
7+
*.py[cod]
8+
*$py.class
9+
10+
# C extensions
11+
*.so
12+
13+
# Distribution / packaging
14+
.Python
15+
build/
16+
out/
17+
develop-eggs/
18+
dist/
19+
downloads/
20+
eggs/
21+
.eggs/
22+
lib/
23+
lib64/
24+
parts/
25+
sdist/
26+
var/
27+
wheels/
28+
pip-wheel-metadata/
29+
share/python-wheels/
30+
*.egg-info/
31+
.installed.cfg
32+
*.egg
33+
MANIFEST
34+
35+
# PyInstaller
36+
# Usually these files are written by a python script from a template
37+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
38+
*.manifest
39+
*.spec
40+
41+
# Installer logs
42+
pip-log.txt
43+
pip-delete-this-directory.txt
44+
45+
# Unit test / coverage reports
46+
htmlcov/
47+
.tox/
48+
.nox/
49+
.coverage
50+
.coverage.*
51+
.cache
52+
nosetests.xml
53+
coverage.xml
54+
*.cover
55+
*.py,cover
56+
.hypothesis/
57+
.pytest_cache/
58+
59+
# Translations
60+
*.mo
61+
*.pot
62+
63+
# Django stuff:
64+
*.log
65+
local_settings.py
66+
db.sqlite3
67+
db.sqlite3-journal
68+
69+
# Flask stuff:
70+
instance/
71+
.webassets-cache
72+
73+
# Scrapy stuff:
74+
.scrapy
75+
76+
# Sphinx documentation
77+
docs/_build/
78+
79+
# PyBuilder
80+
target/
81+
82+
# Jupyter Notebook
83+
.ipynb_checkpoints
84+
85+
# IPython
86+
profile_default/
87+
ipython_config.py
88+
89+
# pyenv
90+
.python-version
91+
92+
# pipenv
93+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
94+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
95+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
96+
# install all needed dependencies.
97+
#Pipfile.lock
98+
99+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
100+
__pypackages__/
101+
102+
# Celery stuff
103+
celerybeat-schedule
104+
celerybeat.pid
105+
106+
# SageMath parsed files
107+
*.sage.py
108+
109+
# Environments
110+
.env
111+
.venv
112+
env/
113+
venv/
114+
ENV/
115+
env.bak/
116+
venv.bak/
117+
118+
# Spyder project settings
119+
.spyderproject
120+
.spyproject
121+
122+
# Rope project settings
123+
.ropeproject
124+
125+
# mkdocs documentation
126+
/site
127+
128+
# mypy
129+
.mypy_cache/
130+
.dmypy.json
131+
dmypy.json
132+
133+
# Pyre type checker
134+
.pyre/
135+
136+
# templates
137+
.github/templates/*
138+
139+
# Intellij
140+
.idea/

.pre-commit-config.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
repos:
2+
- repo: https://github.com/pycqa/isort
3+
rev: 6.0.1
4+
hooks:
5+
- id: isort
6+
name: isort (python)
7+
- repo: https://github.com/psf/black-pre-commit-mirror
8+
rev: 24.8.0
9+
hooks:
10+
- id: black
11+
language_version: python3.12

CONTRIBUTING.md

Whitespace-only changes.

README.md

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
# CGMES2PGM-Suite
2+
3+
`cgmes2pgm_suite` provides additional tools for `cgmes2pgm_converter` to integrate [PowerGridModel](https://github.com/PowerGridModel/power-grid-model) with the Common Grid Model Exchange Standard (CGMES).
4+
It focuses on performing the state estimation on CGMES datasets.
5+
6+
## Features
7+
8+
- Human readable exports of PGM Datasets in TXT and Excel
9+
- Debug state estimation by manipulating datasets (e.g., subnet splitting)
10+
- Configure conversion and state estimation via a configuration file
11+
- Simulate measurements:
12+
- when real measurements are not provided via an Operation Profile, but a State Variable (SV) Profile is available
13+
- generates an Operation Profile with distorted measurements based on the SV Profile
14+
15+
## Installation
16+
17+
### Install from PyPI
18+
19+
The package can be installed via pip:
20+
21+
```bash
22+
pip install cgmes2pgm_suite
23+
```
24+
25+
## Usage
26+
27+
[Example](./example) contains examples on how to use the package.
28+
29+
### Running as Standalone
30+
31+
This package can be run as a standalone application, performing the conversion and running PGM's state estimation. To do so, you need to install the package and then run the following command:
32+
33+
```bash
34+
python -m cgmes2pgm_suite --config <path_to_config_file>
35+
```
36+
37+
The provided configuration file contains the dataset configuration and the parameters for the conversion and state estimation.
38+
An example configuration file can be found in [/example](./example).
39+
40+
### Datasets
41+
42+
The conversion, measurement simulation and state estimation has been tested with the CGMES conformity datasets.
43+
These datasets can be obtained from [ENTSO-E CIM Conformity and Interoperability](https://www.entsoe.eu/data/cim/cim-conformity-and-interoperability/)
44+
respecting their License.
45+
46+
The following datasets have been tested:
47+
48+
| Dataset | Size (Nodes) | Estimation Result | Comment |
49+
| --- | --- | --- | --- |
50+
| PowerFlow | 2 | 🟢 | |
51+
| PST | 2 | 🟢 | All three Scenarios |
52+
| MiniGrid | 13 | 🟢 | |
53+
| MicroGrid | 13 | 🟢 | PST with AsymmetricalPhaseTapChanger (BE-TR2_2) has been split |
54+
| SmallGrid | 167 | 🟢 | |
55+
| Svedala | 191 | 🟢 | |
56+
| RealGrid | 6051 | 🟡 | Requires smaller sigmas in measurement simulation to converge |
57+
| FullGrid | 26 | ? | SV-Profile does not contain power flows for all branches, resulting in an insufficient amount of simulated measurements |
58+
59+
The configuration used for the `SmallGrid` dataset is located at [./example/SmallGrid.yaml](./example/SmallGrid.yaml) and can be executed with the following command:
60+
61+
```bash
62+
python -m cgmes2pgm_suite --config ./example/SmallGrid.yaml
63+
```
64+
65+
See [state_estimation.ipynb](./example/state_estimation.ipynb) on how to create the required SPARQL endpoint.
66+
67+
Dataset Version: CGMES Conformity Assessment Scheme Test Configurations v3.0.2
68+
69+
## License
70+
71+
This project is licensed under the [Apache License 2.0](LICENSE.txt).
72+
73+
## Dependencies
74+
75+
This project includes third-party dependencies, which are licensed under their own respective licenses.
76+
77+
- [cgmes2pgm_converter](https://pypi.org/project/cgmes2pgm_converter/) (Apache License 2.0)
78+
- [bidict](https://pypi.org/project/bidict/) (Mozilla Public License 2.0)
79+
- [numpy](https://pypi.org/project/numpy/) (BSD License)
80+
- [pandas](https://pypi.org/project/pandas/) (BSD License)
81+
- [power-grid-model](https://pypi.org/project/power-grid-model/) (Mozilla Public License 2.0)
82+
- [power-grid-model-io](https://pypi.org/project/power-grid-model-io/) (Mozilla Public License 2.0)
83+
- [SPARQLWrapper](https://pypi.org/project/SPARQLWrapper/) (W3C License)
84+
- [XlsxWriter](https://pypi.org/project/XlsxWriter/) (BSD License)
85+
- [PyYAML](https://pypi.org/project/PyYAML/) (MIT License)
86+
- [StrEnum](https://pypi.org/project/StrEnum/) (MIT License)
87+
88+
## Commercial Support and Services
89+
90+
For organizations requiring commercial support, professional maintenance, integration services,
91+
or custom extensions for this project, these services are available from **SOPTIM AG**.
92+
93+
Please feel free to contact us via [powergridmodel@soptim.de](mailto:powergridmodel@soptim.de).
94+
95+
## Contributing
96+
97+
We welcome contributions to improve this project.
98+
Please see our [Contributing Guide](CONTRIBUTING.md) for details on how to submit pull requests, report issues, and suggest improvements.
99+
100+
## Code of Conduct
101+
102+
This project adheres to a code of conduct adapted from the [Apache Foundation's Code of Conduct](https://www.apache.org/foundation/policies/conduct).
103+
We expect all contributors and users to follow these guidelines to ensure a welcoming and inclusive community.

add-header.sh

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/bin/bash
2+
3+
#
4+
boilerplate="# Copyright [2025] [SOPTIM AG]
5+
#
6+
# Licensed under the Apache License, Version 2.0 (the \"License\");
7+
# you may not use this file except in compliance with the License.
8+
# You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing, software
13+
# distributed under the License is distributed on an \"AS IS\" BASIS,
14+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
# See the License for the specific language governing permissions and
16+
# limitations under the License.
17+
18+
"
19+
20+
# find all python source files
21+
find . -name "*.py" | while read file; do
22+
# check if boiler exist
23+
if ! grep -q "Licensed under the Apache License" "$file"; then
24+
# add Boilerplate-comment to begin of file
25+
echo "$boilerplate$(cat $file)" > $file
26+
echo "Boilerplate added to: $file"
27+
else
28+
echo "Boilerplate already included in: $file"
29+
fi
30+
done

example/SmallGrid.yaml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
Name: "SmallGrid"
2+
OutputFolder: "../out/SmallGrid"
3+
4+
DataSource:
5+
BaseUrl: "http://localhost:3030/SmallGrid"
6+
Graphs:
7+
OP: "/op"
8+
MEAS: "/meas"
9+
CIM-Namespace: "http://iec.ch/TC57/CIM100#"
10+
11+
Steps:
12+
MeasurementSimulation: true
13+
Stes: true
14+
15+
MeasurementSimulation:
16+
Ranges: "./meas_ranges.yaml"
17+
18+
Converter:
19+
onlyTopoIsland: false # convert only elements in a topological island
20+
# topoIslandName: "name" # convert only elements in a specific topological island
21+
sourcesFromSV: false # Add source from SV (cim:TopologicalIsland.AngleRefTopologicalNode)
22+
NetworkSplitting:
23+
Enable: false
24+
AddSources: false # Add sources instead of loads
25+
## only following branches
26+
Branches:
27+
active: "cut1" # Select set of substations
28+
cut1: []
29+
## only branches between substations in following list and the rest of the network
30+
Substations:
31+
active: "cut1" # Select set of substations
32+
cut1: []
33+
34+
Stes:
35+
PgmCalculationParameters:
36+
Threads: -1
37+
MaxIterations: 100
38+
ErrorTolerance: 1.e-6
39+
## compute subnets separately instead of all of them together
40+
ComputeIslandsSeparately: false
41+
## empty list to compute all subnets, or list of subnet names, e.g. `["subnet_1", "subnet_4"]`
42+
ComputeOnlySubnets: []
43+
## after splitting subnets, reconnect branches consecutively and compute the growing network
44+
ReconnectBranches: false
45+
46+
47+
Logging:
48+
Level: "INFO" #CRITICAL, ERROR, WARNING, INFO, DEBUG
49+
File: "SmallGrid.log"

0 commit comments

Comments
 (0)