Skip to content

Commit 6b27573

Browse files
authored
[DEV-7134] Use new averageVoltageSpreadThreshold field for tap optimisation (#55)
--------- Signed-off-by: Marcus Koh <marcus.koh@zepben.com>
1 parent 8cf41cf commit 6b27573

File tree

4 files changed

+62
-6
lines changed

4 files changed

+62
-6
lines changed

changelog.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
# EAS Python client
22
## [0.28.0] - UNRELEASED
33
### Breaking Changes
4-
* None.
4+
* For `CandidateGenerationConfig`, replaced `voltage_delta_avg_threshold` with `average_voltage_spread_threshold`, which serves the same purpose but is
5+
in volts instead of voltage per-unit.
6+
* EAS must support this change in the GraphQL schema (`v2.10.0` and above).
57

68
### New Features
79
* None.

src/zepben/eas/client/eas_client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -386,11 +386,11 @@ def work_package_config_to_json(self, work_package: WorkPackageConfig) -> dict:
386386
"candidateGeneration": work_package.intervention.candidate_generation and {
387387
"type": work_package.intervention.candidate_generation.type.name,
388388
"interventionCriteriaName": work_package.intervention.candidate_generation.intervention_criteria_name,
389-
"voltageDeltaAvgThreshold": work_package.intervention.candidate_generation.voltage_delta_avg_threshold,
389+
"averageVoltageSpreadThreshold": work_package.intervention.candidate_generation.average_voltage_spread_threshold,
390390
"voltageUnderLimitHoursThreshold": work_package.intervention.candidate_generation.voltage_under_limit_hours_threshold,
391391
"voltageOverLimitHoursThreshold": work_package.intervention.candidate_generation.voltage_over_limit_hours_threshold,
392392
"tapWeightingFactorLowerThreshold": work_package.intervention.candidate_generation.tap_weighting_factor_lower_threshold,
393-
"tapWeightingFactorUpperThreshold": work_package.intervention.candidate_generation.tap_weighting_factor_upper_threshold,
393+
"tapWeightingFactorUpperThreshold": work_package.intervention.candidate_generation.tap_weighting_factor_upper_threshold
394394
},
395395
"allocationCriteria": work_package.intervention.allocation_criteria,
396396
"specificAllocationInstance": work_package.intervention.specific_allocation_instance,

src/zepben/eas/client/work_package.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -767,9 +767,13 @@ class CandidateGenerationConfig:
767767
base work package run. Only used when type is CRITERIA.
768768
"""
769769

770-
voltage_delta_avg_threshold: Optional[float] = None
770+
average_voltage_spread_threshold: Optional[int] = None
771771
"""
772-
The threshold for average deviation in voltage p.u. across the transformer. Only used when type is TAP_OPTIMIZATION.
772+
The threshold for average line voltage spread under the transformer over the year, in volts.
773+
Voltage spread at each timestep is calculated by taking the difference between the maximum and minimum phase-to-phase voltage over
774+
the nodes under the transformer, for each phase, then taking the maximum of that difference across all phases.
775+
When the average voltage spread exceeds this threshold, it indicates that the transformer is experiencing a
776+
significant voltage swing that may impact system stability. Only used when type is TAP_OPTIMIZATION.
773777
"""
774778

775779
voltage_under_limit_hours_threshold: Optional[int] = None

test/test_eas_client.py

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
from werkzeug import Response
1818
from zepben.ewb.auth import ZepbenTokenFetcher
1919

20-
from zepben.eas import EasClient, Study, SolveConfig, InterventionConfig, YearRange
20+
from zepben.eas import EasClient, Study, SolveConfig, InterventionConfig, YearRange, CandidateGenerationConfig, CandidateGenerationType
2121
from zepben.eas import FeederConfig, ForecastConfig, FixedTimeLoadOverride
2222
from zepben.eas.client.ingestor import IngestorConfigInput, IngestorRunsSortCriteriaInput, IngestorRunsFilterInput, \
2323
IngestorRunState, IngestorRuntimeKind
@@ -1744,3 +1744,53 @@ def test_work_package_config_to_json_includes_server_defaulted_fields_if_specifi
17441744
"dvms": None,
17451745
"allocationLimitPerYear": 5
17461746
}
1747+
1748+
def test_work_package_config_to_json_for_tap_optimization(httpserver: HTTPServer):
1749+
eas_client = EasClient(
1750+
LOCALHOST,
1751+
httpserver.port,
1752+
verify_certificate=False
1753+
)
1754+
1755+
wp_config = WorkPackageConfig(
1756+
name="wp",
1757+
syf_config=FeederConfigs([]),
1758+
intervention=InterventionConfig(
1759+
base_work_package_id="abc",
1760+
year_range=YearRange(2020, 2025),
1761+
intervention_type=InterventionClass.DISTRIBUTION_TAP_OPTIMIZATION,
1762+
allocation_limit_per_year=5,
1763+
candidate_generation=CandidateGenerationConfig(
1764+
type=CandidateGenerationType.TAP_OPTIMIZATION,
1765+
average_voltage_spread_threshold=40,
1766+
voltage_under_limit_hours_threshold=1,
1767+
voltage_over_limit_hours_threshold=2,
1768+
tap_weighting_factor_lower_threshold=-0.3,
1769+
tap_weighting_factor_upper_threshold=0.4
1770+
)
1771+
)
1772+
)
1773+
json_config = eas_client.work_package_config_to_json(wp_config)
1774+
1775+
assert json_config["intervention"] == {
1776+
"baseWorkPackageId": "abc",
1777+
"yearRange": {
1778+
"maxYear": 2025,
1779+
"minYear": 2020
1780+
},
1781+
"interventionType": "DISTRIBUTION_TAP_OPTIMIZATION",
1782+
"candidateGeneration": {
1783+
"type": "TAP_OPTIMIZATION",
1784+
"interventionCriteriaName": None,
1785+
"averageVoltageSpreadThreshold": 40,
1786+
"voltageUnderLimitHoursThreshold": 1,
1787+
"voltageOverLimitHoursThreshold": 2,
1788+
"tapWeightingFactorLowerThreshold": -0.3,
1789+
"tapWeightingFactorUpperThreshold": 0.4,
1790+
},
1791+
"allocationCriteria": None,
1792+
"specificAllocationInstance": None,
1793+
"phaseRebalanceProportions": None,
1794+
"dvms": None,
1795+
"allocationLimitPerYear": 5
1796+
}

0 commit comments

Comments
 (0)