def evalDryPeatVol(individual): # this should be returning dry peat volume in a tuple wt_canals = utilities.place_dams(oWTcanlist, srfcanlist, BLOCK_HEIGHT, individual, CNM) wt_canal_arr = np.zeros((ny,nx)) # (nx,ny) array with wt canal height in corresponding nodes for canaln, coords in enumerate(c_to_r_list): if canaln == 0: continue # because c_to_r_list begins at 1 wt_canal_arr[coords] = wt_canals[canaln] # phi_ini[coords] = wt_canals[canaln] dry_peat_volume =hydro.hydrology('transient', nx, ny, dx, dy, DAYS, ele, phi_ini, catchment_mask, wt_canal_arr, boundary_arr, peat_type_mask=peat_type_masked, httd=h_to_tra_and_C_dict, tra_to_cut=tra_to_cut, sto_to_cut=sto_to_cut, diri_bc=DIRI_BC, neumann_bc = None, plotOpt=False, remove_ponding_water=True, P=P, ET=ET, dt=TIMESTEP) return dry_peat_volume,
def energy(self): self.wt_canals = utilities.place_dams(oWTcanlist, srfcanlist, BLOCK_HEIGHT, self.state, CNM) wt_canal_arr = np.zeros( (ny, nx)) # (nx,ny) array with wt canal height in corresponding nodes for canaln, coords in enumerate(c_to_r_list): if canaln == 0: continue # because c_to_r_list begins at 1 wt_canal_arr[coords] = self.wt_canals[canaln] # Hinitial[coords] = self.wt_canals[canaln] # It should be like this, but not of much use if hydrology is doing the right thing. e = hydro.hydrology('transient', nx, ny, dx, dy, DAYS, ele, phi_ini, catchment_mask, wt_canal_arr, boundary_arr, peat_type_mask=peat_type_masked, httd=h_to_tra_and_C_dict, tra_to_cut=tra_to_cut, sto_to_cut=sto_to_cut, diri_bc=DIRI_BC, neumann_bc=None, plotOpt=False, remove_ponding_water=True, P=P, ET=ET, dt=TIMESTEP) return e
srfcanlist = [dem[coords] for coords in c_to_r_list] n_canals = len(c_to_r_list) # HANDCRAFTED WATER LEVEL IN CANALS. CHANGE WITH MEASURED, IDEALLY. oWTcanlist = [x - CANAL_WATER_LEVEL for x in srfcanlist] """ ########################################### Initial configuration of blocks in canals ########################################### """ iDamLocation = np.random.randint(1, n_canals, N_BLOCKS).tolist() # Generate random kvector iWTcanlist = utilities.place_dams(oWTcanlist, srfcanlist, BLOCK_HEIGHT, iDamLocation, CNM) wt_canals = iWTcanlist[:] """ ######################################### HYDROLOGY - Parameters ######################################### """ ny, nx = dem.shape dx = 1. dy = 1. # metres per pixel boundary_arr = boundary_mask * (dem - DIRI_BC ) # constant Dirichlet value in the boundaries ele = dem * catchment_mask
# HAND-MADE RULE OF DAM POSITIONS TO ADD: hand_picked_dams = (11170, 10237, 10514, 2932, 4794, 8921, 4785, 5837, 7300, 6868) # rule-based approach hand_picked_dams = [ 6959, 901, 945, 9337, 10089, 7627, 1637, 7863, 7148, 7138, 3450, 1466, 420, 4608, 4303, 6908, 9405, 8289, 7343, 2534, 9349, 6272, 8770, 2430, 2654, 6225, 11152, 118, 4013, 3381, 6804, 6614, 7840, 9839, 5627, 3819, 7971, 402, 6974, 7584, 3188, 8316, 1521, 856, 770, 6504, 707, 5478, 5512, 1732, 3635, 1902, 2912, 9220, 1496, 11003, 8371, 10393, 2293, 4901, 5892, 6110, 2118, 4485, 6379, 10300, 6451, 5619, 9871, 9502, 1737, 4368, 7290, 9071, 11222, 3085, 2013, 5226, 597, 5038 ] damLocation = hand_picked_dams wt_canals = utilities.place_dams(oWTcanlist, srfcanlist, BLOCK_HEIGHT, damLocation, CNM) """ ######################################### HYDROLOGY ######################################### """ ny, nx = dem.shape dx = 1. dy = 1. # metres per pixel (Actually, pixel size is 100m x 100m, so all units have to be converted afterwards) boundary_arr = boundary_mask * ( dem - DIRI_BC) # constant Dirichlet value in the boundaries P = read.read_precipitation() # P = 4 ET = ET * np.ones(shape=P.shape)
gwt=peat_bottom_elevation, h_to_tra_and_C_dict=h_to_tra_and_C_dict) sto_to_cut = hydro_utils.peat_map_h_to_sto( soil_type_mask=peat_type_masked, gwt=peat_bottom_elevation, h_to_tra_and_C_dict=h_to_tra_and_C_dict) sto_to_cut = sto_to_cut * catchment_mask.ravel() srfcanlist = [dem[coords] for coords in c_to_r_list] n_canals = len(c_to_r_list) # HANDCRAFTED WATER LEVEL IN CANALS. CHANGE WITH MEASURED, IDEALLY. oWTcanlist = [x - CANAL_WATER_LEVEL for x in srfcanlist] wt_canals = utilities.place_dams(oWTcanlist, srfcanlist, 0, [], CNM) ny, nx = dem.shape dx = 1. dy = 1. # metres per pixel (Actually, pixel size is 100m x 100m, so all units have to be converted afterwards) boundary_arr = boundary_mask * ( dem - DIRI_BC) # constant Dirichlet value in the boundaries ele = dem * catchment_mask # Get a pickled phi solution (not ele-phi!) computed before without blocks, independently, # and use it as initial condition to improve convergence time of the new solution retrieve_transient_phi_sol_from_pickled = False if retrieve_transient_phi_sol_from_pickled: with open(r"pickled/transient_phi_sol.pkl", 'r') as f: