def test_Bates_analytical(): from landlab import RasterModelGrid grid = RasterModelGrid((32, 240), xy_spacing=25) grid.add_zeros("node", "surface_water__depth") grid.add_zeros("node", "topographic__elevation") grid.set_closed_boundaries_at_grid_edges(True, True, True, True) bates = OverlandFlowBates(grid, mannings_n=0.01, h_init=0.001) time = 0.0 bates.dt = 1.0 while time < 500: bates.overland_flow(grid) h_boundary = ((7. / 3.) * (0.01 ** 2) * (0.4 ** 3) * time) ** (3. / 7.) grid.at_node["surface_water__depth"][grid.nodes[1:-1, 1]] = h_boundary time += bates.dt x = np.arange(0, ((grid.shape[1]) * grid.dx), grid.dx) h_analytical = -(7. / 3.) * (0.01 ** 2) * (0.4 ** 2) * (x - (0.4 * 500)) h_analytical[np.where(h_analytical > 0)] = h_analytical[ np.where(h_analytical > 0) ] ** (3. / 7.) h_analytical[np.where(h_analytical < 0)] = 0.0 hBates = bates.h.reshape(grid.shape) hBates = hBates[1][1:] hBates = np.append(hBates, [0]) np.testing.assert_almost_equal(h_analytical, hBates, decimal=1)
def setup_grid(): from landlab import RasterModelGrid grid = RasterModelGrid((32, 240), spacing=25) grid.add_zeros('node', 'surface_water__depth') grid.add_zeros('node', 'topographic__elevation') bates = OverlandFlowBates(grid, mannings_n=0.01, h_init=0.001) globals().update({'bates': bates})
def bates(): grid = RasterModelGrid((32, 240), xy_spacing=25) grid.add_zeros("surface_water__depth", at="node") grid.add_zeros("topographic__elevation", at="node") return OverlandFlowBates(grid, mannings_n=0.01, h_init=0.001)
# Set our boundaries to closed to prevent water from flowing out of the plane rmg.set_closed_boundaries_at_grid_edges(True, True, True, True) # Create fields in the grid for topographic elevation, water depth, discharge. rmg.add_zeros('topographic__elevation', at='node') # topographic elevation (m) rmg.add_zeros('water__depth', at='node') # water depth (m) # Now we'll identify our leftmost, but interior, column and the IDs of those # nodes. One column in to prevent issues with BC. inside_left_edge = rmg.nodes[1: -1, 1] # Initializing our class... of = OverlandFlowBates(rmg, mannings_n=n, h_init=h_init) # Let's see how long this run takes... starttime = time() while elapsed_time < run_time: # Now, we generate overland flow. of.overland_flow() # Recalculate water depth at the boundary ... # water depth at left side (m) h_boundary = (seven_over_three * n * n * u * u * u * elapsed_time) ** three_over_seven # And now we input that water depth along the left-most interior column,
def bates(): grid = RasterModelGrid((32, 240), spacing = 25) grid.add_zeros('surface_water__depth', at='node') grid.add_zeros('topographic__elevation', at='node') return OverlandFlowBates(grid, mannings_n = 0.01, h_init=0.001)
# Set our boundaries to closed to prevent water from flowing out of the plane rmg.set_closed_boundaries_at_grid_edges(True, True, True, True) # Create fields in the grid for topographic elevation, water depth, discharge. rmg.add_zeros('topographic__elevation', at='node') # topographic elevation (m) rmg.add_zeros('surface_water__depth', at='node') # water depth (m) # Now we'll identify our leftmost, but interior, column and the IDs of those # nodes. One column in to prevent issues with BC. inside_left_edge = rmg.nodes[1: -1, 1] # Initializing our class... of = OverlandFlowBates(rmg, mannings_n=n, h_init=h_init) # Let's see how long this run takes... starttime = time() while elapsed_time < run_time: # Now, we generate overland flow. of.overland_flow() # Recalculate water depth at the boundary ... # water depth at left side (m) h_boundary = (seven_over_three * n * n * u * u * u * elapsed_time) ** three_over_seven # And now we input that water depth along the left-most interior column,
rmg.set_closed_boundaries_at_grid_edges(True, True, True, True) # Create fields in the grid for topographic elevation, water depth and discharge. rmg.add_zeros('topographic__elevation', at='node') # topographic elevation (m) rmg.add_zeros('water_depth', at='node') # water depth (m) rmg.add_zeros('water_discharge', at='active_link') # unit discharge (m2/s) # Add our initial thin layer of water to the field of water depth. rmg['node']['water_depth'] += h_init # Now we'll identify our leftmost, but interior, column and the IDs of those # nodes. One column in to prevent issues with BC. inside_left_edge = rmg.nodes[1: -1, 1] # Initializing our class... of = OverlandFlowBates(rmg) # Let's see how long this run takes... starttime = time() while elapsed_time < run_time: # First, we calculate our time step. dt = of.gear_time_step(rmg) # Now, we generate overland flow. of.overland_flow(rmg) # Recalculate water depth at the boundary ... # water depth at left side (m) h_boundary = (seven_over_three * n * n * u * u * u * elapsed_time) ** three_over_seven
# Set our boundaries to closed to prevent water from flowing out of the plane rmg.set_closed_boundaries_at_grid_edges(True, True, True, True) # Create fields in the grid for topographic elevation, water depth, discharge. rmg.add_zeros('topographic__elevation', at='node') # topographic elevation (m) rmg.add_zeros('water__depth', at='node') # water depth (m) rmg.add_zeros('water__discharge', at='active_link') # unit discharge (m2/s) # Now we'll identify our leftmost, but interior, column and the IDs of those # nodes. One column in to prevent issues with BC. inside_left_edge = rmg.nodes[1: -1, 1] # Initializing our class... of = OverlandFlowBates(rmg, mannings_n=n, h_init=h_init) # Let's see how long this run takes... starttime = time() while elapsed_time < run_time: # Now, we generate overland flow. of.overland_flow(rmg) # Recalculate water depth at the boundary ... # water depth at left side (m) h_boundary = (seven_over_three * n * n * u * u * u * elapsed_time) ** three_over_seven # And now we input that water depth along the left-most interior column,