Skip to content

Commit

Permalink
derConsumer & derUtilityCost: Added working critical load percentage …
Browse files Browse the repository at this point in the history
…inputs
  • Loading branch information
astronobri committed Sep 19, 2024
1 parent 6f771f5 commit e9ac82a
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 10 deletions.
18 changes: 9 additions & 9 deletions omf/models/derConsumer.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,17 +199,17 @@ def create_REopt_jl_jsonFile(modelDir, inputDict):
'outage_end_time_step': int(inputDict['outage_start_hour'])+int(inputDict['outage_duration'])
}

## Critical Load section
if inputDict['criticalLoadSwitch'] == 'No':
## Critical Load input section
if inputDict['criticalLoadSwitch'] == 'No': ## switch = No means the user wants to upload a critical load profile instead of using a critical load factor to determine the critical load
#TODO: This piece is not working. REopt gives an error that the resilience file is not being created. Unclear what the issue is 9/2024
criticalLoad = np.asarray([float(value) for value in inputDict['criticalLoad'].split('\n') if value.strip()]) ## process input format into an array
criticalLoad = criticalLoad.tolist() if isinstance(criticalLoad, np.ndarray) else criticalLoad ## make criticalLoad array into a list for REopt
#scenario['ElectricLoad']['critical_loads_kw'] = criticalLoad
#scenario['ElectricLoad']['critical_load_series_kw'] = criticalLoad
else:
criticalLoadFactor = float(inputDict['criticalLoadFactor'])
criticalLoad = demand_array*criticalLoadFactor
criticalLoad = criticalLoad.tolist() if isinstance(criticalLoad, np.ndarray) else criticalLoad ## make criticalLoad array into a list for REopt
#scenario['ElectricLoad']['critical_loads_kw'] = criticalLoad

scenario['ElectricLoad']['critical_load_fraction'] = float(inputDict['criticalLoadFactor'])
#criticalLoad = demand_array*criticalLoadFactor
#criticalLoad = criticalLoad.tolist() if isinstance(criticalLoad, np.ndarray) else criticalLoad ## make criticalLoad array into a list for REopt
#scenario['ElectricLoad']['critical_load_series_kw'] = criticalLoad

## Save the scenario file
## NOTE: reopt_jl currently requires a path for the input file, so the file must be saved to a location
Expand Down Expand Up @@ -1028,7 +1028,7 @@ def new(modelDir):
'demandCurve': demand_curve,
'tempCurve': temp_curve,
'criticalLoad': criticalLoad_curve,
'criticalLoadSwitch': 'No',
'criticalLoadSwitch': 'Yes',
'criticalLoadFactor': '0.50',
'PV': 'Yes',
'BESS': 'Yes',
Expand Down
22 changes: 21 additions & 1 deletion omf/models/derUtilityCost.html
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,27 @@
<label class="tooltip">Outage Duration (hours)<span class="classic">The duration (in hours) of the outage. Specify a number between 1 - 8760 hours. </span></label>
<input type="number" id="outage_duration" name="outage_duration" value="{{allInputDataDict.outage_duration}}" min="1" max="8760" required="required"/>
</div>

<div class="shortInput">
<label class="tooltip">Critical Load Curve (.csv file)<span class="classic">Critical load profile (.csv) to be used in the outage analysis. Length 8760 in kW units. If critical load factor is given, this file will not be used.</span></label>
<input id="criticalLoadFile" type="file" style="display:none" onchange="handle_files(this.files,'criticalLoad','criticalLoadFileName')">
<input id="criticalLoad" name="criticalLoad" value="{{allInputDataDict.criticalLoad}}" type="hidden">
<div>
<label for="criticalLoadFile" class="fileButton">Choose File</label>
<input id="criticalLoadFileName" name="criticalLoadFileName" value="{{allInputDataDict.criticalLoadFileName}}" value='' readonly class="uploadFileName">
</div>
</div>
<div class="shortInput">
<label class="tooltip">Use Critical Load Factor instead?<span class="classic">Select Yes to use Critical Load Factor instead of the provided Critical Load .csv file.</span></label>
<select id="criticalLoadSwitch" name="criticalLoadSwitch" value="{{allInputDataDict.criticalLoadSwitch}}">
<option value="True" {{ 'selected' if allInputDataDict.outage == 'Yes' }}>Yes</option>
<option value="False" {{ 'selected' if allInputDataDict.outage == 'No' }}>No</option>
</select>
</div>
<div class="shortInput">
<label class="tooltip">Critical Load Factor<span class="classic">The fractional percentage of the demand curve representing the critical load that must be met during an outage. Format 0.XX (e.g. 0.50 signifies 50% of the daily demand is the critical load).</span></label>
<input type="text" id="criticalLoadFactor" name="criticalLoadFactor" value="{{allInputDataDict.criticalLoadFactor}}" min="0" max="1" pattern="^\d+\.?\d*?$" required="required"/>
</div>

<!-- Financial Inputs -->
<div class="wideInput">
<p class="inputSectionHeader">Financial Inputs</p>
Expand Down
8 changes: 8 additions & 0 deletions omf/models/derUtilityCost.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,9 @@ def new(modelDir):
demand_curve = f.read()
with open(pJoin(__neoMetaModel__._omfDir,'static','testFiles','utility_CO_2018_temperatures.csv')) as f:
temp_curve = f.read()
## TODO: Change the critical load to utility scale critical load instead of residential
with open(pJoin(__neoMetaModel__._omfDir,'static','testFiles','residential_critical_load.csv')) as f:
criticalLoad_curve = f.read()

defaultInputs = {
## OMF inputs:
Expand All @@ -294,6 +297,11 @@ def new(modelDir):
'tempFileName': 'utility_CO_2018_temperatures.csv',
'demandCurve': demand_curve,
'tempCurve': temp_curve,
## ODO: Change criticalLoadFileName to utility load instead of residential
'criticalLoadFileName': 'residential_critical_load.csv', ## critical load here = 50% of the daily demand
'criticalLoad': criticalLoad_curve,
'criticalLoadSwitch': 'Yes',
'criticalLoadFactor': '0.50',
'PV': 'Yes',
'BESS': 'Yes',
'generator': 'No',
Expand Down

0 comments on commit e9ac82a

Please sign in to comment.