Changeset 6763
- Timestamp:
- Apr 8, 2009, 12:41:20 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
anuga_core/source/anuga/shallow_water/test_shallow_water_domain.py
r6659 r6763 6887 6887 6888 6888 6889 def Xtest_inflow_using_flowline(self):6889 def test_inflow_using_flowline(self): 6890 6890 """test_inflow_using_flowline 6891 6891 Test the ability of a flowline to match inflow above the flowline by 6892 6892 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 6895 6901 """ 6896 6902 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 #---------------------------------------------------------------------- 6904 6908 # Import necessary modules 6905 #---------------------------------------------------------------------- --------6909 #---------------------------------------------------------------------- 6906 6910 from anuga.abstract_2d_finite_volumes.mesh_factory import rectangular_cross 6907 6911 from anuga.shallow_water import Domain … … 6913 6917 6914 6918 6915 #---------------------------------------------------------------------- --------6919 #---------------------------------------------------------------------- 6916 6920 # Setup computational domain 6917 #---------------------------------------------------------------------- --------6921 #---------------------------------------------------------------------- 6918 6922 number_of_inflows = 2 # Number of inflows on top of each other 6919 finaltime = 1000.0 #6000.06920 6921 length = 300.6923 finaltime = 500 #700.0 # If this is too short, steady state will not be achieved 6924 6925 length = 250. 6922 6926 width = 20. 6923 6927 dx = dy = 5 # Resolution: of grid on both axes … … 6926 6930 len1=length, len2=width) 6927 6931 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]: 6930 6936 # Loop over a range of bedslopes representing sub to super critical flows 6931 6937 6932 if verbose: 6933 print 6934 print 'Slope:', slope, 'Mannings n:', mannings_n 6938 6935 6939 domain = Domain(points, vertices, boundary) 6936 domain.set_name(' Inflow_flowline_test') # Output name6940 domain.set_name('inflow_flowline_test') 6937 6941 6938 6942 6939 #------------------------------------------------------------- -----------------6943 #------------------------------------------------------------- 6940 6944 # Setup initial conditions 6941 #------------------------------------------------------------- -----------------6945 #------------------------------------------------------------- 6942 6946 6943 6947 def topography(x, y): … … 6945 6949 return z 6946 6950 6947 domain.set_quantity('elevation', topography) # Use function for elevation6948 domain.set_quantity('friction', mannings_n) # Constant friction of conc surface6951 domain.set_quantity('elevation', topography) 6952 domain.set_quantity('friction', mannings_n) 6949 6953 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 #-------------------------------------------------------------- 6963 6958 # Seup Inflow 6964 #-------------------------------------------------------------- ----------------6959 #-------------------------------------------------------------- 6965 6960 6966 6961 # Fixed Flowrate onto Area … … 6976 6971 ref_flow = fixed_inflow.rate*number_of_inflows 6977 6972 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 #-------------------------------------------------------------- 6979 7005 # Evolve system through time 6980 #-------------------------------------------------------------- ----------------7006 #-------------------------------------------------------------- 6981 7007 6982 7008 … … 6985 7011 #if verbose : 6986 7012 # 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 #-------------------------------------------------------------- 6994 7017 # Compute flow thru flowlines ds of inflow 6995 #-------------------------------------------------------------- ----------------7018 #-------------------------------------------------------------- 6996 7019 6997 7020 # Square on flowline at 200m … … 7011 7034 assert num.allclose(q, ref_flow, rtol=1.0e-2), msg 7012 7035 7013 # Stage recorder (gauge) in middle of plane at 200m7014 x=200.07015 y=10.007016 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-z7019 7020 7021 # Compute normal depth at gauge location using Manning equation7022 # v=1/n*(r^2/3)*(s^0.5) or r=(Q*n/(s^0.5*W))^0.67023 normal_depth=(ref_flow*mannings_n/(slope**0.5*width))**0.67024 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.17032 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), msg7036 pass7037 else:7038 pass7039 #assert num.allclose(domain_depth,normal_depth, rtol=1.0e-2), msg7040 7036 7041 7037 … … 7048 7044 Flow is applied in the form of boundary conditions with fixed momentum. 7049 7045 """ 7046 7047 # FIXME(Ole): This is not finished and maybe not necessary 7048 # anymore (see test_inflow_using_flowline) 7050 7049 7051 7050 verbose = True … … 7183 7182 7184 7183 if __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') 7190 7185 runner = unittest.TextTestRunner(verbosity=1) 7191 7186 runner.run(suite)
Note: See TracChangeset
for help on using the changeset viewer.