Skip to content

Commit

Permalink
minor running updates
Browse files Browse the repository at this point in the history
  • Loading branch information
stroutm committed Jul 8, 2019
1 parent f625c0e commit 37d40ca
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 37 deletions.
4 changes: 2 additions & 2 deletions code/mbc_fn.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def mbc(ustream, dstream, setpts, uparam, dparam, n_tanks, action, discharge, ma
alpha = uparam*np.ones(n_tanks)
beta = np.zeros(n_tanks)
betamax = 2
N = 1 #TESTING
N = 100 #TESTING
#ORIGINAL.0 uparam = uparam*np.ones(n_tanks)
for i in range(0,n_tanks):
#ORINGAL.1 beta[i] = alpha[i] * (1+ustream[i])
Expand Down Expand Up @@ -172,7 +172,7 @@ def mbc_multi(ustream, dstream, setpts, uparam, dparam, n_tanks, action, dischar
alpha = uparam*np.ones(n_tanks)
beta = np.zeros(n_tanks)
betamax = 2
N = 1 #TESTING
N = 100 #TESTING
#ORIGINAL.0 uparam = uparam*np.ones(n_tanks)
for i in range(0,n_tanks):
#ORIGINAL.1 beta[i] = alpha[i] * (1+ustream[i])
Expand Down
8 changes: 4 additions & 4 deletions code/plot_figures_multi.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@

routime_step = 10 # number of seconds between samples
storm = '201701'
objType = 'both'
objType = 'TSS'
hierarchyOpt = 'NH'
ISD_arrangement = 'A'
noRangeBegin = 2
noRangeEnd = 3
noRangeBegin = 5
noRangeEnd = 6
if storm == '201701':
timeBegin = 2*24*60*60/routime_step #7*24*60*60/routime_step
timeEnd = 62*24*60*60/routime_step #360*24*60*60/routime_step
Expand All @@ -29,7 +29,7 @@
show = 1

fileNamesBase = 'trial2_' + objType + '_' + storm + '_' + hierarchyOpt + '_' + ISD_arrangement + '_flood_short'
fileNamesBase = 'test_both_6'
fileNamesBase = 'test_' + objType + '_final_short'

if hierarchyOpt == 'NH':
hierarchy = 0
Expand Down
40 changes: 20 additions & 20 deletions code/plot_fn.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ def plot_noControl(n_trunkline, n_ISDs, plotParams, time, ustream_depths, WRRF_f
# color = plotParams['colors'][a], linestyle = ':')

# Flow at downstream WRRF
plt.subplot(153)
#plt.subplot(132)
#plt.subplot(153)
plt.subplot(132)
if plotParams['normalize'] == 1:
plt.plot(time[timeBegin:timeEnd],WRRF_flow[timeBegin:timeEnd]/maxes['max_flow_WRRF'], label = "No control, WRRF flow",
color = plotParams['colors'][-1], linestyle = ':')
Expand All @@ -25,8 +25,8 @@ def plot_noControl(n_trunkline, n_ISDs, plotParams, time, ustream_depths, WRRF_f


# TSS load at downstream WRRF
plt.subplot(154)
#plt.subplot(133)
#plt.subplot(154)
plt.subplot(133)
if plotParams['normalize'] == 1:
plt.plot(time[timeBegin:timeEnd],WRRF_TSSLoad[timeBegin:timeEnd]/maxes['max_TSSLoad_WRRF'], label = "No control, WRRF TSS Load",
color = plotParams['colors'][-1], linestyle = ':')
Expand All @@ -39,12 +39,12 @@ def plot_control(n_trunkline, n_ISDs, ctrlParams, plotParams, time_state, time_c

for a in range(0,sum(n_ISDs)):
# Water depths in conduits upstream of ISDs (i.e., demanders of capacity)
plt.subplot(151)
#plt.subplot(131)
#plt.subplot(151)
plt.subplot(131)
plt.plot(time_state,ustream_depths[:,a],
label = "MBC, " + plotParams['labels'][a],
color = plotParams['colors'][a], linestyle = '-')

'''
for a in range(0,sum(n_ISDs)):
plt.subplot(155)
plt.plot(time_control,demands[:,a], label = "Demand " + plotParams['labels'][a],
Expand All @@ -56,10 +56,10 @@ def plot_control(n_trunkline, n_ISDs, ctrlParams, plotParams, time_state, time_c
plt.subplot(152)
plt.plot(time_state,gates[:,a], label = "Gate actions " + plotParams['labels'][a],
color = plotParams['colors'][a], linestyle = '-')

'''
# Flow at downstream WRRF (i.e., seller of capacity)
plt.subplot(153)
#plt.subplot(132)
#plt.subplot(153)
plt.subplot(132)
if plotParams['normalize'] == 1:
plt.plot(time_state,WRRF_flow/maxes['max_flow_WRRF'], label = "MBC, WRRF flow",
color = plotParams['colors'][-1], linestyle = '-')
Expand All @@ -84,8 +84,8 @@ def plot_control(n_trunkline, n_ISDs, ctrlParams, plotParams, time_state, time_c
'''

# TSS load at downstream WRRF (i.e., seller of capacity)
plt.subplot(154)
#plt.subplot(133)
#plt.subplot(154)
plt.subplot(133)
if plotParams['normalize'] == 1:
plt.plot(time_state,WRRF_TSSLoad/maxes['max_TSSLoad_WRRF'], label = "MBC, WRRF TSS Load",
color = plotParams['colors'][-1], linestyle = '-')
Expand Down Expand Up @@ -113,8 +113,8 @@ def plot_finish(normalize, timeBegin, timeEnd, routime_step):
## Adds labels, limits, etc. to plots and shows plot

# Water depths in conduits upstream of ISDs
plt.subplot(151)
#plt.subplot(131)
#plt.subplot(151)
plt.subplot(131)
plt.ylabel('Upstream Normalized Conduit Depth')
plt.ylim(0,1)
#plt.xlim(0,(timeEnd-timeBegin)/(24*60*60/routime_step))
Expand All @@ -123,8 +123,8 @@ def plot_finish(normalize, timeBegin, timeEnd, routime_step):
#plt.legend()

# Flow at downstream WRRF
plt.subplot(153)
#plt.subplot(132)
#plt.subplot(153)
plt.subplot(132)
plt.ylim(0,25)
plt.ylabel('WRRF Flow ($\mathregular{m^3/s}$)')
#plt.xlim(0,(timeEnd-timeBegin)/(24*60*60/routime_step))
Expand All @@ -133,15 +133,15 @@ def plot_finish(normalize, timeBegin, timeEnd, routime_step):
#plt.legend()

# TSS load at downstream WRRF
plt.subplot(154)
#plt.subplot(133)
#plt.subplot(154)
plt.subplot(133)
plt.ylabel('WRRF TSS Load ($\mathregular{kg/s}$)')
plt.ylim(0,3.5)
#plt.xlim(0,(timeEnd-timeBegin)/(24*60*60/routime_step))
plt.xlim(timeBegin/(24*60*60/routime_step),timeEnd/(24*60*60/routime_step))
plt.xlabel('Time (days)')
#plt.legend()

'''
# Gate positions at all controlled ISDs
plt.subplot(152)
plt.ylabel('Gate actions')
Expand All @@ -155,4 +155,4 @@ def plot_finish(normalize, timeBegin, timeEnd, routime_step):
#plt.xlim(0,(timeEnd-timeBegin)/(24*60*60/routime_step))
plt.xlim(timeBegin/(24*60*60/routime_step),timeEnd/(24*60*60/routime_step))
plt.xlabel('Time (days)')

'''
12 changes: 6 additions & 6 deletions code/resultsCompile.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

# Enter result file information
storm = '201701'
objType = 'flow'
objType = 'both'
hierarchyOpt = 'NH'
ISD_arrangement = 'A_flood_short'
# Trial number range
Expand All @@ -13,7 +13,7 @@
# Timestep range
timeBegin = 2*24*60*60/routime_step # start 2 days in
if storm == '201701':
timeEnd = 62*24*60*60/routime_step #365*24*60*60/routime_step #
timeEnd = 365*24*60*60/routime_step #62*24*60*60/routime_step #
elif storm == '201806':
timeEnd = 259200
saveType = "numpy" # "numpy" or "pickle"
Expand All @@ -26,7 +26,7 @@
fileName = 'trial_' + objType + '_' + storm + '_NH_' + ISD_arrangement + '.pkl'
elif saveType == "numpy":
fileName = 'trial2_' + objType + '_' + storm + '_NH_' + ISD_arrangement + '.npy'
fileName = 'test_' + objType + '_final_short.npy'
fileName = 'test_' + objType + '_final_N.npy'

# Loads and stores no control results as workspace variables
if saveType == "pickle":
Expand Down Expand Up @@ -135,7 +135,7 @@
summ_NC[0,16] = no_control_res['flooding']

# Save summary array of no-control performance metrics in a compliation .csv file
saveFileName_NC = '../data/results/no_control/resultSumm_' + storm + '_short.csv'
saveFileName_NC = '../data/results/no_control/resultSumm_' + storm + '_N.csv'
np.savetxt(saveFileName_NC, summ_NC, delimiter=",")

# Initializes summary array for performance metrics
Expand All @@ -149,7 +149,7 @@
fileName = 'trial_' + objType + '_' + storm + '_NH_' + ISD_arrangement + '_' + "%02d" % (i) + '.pkl'
elif saveType == "numpy":
fileName = 'trial2_' + objType + '_' + storm + '_NH_' + ISD_arrangement + '_' + "%02d" % (i) + '.npy'
fileName = 'test_' + objType + '_final_' + "%02d" % (i) + '.npy'
fileName = 'test_' + objType + '_final_N100_' + "%02d" % (i) + '.npy'

n_trunkline = 3
if ISD_arrangement == 'A':
Expand Down Expand Up @@ -382,7 +382,7 @@

# Save summary array of performance metrics after each control simulation in
# a compliation .csv file
saveFileName = '../data/results/control/resultSumm_' + objType + '_' + storm + '_short.csv'
saveFileName = '../data/results/control/resultSumm_' + objType + '_' + storm + '_N100.csv'
np.savetxt(saveFileName, summ, delimiter=",")

del control_res_load, control_res, timeOverFlowSetpt, timeOverTSSLSetpt
Expand Down
10 changes: 5 additions & 5 deletions code/test_mbc_hierarchy_TSS.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import swmmAPI as swmm

# Enter 1 to include no control simulation and 0 otherwise
noControl = 1
noControl = 0
# Enter 1 to include control simulation and 0 otherwise
control = 1

Expand All @@ -32,10 +32,10 @@
'epsilon_TSS': 0.0
}
saveNames = ['trial2_TSS_201701_NH_A_flood_short']
saveNames = ['test_both_final_short']
saveNames = ['test_both_final_N100']
saveType = "numpy" # or "pickle"
eps_flows = [1.,2.5,5.,7.5,10.,12.5,15.,17.5,20.]
eps_TSS = [1.,2.5,5.,7.5,10.,12.5,15.,17.5,20.]
eps_flows = [5.]#[1.,2.5,5.,7.5,10.,12.5,15.,17.5,20.]
eps_TSS = [5.]#[1.,2.5,5.,7.5,10.,12.5,15.,17.5,20.]
# Counter for saving results (starts at counter+1)
counter = 0

Expand Down Expand Up @@ -67,7 +67,7 @@
'[VERTICES]','[Polygons]','[SYMBOLS]','[PROFILES]']
# Enter .inp file name and location
inpF = "../data/input_files/GDRSS/GDRSS_SCT_simple_ISDs_TSS_inflows_201701_timesteps.inp"
timesteps = 62*24*60*60/10 #365*24*60*60/10
timesteps = 365*24*60*60/10 #62*24*60*60/10 #
# Sections and dictionaries generated for SWMM attributes;
# used for pulling parameters and states
sections = swmm.make_sections(inpF,headers)
Expand Down

0 comments on commit 37d40ca

Please sign in to comment.