Ignore:
Timestamp:
Mar 7, 2012, 9:49:06 PM (13 years ago)
Author:
davies
Message:

Updates to balanced_dev and associated tests

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  
    1010import numpy
    1111from anuga.structures.inlet_operator import Inlet_operator
    12 
     12from anuga import *
     13#from swb_domain import domain
    1314#from anuga import *
    1415#from balanced_basic import *
     
    2324floodplain_width = 14.0 # Model domain width
    2425floodplain_slope = 1./300.
    25 chan_initial_depth = 0.8 # Initial depth of water in the channel
     26chan_initial_depth = 0.65 # Initial depth of water in the channel
    2627chan_bankfull_depth = 1.0 # Bankfull depth of the channel
    2728chan_width = 10.0 # Bankfull width of the channel
    2829bankwidth = 2. # Width of the bank regions -- note that these protrude into the channel
    2930man_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)
     31l0 = 1.000 # Length scale associated with triangle side length in channel (min_triangle area = 0.5*l0^2)
    3132
    3233assert chan_width < floodplain_width, \
     
    8182
    8283
    83 domain.set_name('channel_floodplain1_test') # Output name
    84 domain.extrapolate_velocity_second_order=True
     84domain.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
    8588#------------------------------------------------------------------------------
    8689#
     
    139142
    140143# Define inlet operator
     144flow_in_yval=100.0
    141145if 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] \
    144148              ]
    145149    Qin = 0.5*(floodplain_slope*(chan_width*chan_initial_depth)**2.*man_n**(-2.)\
     
    191195Br = anuga.Reflective_boundary(domain) # Solid reflective wall
    192196Bt = 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
     199Bout_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
    196202
    197203def outflow_stage_boundary(t):
     
    226232#------------------------------------------------------------------------------
    227233
    228 for t in domain.evolve(yieldstep=1.0, finaltime=800.0):
     234for t in domain.evolve(yieldstep=2.0, finaltime=3200.0):
    229235    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
    230254    #print domain.quantities['ymomentum'].get_integral()
    231255    #print 'Qin = ', Qin
  • trunk/anuga_work/development/gareth/tests/channel_floodplain/plotme.py

    r8308 r8353  
    11import util
    2 import pylab
     2from matplotlib import pyplot as pyplot
     3#import pylab
    34
    45# Time-index to plot outputs from
    56index=800
    67
    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
     12p2 = util.get_output('channel_floodplain1_bal_dev.sww', 0.01)
     13p=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
     25v = (p.x>6.0)*(p.x<8.0)
    926#util.animate_1D(p.time, p.stage[:, v], p.y[v])
    1027
     
    1835##########################################################################
    1936
    20 Qin=6.6339  # Inflow discharge
     37#Qin=6.6339  # Inflow discharge
     38#Qin=5.2
     39Qin=4.6932
     40#Qin=4.693286 # Inflow discharge
    2141slp=1./300. # Floodplain slope (= water slope for steady uniform flow)
    2242man_n=0.03  # Manning's n
     
    5373# Analytical solution has U*abs(U)*n^2 / D^(4./3.) = Sf = bed slope
    5474# Hence, the following two variables should be equal -- I have checked that x velocities are fairly small
    55 pylab.clf()
    56 pylab.figure(figsize=(12.,8.))
    57 pylab.plot(p.y[v], (V2**2)**0.5,'o', label='computed velocity')
    58 pylab.plot(p.y[v], V2*0+k*dc_analytical**(2./3.), 'o', label='Analytical velocity')
    59 pylab.plot(p.y[v], V1, 'o',label='computed depth')
    60 pylab.plot(p.y[v], V1*0. + dc_analytical, 'o', label='analytical depth')
    61 #pylab.plot( ( (1./300.)*V1**(4./3.)*(1./0.03)**2.)**0.5,'o', label='Analytical velocity based on computed depth')
    62 pylab.title('Mid channel velocities and depths, vs analytical velocities and depths')
     75pyplot.clf()
     76pyplot.figure(figsize=(12.,8.))
     77pyplot.plot(p.y[v], (V2**2)**0.5,'o', label='computed velocity')
     78pyplot.plot(p.y[v], V2*0+k*dc_analytical**(2./3.), 'o', label='Analytical velocity')
     79pyplot.plot(p.y[v], V1, 'o',label='computed depth')
     80pyplot.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')
     82pyplot.title('Mid channel velocities and depths, vs analytical velocities and depths')
    6383# But in my tests, they are not equal
    64 #pylab.legend( ('computed velocity', 'Analytical velocity', 'computed depth', 'analytical depth'))
    65 pylab.savefig('trapz_velocity_downstream_l0_eq_2t.png')
     84pyplot.legend( ('computed velocity', 'Analytical velocity', 'computed depth', 'analytical depth'), loc=4)
     85pyplot.savefig('trapz_velocity_downstream_l0_eq_1_EL.png')
    6686
    6787# Plot velocity over the cross-section
    68 v1 = (p.y<500.0)&(p.y>470.0)
     88v1 = (p.y<500.0)&(p.y>490.0)
    6989
    70 pylab.clf()
     90pyplot.clf()
    7191analytical_stage = min(p.elev[v1]) + dc_analytical
    7292analytic_vel = ( (1./300.)*(analytical_stage-p.elev[v1])**(4./3.)*(1./0.03)**2.)**0.5
    7393analytic_vel = analytic_vel*(analytical_stage>p.elev[v1])
    74 pylab.figure(figsize=(12.,8.))
    75 pylab.plot(p.x[v1], p.yvel[index,v1],'o', label='computed velocity (m/s)')
    76 pylab.plot(p.x[v1], analytic_vel,'o', label='analytical velocity (m/s)')
    77 pylab.plot(p.x[v1],p.elev[v1],'o', label='bed elevation (m)')
    78 pylab.plot(p.x[v1],p.stage[index,v1],'o', label='computed stage (m)')
    79 pylab.plot(p.x[v1],p.stage[index,v1]*0. + analytical_stage,'o', label='analytical stage (m)')
     94pyplot.figure(figsize=(12.,8.))
     95pyplot.plot(p.x[v1], p.yvel[index,v1],'o', label='computed velocity (m/s)')
     96pyplot.plot(p.x[v1], analytic_vel,'o', label='analytical velocity (m/s)')
     97pyplot.plot(p.x[v1],p.elev[v1],'o', label='bed elevation (m)')
     98pyplot.plot(p.x[v1],p.stage[index,v1],'o', label='computed stage (m)')
     99pyplot.plot(p.x[v1],p.stage[index,v1]*0. + analytical_stage,'o', label='analytical stage (m)')
    80100
    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 
     101pyplot.legend( ('computed velocity (m/s)', 'analytical velocity (m/s)', 'bed elevation (m)', 'computed stage (m)', 'analytical_stage (m)') ,loc=10)
     102pyplot.title('Velocity (analytical and numerical) and Stage:' + '\n' +'Central channel regions (470 to 500m)' +'\n')
     103pyplot.savefig('trapz_velocity_cross_channel_l0_eq_1_EL.png')
    85104
    86105
    87106# Plot velocity over the cross-section
    88 v1 = (p.y<800.0)&(p.y>770.0)
     107v1 = (p.y<800.0)&(p.y>790.0)
    89108
    90 pylab.clf()
     109pyplot.clf()
    91110analytical_stage = min(p.elev[v1]) + dc_analytical
    92111analytic_vel = ( (1./300.)*(analytical_stage-p.elev[v1])**(4./3.)*(1./0.03)**2.)**0.5
    93112analytic_vel = analytic_vel*(analytical_stage>p.elev[v1])
    94 pylab.figure(figsize=(12.,8.))
    95 pylab.plot(p.x[v1], p.yvel[index,v1],'o', label='computed velocity (m/s)')
    96 pylab.plot(p.x[v1], analytic_vel,'o', label='analytical velocity (m/s)')
    97 pylab.plot(p.x[v1],p.elev[v1],'o', label='bed elevation (m)')
    98 pylab.plot(p.x[v1],p.stage[index,v1],'o', label='computed stage (m)')
    99 pylab.plot(p.x[v1],p.stage[index,v1]*0. + analytical_stage,'o', label='analytical stage (m)')
     113pyplot.figure(figsize=(12.,8.))
     114pyplot.plot(p.x[v1], p.yvel[index,v1],'o', label='computed velocity (m/s)')
     115pyplot.plot(p.x[v1], analytic_vel,'o', label='analytical velocity (m/s)')
     116pyplot.plot(p.x[v1],p.elev[v1],'o', label='bed elevation (m)')
     117pyplot.plot(p.x[v1],p.stage[index,v1],'o', label='computed stage (m)')
     118pyplot.plot(p.x[v1],p.stage[index,v1]*0. + analytical_stage,'o', label='analytical stage (m)')
    100119
    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 
     120pyplot.legend( ('computed velocity (m/s)', 'analytical velocity (m/s)', 'bed elevation (m)', 'computed stage (m)', 'analytical_stage (m)') ,loc=10)
     121pyplot.title('Velocity (analytical and numerical) and Stage:' + '\n' +'Central channel regions (470 to 500m)' +'\n')
     122pyplot.savefig('trapz_velocity_cross_channel_l0_eq_1b_EL.png')
    106123
    107124# Plot velocity over the cross-section
    108 v1 = (p.y<900.0)&(p.y>870.0)
     125v1 = (p.y<900.0)&(p.y>890.0)
    109126
    110 pylab.clf()
     127pyplot.clf()
    111128analytical_stage = min(p.elev[v1]) + dc_analytical
    112129analytic_vel = ( (1./300.)*(analytical_stage-p.elev[v1])**(4./3.)*(1./0.03)**2.)**0.5
    113130analytic_vel = analytic_vel*(analytical_stage>p.elev[v1])
    114 pylab.figure(figsize=(12.,8.))
    115 pylab.plot(p.x[v1], p.yvel[index,v1],'o', label='computed velocity (m/s)')
    116 pylab.plot(p.x[v1], analytic_vel,'o', label='analytical velocity (m/s)')
    117 pylab.plot(p.x[v1],p.elev[v1],'o', label='bed elevation (m)')
    118 pylab.plot(p.x[v1],p.stage[index,v1],'o', label='computed stage (m)')
    119 pylab.plot(p.x[v1],p.stage[index,v1]*0. + analytical_stage,'o', label='analytical stage (m)')
     131pyplot.figure(figsize=(12.,8.))
     132pyplot.plot(p.x[v1], p.yvel[index,v1],'o', label='computed velocity (m/s)')
     133pyplot.plot(p.x[v1], analytic_vel,'o', label='analytical velocity (m/s)')
     134pyplot.plot(p.x[v1],p.elev[v1],'o', label='bed elevation (m)')
     135pyplot.plot(p.x[v1],p.stage[index,v1],'o', label='computed stage (m)')
     136pyplot.plot(p.x[v1],p.stage[index,v1]*0. + analytical_stage,'o', label='analytical stage (m)')
    120137
    121 #pylab.legend( ('computed velocity (m/s)', 'analytical velocity (m/s)', 'bed elevation (m)', 'computed stage (m)', 'analytical_stage (m)') )
    122 pylab.title('Velocity (analytical and numerical) and Stage:' + '\n' +'Central channel regions (870 to 900m)' +'\n')
    123 pylab.savefig('trapz_velocity_cross_channel_l0_eq_2tc.png')
     138pyplot.legend( ('computed velocity (m/s)', 'analytical velocity (m/s)', 'bed elevation (m)', 'computed stage (m)', 'analytical_stage (m)') , loc=10)
     139pyplot.title('Velocity (analytical and numerical) and Stage:' + '\n' +'Central channel regions (870 to 900m)' +'\n')
     140pyplot.savefig('trapz_velocity_cross_channel_l0_eq_1c_EL.png')
Note: See TracChangeset for help on using the changeset viewer.