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
ASC95 committed Feb 16, 2024
2 parents 5d90a40 + 170bbb2 commit f462e15
Show file tree
Hide file tree
Showing 12 changed files with 464 additions and 79 deletions.
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,9 @@ omf/scratch/disaggDataGeneration/regression/*
omf/scratch/disaggDataGeneration/regression/workingDir/*
__pycache__/
.vscode/
*.code-workspace
*.code-workspace
omf/solvers/reopt_jl/testFiles/Scenario_test_POST.json
omf/solvers/reopt_jl/testFiles/resultsResilience.json
omf/solvers/reopt_jl/testFiles/results.json
omf/solvers/reopt_jl/testFiles/REoptInputs.json
omf/solvers/reopt_jl/reopt_jl.so
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
47 changes: 18 additions & 29 deletions omf/models/transformerPairing.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,19 @@
<script src="{{pathPrefix}}/static/highcharts4.src.js"></script>
<script src="https://cdn.plot.ly/plotly-1.50.1.min.js"></script>

<style>
#customerLatLong { display: none; }
</style>
<!--
file_upload('voltageDataFile', 'userInputVoltage', 'voltageDataFileName')
input for the actual file
the name of the file the user is using/inputting in
allInputDataDict[voltageDataFileName] = .csv name
<script>
function toggleFileInput() {
var algorithm = document.getElementById("algorithm").value;

if (algorithm === "customerLatLong") {
document.getElementById("customerLatLong").style.display = "block";
document.getElementById("reactivePower").style.display = "none";
}
else if (algorithm === "reactivePower") {
document.getElementById("reactivePower").style.display = "block";
document.getElementById("customerLatLong").style.display = "none";
}
}
</script>

{% macro file_upload(fileInputID, displayNameID) -%}
<input type="file" id="{{fileInputID}}" name="{{fileInputID}}" accept=".csv" class="fileButton" onchange="updateFileNameDisplay('{{fileInputID}}', '{{displayNameID}}')" style="display:none"><br>
<label for="{{fileInputID}}" class="fileButton">Choose File</label>
<input id="{{displayNameID}}" name="{{displayNameID}}" value="{{ allInputDataDict[displayNameID] }}" readonly class="uploadFileName">
{%- endmacro %}
-->
{% macro file_upload(fileInputID, displayNameID, fileNameID) -%}
<input type="file" id="{{fileInputID}}" name="{{ allInputDataDict[fileNameID] }}" accept=".csv" class="fileButton" onchange="updateFileNameDisplay('{{fileInputID}}', '{{displayNameID}}', '{{fileNameID}}')" style="display:none"><br>
<label for="{{fileInputID}}" class="fileButton">Choose File</label>
<input id="{{displayNameID}}" name="{{displayNameID}}" value="{{ allInputDataDict[fileNameID] }}" readonly class="uploadFileName">
<input id="{{fileNameID}}" name= {{fileNameID}} type="hidden" value="{{ allInputDataDict[fileNameID] }}">
{% endmacro %}

</style>
</head>
Expand Down Expand Up @@ -62,32 +51,32 @@
<br>
<div class="shortInput">
<label class="tooltip">Voltage AMI - Data Input File <span class="classic">File type: .csv</span></label>
<div>{{ file_upload('voltageDataFile','voltageDataFileName') }}</div>
<div>{{ file_upload('voltageDataFile', 'userInputVoltage', 'voltageDataFileName' )}}</div>
</div>
<div class="shortInput">
<label class="tooltip">Real Power - AMI Data Input File <span class="classic">File type: .csv</span></label>
<div>{{ file_upload('realPowerDataFile','realPowerDataFileName') }}</div>
<div>{{ file_upload('realPowerDataFile', 'userInputReal', 'realPowerDataFileName') }}</div>
</div>
<div class="shortInput">
<label class="tooltip">Customer ID Data - AMI Data Input File <span class="classic">File type: .csv</span></label>
<div>{{ file_upload('customerIDDataFile','customerIDDataFileName') }}</div>
<div>{{ file_upload('customerIDDataFile', 'userInputCustID', 'customerIDDataFileName') }}</div>
</div>
<br>
<div class="shortInput">
<label class="tooltip">Choose Algorithm: Customer Distance Based or Reactive Power Based</label>
<select id="algorithm" name="algorithm" value="{{allInputDataDict.algorithm}}" required onchange="toggleFileInput()">
<select id="algorithm" name="algorithm" value="{{allInputDataDict.algorithm}}" required>
<option value="reactivePower" {% if allInputDataDict.algorithm == 'reactivePower' %}selected{% endif %}>Reactive Power</option>
<option value="customerLatLong" {% if allInputDataDict.algorithm == 'customerLatLong' %}selected{% endif %}>Customer LatLong</option>
</select>
</div>
<br>
<div class="shortInput" id="customerLatLong">
<label class="tooltip">Customer Latitude & Longitutde - AMI Data Input File <span class="classic">File type: .csv</span></label>
<div>{{ file_upload('customerLatLongDataFile','customerLatLongDataFileName') }}</div>
<div>{{ file_upload('customerLatLongDataFile', 'userInputCustLatLong', 'customerLatLongDataFileName') }}</div>
</div>
<div class="shortInput" id="reactivePower">
<label class="tooltip">Reactive Power - AMI Data Input File <span class="classic">File type: .csv</span></label>
<div>{{ file_upload('reactivePowerDataFile','reactivePowerDataFileName') }}</div>
<div>{{ file_upload('reactivePowerDataFile', 'userInputReactive', 'reactivePowerDataFileName') }}</div>
</div>
<hr>
{{ omfModelButtons }}
Expand Down
Loading

0 comments on commit f462e15

Please sign in to comment.