Skip to content

Commit

Permalink
Merge pull request #445 from NREL/max-outage-duration-bug
Browse files Browse the repository at this point in the history
Fix ERP max_outage_duration bug
  • Loading branch information
hdunham authored Mar 24, 2023
2 parents 417122e + 70a298d commit 5d0799b
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 5 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ Classify the change according to the following categories:
##### Removed
### Patches

## v2.10.1
### Patches
- Make **ERPOutageInputs** field **max_outage_duration** required
- In ERP inputs processing, check that **ElectricUtility** **outage_durations** is not empty before calculating max
- Respond with validation error if **max_outage_duration** not provided and can't be calculated

## v2.10.0
### Minor Updates
##### Added
Expand Down
12 changes: 9 additions & 3 deletions resilience_stats/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,15 @@ def update_user_dict_with_values_from_reopt(user_dict_key:str, reopt_dict:dict):
## Outage ##
critical_loads_kw = reopt_run_meta.ElectricLoadOutputs.dict["critical_load_series_kw"]
update_user_dict_with_values_from_reopt("Outage", {"critical_loads_kw": critical_loads_kw})
update_user_dict_with_values_from_reopt("Outage", {
"max_outage_duration": max(reopt_run_meta.ElectricUtilityInputs.dict["outage_durations"])
})
if len(reopt_run_meta.ElectricUtilityInputs.dict["outage_durations"]) > 0:
update_user_dict_with_values_from_reopt("Outage", {
"max_outage_duration": max(reopt_run_meta.ElectricUtilityInputs.dict["outage_durations"])
})
if bundle.data.get("Outage", {}).get("max_outage_duration",None) is None:
add_validation_err_msg_and_raise_400_response(
meta_dict,
"You must provide Outage max_outage_duration or the reopt_run_uuid of an optimization where ElectricUtility outage_durations was provided."
)

## Generator ##
try:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Generated by Django 4.0.4 on 2023-03-24 17:35

import django.core.validators
from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('resilience_stats', '0011_alter_erpgeneratorinputs_electric_efficiency_half_load_and_more'),
]

operations = [
migrations.AlterField(
model_name='erpoutageinputs',
name='max_outage_duration',
field=models.IntegerField(help_text='Maximum outage duration modeled', validators=[django.core.validators.MinValueValidator(1), django.core.validators.MaxValueValidator(672)]),
),
]
2 changes: 0 additions & 2 deletions resilience_stats/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -493,8 +493,6 @@ class ERPOutageInputs(BaseModel, models.Model):
related_name="ERPOutageInputs"
)
max_outage_duration = models.IntegerField(
blank=True,
default=336,
validators=[
MinValueValidator(1),
MaxValueValidator(672),
Expand Down

0 comments on commit 5d0799b

Please sign in to comment.