Skip to content

Commit

Permalink
Modified hosting capacity for iowa state algorithm
Browse files Browse the repository at this point in the history
  • Loading branch information
jenny-nyx committed Feb 15, 2024
1 parent 889a734 commit c8e0690
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 34 deletions.
28 changes: 14 additions & 14 deletions omf/models/hostingCapacity.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
</div>
{% endif %}
<div class="wideInput">
<p class="inputSectionHeader">AMI-Based or "MoHCa" Hosting Capacity</p>
<p class="inputSectionHeader">AMI-Based Hosting Capacity</p>
</div>
<hr>
<div class="shortInput">
Expand Down Expand Up @@ -94,33 +94,33 @@
<style>td, th {padding:7 0 5 20;text-align: left;font-size:0.8em; border: 1px solid #cccccc;} </style>
<div id="output">
{% if allInputDataDict['runAmiAlgorithm'] == 'on' %}
<p class="reportTitle">AMI-Based "MoHCA" Hosting Capacity Runtime </p>
<div id="mohcaRunTime" class="tightContent">
<span style="border: 1px solid grey; padding: 3px;"> {{ allOutputDataDict['mohcaRuntime']}} </span>
<p class="reportTitle">AMI-Based Hosting Capacity Runtime </p>
<div id="AMI_runtime" class="tightContent">
<span style="border: 1px solid grey; padding: 3px;"> {{ allOutputDataDict['AMI_runtime']}} </span>
</div>
<p class="reportTitle">AMI-Based Hosting Capacity Distribution</p>
<div id="mohcaHistogramChart" class="tightContent">
<div id="mohcaHistogramChart" style="width:1000px"></div>
<div id="histogramFigure" class="tightContent">
<div id="histogramFigure" style="width:1000px"></div>
<script type="text/javascript">
Plotly.newPlot("mohcaHistogramChart", JSON.parse( allOutputData["mohcaHistogramFigure"]) )
Plotly.newPlot("histogramFigure", JSON.parse( allOutputData["histogramFigure"]) )
</script>
</div>
<p class="reportTitle">AMI-Based Hosting Capacity By Bus</p>
<div id="mohcaBarChart" class="tightContent">
<div id="mohcaBarChart" style="width:1000px"></div>
<div id="barChartFigure" class="tightContent">
<div id="barChartFigure" style="width:1000px"></div>
<script type="text/javascript">
Plotly.newPlot("mohcaBarChart", JSON.parse( allOutputData["mohcaBarChartFigure"]) )
Plotly.newPlot("barChartFigure", JSON.parse( allOutputData["barChartFigure"]) )
</script>
</div>
<p class="reportTitle">AMI-Based Full Hosting Capacity Data Table</p>
<div id="mohcaHostingCapacityTable" class="tightContent">
<div id="AMIhostingCapacityTable" class="tightContent">
<table style='margin:5px;width:990px'>
<tr>
{% for header in allOutputDataDict["mohcaHCTableHeadings"] %}
{% for header in allOutputDataDict["AMI_tableHeadings"] %}
<th>{{ header }}</th>
{% endfor %}
</tr>
{% for values in allOutputDataDict["mohcaHCTableValues"] %}
{% for values in allOutputDataDict["AMI_tableValues"] %}
<tr>
{% for val in values %}
<td>{{ val }}</td>
Expand All @@ -132,7 +132,7 @@
{% endif %}
{% if allInputDataDict['optionalCircuitFile'] == 'on' %}
<p class="reportTitle">Traditional/Model-Based Hosting Capacity Runtime</p>
<div id="mohcaRunTime" class="tightContent">
<div id="traditionalRunTime" class="tightContent">
<span style="border: 1px solid grey; padding: 3px;"> {{ allOutputDataDict['traditionalRuntime'] }} </span>
</div>
<p class="reportTitle" style="page-break-before:always">Traditional Hosting Capacity Map</p>
Expand Down
41 changes: 21 additions & 20 deletions omf/models/hostingCapacity.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
''' Calculate hosting capacity using traditional and/or AMI-based methods. '''
import shutil
from os.path import join as pJoin
import plotly as py
import plotly.express as px
import plotly.graph_objects as go
Expand Down Expand Up @@ -58,30 +57,32 @@ def run_ami_algorithm(modelDir, inputDict, outData):
except:
errorMessage = "AMI-Data CSV file is incorrect format. Please see valid format definition at <a target='_blank' href='https://github.com/dpinney/omf/wiki/Models-~-hostingCapacity#meter-data-input-csv-file-format'>OMF Wiki hostingCapacity</a>"
raise Exception(errorMessage)
outputPath = Path(modelDir, 'mohcaOutput.csv')
mohcaOutput = []
mohca_start_time = time.time()
outputPath = Path(modelDir, 'AMI_output.csv')
AMI_output = []
AMI_start_time = time.time()
if inputDict[ "algorithm" ] == "sandia1":
mohcaOutput = mohca_cl.sandia1( inputPath, outputPath )
elif inputDict[ "algorithm" ] == "sandia2":
mohcaOutput = mohca_cl.sandia2( inputPath, outputPath )
AMI_output = mohca_cl.sandia1( inputPath, outputPath )
elif inputDict[ "algorithm" ] == "iastate":
AMI_output = mohca_cl.iastate( inputPath, outputPath )
else:
errorMessage = "Algorithm name error"
raise Exception(errorMessage)
mohca_end_time = time.time()
mohcaResults = mohcaOutput[0].rename(columns={'kW_hostable': 'voltage_cap_kW'})
mohcaHistogramFigure = px.histogram( mohcaResults, x='voltage_cap_kW', template="simple_white", color_discrete_sequence=["MediumPurple"] )
mohcaHistogramFigure.update_layout(bargap=0.5)
AMI_end_time = time.time()
AMI_results = AMI_output[0].rename(columns={'kW_hostable': 'voltage_cap_kW'})
histogramFigure = px.histogram( AMI_results, x='voltage_cap_kW', template="simple_white", color_discrete_sequence=["MediumPurple"] )
histogramFigure.update_layout(bargap=0.5)
# TBD - Needs to be modified when the MoHCA algorithm supports calculating thermal hosting capacity
mohcaResults['thermal_cap_kW'] = [7.23, 7.34, 7.45, 7.53, 7.24, 6.24, 7.424, 7.23 ]
mohcaResults['max_cap_allowed_kW'] = np.minimum( mohcaResults['voltage_cap_kW'], mohcaResults['thermal_cap_kW'])
mohcaBarChartFigure = px.bar(mohcaResults, x='busname', y=['voltage_cap_kW', 'thermal_cap_kW', 'max_cap_allowed_kW'], barmode='group', color_discrete_sequence=["green", "lightblue", "MediumPurple"], template="simple_white" )
mohcaBarChartFigure.add_traces( list(px.line(mohcaResults, x='busname', y='max_cap_allowed_kW', markers=True).select_traces()) )
outData['mohcaHistogramFigure'] = json.dumps( mohcaHistogramFigure, cls=py.utils.PlotlyJSONEncoder )
outData['mohcaBarChartFigure'] = json.dumps( mohcaBarChartFigure, cls=py.utils.PlotlyJSONEncoder )
outData['mohcaHCTableHeadings'] = mohcaResults.columns.values.tolist()
outData['mohcaHCTableValues'] = ( list(mohcaResults.sort_values( by="max_cap_allowed_kW", ascending=False, ignore_index=True ).itertuples(index=False, name=None)) )
outData['mohcaRuntime'] = mohca_end_time - mohca_start_time
min_value = 5
max_value = 8
AMI_results['thermal_cap_kW'] = np.random.randint(min_value, max_value + 1, size=len(AMI_results))
AMI_results['max_cap_allowed_kW'] = np.minimum( AMI_results['voltage_cap_kW'], AMI_results['thermal_cap_kW'])
barChartFigure = px.bar(AMI_results, x='busname', y=['voltage_cap_kW', 'thermal_cap_kW', 'max_cap_allowed_kW'], barmode='group', color_discrete_sequence=["green", "lightblue", "MediumPurple"], template="simple_white" )
barChartFigure.add_traces( list(px.line(AMI_results, x='busname', y='max_cap_allowed_kW', markers=True).select_traces()) )
outData['histogramFigure'] = json.dumps( histogramFigure, cls=py.utils.PlotlyJSONEncoder )
outData['barChartFigure'] = json.dumps( barChartFigure, cls=py.utils.PlotlyJSONEncoder )
outData['AMI_tableHeadings'] = AMI_results.columns.values.tolist()
outData['AMI_tableValues'] = ( list(AMI_results.sort_values( by="max_cap_allowed_kW", ascending=False, ignore_index=True ).itertuples(index=False, name=None)) )
outData['AMI_runtime'] = AMI_end_time - AMI_start_time


def run_traditional_algorithm(modelDir, inputDict, outData):
Expand Down

0 comments on commit c8e0690

Please sign in to comment.