source: trunk/anuga_work/development/gareth/tests/levee2/runuplot.py @ 9121

Last change on this file since 9121 was 9121, checked in by davies, 10 years ago

Adding riverwall validation test

File size: 7.5 KB
Line 
1"""View results of runup.py
2"""
3#---------------
4# Import Modules
5#---------------
6import anuga
7import numpy
8import scipy
9from matplotlib import pyplot as pyplot
10#import util # Routines to read in and work with ANUGA output
11#from bal_and import plot_utils as util
12from anuga.utilities import plot_utils as util
13
14p2=util.get_output('runup_riverwall.sww', minimum_allowed_height=1.0e-03)
15p=util.get_centroids(p2, velocity_extrapolation=True)
16
17#p=util.get_output('runup_v2.sww', minimum_allowed_height=1.0e-03)
18
19#------------------
20# Select line
21#------------------
22#py_central=p.y[scipy.argmin(abs(p.y-50.))]
23#v=(p.y==p.y[py_central])
24v=util.near_transect(p, [0., 50.], [100., 50.], 10.)
25v=v[0]
26v=v[p.x[v].argsort()]
27
28#--------------------
29# Make plot animation
30#--------------------
31pyplot.close() #If the plot is open, there will be problems
32
33if False:
34    pyplot.ion()
35    line, = pyplot.plot( (p.x[v].min(),p.x[v].max()) ,(p.xvel[:,v].min(),p.xvel[:,v].max() ) )
36    for i in range(p.xmom.shape[0]):
37        line.set_xdata(p.x[v])
38        line.set_ydata(p.xvel[i,v])
39        pyplot.draw()
40        pyplot.plot( (0,1),(0,0), 'r' )
41        pyplot.title(str(i)) # : velocity does not converge to zero' )
42        pyplot.xlabel('x')
43        pyplot.ylabel('Velocity (m/s)')
44
45    pyplot.savefig('runup_x_velocities.png')
46
47## Get reference stage points
48seaLev=(abs(p.x-51.)+abs(p.y-50.)).argmin() # Index near levee on sea side
49landLev=(abs(p.x-49.)+abs(p.y-50.)).argmin() # Index near levee on land side
50heightDiff=p.stage[:,seaLev]-p.stage[:,landLev]
51## Get indices on 'landward' side of riverwall
52landInds=(p.x<50.).nonzero()
53# Get volume on landward side of riverwall
54landVol=util.water_volume(p=p2,p2=p,subset=landInds)
55l=len(landVol)
56# Compute rate of influx of water
57d_landVol_dt=(landVol[1:l]-landVol[0:(l-1)])/(p.time[1:l]-p.time[0:(l-1)])
58
59# Estimated flux rate using C*L*H^(3/2)
60# '1' indicates the region where the wall = -0.2
61# '2' indicates the region where the wall = 0.0
62refStage1=p.stage[:,seaLev]
63refStage2=p.stage[:,landLev]
64w1=-0.2
65w2=0.0
66H1_sea =(refStage1-w1)*(refStage1> w1) 
67H2_sea =(refStage1-w2)*(refStage1> w2)
68H1_land=(refStage2-w1)*(refStage2> w1)
69H2_land=(refStage2-w2)*(refStage2> w2)
70# Compute 'uncorrected' flow rates, then villemonte correction, then add
71# Note the '_land' discharge values, which are as suggested by Villemonte for
72# sharp crested weirs. See the paper in my hydraulics references
73
74ft_to_m=0.3048 # 1 foot = ft_to_m metres
75#C=3.2 # Standard constant for sharp crested weir from e.g. HecRas, in units ft^(0.5)/s
76#C=C*(ft_to_m)**0.5 # Convert to m^0.5/s
77C=2./3.*(9.81*2./3.)**0.5 # Another standard coefficient.
78L1=9.0 # In the model, the L1 region is 8m with two 1m rises at each edge, leading to the equivalent of 9m width on average
79L2=91.
80def simple_weir(H, C, L):
81    return L*C*H**(1.5)
82
83InRate1= simple_weir(H1_sea, C, L1) #L1*C*(H1_sea)**1.5
84InRate1_land=simple_weir(H1_land,C,L1) #L1*C*(H1_land)**1.5
85InRate2= simple_weir(H2_sea, C, L2) #L2*C*(H2_sea)**1.5
86InRate2_land= simple_weir(H2_land, C, L2) #L2*C*(H2_land)**1.5
87
88def Vil_cor(InRate_land, InRate, n=1.0):
89    """
90    Apply Villemonte correction to InRate
91    If InRate_land>InRate, then the submergence_adjusted discharge is computed from InRate_land. In that case it is negative
92    Otherwise, the submergence_adjusted discharge is computed from InRate, and is positive
93     
94    """
95    #Fact=InRate_land/(InRate+1.0e-10)*(InRate_land<=InRate) + 1.0*(InRate_land>InRate)
96    Fact=InRate_land/(InRate+1.0e-10)*(InRate_land<=InRate) + InRate/(InRate_land+1.0e-10)*(InRate<InRate_land)
97    assert Fact.max()<=1.0, 'Error Fact > 1'
98    out=InRate*(InRate_land<=InRate)*(1.0 - Fact**n)**0.385 -\
99        InRate_land*(InRate_land>InRate)*(1.0 - Fact**n)**0.385
100    return out
101
102#n=1.0
103Villemonte_correction1=Vil_cor(InRate1_land, InRate1) #(1.0 - (InRate1_land/(InRate1+1.0e-06))**n)**0.385
104Villemonte_correction2=Vil_cor(InRate2_land, InRate2) #(1.0 - (InRate2_land/(InRate2+1.0e-06))**n)**0.385
105
106
107#InRate=InRate1*Villemonte_correction1+InRate2*Villemonte_correction2
108InRate=Villemonte_correction1+Villemonte_correction2
109
110pyplot.close()
111pyplot.figure(figsize=(12,8))
112lab2='ANUGA weir computations [yieldstep-averaged]'
113pyplot.plot(0.5*(p.time[0:(l-1)]+p.time[1:l]), d_landVol_dt, color='red', label=lab2)
114lab1='Simple weir with Villemonte submergence correction'
115pyplot.plot(p.time[1:l], InRate[1:l],color='blue', label=lab1)
116#pyplot.clf()
117#pyplot.plot(InRate[1:l]/ d_landVol_dt)
118#pyplot.ylim((0.,3.))
119
120# Try the Hager approach
121n=1.
122c=1.
123h=p.height[:, seaLev] #refStage1-p.elev[seaLev] # Depth
124H=p.height[:, seaLev] #refStage1-p.elev[seaLev] # Energy head ~ depth
125w=w1-p.elev[seaLev] # Weir height - bed elevation on channel side
126def Hager_weir(h, H, w, n, c, L1):
127    # Terms in Hager, eq 12
128    y=h/(H+1.0e-30)
129    W=w/(H+1.0e-30)
130    # Compute first terms in inrate (which have dimension)
131    InRate_H1=3./5.*n*c*(9.8*H**3)**0.5
132    # Adjust with further dimensionless terms
133    InRate_H1=InRate_H1*((y-W)*(y>W))**(1.5)*( (1.-W)/(3.-2.*y-W))**0.5*(1.-0.)
134    # Multiply by length
135    InRate_H1=InRate_H1*L1
136    return(InRate_H1)
137
138# Compute 'raw' haegar weir outflow
139InRate_H1=Hager_weir(h,H,w,n,c,L1)
140InRate_H1_land=Hager_weir( p.height[:, landLev], p.height[:, landLev], w1-p.elev[landLev], n, c, L1)
141Vil_H1_cor=Vil_cor(InRate_H1_land,InRate_H1)
142#InRate_H1=InRate_H1*Vil_H1_cor
143InRate_H1=Vil_H1_cor
144lab3='Hager weir with Villemonte submergence correction'
145pyplot.plot(p.time[1:l], InRate_H1[1:l],color='green', label=lab3)
146
147# Another correction, eqn 5, Fritz and Hager
148yt=H1_land/(H1_sea+1.0e-30)
149weir_flat_width=0.
150eps=(H1_sea)/(H1_sea+weir_flat_width+1.0e-30)
151yl=0.85-0.5*eps
152def Hager_cor(yt, yl):
153    # 0<=yt<=1
154    yt = yt*(yt<=1.0)*(yt>=0.) + 1.0*(yt>1.0)
155    #
156    Yt=(yt-yl)*(yt>yl)/(1.-yl)
157    n=6.0
158    cor=(1.-Yt)**(1./n)
159    return cor
160
161InRate_H1Raw=Hager_weir(h,H,w,n,c,L1)
162HagerCor1= Hager_cor(yt,yl)
163InRate_H1B = InRate_H1Raw*HagerCor1
164lab4='Hager weir with Fritz and Hager submergence correction [positive flux only]'
165pyplot.plot(p.time[1:l], InRate_H1B[1:l],color='pink', label=lab4)
166pyplot.legend( (lab2, lab1, lab3, lab4), loc='upper right', prop={'size':10},
167                title='Non-ANUGA computations assume a spatially constant \n headwater/tailwater stage, and use submergence corrections \n from the engineering literature')
168pyplot.title('Flux over riverwall (m^3/s)',fontsize=20)
169pyplot.xlabel('Time (s)')
170pyplot.ylabel('Flux (m^3/s)')
171pyplot.savefig('Fluxes.png')
172pyplot.close()
173
174pyplot.figure(figsize=(12,8))
175lab1='Stage minus wall top on "sea" side of riverwall'
176pyplot.plot(p.time, H1_sea, label=lab1)
177lab2='Stage minus wall top on "land" side of riverwall'
178pyplot.plot(p.time, H1_land, label=lab2)
179#pyplot.plot(p.time[[0,l-1]], 0.*p.time[[0,l-1]]-0.2,'-')
180pyplot.legend((lab1,lab2), loc='lower right')
181pyplot.title('Stage above wall top at 2 points near the overflowing riverwall',fontsize=20)
182pyplot.savefig('Stage.png')
183pyplot.close()
184# NOTE: HecRas reduces submerged weir flow OVER BRIDGES according to the
185# submergence ratio = (depth of water above min weir elevation on downstream
186# side)/(height of energy grade line above min weir elevation on upstream
187# side).
188# The discharge reduction factor is > 0.9 for submergence ratio < 0.9, and gets
189# small quickly after that. It is nearly 1.  for ratios around 0.75. Greater
190# reductions are suggested by this version of Villemonte's equations.
191# On the other hand, the WA roads manual indicates that for ratios < 0.75, the
192# flow becomes critical over the bridge, so there is no issue with submergence.
193
194# HOWEVER note presentation 'Weir_submergence_issues.pdf' which discusses different relations
Note: See TracBrowser for help on using the repository browser.