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

[Release] v1.8.0 #637

Merged
merged 3 commits into from
Jun 10, 2024
Merged
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
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.7
1.8
40 changes: 10 additions & 30 deletions docs/examples/Transformer Examples.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -553,26 +553,6 @@
"```"
]
},
{
"cell_type": "code",
"execution_count": 9,
"id": "2d786f12",
"metadata": {},
"outputs": [],
"source": [
"from power_grid_model.enum import _ExperimentalFeatures\n",
"\n",
"\n",
"# Power flow with automatic tap changing is still experimental at the time of writing.\n",
"# Create a derived PowerGridModel that has experimental features enabled.\n",
"class PowerGridModelWithExperimentalFeatures(PowerGridModel):\n",
" def __init__(self, *args, **kwargs):\n",
" super().__init__(*args, **kwargs)\n",
"\n",
" def calculate_power_flow(self, **kwargs):\n",
" return super()._calculate_power_flow(experimental_features=_ExperimentalFeatures.enabled, **kwargs)"
]
},
{
"cell_type": "markdown",
"id": "5ab5adba",
Expand All @@ -587,7 +567,7 @@
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": 9,
"id": "0c89a335",
"metadata": {},
"outputs": [],
Expand Down Expand Up @@ -684,7 +664,7 @@
},
{
"cell_type": "code",
"execution_count": 11,
"execution_count": 10,
"id": "2ff01266",
"metadata": {},
"outputs": [
Expand Down Expand Up @@ -753,7 +733,7 @@
],
"source": [
"# construction\n",
"model5 = PowerGridModelWithExperimentalFeatures(input_data5)\n",
"model5 = PowerGridModel(input_data5)\n",
"\n",
"# one-time power flow calculation without automatic tap changing\n",
"output_data5 = model5.calculate_power_flow()\n",
Expand All @@ -777,7 +757,7 @@
},
{
"cell_type": "code",
"execution_count": 12,
"execution_count": 11,
"id": "7ad86bf0",
"metadata": {},
"outputs": [
Expand Down Expand Up @@ -919,7 +899,7 @@
},
{
"cell_type": "code",
"execution_count": 13,
"execution_count": 12,
"id": "be276930",
"metadata": {},
"outputs": [
Expand Down Expand Up @@ -1136,7 +1116,7 @@
},
{
"cell_type": "code",
"execution_count": 14,
"execution_count": 13,
"id": "21b01a77",
"metadata": {},
"outputs": [
Expand Down Expand Up @@ -1279,7 +1259,7 @@
},
{
"cell_type": "code",
"execution_count": 15,
"execution_count": 14,
"id": "c0314199",
"metadata": {},
"outputs": [
Expand Down Expand Up @@ -1432,7 +1412,7 @@
},
{
"cell_type": "code",
"execution_count": 16,
"execution_count": 15,
"id": "ac091392",
"metadata": {},
"outputs": [],
Expand All @@ -1444,7 +1424,7 @@
"input_data6[\"transformer_tap_regulator\"][\"line_drop_compensation_r\"] = [10.0]\n",
"\n",
"# construction\n",
"model6 = PowerGridModelWithExperimentalFeatures(input_data=input_data6)"
"model6 = PowerGridModel(input_data=input_data6)"
]
},
{
Expand All @@ -1457,7 +1437,7 @@
},
{
"cell_type": "code",
"execution_count": 17,
"execution_count": 16,
"id": "9b66d16e",
"metadata": {},
"outputs": [
Expand Down
8 changes: 0 additions & 8 deletions docs/user_manual/calculations.md
Original file line number Diff line number Diff line change
Expand Up @@ -572,10 +572,6 @@ There are {py:class}`4 types <power_grid_model.enum.FaultType>` of fault situati

### Regulated power flow calculations

```{warning}
At the time of writing, this feature is still experimental and is not yet publicly available.
```

Regulated power flow calculations are disabled by default.

At the time of writing, the following regulated power flow calculation types are implemented.
Expand All @@ -587,10 +583,6 @@ Please refer to their respective sections for detailed documentation.

#### Power flow with automatic tap changing

```{warning}
At the time of writing, this feature is still experimental and is not yet publicly available.
```

Some of the most important regulators in the grid affect the tap position of transformers.
These {hoverxreftooltip}`user_manual/components:Transformer Tap Regulator`s try to regulate a control voltage $U_{\text{control}}$ such that it is within a specified voltage band.
The $U_{\text{control}}$ may be compensated for the voltage drop during transport.
Expand Down
22 changes: 2 additions & 20 deletions power_grid_model_c/power_grid_model_c/src/model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,26 +56,8 @@ void PGM_get_indexer(PGM_Handle* handle, PGM_PowerGridModel const* model, char c
}

namespace {
void check_calculate_experimental_features(PGM_Options const& opt) {
using namespace std::string_literals;

if (opt.calculation_type == PGM_power_flow) {
switch (opt.tap_changing_strategy) {
case PGM_tap_changing_strategy_any_valid_tap:
case PGM_tap_changing_strategy_max_voltage_tap:
case PGM_tap_changing_strategy_min_voltage_tap: {
// this option is experimental and should not be exposed to the user
throw ExperimentalFeature{
"PGM_calculate",
ExperimentalFeature::TypeValuePair{.name = "PGM_CalculationType",
.value = std::to_string(opt.calculation_type)},
ExperimentalFeature::TypeValuePair{.name = "PGM_TapChangingStrategy",
.value = std::to_string(opt.tap_changing_strategy)}};
}
default:
break;
}
}
void check_calculate_experimental_features(PGM_Options const& /* opt */) {
// optionally add experimental feature checks here
}

void check_calculate_valid_options(PGM_Options const& opt) {
Expand Down
2 changes: 2 additions & 0 deletions src/power_grid_model/core/power_grid_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,7 @@ def calculate_power_flow(
output_component_types: Optional[Union[Set[str], List[str]]] = None,
continue_on_batch_error: bool = False,
decode_error: bool = True,
tap_changing_strategy: Union[TapChangingStrategy, str] = TapChangingStrategy.disabled,
) -> Dict[str, np.ndarray]:
"""
Calculate power flow once with the current model attributes.
Expand Down Expand Up @@ -463,6 +464,7 @@ def calculate_power_flow(
output_component_types=output_component_types,
continue_on_batch_error=continue_on_batch_error,
decode_error=decode_error,
tap_changing_strategy=tap_changing_strategy,
)

def calculate_state_estimation(
Expand Down
11 changes: 2 additions & 9 deletions tests/c_api_tests/test_c_api_model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,16 +217,9 @@ TEST_CASE("C API Model") {
PGM_calculate(hl, model, opt, single_output_dataset, nullptr);
}

SUBCASE("Tap changing strategy is experimental") {
SUBCASE("experimental features disabled") {
expected_error = "PGM_calculate is not implemented for the following combination of options!\n"s;
}
SUBCASE("experimental features enabled") {
// normal calculation
PGM_set_experimental_features(hl, opt, PGM_experimental_features_enabled);
}
SUBCASE("Tap changing strategy") {
PGM_set_tap_changing_strategy(hl, opt, PGM_tap_changing_strategy_any_valid_tap);
PGM_calculate(hl, model, opt, single_output_dataset, nullptr);
CHECK_NOTHROW(PGM_calculate(hl, model, opt, single_output_dataset, nullptr));
}

if (expected_error.empty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,5 @@
"calculation_method": "newton_raphson",
"tap_changing_strategy": "max_voltage_tap",
"rtol": 1e-05,
"atol": 1e-05,
"extra_params": {
"newton_raphson": {
"experimental_features": "enabled"
}
}
"atol": 1e-05
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,5 @@
"calculation_method": "newton_raphson",
"tap_changing_strategy": "min_voltage_tap",
"rtol": 1e-05,
"atol": 1e-05,
"extra_params": {
"newton_raphson": {
"experimental_features": "enabled"
}
}
"atol": 1e-05
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,5 @@
"atol": {
"default": 1e-05,
"u": 100.0
},
"extra_params": {
"newton_raphson": {
"experimental_features": "enabled"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,5 @@
"atol": {
"default": 1e-05,
"u": 100.0
},
"extra_params": {
"newton_raphson": {
"experimental_features": "enabled"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,5 @@
"atol": {
"default": 1e-05,
"u": 100.0
},
"extra_params": {
"newton_raphson": {
"experimental_features": "enabled"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,5 @@
"atol": {
"default": 1e-05,
"u": 100.0
},
"extra_params": {
"newton_raphson": {
"experimental_features": "enabled"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,5 @@
"atol": {
"default": 1e-05,
"u": 100.0
},
"extra_params": {
"newton_raphson": {
"experimental_features": "enabled"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,5 @@
"atol": {
"default": 1e-05,
"u": 100.0
},
"extra_params": {
"newton_raphson": {
"experimental_features": "enabled"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,5 @@
"calculation_method": "newton_raphson",
"tap_changing_strategy": "any_valid_tap",
"rtol": 1e-5,
"atol": 1e-5,
"extra_params": {
"newton_raphson": {
"experimental_features": "enabled"
}
}
"atol": 1e-5
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,5 @@
"calculation_method": "newton_raphson",
"tap_changing_strategy": "any_valid_tap",
"rtol": 1e-5,
"atol": 1e-5,
"extra_params": {
"newton_raphson": {
"experimental_features": "enabled"
}
}
"atol": 1e-5
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,5 @@
"calculation_method": "newton_raphson",
"tap_changing_strategy": "max_voltage_tap",
"rtol": 1e-5,
"atol": 1e-5,
"extra_params": {
"newton_raphson": {
"experimental_features": "enabled"
}
}
"atol": 1e-5
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,5 @@
"calculation_method": "newton_raphson",
"tap_changing_strategy": "min_voltage_tap",
"rtol": 1e-5,
"atol": 1e-5,
"extra_params": {
"newton_raphson": {
"experimental_features": "enabled"
}
}
"atol": 1e-5
}
12 changes: 3 additions & 9 deletions tests/unit/test_error_handling.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,15 +310,9 @@ def test_transformer_tap_regulator_at_lv_tap_side():
)


def test_automatic_tap_changing_is_experimental():
model = PowerGridModelWithExt(input_data={})

with pytest.raises(InvalidArguments):
model.calculate_power_flow_with_ext(tap_changing_strategy=TapChangingStrategy.any_valid_tap)

model.calculate_power_flow_with_ext(
tap_changing_strategy=TapChangingStrategy.any_valid_tap, experimental_features=_ExperimentalFeatures.enabled
)
def test_automatic_tap_changing():
model = PowerGridModel(input_data={})
model.calculate_power_flow(tap_changing_strategy=TapChangingStrategy.any_valid_tap)


@pytest.mark.skip(reason="TODO")
Expand Down
Loading