Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add readthedocs #356

Merged
merged 15 commits into from
Jun 26, 2024
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,6 @@ org.sonarlint.eclipse.core.prefs

# Log files
powsybl.log

# Generated readthedocs pages
build-docs/
13 changes: 13 additions & 0 deletions docs/.readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
version: 2

build:
os: ubuntu-20.04
tools:
python: "3.9"

sphinx:
configuration: docs/conf.py

python:
install:
- requirements: docs/requirements.txt
27 changes: 27 additions & 0 deletions docs/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Minimal makefile for Sphinx documentation
#

# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = .
BUILDDIR = _build

# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help Makefile


clean:
@echo "Removing $(SOURCEDIR)/reference/api"
@rm -rf "$(SOURCEDIR)/reference/api"
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)


# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
11 changes: 11 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
These are the documentation sources for PowSybl Dynawo features.

Please keep them up to date with your developments.
They are published on powsybl.readthedocs.io/ and pull requests are built and previewed automatically.

To build the docs locally, run the following commands:
~~~bash
pip install -r docs/requirements.txt
sphinx-build -a docs ./build-docs
~~~
Then open `build-docs/index.html` in your browser.
Binary file added docs/_static/favicon.ico
Binary file not shown.
76 changes: 76 additions & 0 deletions docs/_static/logos/logo_lfe_powsybl.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
99 changes: 99 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
# Configuration file for the Sphinx documentation builder.
#
# This file only contains a selection of the most common options. For a full
# list see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html

# -- Path setup --------------------------------------------------------------

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
import os
import sys

# Path to python sources, for doc generation on readthedocs
source_path = os.path.abspath('..')
sys.path.insert(0, source_path)
print(f'appended {source_path}')


# -- Project information -----------------------------------------------------

project = 'powsybl dynawo'
copyright = '2024, RTE (http://www.rte-france.com)'


# -- General configuration ---------------------------------------------------

# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = ['sphinx.ext.autodoc',
'sphinx.ext.autosummary',
'sphinx.ext.viewcode',
'sphinx.ext.doctest',
'sphinx.ext.napoleon',
'sphinx.ext.todo',
'sphinx.ext.intersphinx',
'sphinx_tabs.tabs',
'myst_parser']
myst_enable_extensions = [
"amsmath",
"colon_fence",
"dollarmath",
"attrs_inline"
]
myst_heading_anchors = 6

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']


# -- Options for HTML output -------------------------------------------------

# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = "furo"

html_title = 'powsybl-dynawo'
html_short_title = 'powsybl-dynawo'

html_logo = '_static/logos/logo_lfe_powsybl.svg'
html_favicon = "_static/favicon.ico"

html_context = {
# TODO : replace next option with "https://powsybl.readthedocs.org" when website is published
"sidebar_logo_href": "https://www.powsybl.org/"
}

html_theme_options = {
# the following 3 lines enable edit button
"source_repository": "https://github.com/powsybl/powsybl-dynawo/",
"source_branch": "main",
"source_directory": "docs/",
}

# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
html_css_files = ['styles/styles.css']
flo-dup marked this conversation as resolved.
Show resolved Hide resolved

todo_include_todos = True

# Links to external documentations : python 3 and pandas
intersphinx_mapping = {
"powsyblcore": ("https://powsybl-core.readthedocs.io/en/latest/", None),
}
intersphinx_disabled_reftypes = ["*"]

# Generate one file per method
autosummary_generate = True
41 changes: 41 additions & 0 deletions docs/dynamic_simulation/curves-dsl.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
---
layout: default
---

# Curves DSL
The curves domain specific language allow a user to configure the curves Dynawo will export at the end of the simulation. This DSL defines the `curve` and the `curves` keywords.

The `curve` keyword create a single curve for a dynamic model. One identifies a dynamic model by its ID, the same as the one used in the [Dynamic Models DSL](dynamic-models-dsl). The variable to plot is identified by its name.
```groovy
curve {
dynamicModelId load.id
variable "load_PPu"
}
```

If you want to plot a static variable, the `dynamicModelId` parameter has to be replaced by the `staticId` keyword and refers to an ID present in the static network.
```groovy
curve {
staticId bus.id
variable "Upu_value"
}
```

