source: anuga_validation/automated_validation_tests/flow_tests/test_inflow_using_flowline.py @ 7774

Last change on this file since 7774 was 7774, checked in by hudson, 14 years ago

Validation tests use new API.

File size: 5.7 KB
Line 
1
2
3"""test_inflow_using_flowline
4Test the ability of a flowline to match inflow above the flowline by
5creating constant inflow onto a circle at the head of a 20m
6wide by 400m long plane dipping at various slopes with a perpendicular flowline and gauge
7downstream of the inflow and a 45 degree flowlines at 200m downstream
8"""
9
10verbose = True
11import numpy as num
12
13#------------------------------------------------------------------------------
14# Import necessary modules
15#------------------------------------------------------------------------------
16
17# Get the standard ANUGA API.
18import anuga
19
20
21#------------------------------------------------------------------------------
22# Setup computational domain
23#------------------------------------------------------------------------------
24
25number_of_inflows = 2 # Number of inflows on top of each other
26finaltime = 1000.0
27
28length = 400.
29width  = 20.
30dx = dy = 2          # Resolution: of grid on both axes
31
32points, vertices, boundary = anuga.rectangular_cross(int(length/dx), \
33                                int(width/dy), len1=length, len2=width)
34
35for mannings_n in [0.012, 0.035, 0.070, 0.150]:
36    # Loop over a range of roughnesses 
37   
38    for slope in [1.0/300, 1.0/150, 1.0/75]:
39        # Loop over a range of bedslopes 
40       
41
42        domain = anuga.Domain(points, vertices, boundary)   
43        domain.set_name('inflow_flowline_test')
44
45
46        #----------------------------------------------------------------------
47        # Setup initial conditions
48        #----------------------------------------------------------------------
49
50        def topography(x, y):
51            z=-x * slope
52            return z
53
54        domain.set_quantity('elevation', topography)
55        domain.set_quantity('friction', mannings_n)
56        domain.set_quantity('stage',
57                            expression='elevation') # Dry initial condition
58
59
60        #----------------------------------------------------------------------
61        # Seup Inflow and compute flow characteristics
62        #----------------------------------------------------------------------
63
64        # Fixed Flowrate onto Area
65        fixed_inflow = anuga.Inflow(domain,
66                              center=(10.0, 10.0),
67                              radius=5.00,
68                              rate=10.00)   
69       
70        # Stack this flow
71        for i in range(number_of_inflows):
72            domain.forcing_terms.append(fixed_inflow)
73       
74        ref_flow = fixed_inflow.rate*number_of_inflows
75       
76        # Compute normal depth on plane using Mannings equation
77        # v=1/n*(r^2/3)*(s^0.5) or r=(Q*n/(s^0.5*W))^0.6
78        normal_depth=(ref_flow*mannings_n/(slope**0.5*width))**0.6
79        flow_velocity = ref_flow/(width*normal_depth)
80        froude_no = flow_velocity/(9.8*normal_depth)**0.5
81        if verbose:
82            print
83            print 'Slope:', slope, 'Mannings n:', mannings_n, 'Velocity:',flow_velocity,'Froude:',froude_no
84
85
86        #----------------------------------------------------------------------
87        # Setup boundary conditions
88        #----------------------------------------------------------------------
89
90        Br = anuga.Reflective_boundary(domain) # Solid reflective wall
91
92        # Define downstream boundary based on predicted depth
93        def normal_depth_stage_downstream(t):
94            return (-slope*length) + normal_depth
95       
96        Bt = anuga.Transmissive_momentum_set_stage_boundary(domain=domain,
97                                                      function=normal_depth_stage_downstream)
98       
99        domain.set_boundary({'left': Br, 'right': Bt, 'top': Br, 'bottom': Br})
100
101        #----------------------------------------------------------------------
102        # Evolve system through time
103        #----------------------------------------------------------------------
104
105        x=200.0      # Reference location for flowlines and gauges
106        y=10.00
107       
108        for t in domain.evolve(yieldstep=100.0, finaltime=finaltime):
109            if verbose :
110                print domain.timestepping_statistics()
111                print domain.volumetric_balance_statistics()               
112
113
114        #----------------------------------------------------------------------
115        # Compute flow thru flowlines ds of inflow and check against normal depth
116        #----------------------------------------------------------------------
117
118        # Square on flowline at 200m
119        q=domain.get_flow_through_cross_section([[200.0,0.0],[200.0,20.0]])
120        msg = 'Predicted square on flow was %f, should have been %f' % (q, ref_flow)
121        if verbose:
122            print '90 degree flowline: ANUGA = %f, Ref = %f' % (q, ref_flow)
123        assert num.allclose(q, ref_flow, rtol=1.0e-2), msg         
124       
125        # 45 degree flowline at 200m
126        q=domain.get_flow_through_cross_section([[200.0,0.0],[220.0,20.0]])
127        msg = 'Predicted 45 flow was %f, should have been %f' % (q, ref_flow)
128        if verbose:
129            print '45 degree flowline: ANUGA = %f, Ref = %f' % (q, ref_flow)
130        assert num.allclose(q, ref_flow, rtol=1.0e-2), msg         
131
132
133       # Stage recorder (gauge) in middle of plane at 200m
134        w = domain.get_quantity('stage').get_values(interpolation_points=[[x, y]])[0]
135        z = domain.get_quantity('elevation').get_values(interpolation_points=[[x, y]])[0]
136        domain_depth = w-z
137       
138       
139        msg = 'Predicted depth of flow at 200m was %f, should have been %f' % (normal_depth, domain_depth)
140        msg = 'Mannings n = %s, slope = %s' % (mannings_n, slope)
141        if verbose:
142            print 'Depth at 200m: ANUGA = %f, Mannings = %f' % (domain_depth, normal_depth)
143        assert num.allclose(domain_depth,normal_depth, rtol=1.0e-2), msg
144
145
146
Note: See TracBrowser for help on using the repository browser.