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 Aug 25, 2024
2 parents 21ffd3d + 503c231 commit e1ec456
Show file tree
Hide file tree
Showing 36 changed files with 283,167 additions and 422,616 deletions.
2 changes: 2 additions & 0 deletions omf/models/derConsumer.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,8 @@ def create_REopt_jl_jsonFile(modelDir, inputDict):
scenario['ElectricStorage'] = {
##TODO: Add options here, if needed
#scenario['ElectricStorage']['size_kw'] = 2
"min_kw": 2,
"min_kwh": 2,
}


Expand Down
51 changes: 28 additions & 23 deletions omf/models/derUtilityCost.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,20 +98,20 @@ def work(modelDir, inputDict):
PV = np.zeros_like(demand)

if inputDict['BESS'] == 'Yes': ## BESS
#BESS = reoptResults['ElectricStorage']['storage_to_load_series_kw']
BESS = reoptResults['ElectricStorage']['storage_to_load_series_kw']
#print(BESS)
#BESS = np.ones_like(demand) ## Ad-hoc line used because BESS is not being built in REopt for some reason. Currently debugging 5/2024
#grid_charging_BESS = reoptResults['ElectricUtility']['electric_to_storage_series_kw']
#outData['chargeLevelBattery'] = reoptResults['ElectricStorage']['soc_series_fraction']
grid_charging_BESS = reoptResults['ElectricUtility']['electric_to_storage_series_kw']
outData['chargeLevelBattery'] = reoptResults['ElectricStorage']['soc_series_fraction']

## NOTE: The following 3 lines of code are temporary; it reads in the SOC info from a static reopt test file
## For some reason REopt is not producing BESS results so this is a workaround
with open(pJoin(__neoMetaModel__._omfDir,'static','testFiles','utility_reopt_results.json')) as f:
static_reopt_results = json.load(f)
BESS = static_reopt_results['outputs']['ElectricStorage']['storage_to_load_series_kw']
grid_charging_BESS = static_reopt_results['outputs']['ElectricUtility']['electric_to_storage_series_kw']
outData['chargeLevelBattery'] = static_reopt_results['outputs']['ElectricStorage']['soc_series_fraction']
outData.update(static_reopt_results['outputs'])
#with open(pJoin(__neoMetaModel__._omfDir,'static','testFiles','utility_reopt_results.json')) as f:
# static_reopt_results = json.load(f)
#BESS = static_reopt_results['outputs']['ElectricStorage']['storage_to_load_series_kw']
#grid_charging_BESS = static_reopt_results['outputs']['ElectricUtility']['electric_to_storage_series_kw']
#outData['chargeLevelBattery'] = static_reopt_results['outputs']['ElectricStorage']['soc_series_fraction']
#outData.update(static_reopt_results['outputs'])
else:
BESS = np.zeros_like(demand)
grid_charging_BESS = np.zeros_like(demand)
Expand All @@ -126,17 +126,6 @@ def work(modelDir, inputDict):
vbat_discharge_component = np.zeros_like(demand)
vbat_charge_component = np.zeros_like(demand)

## BESS serving load piece
if (inputDict['BESS'] == 'Yes'):
fig.add_trace(go.Scatter(x=timestamps,
y=np.asarray(BESS) + np.asarray(demand) + vbat_discharge_component,
yaxis='y1',
mode='none',
fill='tozeroy',
name='BESS Serving Load (kW)',
fillcolor='rgba(0,137,83,1)',
showlegend=showlegend))
fig.update_traces(fillpattern_shape='/', selector=dict(name='BESS Serving Load (kW)'))

## Original load piece (minus any vbat or BESS charging aka 'new/additional loads')
fig.add_trace(go.Scatter(x=timestamps,
Expand Down Expand Up @@ -194,6 +183,18 @@ def work(modelDir, inputDict):
# showlegend=showlegend))
#fig.update_traces(legendgroup='Demand', visible='legendonly', selector=dict(name='Original Load (kW)')) ## Make demand hidden on plot by default

## BESS serving load piece
if (inputDict['BESS'] == 'Yes'):
fig.add_trace(go.Scatter(x=timestamps,
y=np.asarray(BESS), # + np.asarray(demand) + vbat_discharge_component,
yaxis='y1',
mode='none',
fill='tozeroy',
name='BESS Serving Load (kW)',
fillcolor='rgba(0,137,83,1)',
showlegend=showlegend))
fig.update_traces(fillpattern_shape='/', selector=dict(name='BESS Serving Load (kW)'))

## PV piece, if enabled
if (inputDict['PV'] == 'Yes'):
fig.add_trace(go.Scatter(x=timestamps,
Expand All @@ -205,6 +206,9 @@ def work(modelDir, inputDict):
fillcolor='rgba(255,246,0,1)',
showlegend=showlegend
))

##vbatDispatch (TESS) piece
#TODO: add enabling/disabling switch here
fig.add_trace(go.Scatter(x=timestamps,
y=np.asarray(vbat_discharge_flipsign),
yaxis='y1',
Expand All @@ -214,6 +218,7 @@ def work(modelDir, inputDict):
name='TESS Serving Load (kW)',
showlegend=showlegend))
fig.update_traces(fillpattern_shape='/', selector=dict(name='TESS Serving Load (kW)'))

## Plot layout
fig.update_layout(
title='Utility Data Test',
Expand Down Expand Up @@ -293,13 +298,13 @@ def new(modelDir):
'BESS': 'Yes',
'generator': 'No',
'outage': True,
'outage_start_hour': '2100',
'outage_duration': '3',
'outage_start_hour': '1836', #march 18, 2018, 2pm
'outage_duration': '4',

## Financial Inputs
'demandChargeURDB': 'Yes',
'demandChargeCost': '0.05',
'projectionLength': '10',
'projectionLength': '25',

## vbatDispatch inputs:
'load_type': '2', ## Heat Pump
Expand Down
1 change: 1 addition & 0 deletions omf/models/hostingCapacity.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ def run_traditional_algorithm( modelDir, inputDict, outData ):
# - opendss.hosting_capacity_all() changes the cwd, so change it back so other code isn't affected
tradHCDF = pd.DataFrame( traditionalHCResults )
sorted_tradHCDF = tradHCDF.sort_values(by='bus')
sorted_tradHCDF.to_csv( "output_tradHC.csv")
sorted_tradHCDF['plot_color'] = sorted_tradHCDF.apply ( lambda row: bar_chart_coloring(row), axis=1 )
# Plotly has its own colors - need to map the "name" of given colors to theirs
traditionalHCFigure = px.bar( sorted_tradHCDF, x='bus', y='max_kw', barmode='group', color='plot_color', color_discrete_map={ 'red': 'red', 'orange': 'orange', 'green': 'green', 'yellow': 'yellow'}, template='simple_white' )
Expand Down
Loading

0 comments on commit e1ec456

Please sign in to comment.