## At the start of each loop, we calculate a new time step. #of.dt = of.gear_time_step()#rmg) ## The storm starts when the model starts. While the elapsed time is less ## than the storm duration, we add water to the system as rainfall. if elapsed_time < storm_duration: of.rainfall_intensity = 4.07222 * (10**-7) # Rainfall intensity in m/s ## Then the elapsed time exceeds the storm duration, rainfall ceases. else: of.rainfall_intensity = 0.0 ## Generating overland flow based on the deAlmeida solution. of.overland_flow() #rmg) ## Append time and discharge to their lists to save data and for plotting. hydrograph_time_sec.append(elapsed_time) hydrograph_time_hrs.append(round(elapsed_time / 3600., 2)) discharge_at_outlet.append(of.q[link_to_sample]) ## Add the time step, repeat until elapsed time >= model_run_time elapsed_time += of.dt plt.figure(2) plt.plot(hydrograph_time_hrs, (np.abs(discharge_at_outlet) * rmg.dx), 'k-') plt.xlabel('Time (hrs)') plt.ylabel('Discharge (cms)') plt.title('Hydrograph')
# and find the ids of the arrays along the west edge of the grid. We actually # will set the discharge values here at every time step in the loop. left_inactive_ids = links.left_edge_horizontal_ids(rmg.shape) # 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 are going to set the left edge horizontal links to their neighboring discharge value rmg['link']['water_discharge'][left_inactive_ids] = rmg['link']['water_discharge'][left_inactive_ids + 1] # Now, we can generate overland flow. of.overland_flow(rmg, dt) # Recalculate water depth at the boundary ... h_boundary = ((seven_over_three)*n*n*u*u*u*elapsed_time)**(three_over_seven) # water depth at left side (m) # And now we input that water depth along the left-most interior column, in all rows that are not boundary rows. rmg['node']['water_depth'][(leftside)[1:len(leftside)-1]] = h_boundary # Print time #print(elapsed_time) # Increased elapsed time elapsed_time += dt # End time... endtime = time()
## At the start of each loop, we calculate a new time step. #of.dt = of.gear_time_step(rmg) ## The storm starts when the model starts. While the elapsed time is less ## than the storm duration, we add water to the system as rainfall. if elapsed_time < storm_duration: of.rainfall_intensity = 4.07222 * (10**-7) # Rainfall intensity in m/s ## Then the elapsed time exceeds the storm duration, rainfall ceases. else: of.rainfall_intensity = 0.0 ## Generating overland flow based on the deAlmeida solution. of.overland_flow() ## Append time and discharge to their lists to save data and for plotting. hydrograph_time_sec.append(elapsed_time) hydrograph_time_hrs.append(round(elapsed_time / 3600., 2)) discharge_at_outlet.append(of.q[link_to_sample]) ## Add the time step, repeat until elapsed time >= model_run_time elapsed_time += of.dt plt.figure(1) plt.plot(hydrograph_time_hrs, (np.abs(discharge_at_outlet) * rmg.dx), 'b-') plt.xlabel('Time (hrs)') plt.ylabel('Discharge (cms)') plt.title('Hydrograph at Outlet')
## At the start of each loop, we calculate a new time step. #of.dt = of.gear_time_step(rmg) ## The storm starts when the model starts. While the elapsed time is less ## than the storm duration, we add water to the system as rainfall. if elapsed_time < storm_duration: of.rainfall_intensity = 4.07222 * (10 ** -7) # Rainfall intensity in m/s ## Then the elapsed time exceeds the storm duration, rainfall ceases. else: of.rainfall_intensity = 0.0 ## Generating overland flow based on the deAlmeida solution. of.overland_flow() ## Append time and discharge to their lists to save data and for plotting. hydrograph_time_sec.append(elapsed_time) hydrograph_time_hrs.append(round(elapsed_time/3600., 2)) discharge_at_outlet.append(of.q[link_to_sample]) ## Add the time step, repeat until elapsed time >= model_run_time elapsed_time += of.dt plt.figure(1) plt.plot(hydrograph_time_hrs, (np.abs(discharge_at_outlet)*rmg.dx), 'b-') plt.xlabel('Time (hrs)') plt.ylabel('Discharge (cms)') plt.title('Hydrograph at Outlet')
## At the start of each loop, we calculate a new time step. of.dt = of.gear_time_step(rmg) ## The storm starts when the model starts. While the elapsed time is less ## than the storm duration, we add water to the system as rainfall. if elapsed_time < storm_duration: of.rainfall_intensity = 4.07222 * (10 ** -7) # Rainfall intensity in m/s ## Then the elapsed time exceeds the storm duration, rainfall ceases. else: of.rainfall_intensity = 0.0 ## Generating overland flow based on the deAlmeida solution. of.overland_flow(rmg) ## Append time and discharge to their lists to save data and for plotting. hydrograph_time_sec.append(elapsed_time) hydrograph_time_hrs.append(round(elapsed_time/3600., 2)) discharge_at_outlet.append(of.q[link_to_sample]) ## Add the time step, repeat until elapsed time >= model_run_time elapsed_time += of.dt plt.figure(1) plt.plot(hydrograph_time_hrs, (np.abs(discharge_at_outlet)*rmg.dx), 'b-') plt.xlabel('Time (hrs)') plt.ylabel('Discharge (cms)') plt.title('Hydrograph at Outlet')