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 Load Flow specific parameters categories #877

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions docs/user_guide/loadflow.rst
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,11 @@ possible values if applicable, using:
.. doctest::
:options: +NORMALIZE_WHITESPACE

>>> lf.get_provider_parameters().iloc[:2]
description type default possible_values
>>> lf.get_provider_parameters().query('name == "slackBusSelectionMode" or name == "slackBusesIds"')
category_key description type default possible_values
name
slackBusSelectionMode Slack bus selection mode STRING MOST_MESHED [FIRST, MOST_MESHED, NAME, LARGEST_GENERATOR]
slackBusesIds Slack bus IDs STRING_LIST
slackBusSelectionMode SlackDistribution Slack bus selection mode STRING MOST_MESHED [FIRST, MOST_MESHED, NAME, LARGEST_GENERATOR]
slackBusesIds SlackDistribution Slack bus IDs STRING_LIST

For instance, OLF supports configuration of slack bus from its ID like this:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import com.powsybl.python.commons.PyPowsyblConfiguration;
import org.graalvm.nativeimage.UnmanagedMemory;

import java.util.Comparator;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;
Expand All @@ -31,8 +32,9 @@
public final class LoadFlowCUtils {

static final DataframeMapper<LoadFlowProvider, Void> SPECIFIC_PARAMETERS_MAPPER = new DataframeMapperBuilder<LoadFlowProvider, Parameter, Void>()
.itemsProvider(provider -> provider.getSpecificParameters())
.itemsProvider(provider -> provider.getSpecificParameters().stream().sorted(Comparator.comparing(Parameter::getCategoryKey).thenComparing(Parameter::getName)).toList())
.stringsIndex("name", Parameter::getName)
.strings("category_key", p -> Objects.toString(p.getCategoryKey(), ""))
.strings("description", Parameter::getDescription)
.enums("type", ParameterType.class, Parameter::getType)
.strings("default", p -> Objects.toString(p.getDefaultValue(), ""))
Expand Down
4 changes: 4 additions & 0 deletions pypowsybl/loadflow/impl/loadflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,12 +135,16 @@ def get_provider_parameters(provider: str = None) -> DataFrame:
.. doctest::

>>> parameters = pp.loadflow.get_provider_parameters('OpenLoadFlow')
>>> parameters['category_key']['slackBusSelectionMode']
'SlackDistribution'
>>> parameters['description']['slackBusSelectionMode']
'Slack bus selection mode'
>>> parameters['type']['slackBusSelectionMode']
'STRING'
>>> parameters['default']['slackBusSelectionMode']
'MOST_MESHED'
>>> parameters['possible_values']['slackBusSelectionMode']
'[FIRST, MOST_MESHED, NAME, LARGEST_GENERATOR]'
"""
series_array = _pypowsybl.create_loadflow_provider_parameters_series_array('' if provider is None else provider)
return create_data_frame_from_series_array(series_array)
Expand Down
Loading