Ejemplo n.º 1
0
    #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,
                     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)]
Ejemplo n.º 2
0
            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']
            fill_percent = np.repeat(
                [.99], n_dams4)  #np.random.uniform(0,0.8,n_dams4).round(2)#
            S = (S_max * fill_percent).tolist()
            SSN5.set_dam_state(states=[1 for _ in range(n_dams4)])
            SSN5.initialize(q=q, S=S, s_t=s_t, s_p=s_p, s_s=s_s)

            dc_passive_S4, st_passive_S4 = SSN5.Run_256([0, te], forcing,
                                                        dam_params256)
            out_passive_S4 = SSN5.CalculateOutflow(dam_params256,
                                                   st_passive_S4)

            temp1 = dc_passive_S4.max(
            )  #dc_passive_S4[dc_passive_S4.index>120].max()
            temp2 = out_passive_S4.max(
            )  #out_passive_S4[out_passive_S4.index>120].max()

            dc_passive_Peak_S4 = dc_passive_Peak_S4.append(temp1,
                                                           ignore_index=True)
            out_passive_Peak_S4 = out_passive_Peak_S4.append(temp2,
                                                             ignore_index=True)

        print(
            f'(Scenario-4)Storm:{dstorm} is simulated with given initial conditions!'
Ejemplo n.º 3
0
                 L_i=L_i,
                 A_h=A_h)
 H_spill, H_max, S_max, _alpha, diam, c1, c2, L_spill, L_crest = PrepareDamParams(
     dams5
 )  #!! TODO: make the code run without this parameters when no dam introduced
 dam_params256 = SSN.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']
 SSN.initialize(q=q, s_p=s_p, s_t=s_t, s_s=s_s)
 SSN.set_dam_state()
 dc_nodam, _ = SSN.Run_256(
     [0, te],
     forcing,
     dam_params256,
     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)
Ejemplo n.º 4
0
            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']
            fill_percent = np.repeat(
                [.99], n_dams1)  #()np.random.uniform(0,0.8,n_dams1).round(2)
            S = (S_max * fill_percent).tolist()
            SSN2.set_dam_state(states=[1 for _ in range(n_dams1)])
            SSN2.initialize(q=q, S=S, s_t=s_t, s_p=s_p, s_s=s_s)

            dc_passive_S1, st_passive_S1 = SSN2.Run_256([0, te], forcing,
                                                        dam_params256)
            out_passive_S1 = SSN2.CalculateOutflow(dam_params256,
                                                   st_passive_S1)

            temp1 = dc_passive_S1.max(
            )  #dc_passive_S1[dc_passive_S1.index>120].max()
            temp2 = out_passive_S1.max(
            )  #out_passive_S1[out_passive_S1.index>120].max()

            dc_passive_Peak_S1 = dc_passive_Peak_S1.append(temp1,
                                                           ignore_index=True)
            out_passive_Peak_S1 = out_passive_Peak_S1.append(temp2,
                                                             ignore_index=True)

        print(
            f'(Scenario-1)Storm:{dstorm} is simulated with given initial conditions!'