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)
# 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, # in all rows that are not boundary rows. rmg.at_node['water__depth'][inside_left_edge] = h_boundary # Increased elapsed time elapsed_time += of.dt # End time... endtime = time()
# 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, # in all rows that are not boundary rows. rmg.at_node['surface_water__depth'][inside_left_edge] = h_boundary # Increased elapsed time elapsed_time += of.dt # End time... endtime = time()
# 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 # And now we input that water depth along the left-most interior column, in all rows that are not boundary rows. rmg.at_node['water_depth'][inside_left_edge] = h_boundary # Print time #print(elapsed_time) # Increased elapsed time elapsed_time += dt
# 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) dt = 1.0 # Let's see how long this run takes... starttime = time() while elapsed_time < run_time: # Now, we generate overland flow. of.overland_flow(rmg, dt) # 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, # in all rows that are not boundary rows. rmg.at_node['water_depth'][inside_left_edge] = h_boundary # Print time #print(elapsed_time) dt = of.gear_time_step(rmg) #print(elapsed_time)
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, # in all rows that are not boundary rows. rmg.at_node['water__depth'][inside_left_edge] = h_boundary # Increased elapsed time elapsed_time += of.dt # End time... endtime = time()