If you want to plot several variables of the same dynamic model, you can use the `curves` keyword that permit limiting boilerplate code in the script.
```
// This:
curve {
dynamicModelId load.id
variable "load_PPu"
}
curve {
dynamicModelId load.id
variable "load_QPu"
}

// is equivalent to:
curves {
dynamicModelId load.id
variables "load_PPu", "load_QPu"
}
```
98 changes: 98 additions & 0 deletions docs/dynamic_simulation/dynamic-models-dsl.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
---
layout: default
---

# Dynamic Models DSL

The Dynamic Models DSL is a domain specific language written in groovy for the creation dynamic models used by Dynawo, most of them associated with a static equipment present in the network.
If some equipments are not configured, Dynawo would use a default model and set of parameters.

## BlackBoxModel
All the models supported are `BlackBoxModel`. This kind of dynamic model have three attributes:
- `lib` refers to the dynamic model library used in Dynawo.
- `dynamicModelId` identifies the model.
- `parameterSetId` refers a set of parameters for this model in one of the network parameters file.

## Equipment models
These models are `BlackBoxModel` matching an IIDM equipment (generator, load, ...).
To instantiate them with DSL, you have to use their model name as a keyword and define at least a `staticId` and a `parameterSetId`.
The `dynamicModelId` is optional and would be equal to the `staticId` if not set.

**Example**
```groovy
GeneratorSynchronousThreeWindings {
staticId '<GENERATOR_ID>'
dynamicModelId '<DYNAMIC_MODEL_ID>'
parameterSetId '<PARAMETER_ID>'
}
LoadAlphaBeta {
staticId '<LOAD_ID>'
parameterSetId '<PARAMETER_ID>'
}
```

## Automation system models
These models are `BlackBoxModel` of automation system without IIDM equipment.

### OverloadManagementSystem
This model connect to IIDM line or two windings transformer. Besides `dynamicModelId` and `parameterSetId` it needs:
- one control branch
- one measurement branch (can be the controlled one)
- which side is monitored.

**Example**
```groovy
OverloadManagementSystem {
dynamicModelId '<DYN_ID>'
parameterSetId '<PARAMETER_ID>'
controlledBranch '<BRANCH_ID>'
iMeasurement '<BRANCH_ID>'
iMeasurementSide TwoSides.TWO
}
```

#### TODO add all automation systems

## Supported models
Models are listed in [models.json](../../dynawaltz/src/main/resources/models.json).
The list is divided in categories each linked to a dedicated builder.
### Categories properties
* `defaultLib` : name of the default library
* `libs` : list of dynawo libraries supported for this category

The list is statically loaded via [ModelConfigLoader](https://javadoc.io/doc/com.powsybl/powsybl-dynawo/latest/com/powsybl/dynawaltz/builders/ModelConfigLoader.html) services and thus can be extended.

### Library properties
* `lib`: library name used in dynawo
* `alias`: name used in powsybl-dynawo instead of lib
* `properties`: dynamic model properties (synchronized, dangling, etc.)
* `internalModelPrefix`: used for dyd file creation

## Dynamic model Builder List
Ultimately, all groovy scripts call dedicated builders that can be used directly by developers.
### Equipments
* BaseStaticVarCompensatorBuilder
* HvdcPBuilder
* HvdcVscBuilder
* GeneratorFictitiousBuilder
* SynchronizedGeneratorBuilder
* SynchronousGeneratorBuilder
* WeccBuilder
* GridFormingConverterBuilder
* LineBuilder
* StandardBusBuilder
* InfiniteBusBuilder
* TransformerFixedRatioBuilder
* BaseLoadBuilder
* LoadOneTransformerBuilder
* LoadTwoTransformersBuilder
* LoadOneTransformerTapChangerBuilder
* LoadTwoTransformersTapChangersBuilder
### Automation Systems
* TapChangerAutomationSystemBuilder
* TapChangerBlockingAutomationSystemBuilder
* UnderVoltageAutomationSystemBuilder
* DynamicOverloadManagementSystemBuilder
* DynamicTwoLevelsOverloadManagementSystemBuilder
* PhaseShifterPAutomationSystemBuilder
* PhaseShifterIAutomationSystemBuilder
Loading
Loading