Changeset 6652


Ignore:
Timestamp:
Mar 28, 2009, 1:02:07 PM (15 years ago)
Author:
ole
Message:

Added another test that shows problems with internal flows which vary
considerably with friction towards understanding ticket:324.
This test does not use the Inflow forcing term, but applies instead a boundary
condition driving the flow.
Test has been disabled.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • anuga_core/source/anuga/shallow_water/test_shallow_water_domain.py

    r6651 r6652  
    68326832
    68336833
    6834                 x=200.0
    6835                 y=10.00
    6836                
    6837                
    6838 
    68396834                #------------------------------------------------------------------------------
    68406835                # Compute flow thru flowlines ds of inflow
     
    68586853
    68596854                # Stage recorder (gauge) in middle of plane at 200m
     6855                x=200.0
     6856                y=10.00
    68606857                w = domain.get_quantity('stage').get_values(interpolation_points=[[x, y]])[0]
    68616858                z = domain.get_quantity('elevation').get_values(interpolation_points=[[x, y]])[0]
     
    68666863                # v=1/n*(r^2/3)*(s^0.5) or r=(Q*n/(s^0.5*W))^0.6
    68676864                normal_depth=(ref_flow*mannings_n/(slope**0.5*width))**0.6
    6868                 msg = 'Predicted depth of flow was %f, should have been %f' % (normal_depth, domain_depth)
     6865                msg = 'Predicted depth of flow was %f, should have been %f' % (domain_depth, normal_depth)               
    68696866                if verbose:
    68706867                    print 'Depth: ANUGA = %f, Mannings = %f' % (domain_depth, normal_depth)
     
    68796876       
    68806877       
    6881 
    6882    
     6878    def Xtest_friction_dependent_flow_using_flowline(self):
     6879        """test_friction_dependent_flow_using_flowline
     6880       
     6881        Test the internal flow (using flowline) as a function of
     6882        different values of Mannings n and different slopes.
     6883       
     6884        Flow is applied in the form of boundary conditions with fixed momentum.
     6885        """
     6886
     6887        verbose = True
     6888       
     6889
     6890        #------------------------------------------------------------------------------
     6891        # Import necessary modules
     6892        #------------------------------------------------------------------------------
     6893        from anuga.abstract_2d_finite_volumes.mesh_factory import rectangular_cross
     6894        from anuga.shallow_water import Domain
     6895        from anuga.shallow_water.shallow_water_domain import Reflective_boundary
     6896        from anuga.shallow_water.shallow_water_domain import Dirichlet_boundary
     6897        from anuga.shallow_water.shallow_water_domain import Inflow
     6898        from anuga.shallow_water.data_manager import get_flow_through_cross_section
     6899        from anuga.abstract_2d_finite_volumes.util import sww2csv_gauges, csv2timeseries_graphs
     6900
     6901
     6902        #------------------------------------------------------------------------------
     6903        # Setup computational domain
     6904        #------------------------------------------------------------------------------
     6905        finaltime = 300.0
     6906
     6907        length = 300.
     6908        width  = 20.
     6909        dx = dy = 5       # Resolution: of grid on both axes
     6910       
     6911        # Input parameters
     6912        uh = 1.0
     6913        vh = 0.0
     6914        d = 1.0
     6915       
     6916        ref_flow = uh*d*width # 20 m^3/s in the x direction across entire domain
     6917
     6918        points, vertices, boundary = rectangular_cross(int(length/dx), int(width/dy),
     6919                                                       len1=length, len2=width)
     6920
     6921        for mannings_n in [0.0, 0.012, 0.035]:
     6922            for slope in [0.0, 1.0/300, 1.0/150]:
     6923                # Loop over a range of bedslopes representing sub to super critical flows
     6924
     6925                if verbose:
     6926                    print
     6927                    print 'Slope:', slope, 'Mannings n:', mannings_n
     6928                domain = Domain(points, vertices, boundary)   
     6929                domain.set_name('Inflow_flowline_test')              # Output name
     6930               
     6931
     6932                #------------------------------------------------------------------------------
     6933                # Setup initial conditions
     6934                #------------------------------------------------------------------------------
     6935
     6936                def topography(x, y):
     6937                    z=-x * slope
     6938                    return z
     6939
     6940                domain.set_quantity('elevation', topography)  # Use function for elevation
     6941                domain.set_quantity('friction', mannings_n)   # Constant friction
     6942               
     6943                #domain.set_quantity('stage',
     6944                #                    expression='elevation')
     6945                                                   
     6946               
     6947                # Set initial flow as depth=1m, uh=1.0 m/s, vh = 0.0
     6948                # making it 20 m^3/s across entire domain
     6949                domain.set_quantity('stage',
     6950                                    expression='elevation + %f' % d)
     6951                domain.set_quantity('xmomentum', uh)
     6952                domain.set_quantity('ymomentum', vh)               
     6953
     6954
     6955                #------------------------------------------------------------------------------
     6956                # Setup boundary conditions
     6957                #------------------------------------------------------------------------------
     6958
     6959                Br = Reflective_boundary(domain)      # Solid reflective wall
     6960               
     6961                # Constant flow in and out of domain
     6962                # Depth = 1m, uh=1 m/s, i.e. a flow of 20 m^3/s
     6963                # across boundaries
     6964                Bi = Dirichlet_boundary([d, uh, vh])
     6965                Bo = Dirichlet_boundary([-length*slope+d, uh, vh])
     6966                #Bo = Dirichlet_boundary([-100, 0, 0])
     6967
     6968                domain.set_boundary({'left': Bi, 'right': Bo, 'top': Br, 'bottom': Br})
     6969
     6970
     6971               
     6972               
     6973                #------------------------------------------------------------------------------
     6974                # Evolve system through time
     6975                #------------------------------------------------------------------------------
     6976                for t in domain.evolve(yieldstep=100.0, finaltime=finaltime):
     6977                    if verbose :
     6978                        print domain.timestepping_statistics()
     6979                                   
     6980                # 90 degree flowline at 200m                                   
     6981                q=domain.get_flow_through_cross_section([[200.0,0.0],[200.0,20.0]])
     6982                msg = 'Predicted flow was %f, should have been %f' % (q, ref_flow)
     6983                if verbose:
     6984                    print '90 degree flowline: ANUGA = %f, Ref = %f' % (q, ref_flow)
     6985                     
     6986                     
     6987                # 45 degree flowline at 200m
     6988                q=domain.get_flow_through_cross_section([[200.0,0.0],[220.0,20.0]])
     6989                msg = 'Predicted flow was %f, should have been %f' % (q, ref_flow)
     6990                if verbose:
     6991                    print '45 degree flowline: ANUGA = %f, Ref = %f' % (q, ref_flow)
     6992                   
     6993
     6994                # Stage recorder (gauge) in middle of plane at 200m
     6995                x=200.0
     6996                y=10.00               
     6997                w = domain.get_quantity('stage').get_values(interpolation_points=[[x, y]])[0]
     6998                z = domain.get_quantity('elevation').get_values(interpolation_points=[[x, y]])[0]
     6999                domain_depth = w-z
     7000               
     7001                xmom = domain.get_quantity('xmomentum').get_values(interpolation_points=[[x, y]])[0]               
     7002                ymom = domain.get_quantity('ymomentum').get_values(interpolation_points=[[x, y]])[0]           
     7003                if verbose:                   
     7004                    print 'At interpolation point (h, uh, vh): ', domain_depth, xmom, ymom
     7005                    print 'uh * d * width = ', xmom*domain_depth*width
     7006                               
     7007                if slope > 0.0:
     7008                    # Compute normal depth at gauge location using Manning equation
     7009                    # v=1/n*(r^2/3)*(s^0.5) or r=(Q*n/(s^0.5*W))^0.6
     7010                    normal_depth=(ref_flow*mannings_n/(slope**0.5*width))**0.6
     7011                    if verbose:
     7012                        print 'Depth: ANUGA = %f, Mannings = %f' % (domain_depth, normal_depth)                   
    68837013       
    68847014if __name__ == "__main__":
    6885     #suite = unittest.makeSuite(Test_Shallow_Water, 'test_inflow_using_flowline')
     7015    #suite = unittest.makeSuite(Test_Shallow_Water, 'test_friction_dependent_flow_using_flowline')
    68867016    suite = unittest.makeSuite(Test_Shallow_Water, 'test')   
    68877017    runner = unittest.TextTestRunner(verbosity=1)   
Note: See TracChangeset for help on using the changeset viewer.