SSN1.initialize(q=q, s_p=s_p, s_t=s_t, s_s=s_s) dc_nodam = SSN1.Run_254( [0, te], forcing, rtol=1e-6, ) #Passive Scenario print('Running passive case..') 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 = dams dam_params256 = SSN2.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)] SSN2.set_dam_state(states=[1 for _ in range(n_dams)]) SSN2.initialize(q=q, S=S, s_t=s_t, s_p=s_p, s_s=s_s) dc_passive, st_passive = SSN2.Run_256([0, te], forcing, dam_params256) #Active Control with GA print('Running active control case') # watershed object initialization SSN5 = Watershed(Model=256) SSN5.init_custom(links=l_id, connectivity=connectivity, A_i=A_i,
rate10 = [ 12, 30, 63, 75, 84, 87, 90, 93.5, 95, 96.01, 97.44, 97.44, 99.42, 99.42, 99.67, 100 ] print(f'Simulations started at {datetime.datetime.now().time()}') ## 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)
rtol=1e-6, ) dc_nodam.to_csv( f'/Users/gurbuz/Supp_DamStudy/final_ActiveControl/dc_nodam_{save_ext}.csv' ) print(f'Done nodam in {time.time()-start}') ################################################################################################### start = time.time() print('Running Passive..') 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 = dams5 H_spill, H_max, S_max, _alpha, diam, c1, c2, L_spill, L_crest = PrepareDamParams( dams5) dam_params256 = SSN5.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() SSN5.set_dam_state(states=[1 for _ in range(n_dams5)]) SSN5.initialize(q=q, S=S, s_t=s_t, s_p=s_p, s_s=s_s) dc_passive_S5, st_passive_S5 = SSN5.Run_256([0, te], forcing, dam_params256) out_passive_S5 = SSN5.CalculateOutflow(dam_params256, st_passive_S5)
# pass # print(f'(NODAM)Storm:{dstorm} is simulated with given initial conditions!') # dc_nodam_Peak.to_csv('/Users/gurbuz/Supp_DamStudy/Dam_Configuration/dc_nodam_Peak_rand08.csv') # print('No dam scenario is done and results are saved!\n') # print(f'Time: {datetime.datetime.now().time()}') ## 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