Skip to content

Commit

Permalink
Merge pull request #562 from NREL/develop
Browse files Browse the repository at this point in the history
master < develop
  • Loading branch information
adfarth committed Feb 5, 2024
2 parents 5468d26 + a7f10b3 commit 6d474f7
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 7 deletions.
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,14 @@ Classify the change according to the following categories:
##### Removed
### Patches


## v3.4.1
### Minor Updates
#### Fixed
- Fixed Wind validation code to prevent erroring when user provides `production_factor_series` for location outside of WindToolkit bounds.
- Fixed divide by zero error when POSTing to the `/erp` endpoint with a `battery_size_kw` of 0
#### Changed
- Updated `reopt_version` in `ERPJob` to 0.39.1

## v3.4.0
### Minor Updates
#### Added
Expand Down
4 changes: 2 additions & 2 deletions reoptjl/validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ def update_pv_defaults_offgrid(self, pvmodel):
for time_series in ["production_factor_series"] + wind_resource_inputs:
self.clean_time_series("Wind", time_series)

if not all([self.models["Wind"].__getattribute__(wr) for wr in wind_resource_inputs]):
if not all([self.models["Wind"].__getattribute__(wr) for wr in wind_resource_inputs]) and not self.models["Wind"].__getattribute__("production_factor_series"):
# then no wind_resource_inputs provided, so we need to get the resource from WindToolkit
if not lat_lon_in_windtoolkit(self.models["Site"].__getattribute__("latitude"),
self.models["Site"].__getattribute__("longitude")):
Expand Down Expand Up @@ -663,5 +663,5 @@ def lat_lon_in_windtoolkit(lat, lon):
y = int(round((point[1] - origin[1]) / 2000))
y_max, x_max = (1602, 2976)
if (x < 0) or (y < 0) or (x >= x_max) or (y >= y_max):
raise ValueError("Latitude/Longitude is outside of wind resource dataset bounds.")
return None
return y, x
2 changes: 1 addition & 1 deletion resilience_stats/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def obj_create(self, bundle, **kwargs):

meta_dict = {
"run_uuid": erp_run_uuid,
"reopt_version": "0.30.0",
"reopt_version": "0.39.1",
"status": "Validating..."
}

Expand Down
5 changes: 4 additions & 1 deletion resilience_stats/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,10 @@ class ERPElectricStorageInputs(BaseModel, models.Model):

def clean(self):
if self.num_battery_bins is None:
self.num_battery_bins = round(20 * self.size_kwh / self.size_kw)
if self.size_kw == 0:
self.num_battery_bins = 1
else:
self.num_battery_bins = round(20 * self.size_kwh / self.size_kw)


class ERPPVInputs(BaseModel, models.Model):
Expand Down
14 changes: 12 additions & 2 deletions resilience_stats/tests/test_erp.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def get_chp_defaults(self, prime_mover, is_chp, size_kw):
self.reopt_base_erp_chp_defaults.format(prime_mover, is_chp, size_kw),
format='json'
)

def test_erp_long_duration_battery(self):
post_opt = json.load(open(self.post_opt_long_dur_stor, 'rb'))
resp = self.get_response_opt(post_opt)
Expand Down Expand Up @@ -171,7 +171,17 @@ def test_erp_with_no_opt(self):
results = json.loads(resp.content)

self.assertAlmostEqual(results["outputs"]["mean_cumulative_survival_final_time_step"], 0.904242, places=4) #0.990784, places=4)


# Test that zero battery doesn't cause error
post_sim["ElectricStorage"]["size_kwh"] = 0
post_sim["ElectricStorage"]["size_kwh"] = 0
resp = self.get_response_sim(post_sim)
self.assertHttpCreated(resp)
r_sim = json.loads(resp.content)
erp_run_uuid = r_sim.get('run_uuid')
resp = self.get_results_sim(erp_run_uuid)
self.assertHttpOK(resp)

def test_erp_help_view(self):
"""
Tests hiting the erp/help url to get defaults and other info about inputs
Expand Down

0 comments on commit 6d474f7

Please sign in to comment.