1 | """View results of runup.py |
---|
2 | """ |
---|
3 | #--------------- |
---|
4 | # Import Modules |
---|
5 | #--------------- |
---|
6 | import anuga |
---|
7 | import numpy |
---|
8 | import scipy |
---|
9 | from 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 |
---|
12 | from anuga.utilities import plot_utils as util |
---|
13 | |
---|
14 | p2=util.get_output('runup_riverwall.sww', minimum_allowed_height=1.0e-03) |
---|
15 | p=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]) |
---|
24 | v=util.near_transect(p, [0., 50.], [100., 50.], 10.) |
---|
25 | v=v[0] |
---|
26 | v=v[p.x[v].argsort()] |
---|
27 | |
---|
28 | #-------------------- |
---|
29 | # Make plot animation |
---|
30 | #-------------------- |
---|
31 | pyplot.close() #If the plot is open, there will be problems |
---|
32 | |
---|
33 | if 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 |
---|
48 | seaLev=(abs(p.x-50.7)+abs(p.y-50.)).argmin() # Index near levee on sea side |
---|
49 | landLev=(abs(p.x-49.3)+abs(p.y-50.)).argmin() # Index near levee on land side |
---|
50 | heightDiff=p.stage[:,seaLev]-p.stage[:,landLev] |
---|
51 | ## Get indices on 'landward' side of riverwall |
---|
52 | landInds=(p.x<50.).nonzero() |
---|
53 | # Get volume on landward side of riverwall |
---|
54 | landVol=util.water_volume(p=p2,p2=p,subset=landInds) |
---|
55 | l=len(landVol) |
---|
56 | # Compute rate of influx of water |
---|
57 | d_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 |
---|
62 | refStage1=p.stage[:,seaLev] |
---|
63 | refStage2=p.stage[:,landLev] |
---|
64 | w1=-0.2 |
---|
65 | w2=0.0 |
---|
66 | H1_sea =(refStage1-w1)*(refStage1> w1) |
---|
67 | H2_sea =(refStage1-w2)*(refStage1> w2) |
---|
68 | H1_land=(refStage2-w1)*(refStage2> w1) |
---|
69 | H2_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 | |
---|
74 | ft_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 |
---|
77 | C=2./3.*(9.81*2./3.)**0.5 # Another standard coefficient. |
---|
78 | L1=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 |
---|
79 | L2=91. |
---|
80 | def simple_weir(H, C, L): |
---|
81 | return L*C*H**(1.5) |
---|
82 | |
---|
83 | InRate1= simple_weir(H1_sea, C, L1) #L1*C*(H1_sea)**1.5 |
---|
84 | InRate1_land=simple_weir(H1_land,C,L1) #L1*C*(H1_land)**1.5 |
---|
85 | InRate2= simple_weir(H2_sea, C, L2) #L2*C*(H2_sea)**1.5 |
---|
86 | InRate2_land= simple_weir(H2_land, C, L2) #L2*C*(H2_land)**1.5 |
---|
87 | |
---|
88 | def 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 |
---|
103 | Villemonte_correction1=Vil_cor(InRate1_land, InRate1) #(1.0 - (InRate1_land/(InRate1+1.0e-06))**n)**0.385 |
---|
104 | Villemonte_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 |
---|
108 | InRate=Villemonte_correction1+Villemonte_correction2 |
---|
109 | |
---|
110 | pyplot.close() |
---|
111 | pyplot.figure(figsize=(12,8)) |
---|
112 | lab2='ANUGA weir computations [yieldstep-averaged]' |
---|
113 | pyplot.plot(0.5*(p.time[0:(l-1)]+p.time[1:l]), d_landVol_dt, color='red', label=lab2) |
---|
114 | lab1='Simple weir with Villemonte submergence correction' |
---|
115 | pyplot.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 |
---|
121 | n=1. |
---|
122 | c=1. |
---|
123 | h=p.height[:, seaLev] #refStage1-p.elev[seaLev] # Depth |
---|
124 | H=p.height[:, seaLev] #refStage1-p.elev[seaLev] # Energy head ~ depth |
---|
125 | w=w1-p.elev[seaLev] # Weir height - bed elevation on channel side |
---|
126 | def 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 |
---|
139 | InRate_H1=Hager_weir(h,H,w,n,c,L1) |
---|
140 | InRate_H1_land=Hager_weir( p.height[:, landLev], p.height[:, landLev], w1-p.elev[landLev], n, c, L1) |
---|
141 | Vil_H1_cor=Vil_cor(InRate_H1_land,InRate_H1) |
---|
142 | #InRate_H1=InRate_H1*Vil_H1_cor |
---|
143 | InRate_H1=Vil_H1_cor |
---|
144 | lab3='Hager weir with Villemonte submergence correction' |
---|
145 | pyplot.plot(p.time[1:l], InRate_H1[1:l],color='green', label=lab3) |
---|
146 | |
---|
147 | # Another correction, eqn 5, Fritz and Hager |
---|
148 | yt=H1_land/(H1_sea+1.0e-30) |
---|
149 | weir_flat_width=0. |
---|
150 | eps=(H1_sea)/(H1_sea+weir_flat_width+1.0e-30) |
---|
151 | yl=0.85-0.5*eps |
---|
152 | def 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 | |
---|
161 | InRate_H1Raw=Hager_weir(h,H,w,n,c,L1) |
---|
162 | HagerCor1= Hager_cor(yt,yl) |
---|
163 | InRate_H1B = InRate_H1Raw*HagerCor1 |
---|
164 | lab4='Hager weir with Fritz and Hager submergence correction [positive flux only]' |
---|
165 | pyplot.plot(p.time[1:l], InRate_H1B[1:l],color='pink', label=lab4) |
---|
166 | pyplot.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') |
---|
168 | pyplot.title('Flux over riverwall (m^3/s)',fontsize=20) |
---|
169 | pyplot.xlabel('Time (s)') |
---|
170 | pyplot.ylabel('Flux (m^3/s)') |
---|
171 | pyplot.savefig('Fluxes.png') |
---|
172 | pyplot.close() |
---|
173 | |
---|
174 | pyplot.figure(figsize=(12,8)) |
---|
175 | lab1='Stage minus wall top on "sea" side of riverwall' |
---|
176 | pyplot.plot(p.time, H1_sea, label=lab1) |
---|
177 | lab2='Stage minus wall top on "land" side of riverwall' |
---|
178 | pyplot.plot(p.time, H1_land, label=lab2) |
---|
179 | #pyplot.plot(p.time[[0,l-1]], 0.*p.time[[0,l-1]]-0.2,'-') |
---|
180 | pyplot.legend((lab1,lab2), loc='lower right') |
---|
181 | pyplot.title('Stage above wall top at 2 points near the overflowing riverwall',fontsize=20) |
---|
182 | pyplot.savefig('Stage.png') |
---|
183 | pyplot.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 |
---|