Changeset 6763


Ignore:
Timestamp:
Apr 8, 2009, 12:41:20 PM (15 years ago)
Author:
ole
Message:

Added cut down version of Ted's flow test to test_shallow_water_domain.py

File:
1 edited

Legend:

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

    r6659 r6763  
    68876887                               
    68886888       
    6889     def Xtest_inflow_using_flowline(self):
     6889    def test_inflow_using_flowline(self):
    68906890        """test_inflow_using_flowline
    68916891        Test the ability of a flowline to match inflow above the flowline by
    68926892        creating constant inflow onto a circle at the head of a 20m
    6893         wide by 300m long plane dipping at various slopes with a perpendicular flowline and gauge
    6894         downstream of the inflow and a 45 degree flowlines at 200m downstream
     6893        wide by 300m long plane dipping at various slopes with a
     6894        perpendicular flowline and gauge downstream of the inflow and
     6895        a 45 degree flowlines at 200m downstream
     6896
     6897        A more substantial version of this test with finer resolution and
     6898        including the depth calculation using Manning's equation is
     6899        available under the validate_all suite in the directory
     6900        anuga_validation/automated_validation_tests/flow_tests
    68956901        """
    68966902
    6897         # FIXME(Ole): Move this and the following test to validate_all.py as they are
    6898         # rather time consuming
    6899        
    6900         verbose = True
    6901        
    6902 
    6903         #------------------------------------------------------------------------------
     6903       
     6904        verbose = False
     6905       
     6906
     6907        #----------------------------------------------------------------------
    69046908        # Import necessary modules
    6905         #------------------------------------------------------------------------------
     6909        #----------------------------------------------------------------------
    69066910        from anuga.abstract_2d_finite_volumes.mesh_factory import rectangular_cross
    69076911        from anuga.shallow_water import Domain
     
    69136917
    69146918
    6915         #------------------------------------------------------------------------------
     6919        #----------------------------------------------------------------------
    69166920        # Setup computational domain
    6917         #------------------------------------------------------------------------------
     6921        #----------------------------------------------------------------------
    69186922        number_of_inflows = 2 # Number of inflows on top of each other
    6919         finaltime = 1000.0 #6000.0
    6920 
    6921         length = 300.
     6923        finaltime = 500 #700.0 # If this is too short, steady state will not be achieved
     6924
     6925        length = 250.
    69226926        width  = 20.
    69236927        dx = dy = 5          # Resolution: of grid on both axes
     
    69266930                                                       len1=length, len2=width)
    69276931
    6928         for mannings_n in [0.150, 0.07, 0.035]: #[0.012, 0.035, 0.070, 0.150]:
    6929             for slope in [1.0/300, 1.0/150, 1.0/75]:
     6932        for mannings_n in [0.1, 0.01]:
     6933            # Loop over a range of roughnesses             
     6934           
     6935            for slope in [1.0/300, 1.0/100]:
    69306936                # Loop over a range of bedslopes representing sub to super critical flows
    69316937
    6932                 if verbose:
    6933                     print
    6934                     print 'Slope:', slope, 'Mannings n:', mannings_n
     6938
    69356939                domain = Domain(points, vertices, boundary)   
    6936                 domain.set_name('Inflow_flowline_test')              # Output name
     6940                domain.set_name('inflow_flowline_test')
    69376941               
    69386942
    6939                 #------------------------------------------------------------------------------
     6943                #-------------------------------------------------------------
    69406944                # Setup initial conditions
    6941                 #------------------------------------------------------------------------------
     6945                #-------------------------------------------------------------
    69426946
    69436947                def topography(x, y):
     
    69456949                    return z
    69466950
    6947                 domain.set_quantity('elevation', topography)  # Use function for elevation
    6948                 domain.set_quantity('friction', mannings_n)   # Constant friction of conc surface   
     6951                domain.set_quantity('elevation', topography)
     6952                domain.set_quantity('friction', mannings_n)
    69496953                domain.set_quantity('stage',
    6950                                     expression='elevation')   # Dry initial condition
    6951 
    6952 
    6953                 #------------------------------------------------------------------------------
    6954                 # Setup boundary conditions
    6955                 #------------------------------------------------------------------------------
    6956 
    6957                 Br = Reflective_boundary(domain)              # Solid reflective wall
    6958                 Bo = Dirichlet_boundary([-100, 0, 0])           # Outflow stsge at -0.9m d=0.1m
    6959 
    6960                 domain.set_boundary({'left': Br, 'right': Bo, 'top': Br, 'bottom': Br})
    6961 
    6962                 #------------------------------------------------------------------------------
     6954                                    expression='elevation')
     6955
     6956
     6957                #--------------------------------------------------------------
    69636958                # Seup Inflow
    6964                 #------------------------------------------------------------------------------
     6959                #--------------------------------------------------------------
    69656960
    69666961                # Fixed Flowrate onto Area
     
    69766971                ref_flow = fixed_inflow.rate*number_of_inflows
    69776972
    6978                 #------------------------------------------------------------------------------
     6973                # Compute normal depth on plane using Mannings equation
     6974                # v=1/n*(r^2/3)*(s^0.5) or r=(Q*n/(s^0.5*W))^0.6
     6975                normal_depth=(ref_flow*mannings_n/(slope**0.5*width))**0.6
     6976                if verbose:
     6977                    print
     6978                    print 'Slope:', slope, 'Mannings n:', mannings_n
     6979                   
     6980                   
     6981                #--------------------------------------------------------------
     6982                # Setup boundary conditions
     6983                #--------------------------------------------------------------
     6984
     6985                Br = Reflective_boundary(domain)
     6986               
     6987                # Define downstream boundary based on predicted depth
     6988                def normal_depth_stage_downstream(t):
     6989                    return (-slope*length) + normal_depth
     6990               
     6991                Bt = Transmissive_momentum_set_stage_boundary(domain=domain,
     6992                                                              function=normal_depth_stage_downstream)
     6993               
     6994
     6995               
     6996
     6997                domain.set_boundary({'left': Br,
     6998                                     'right': Bt,
     6999                                     'top': Br,
     7000                                     'bottom': Br})
     7001
     7002
     7003
     7004                #--------------------------------------------------------------
    69797005                # Evolve system through time
    6980                 #------------------------------------------------------------------------------
     7006                #--------------------------------------------------------------
    69817007
    69827008
     
    69857011                    #if verbose :
    69867012                    #    print domain.timestepping_statistics()
    6987 
    6988                 if verbose:
    6989                     print domain.volumetric_balance_statistics()                                                           
    6990 
    6991 
    6992 
    6993                 #------------------------------------------------------------------------------
     7013                    #    print domain.volumetric_balance_statistics()                                   
     7014
     7015
     7016                #--------------------------------------------------------------
    69947017                # Compute flow thru flowlines ds of inflow
    6995                 #------------------------------------------------------------------------------
     7018                #--------------------------------------------------------------
    69967019                   
    69977020                # Square on flowline at 200m
     
    70117034                assert num.allclose(q, ref_flow, rtol=1.0e-2), msg         
    70127035
    7013                 # Stage recorder (gauge) in middle of plane at 200m
    7014                 x=200.0
    7015                 y=10.00
    7016                 w = domain.get_quantity('stage').get_values(interpolation_points=[[x, y]])[0]
    7017                 z = domain.get_quantity('elevation').get_values(interpolation_points=[[x, y]])[0]
    7018                 domain_depth = w-z
    7019                
    7020                
    7021                 # Compute normal depth at gauge location using Manning equation
    7022                 # v=1/n*(r^2/3)*(s^0.5) or r=(Q*n/(s^0.5*W))^0.6
    7023                 normal_depth=(ref_flow*mannings_n/(slope**0.5*width))**0.6
    7024                 msg = 'Predicted depth of flow was %f, should have been %f' % (domain_depth, normal_depth)               
    7025                 if verbose:
    7026                     diff = abs(domain_depth-normal_depth)
    7027                     print 'Depth: ANUGA = %f, Mannings = %f, E=%f' % (domain_depth,
    7028                                                                       normal_depth,
    7029                                                                       diff/domain_depth)
    7030                    
    7031                     assert diff < 0.1
    7032                    
    7033                 if slope >= 1.0/100:
    7034                     # Really super critical flow is not as stable.
    7035                     #assert num.allclose(domain_depth,normal_depth, rtol=1.0e-1), msg
    7036                     pass
    7037                 else:
    7038                     pass
    7039                     #assert num.allclose(domain_depth,normal_depth, rtol=1.0e-2), msg
    70407036       
    70417037       
     
    70487044        Flow is applied in the form of boundary conditions with fixed momentum.
    70497045        """
     7046
     7047        # FIXME(Ole): This is not finished and maybe not necessary
     7048        # anymore (see test_inflow_using_flowline)
    70507049
    70517050        verbose = True
     
    71837182                               
    71847183if __name__ == "__main__":
    7185     #suite = unittest.makeSuite(Test_Shallow_Water, 'test_friction_dependent_flow_using_flowline')
    7186     suite = unittest.makeSuite(Test_Shallow_Water, 'test_inflow')
    7187     #suite = unittest.makeSuite(Test_Shallow_Water, 'test_total_volume')           
    7188     #suite = unittest.makeSuite(Test_Shallow_Water, 'test')       
    7189 
     7184    suite = unittest.makeSuite(Test_Shallow_Water, 'test')
    71907185    runner = unittest.TextTestRunner(verbosity=1)   
    71917186    runner.run(suite)
Note: See TracChangeset for help on using the changeset viewer.