Skip to content

Commit 3bfc971

Browse files
Esaotuelrkgreav
andauthored
[DEV 3583] added span level threshold related functionality. (#42)
Signed-off-by: Jimmy Tung <jimmy.tung@zepben.com> Signed-off-by: Kurt Greaves <kurt.greaves@zepben.com> Co-authored-by: Kurt Greaves <kurt.greaves@zepben.com>
1 parent 02b8da8 commit 3bfc971

File tree

4 files changed

+86
-11
lines changed

4 files changed

+86
-11
lines changed

changelog.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@
77
### New Features
88
* Added optional fields to `ModelConfig` to control network simplification: `simplify_network`, `collapse_negligible_impedances`, and `combine_common_impedances`.
99
* Added optional `node_level_results` field to `GeneratorConfig`. This `NodeLevelResultsConfig` allows the configuration of node level power flow results from OpenDss.
10+
* Introduce `span_level_threshold` and `simplify_plsi` into `work_package` so it can be passed through for hosting capacity studies.
11+
* Introduce new variables into `work_package` so it can be passed through for hosting capacity studies.
12+
* `use_span_level_threshold`
13+
* `rating_threshold`
14+
* `simplify_plsi_threshold`
15+
* `emerg_amp_scaling`
1016

1117
### Enhancements
1218
* None.

src/zepben/eas/client/eas_client.py

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,10 @@ def generator_config_to_json(self, generator_config: Optional[GeneratorConfig])
241241
"defaultGenVar": generator_config.model.default_gen_var,
242242
"transformerTapSettings": generator_config.model.transformer_tap_settings,
243243
"ctPrimScalingFactor": generator_config.model.ct_prim_scaling_factor,
244+
"useSpanLevelThreshold": generator_config.model.use_span_level_threshold,
245+
"ratingThreshold": generator_config.model.rating_threshold,
246+
"simplifyPLSIThreshold": generator_config.model.simplify_plsi_threshold,
247+
"emergAmpScaling": generator_config.model.emerg_amp_scaling
244248
},
245249
"solve": generator_config.solve and {
246250
"normVMinPu": generator_config.solve.norm_vmin_pu,
@@ -316,15 +320,27 @@ def work_package_config_to_json(self, work_package: Optional[WorkPackageConfig])
316320
"timePeriod": {
317321
"startTime": work_package.syf_config.load_time.start_time.isoformat(),
318322
"endTime": work_package.syf_config.load_time.end_time.isoformat(),
319-
"overrides": work_package.syf_config.load_time.load_overrides and {
320-
key: value.__dict__
321-
for key, value in work_package.syf_config.load_time.load_overrides.items()}
323+
"overrides": work_package.syf_config.load_time.load_overrides and [
324+
{
325+
"loadId": key,
326+
"loadWattsOverride": value.load_watts,
327+
"genWattsOverride": value.gen_watts,
328+
"loadVarOverride": value.load_var,
329+
"genVarOverride": value.gen_var,
330+
} for key, value in work_package.syf_config.load_time.load_overrides.items()
331+
]
322332
} if isinstance(work_package.syf_config.load_time, TimePeriod) else None,
323333
"fixedTime": work_package.syf_config.load_time and {
324334
"loadTime": work_package.syf_config.load_time.load_time.isoformat(),
325-
"overrides": work_package.syf_config.load_time.load_overrides and {
326-
key: value.__dict__
327-
for key, value in work_package.syf_config.load_time.load_overrides.items()}
335+
"overrides": work_package.syf_config.load_time.load_overrides and [
336+
{
337+
"loadId": key,
338+
"loadWattsOverride": value.load_watts,
339+
"genWattsOverride": value.gen_watts,
340+
"loadVarOverride": value.load_var,
341+
"genVarOverride": value.gen_var,
342+
} for key, value in work_package.syf_config.load_time.load_overrides.items()
343+
]
328344
} if isinstance(work_package.syf_config.load_time, FixedTime) else None
329345
} if isinstance(work_package.syf_config, ForecastConfig) else None,
330346
"qualityAssuranceProcessing": work_package.quality_assurance_processing,
@@ -1310,6 +1326,10 @@ async def async_get_paged_opendss_models(
13101326
defaultGenVar
13111327
transformerTapSettings
13121328
ctPrimScalingFactor
1329+
useSpanLevelThreshold
1330+
ratingThreshold
1331+
simplifyPLSIThreshold
1332+
emergAmpScaling
13131333
}
13141334
solve {
13151335
normVMinPu

src/zepben/eas/client/work_package.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -467,6 +467,31 @@ class ModelConfig:
467467
Optional setting for scaling factor of calculated CTPrim for zone sub transformers.
468468
"""
469469

470+
use_span_level_threshold: bool = False
471+
"""
472+
Set to true if `AcLineSegment.designRating` is to be used for conductor rated current in the model.
473+
"""
474+
475+
rating_threshold: Optional[float] = None
476+
"""
477+
Optional setting to loosen rated current comparison between conductors during network simplification by providing a threshold
478+
of allowed differences. Neighbouring conductors within this threshold and matching impedance's will be collapsed.
479+
Set as a % value, i.e put as 50.0 if threshold is 50%
480+
"""
481+
482+
simplify_plsi_threshold: Optional[float] = None
483+
"""
484+
Optional setting to indicate if sequence impedance's should be normalized during network simplification.
485+
Connected AcLineSegments with PerLengthSequenceImpedance value differences within the threshold will be normalized.
486+
Set as a % value, i.e put as 50.0 if threshold is 50%
487+
"""
488+
489+
emerg_amp_scaling: Optional[float] = None
490+
"""
491+
Scaling factor for emergency current rating for conductors.
492+
Set as a factor value, i.e put as 1.5 if scaling is 150%
493+
"""
494+
470495

471496
class SolveMode(Enum):
472497
YEARLY = "YEARLY"

test/test_eas_client.py

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import random
88
import ssl
99
import string
10-
from datetime import datetime, timezone, timedelta
10+
from datetime import datetime
1111
from http import HTTPStatus
1212
from unittest import mock
1313

@@ -769,6 +769,10 @@ def hosting_capacity_run_calibration_with_calibration_time_request_handler(reque
769769
'pFactorForecastPv': None,
770770
'seed': None,
771771
'simplifyNetwork': None,
772+
'useSpanLevelThreshold': False,
773+
'ratingThreshold': None,
774+
'simplifyPLSIThreshold': None,
775+
'emergAmpScaling': None,
772776
'splitPhaseDefaultLoadLossPercentage': None,
773777
'splitPhaseLVKV': None,
774778
'swerVoltageToLineVoltage': None,
@@ -872,6 +876,10 @@ def hosting_capacity_run_calibration_with_generator_config_request_handler(reque
872876
'pFactorForecastPv': None,
873877
'seed': None,
874878
'simplifyNetwork': None,
879+
'useSpanLevelThreshold': False,
880+
'ratingThreshold': None,
881+
'simplifyPLSIThreshold': None,
882+
'emergAmpScaling': None,
875883
'splitPhaseDefaultLoadLossPercentage': None,
876884
'splitPhaseLVKV': None,
877885
'swerVoltageToLineVoltage': None,
@@ -969,6 +977,10 @@ def hosting_capacity_run_calibration_with_partial_model_config_request_handler(r
969977
'pFactorForecastPv': None,
970978
'seed': None,
971979
'simplifyNetwork': None,
980+
'useSpanLevelThreshold': False,
981+
'ratingThreshold': None,
982+
'simplifyPLSIThreshold': None,
983+
'emergAmpScaling': None,
972984
'splitPhaseDefaultLoadLossPercentage': None,
973985
'splitPhaseLVKV': None,
974986
'swerVoltageToLineVoltage': None,
@@ -1023,6 +1035,7 @@ def test_run_hosting_capacity_calibration_with_explicit_transformer_tap_settings
10231035
httpserver.check_assertions()
10241036
assert res == {"result": "success"}
10251037

1038+
10261039
def get_hosting_capacity_calibration_sets_request_handler(request):
10271040
actual_body = json.loads(request.data.decode())
10281041
query = " ".join(actual_body['query'].split())
@@ -1152,7 +1165,11 @@ def run_opendss_export_request_handler(request):
11521165
"defaultLoadVar": [10.0, 20.0, 30.0],
11531166
"defaultGenVar": [5.0, 15.0, 25.0],
11541167
"transformerTapSettings": "tap-3",
1155-
"ctPrimScalingFactor": 2.0
1168+
"ctPrimScalingFactor": 2.0,
1169+
"useSpanLevelThreshold": True,
1170+
"ratingThreshold": 20.0,
1171+
"simplifyPLSIThreshold": 20.0,
1172+
"emergAmpScaling": 1.8
11561173
},
11571174
"solve": {
11581175
"normVMinPu": 0.9,
@@ -1261,7 +1278,11 @@ def run_opendss_export_request_handler(request):
12611278
default_load_var=[10.0, 20.0, 30.0],
12621279
default_gen_var=[5.0, 15.0, 25.0],
12631280
transformer_tap_settings="tap-3",
1264-
ct_prim_scaling_factor=2.0
1281+
ct_prim_scaling_factor=2.0,
1282+
use_span_level_threshold=True,
1283+
rating_threshold=20.0,
1284+
simplify_plsi_threshold=20.0,
1285+
emerg_amp_scaling= 1.8
12651286
),
12661287
SolveConfig(
12671288
norm_vmin_pu=0.9,
@@ -1333,8 +1354,7 @@ def test_run_opendss_export_valid_certificate_success(ca: trustme.CA, httpserver
13331354
)
13341355

13351356
OPENDSS_CONFIG.load_time = FixedTime(datetime(2022, 4, 1), {"meter1": FixedTimeLoadOverride([1.0], [2.0], [3.0], [4.0])})
1336-
httpserver.expect_oneshot_request("/api/graphql").respond_with_handler(
1337-
run_opendss_export_request_handler)
1357+
httpserver.expect_oneshot_request("/api/graphql").respond_with_handler(run_opendss_export_request_handler)
13381358
res = eas_client.run_opendss_export(OPENDSS_CONFIG)
13391359
httpserver.check_assertions()
13401360
assert res == {"result": "success"}
@@ -1440,6 +1460,10 @@ def test_run_opendss_export_valid_certificate_success(ca: trustme.CA, httpserver
14401460
defaultGenVar
14411461
transformerTapSettings
14421462
ctPrimScalingFactor
1463+
useSpanLevelThreshold
1464+
ratingThreshold
1465+
simplifyPLSIThreshold
1466+
emergAmpScaling
14431467
}
14441468
solve {
14451469
normVMinPu

0 commit comments

Comments
 (0)