Skip to content

Commit

Permalink
Merge branch 'master' of github.com:dpinney/omf
Browse files Browse the repository at this point in the history
  • Loading branch information
dpinney committed Jan 9, 2024
2 parents 403bd4c + 703cbd8 commit c323dd4
Show file tree
Hide file tree
Showing 9 changed files with 1,269 additions and 536 deletions.
32 changes: 20 additions & 12 deletions omf/models/derUtilityCost.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,13 @@ def create_REopt_jl_jsonFile(modelDir, inputDict):
},
}

## Outages
if inputDict["outage"] == True:
scenario['ElectricUtility'] = {
'outage_start_time_step': int(inputDict['outage_start_hour']),
'outage_end_time_step': int(inputDict['outage_start_hour'])+int(inputDict['outage_duration'])
}

with open(pJoin(modelDir, "Scenario_test.json"), "w") as jsonFile:
json.dump(scenario, jsonFile)

Expand All @@ -184,14 +191,14 @@ def work(modelDir, inputDict):
correctData = [x+'\n' if x != '999.0' else inputDict['setpoint']+'\n' for x in lines if x != '']
f.write(''.join(correctData))
assert len(correctData) == 8760

outage = True if inputDict["outage"] == "on" else False


## Create REopt input file
create_REopt_jl_jsonFile(modelDir, inputDict)

## Run REopt.jl
reopt_jl.run_reopt_jl(modelDir, "Scenario_test.json")
outage_flag = inputDict['outage']
reopt_jl.run_reopt_jl(modelDir, "Scenario_test.json", outages=outage_flag)
with open(pJoin(modelDir, 'results.json')) as jsonFile:
results = json.load(jsonFile)

Expand Down Expand Up @@ -219,9 +226,10 @@ def work(modelDir, inputDict):
#with open(pJoin(modelDir, 'REoptInputs.json')) as jsonFile:
#reopt_inputs = json.load(jsonFile)

if (outage):
if (inputDict['outage']):
with open(pJoin(modelDir, 'resultsResilience.json')) as jsonFile:
resultsResilience = json.load(jsonFile)
out.update(resultsResilience) ## Update out file with resilience results

## Run vbatDispatch with outputs from REopt
#VB.new(modelDir)
Expand All @@ -230,9 +238,7 @@ def work(modelDir, inputDict):
vbatResults = vb.work(modelDir,inputDict)
with open(pJoin(modelDir, 'vbatResults.json'), 'w') as jsonFile:
json.dump(vbatResults, jsonFile)

## Merge vbatResults dictionary with the out dictionary
out.update(vbatResults)
out.update(vbatResults) ## Update out file with vbat results

## vbatDispatch out data

Expand Down Expand Up @@ -262,16 +268,17 @@ def new(modelDir):
#"latitude" : '39.532165', ## Rivesville, WV
#"longitude" : '-80.120618',
"year" : '2018',
"analysis_years" : 25,
"analysis_years" : '25',
#"urdbLabel" : '612ff9c15457a3ec18a5f7d3', ## Brighton, CO - United Power
"urdbLabel" : '643476222faee2f0f800d8b1', ## Rivesville, WV - Monongahela Power
"demandCurve": demand_curve,
"tempCurve": temp_curve,
"outage": False,
"outage": True,
"outage_start_hour": '2100',
"outage_duration": '3',
"solar" : "on",
"battery" : "on",
"generator" : "off",
"created":str(datetime.datetime.now()),
"load_type": "2",
"number_devices": "1",
"power": "5.6",
Expand All @@ -288,6 +295,7 @@ def new(modelDir):
"unitUpkeepCost":"5",
"fileName": "Texas_1yr_Load.csv",
"tempFileName": "Texas_1yr_Temp.csv",
"created":str(datetime.datetime.now()),
#"fileName": "/Users/astronobri/Documents/CIDER/reopt/inputs/residential_PV_load.csv",
#"fileName": "/Users/astronobri/Documents/CIDER/UP-slide18/3reopt-web-residential-load-profile.csv",
#"tempFileName": "/Users/astronobri/Desktop/extended_temperature_data.csv",
Expand All @@ -298,7 +306,7 @@ def new(modelDir):
@neoMetaModel_test_setup
def _tests():
## Location
modelLoc = pJoin(__neoMetaModel__._omfDir,"data","Model","admin","Automated_Testing_of_" + modelName)
modelLoc = pJoin(__neoMetaModel__._omfDir,"data","Model","admin","Automated Testing of " + modelName)
## Blow away old test results if necessary.
try:
shutil.rmtree(modelLoc)
Expand All @@ -310,7 +318,7 @@ def _tests():
## Pre-run.
__neoMetaModel__.renderAndShow(modelLoc)
## Run the model.
__neoMetaModel__.runForeground(modelLoc)
#__neoMetaModel__.runForeground(modelLoc)
## Show the output.
__neoMetaModel__.renderAndShow(modelLoc)

Expand Down
7 changes: 7 additions & 0 deletions omf/models/restoration.html
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,13 @@
<div id="utilityOutageCostCalc" class="tightContent">
{{ allOutputDataDict['utilityOutageHtml'] }}
</div>
<p class="reportTitle"><label class="tooltip">Outage Incidence <span class="classic">The "Before" status of loads at each timestep as seen in the Timeline below is used to calculate Outage Incidence. The final timestep represents values using the "After" status for the last time in the Timeline. E.g. The Load Outage % value at Before Hour X=5 is the % of loads experiencing an outage calculated with the "Before" value of each load in the Timeline at Time 5. </span></label></p>
<div id="fig6" class="tightContent">
<div id="fig6Chart" style="width:1000px"></div>
<script type="text/javascript">
Plotly.newPlot("fig6Chart", JSON.parse(allOutputData["fig6Data"]), JSON.parse(allOutputData["fig6Layout"]) || {})
</script>
</div>
<p class="reportTitle" style="page-break-before:always">Timeline</p>
<div id="outageCostCalc" class="tightContent sorttable" style="max-height:500px; overflow-y:scroll">
{{ allOutputDataDict['timelineStatsHtml'] }}
Expand Down
Loading

0 comments on commit c323dd4

Please sign in to comment.