- Timestamp:
- Mar 7, 2012, 9:49:06 PM (13 years ago)
- Location:
- trunk/anuga_work/development/gareth/tests/channel_floodplain
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/anuga_work/development/gareth/tests/channel_floodplain/channel_floodplain1.py
r8309 r8353 10 10 import numpy 11 11 from anuga.structures.inlet_operator import Inlet_operator 12 12 from anuga import * 13 #from swb_domain import domain 13 14 #from anuga import * 14 15 #from balanced_basic import * … … 23 24 floodplain_width = 14.0 # Model domain width 24 25 floodplain_slope = 1./300. 25 chan_initial_depth = 0. 8# Initial depth of water in the channel26 chan_initial_depth = 0.65 # Initial depth of water in the channel 26 27 chan_bankfull_depth = 1.0 # Bankfull depth of the channel 27 28 chan_width = 10.0 # Bankfull width of the channel 28 29 bankwidth = 2. # Width of the bank regions -- note that these protrude into the channel 29 30 man_n=0.03 # Manning's n 30 l0 = 2.009# Length scale associated with triangle side length in channel (min_triangle area = 0.5*l0^2)31 l0 = 1.000 # Length scale associated with triangle side length in channel (min_triangle area = 0.5*l0^2) 31 32 32 33 assert chan_width < floodplain_width, \ … … 81 82 82 83 83 domain.set_name('channel_floodplain1_test') # Output name 84 domain.extrapolate_velocity_second_order=True 84 domain.set_name('channel_floodplain1_bal_dev_lowvisc') # Output name 85 #domain.set_store_vertices_uniquely(True) 86 #domain.use_edge_limiter=False 87 #domain.extrapolate_velocity_second_order=False 85 88 #------------------------------------------------------------------------------ 86 89 # … … 139 142 140 143 # Define inlet operator 144 flow_in_yval=100.0 141 145 if True: 142 line1 = [ [floodplain_width/2. - chan_width/2., 0.],\143 [floodplain_width/2. + chan_width/2., 0.] \146 line1 = [ [floodplain_width/2. - chan_width/2., flow_in_yval],\ 147 [floodplain_width/2. + chan_width/2., flow_in_yval] \ 144 148 ] 145 149 Qin = 0.5*(floodplain_slope*(chan_width*chan_initial_depth)**2.*man_n**(-2.)\ … … 191 195 Br = anuga.Reflective_boundary(domain) # Solid reflective wall 192 196 Bt = anuga.Transmissive_boundary(domain) # Transmissive boundary 193 #Bout_sub = anuga.Dirichlet_boundary( \ 194 # [-floodplain_length*floodplain_slope - chan_bankfull_depth + \ 195 # chan_initial_depth, 0., 0.]) #An outflow boundary for subcritical steady flow 197 198 199 Bout_sub = anuga.Dirichlet_boundary( \ 200 [-floodplain_length*floodplain_slope - chan_bankfull_depth + \ 201 chan_initial_depth, 0., 0.]) #An outflow boundary for subcritical steady flow 196 202 197 203 def outflow_stage_boundary(t): … … 226 232 #------------------------------------------------------------------------------ 227 233 228 for t in domain.evolve(yieldstep= 1.0, finaltime=800.0):234 for t in domain.evolve(yieldstep=2.0, finaltime=3200.0): 229 235 print domain.timestepping_statistics() 236 xx=domain.quantities['ymomentum'].centroid_values 237 dd=(domain.quantities['stage'].centroid_values - domain.quantities['elevation'].centroid_values) 238 dd=dd*(dd>0.) 239 240 tmp = xx/(dd+1.0e-06)*(dd>0.0) 241 print tmp.max(), tmp.argmax(), tmp.min(), tmp.argmin() 242 243 # Compute flow through cross-section -- check that the inflow boundary condition is doing its job 244 # This also provides another useful steady-state check 245 if( numpy.floor(t/100.) == t/100. ): 246 print '#### COMPUTING FLOW THROUGH CROSS-SECTIONS########' 247 s1 = domain.get_flow_through_cross_section([[0., floodplain_length-300.0], [floodplain_width, floodplain_length-300.0]]) 248 s2 = domain.get_flow_through_cross_section([[0., floodplain_length-1.0], [floodplain_width, floodplain_length-1.0]]) 249 250 print 'Cross sectional flows: ', s1, s2 251 print '$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$' 252 253 #vv = domain.get_flow_through_cross_section 230 254 #print domain.quantities['ymomentum'].get_integral() 231 255 #print 'Qin = ', Qin -
trunk/anuga_work/development/gareth/tests/channel_floodplain/plotme.py
r8308 r8353 1 1 import util 2 import pylab 2 from matplotlib import pyplot as pyplot 3 #import pylab 3 4 4 5 # Time-index to plot outputs from 5 6 index=800 6 7 7 p = util.get_output('channel_floodplain1_test.sww') 8 v = (p.x>5.0)*(p.x<7.0) 8 #p2 = util.get_output('channel_floodplain1_bal_dev.sww', minimum_allowed_height=0.01) 9 #p=p2 10 #p=util.get_centroids(p2, velocity_extrapolation=True) 11 12 p2 = util.get_output('channel_floodplain1_bal_dev.sww', 0.01) 13 p=util.get_centroids(p2, velocity_extrapolation=True) 14 15 16 #p2 = util.get_output('channel_floodplain1_test_edge_lim.sww', minimum_allowed_height=0.01) 17 #p2 = util.get_output('channel_floodplain1_test.sww', minimum_allowed_height=0.01) 18 #p=util.get_centroids(p2, velocity_extrapolation=False) 19 20 #p2 = util.get_output('channel_floodplain1_standard.sww', minimum_allowed_height=0.01) 21 #p2 = util.get_output('channel_floodplain1_balanced_basic.sww', minimum_allowed_height=0.01) 22 #p2 = util.get_output('channel_floodplain1_dev.sww') 23 #p=util.get_centroids(p2, velocity_extrapolation=True) 24 #p=p2 25 v = (p.x>6.0)*(p.x<8.0) 9 26 #util.animate_1D(p.time, p.stage[:, v], p.y[v]) 10 27 … … 18 35 ########################################################################## 19 36 20 Qin=6.6339 # Inflow discharge 37 #Qin=6.6339 # Inflow discharge 38 #Qin=5.2 39 Qin=4.6932 40 #Qin=4.693286 # Inflow discharge 21 41 slp=1./300. # Floodplain slope (= water slope for steady uniform flow) 22 42 man_n=0.03 # Manning's n … … 53 73 # Analytical solution has U*abs(U)*n^2 / D^(4./3.) = Sf = bed slope 54 74 # Hence, the following two variables should be equal -- I have checked that x velocities are fairly small 55 py lab.clf()56 py lab.figure(figsize=(12.,8.))57 py lab.plot(p.y[v], (V2**2)**0.5,'o', label='computed velocity')58 py lab.plot(p.y[v], V2*0+k*dc_analytical**(2./3.), 'o', label='Analytical velocity')59 py lab.plot(p.y[v], V1, 'o',label='computed depth')60 py lab.plot(p.y[v], V1*0. + dc_analytical, 'o', label='analytical depth')61 #py lab.plot( ( (1./300.)*V1**(4./3.)*(1./0.03)**2.)**0.5,'o', label='Analytical velocity based on computed depth')62 py lab.title('Mid channel velocities and depths, vs analytical velocities and depths')75 pyplot.clf() 76 pyplot.figure(figsize=(12.,8.)) 77 pyplot.plot(p.y[v], (V2**2)**0.5,'o', label='computed velocity') 78 pyplot.plot(p.y[v], V2*0+k*dc_analytical**(2./3.), 'o', label='Analytical velocity') 79 pyplot.plot(p.y[v], V1, 'o',label='computed depth') 80 pyplot.plot(p.y[v], V1*0. + dc_analytical, 'o', label='analytical depth') 81 #pyplot.plot( ( (1./300.)*V1**(4./3.)*(1./0.03)**2.)**0.5,'o', label='Analytical velocity based on computed depth') 82 pyplot.title('Mid channel velocities and depths, vs analytical velocities and depths') 63 83 # But in my tests, they are not equal 64 #pylab.legend( ('computed velocity', 'Analytical velocity', 'computed depth', 'analytical depth'))65 py lab.savefig('trapz_velocity_downstream_l0_eq_2t.png')84 pyplot.legend( ('computed velocity', 'Analytical velocity', 'computed depth', 'analytical depth'), loc=4) 85 pyplot.savefig('trapz_velocity_downstream_l0_eq_1_EL.png') 66 86 67 87 # Plot velocity over the cross-section 68 v1 = (p.y<500.0)&(p.y>4 70.0)88 v1 = (p.y<500.0)&(p.y>490.0) 69 89 70 py lab.clf()90 pyplot.clf() 71 91 analytical_stage = min(p.elev[v1]) + dc_analytical 72 92 analytic_vel = ( (1./300.)*(analytical_stage-p.elev[v1])**(4./3.)*(1./0.03)**2.)**0.5 73 93 analytic_vel = analytic_vel*(analytical_stage>p.elev[v1]) 74 py lab.figure(figsize=(12.,8.))75 py lab.plot(p.x[v1], p.yvel[index,v1],'o', label='computed velocity (m/s)')76 py lab.plot(p.x[v1], analytic_vel,'o', label='analytical velocity (m/s)')77 py lab.plot(p.x[v1],p.elev[v1],'o', label='bed elevation (m)')78 py lab.plot(p.x[v1],p.stage[index,v1],'o', label='computed stage (m)')79 py lab.plot(p.x[v1],p.stage[index,v1]*0. + analytical_stage,'o', label='analytical stage (m)')94 pyplot.figure(figsize=(12.,8.)) 95 pyplot.plot(p.x[v1], p.yvel[index,v1],'o', label='computed velocity (m/s)') 96 pyplot.plot(p.x[v1], analytic_vel,'o', label='analytical velocity (m/s)') 97 pyplot.plot(p.x[v1],p.elev[v1],'o', label='bed elevation (m)') 98 pyplot.plot(p.x[v1],p.stage[index,v1],'o', label='computed stage (m)') 99 pyplot.plot(p.x[v1],p.stage[index,v1]*0. + analytical_stage,'o', label='analytical stage (m)') 80 100 81 #pylab.legend( ('computed velocity (m/s)', 'analytical velocity (m/s)', 'bed elevation (m)', 'computed stage (m)', 'analytical_stage (m)') ) 82 pylab.title('Velocity (analytical and numerical) and Stage:' + '\n' +'Central channel regions (470 to 500m)' +'\n') 83 pylab.savefig('trapz_velocity_cross_channel_l0_eq_2t.png') 84 101 pyplot.legend( ('computed velocity (m/s)', 'analytical velocity (m/s)', 'bed elevation (m)', 'computed stage (m)', 'analytical_stage (m)') ,loc=10) 102 pyplot.title('Velocity (analytical and numerical) and Stage:' + '\n' +'Central channel regions (470 to 500m)' +'\n') 103 pyplot.savefig('trapz_velocity_cross_channel_l0_eq_1_EL.png') 85 104 86 105 87 106 # Plot velocity over the cross-section 88 v1 = (p.y<800.0)&(p.y>7 70.0)107 v1 = (p.y<800.0)&(p.y>790.0) 89 108 90 py lab.clf()109 pyplot.clf() 91 110 analytical_stage = min(p.elev[v1]) + dc_analytical 92 111 analytic_vel = ( (1./300.)*(analytical_stage-p.elev[v1])**(4./3.)*(1./0.03)**2.)**0.5 93 112 analytic_vel = analytic_vel*(analytical_stage>p.elev[v1]) 94 py lab.figure(figsize=(12.,8.))95 py lab.plot(p.x[v1], p.yvel[index,v1],'o', label='computed velocity (m/s)')96 py lab.plot(p.x[v1], analytic_vel,'o', label='analytical velocity (m/s)')97 py lab.plot(p.x[v1],p.elev[v1],'o', label='bed elevation (m)')98 py lab.plot(p.x[v1],p.stage[index,v1],'o', label='computed stage (m)')99 py lab.plot(p.x[v1],p.stage[index,v1]*0. + analytical_stage,'o', label='analytical stage (m)')113 pyplot.figure(figsize=(12.,8.)) 114 pyplot.plot(p.x[v1], p.yvel[index,v1],'o', label='computed velocity (m/s)') 115 pyplot.plot(p.x[v1], analytic_vel,'o', label='analytical velocity (m/s)') 116 pyplot.plot(p.x[v1],p.elev[v1],'o', label='bed elevation (m)') 117 pyplot.plot(p.x[v1],p.stage[index,v1],'o', label='computed stage (m)') 118 pyplot.plot(p.x[v1],p.stage[index,v1]*0. + analytical_stage,'o', label='analytical stage (m)') 100 119 101 #pylab.legend( ('computed velocity (m/s)', 'analytical velocity (m/s)', 'bed elevation (m)', 'computed stage (m)', 'analytical_stage (m)') ) 102 pylab.title('Velocity (analytical and numerical) and Stage:' + '\n' +'Central channel regions (770 to 800m)' +'\n') 103 pylab.savefig('trapz_velocity_cross_channel_l0_eq_2tb.png') 104 105 120 pyplot.legend( ('computed velocity (m/s)', 'analytical velocity (m/s)', 'bed elevation (m)', 'computed stage (m)', 'analytical_stage (m)') ,loc=10) 121 pyplot.title('Velocity (analytical and numerical) and Stage:' + '\n' +'Central channel regions (470 to 500m)' +'\n') 122 pyplot.savefig('trapz_velocity_cross_channel_l0_eq_1b_EL.png') 106 123 107 124 # Plot velocity over the cross-section 108 v1 = (p.y<900.0)&(p.y>8 70.0)125 v1 = (p.y<900.0)&(p.y>890.0) 109 126 110 py lab.clf()127 pyplot.clf() 111 128 analytical_stage = min(p.elev[v1]) + dc_analytical 112 129 analytic_vel = ( (1./300.)*(analytical_stage-p.elev[v1])**(4./3.)*(1./0.03)**2.)**0.5 113 130 analytic_vel = analytic_vel*(analytical_stage>p.elev[v1]) 114 py lab.figure(figsize=(12.,8.))115 py lab.plot(p.x[v1], p.yvel[index,v1],'o', label='computed velocity (m/s)')116 py lab.plot(p.x[v1], analytic_vel,'o', label='analytical velocity (m/s)')117 py lab.plot(p.x[v1],p.elev[v1],'o', label='bed elevation (m)')118 py lab.plot(p.x[v1],p.stage[index,v1],'o', label='computed stage (m)')119 py lab.plot(p.x[v1],p.stage[index,v1]*0. + analytical_stage,'o', label='analytical stage (m)')131 pyplot.figure(figsize=(12.,8.)) 132 pyplot.plot(p.x[v1], p.yvel[index,v1],'o', label='computed velocity (m/s)') 133 pyplot.plot(p.x[v1], analytic_vel,'o', label='analytical velocity (m/s)') 134 pyplot.plot(p.x[v1],p.elev[v1],'o', label='bed elevation (m)') 135 pyplot.plot(p.x[v1],p.stage[index,v1],'o', label='computed stage (m)') 136 pyplot.plot(p.x[v1],p.stage[index,v1]*0. + analytical_stage,'o', label='analytical stage (m)') 120 137 121 #pylab.legend( ('computed velocity (m/s)', 'analytical velocity (m/s)', 'bed elevation (m)', 'computed stage (m)', 'analytical_stage (m)'))122 py lab.title('Velocity (analytical and numerical) and Stage:' + '\n' +'Central channel regions (870 to 900m)' +'\n')123 py lab.savefig('trapz_velocity_cross_channel_l0_eq_2tc.png')138 pyplot.legend( ('computed velocity (m/s)', 'analytical velocity (m/s)', 'bed elevation (m)', 'computed stage (m)', 'analytical_stage (m)') , loc=10) 139 pyplot.title('Velocity (analytical and numerical) and Stage:' + '\n' +'Central channel regions (870 to 900m)' +'\n') 140 pyplot.savefig('trapz_velocity_cross_channel_l0_eq_1c_EL.png')
Note: See TracChangeset
for help on using the changeset viewer.