def test_water_volume(self): """ Check that water volume is right We assume triangle areas are computed ok, but note they are tested above """ self.create_domain(InitialOceanStage=1., InitialLandStage=0., flowAlg='DE0', verbose=verbose) p=util.get_output('test_plot_utils.sww') pc=util.get_centroids(p,velocity_extrapolation=True) # Check that subsetting works ta=util.triangle_areas(p) # Independently computed water volume wVol_2=(ta*pc.height[2,:]).sum() wv=util.water_volume(p,pc) assert(np.allclose(wVol_2, wv[2])) os.remove('test_plot_utils.sww')
def test_water_volume(self): """ Check that water volume is right We assume triangle areas are computed ok, but note they are tested above """ self.create_domain(InitialOceanStage=1., InitialLandStage=0., flowAlg='DE0', verbose=verbose) p = util.get_output('test_plot_utils.sww') pc = util.get_centroids(p, velocity_extrapolation=True) # Check that subsetting works ta = util.triangle_areas(p) # Independently computed water volume wVol_2 = (ta * pc.height[2, :]).sum() wv = util.water_volume(p, pc) assert (np.allclose(wVol_2, wv[2])) os.remove('test_plot_utils.sww')
pyplot.draw() pyplot.plot( (0,1),(0,0), 'r' ) pyplot.title(str(i)) # : velocity does not converge to zero' ) pyplot.xlabel('x') pyplot.ylabel('Velocity (m/s)') pyplot.savefig('runup_x_velocities.png') ## Get reference stage points seaLev=(abs(p.x-51.)+abs(p.y-50.)).argmin() # Index near levee on sea side landLev=(abs(p.x-49.)+abs(p.y-50.)).argmin() # Index near levee on land side heightDiff=p.stage[:,seaLev]-p.stage[:,landLev] ## Get indices on 'landward' side of riverwall landInds=(p.x<50.).nonzero() # Get volume on landward side of riverwall landVol=util.water_volume(p=p2,p2=p,subset=landInds) l=len(landVol) # Compute rate of influx of water d_landVol_dt=(landVol[1:l]-landVol[0:(l-1)])/(p.time[1:l]-p.time[0:(l-1)]) # Estimated flux rate using C*L*H^(3/2) # '1' indicates the region where the wall = -0.2 # '2' indicates the region where the wall = 0.0 refStage1=p.stage[:,seaLev] refStage2=p.stage[:,landLev] w1=-0.2 w2=0.0 H1_sea =(refStage1-w1)*(refStage1> w1) H2_sea =(refStage1-w2)*(refStage1> w2) H1_land=(refStage2-w1)*(refStage2> w1) H2_land=(refStage2-w2)*(refStage2> w2)