connectivity=connectivity, A_i=A_i, L_i=L_i, A_h=A_h) SSN5.dam_ids = dams dam_params256 = SSN5.init_dam_params256(H_spill, H_max, S_max, _alpha, diam, c1, c2, L_spill, L_crest) q, s_p, s_t, s_s = Set_InitialConditions(0.5, A_i[0], A_i) S = [100000 for _ in range(n_dams)] # continuous simulation update = 60 #mins lead_time = 360 # the time window checked if there will be any flooding lead_time_opt = 60 # the time window used in optimization procedure t0 = 0 states_all = [(-60, [1 for _ in range(len(dams))])] columns = SSN5.__columns__() dc_ga = pd.DataFrame(columns=columns[0]) st_ga = pd.DataFrame(columns=columns[1]) while t0 < te - lead_time: if t0 != 0: q, S, s_p, s_t, s_s = SSN5.Get_Snapshot() #define initial conditions SSN5.initialize(q=q, S=S, s_p=s_p, s_t=s_t, s_s=s_s) #check if flooding occurs data = RunSimulation([ SSN5, [1 for _ in range(n_dams)], t0, forcing, dam_params256, lead_time ]) flow = data[0]
## SCENARIO-4 ############################################################################# SSN5 = Watershed(Model=256) SSN5.init_custom(links=l_id, connectivity=connectivity, A_i=A_i, L_i=L_i, A_h=A_h) SSN5.dam_ids = dams4 H_spill, H_max, S_max, _alpha, diam, c1, c2, L_spill, L_crest = PrepareDamParams( dams4) diam = [1.25 for _ in range(len(dams2))] + diam[4:] dam_params256 = SSN5.init_dam_params256(H_spill, H_max, S_max, _alpha, diam, c1, c2, L_spill, L_crest) dc_passive_Peak_S4 = pd.DataFrame(columns=SSN5.__columns__()[0]) out_passive_Peak_S4 = pd.DataFrame(columns=SSN5.__columns__()[1]) for dstorm in dstorms: forcing, cum_forcing, forcing_hour = Generate_SyntheticStorm( dstorm, 24, rate=(0.01 * np.diff(rate10, prepend=0)).tolist(), timescale=30) te = len(forcing) - 1 for key in initial_conditions.keys(): initial_condition = initial_conditions[key] q = initial_condition['q'] s_p = initial_condition['s_p'] s_t = initial_condition['s_t']
A_h=A_h) SSN5_r.dam_ids = dams5 H_spill, H_max, S_max, _alpha, diam, c1, c2, L_spill, L_crest = PrepareDamParams( dams5) dam_params256 = SSN5_r.init_dam_params256(H_spill, H_max, S_max, _alpha, diam, c1, c2, L_spill, L_crest) q = initial_condition['q'] s_p = initial_condition['s_p'] s_t = initial_condition['s_t'] s_s = initial_condition['s_s'] fill_percent = np.repeat([0.0001], n_dams5) S = (S_max * fill_percent).tolist() t0 = 0 update = 30 #mins columns = SSN5_r.__columns__() dc_active_S5r = pd.DataFrame(columns=columns[0]) st_active_S5r = pd.DataFrame(columns=columns[1]) out_active_S5r = pd.DataFrame(columns=columns[1]) while t0 < te: if t0 != 0: q, S, s_p, s_t, s_s = SSN5_r.Get_Snapshot() SSN5_r.initialize(q=q, S=S, s_t=s_t, s_p=s_p, s_s=s_s) SSN5_r.set_dam_state( states=np.random.choice([0, 0.25, 0.50, 0.75, 1], size=(n_dams5))) try: dc_S5, st_S5 = SSN5_r.Run_256([t0, t0 + update], forcing, dam_params256)
## SCENARIO-1 ############################################################################# SSN2 = Watershed(Model=256) SSN2.init_custom(links=l_id, connectivity=connectivity, A_i=A_i, L_i=L_i, A_h=A_h) SSN2.dam_ids = dams1 H_spill, H_max, S_max, _alpha, diam, c1, c2, L_spill, L_crest = PrepareDamParams( dams1) dam_params256 = SSN2.init_dam_params256(H_spill, H_max, S_max, _alpha, diam, c1, c2, L_spill, L_crest) dc_passive_Peak_S1 = pd.DataFrame(columns=SSN2.__columns__()[0]) out_passive_Peak_S1 = pd.DataFrame(columns=SSN2.__columns__()[1]) for dstorm in dstorms: forcing, cum_forcing, forcing_hour = Generate_SyntheticStorm( dstorm, 24, rate=(0.01 * np.diff(rate10, prepend=0)).tolist(), timescale=30) te = len(forcing) - 1 for key in initial_conditions.keys(): initial_condition = initial_conditions[key] q = initial_condition['q'] s_p = initial_condition['s_p'] s_t = initial_condition['s_t'] s_s = initial_condition['s_s']