source: anuga_work/development/ted_rigby/test_flowhydraulics_in_vee_using_inflow.py @ 7475

Last change on this file since 7475 was 7475, checked in by ole, 15 years ago

Added tests from Ted Rigby that cause unexpected flows.

File size: 6.3 KB
Line 
1"""test_flow_in_vee_using_inflow.py
2Test the ability of ANUGA to
3a) maintain the flow rate input into the channel at the upstream end
4b) replicate normal depth half way down the channel after half an hour
5c) replicate a typical velocity profile across the channel after half an hour
6
7The vee channel is 20m wide by 1000m long with side slopes of 1:1
8The equations for dn are generalised with side slope as 1 V in Side_Slope H
9The test location is in the invert of (y=10m)and half way down the channel (x=500m)
10This script explores flow behaviour predicted by ANUGA and compares it with known solutions
11
12This test inputs flow using the 'inflow' function .
13
14"""
15
16verbose = True
17import numpy as num
18
19#------------------------------------------------------------------------------
20# Import necessary modules
21#------------------------------------------------------------------------------
22from anuga.abstract_2d_finite_volumes.mesh_factory import rectangular_cross
23from anuga.shallow_water import Domain
24from anuga.shallow_water.shallow_water_domain import Reflective_boundary
25from anuga.shallow_water.shallow_water_domain import Dirichlet_boundary
26from anuga.shallow_water.shallow_water_domain import Transmissive_Momentum_Set_Stage_boundary
27from anuga.shallow_water.shallow_water_domain import Transmissive_boundary
28from anuga.shallow_water.shallow_water_domain import Inflow
29from anuga.shallow_water.data_manager import get_flow_through_cross_section
30from anuga.abstract_2d_finite_volumes.util import sww2csv_gauges, csv2timeseries_graphs
31
32
33#------------------------------------------------------------------------------
34# Setup computational domain
35#------------------------------------------------------------------------------
36
37finaltime = 1800.0    # 1/2 hour
38
39length     = 1000.
40width      = 20.
41side_slope = 1.0
42dx = dy    = 1          # Resolution: of points (elev) grid on both axes
43ref_flow   = 50.0       # Inflow at head of vee
44slope      = 1.0/1000
45mannings_n = 0.150
46
47points, vertices, boundary = rectangular_cross(int(length/dx), int(width/dy),
48                                               len1=length, len2=width)
49
50
51
52domain = Domain(points, vertices, boundary)   
53domain.set_name('test_flowhydraulics_in_vee_using_inflow')  # Output name
54
55
56#------------------------------------------------------------------------------
57# Setup initial conditions
58#------------------------------------------------------------------------------
59
60def topography(x, y):
61    z=-x * slope + abs((y-10)* side_slope)
62    return z
63
64domain.set_quantity('elevation', topography)  # Use function for elevation
65domain.set_quantity('friction', mannings_n)   # Constant friction of conc surface   
66domain.set_quantity('stage',
67                    expression='elevation')   # zero depth initial condition
68
69
70#------------------------------------------------------------------------------
71# Compute normal depth flow characteristics for vee using Mannings equation
72#------------------------------------------------------------------------------
73
74normal_depth  = ( ref_flow*mannings_n* ( (2.0*( (1.0+(1.0/side_slope)**2.0)**0.5) )**0.6667 ) / (side_slope*(slope**0.5))  )**0.375
75area          = (normal_depth**2.0) *side_slope
76wet_perimeter = 2* normal_depth*((1+(side_slope)**2.0)**0.5)
77hyd_radius    = area/wet_perimeter
78flow_velocity = ref_flow/area
79top_width     = 2* side_slope*normal_depth
80
81print 'Mannings solution for normal depth flow in vee is; '
82print '    Channel sideslopes = ', side_slope
83print '    Channel n          = ', mannings_n
84print '    Channel slope      = ', slope
85print '    Reference flow     = ', ref_flow
86print '    Normal depth       = ', normal_depth
87print '    Flow area          = ', area
88print '    Wet perimeter      = ', wet_perimeter
89print '    Hydraulic radius   = ', hyd_radius
90print '    Avg velocity       = ', flow_velocity
91print '    Flow width         = ', top_width
92
93#------------------------------------------------------------------------------
94# Calculate inflow and append to domain forcing terms
95#------------------------------------------------------------------------------
96
97# Fixed Flowrate onto Area
98fixed_inflow = Inflow(domain,
99                      center=(10.0, 10.0),
100                      radius=5.00,
101                      rate=ref_flow)   
102domain.forcing_terms.append(fixed_inflow)
103
104#------------------------------------------------------------------------------
105# Setup boundary conditions
106#------------------------------------------------------------------------------
107
108
109Br = Reflective_boundary(domain)                       # Solid reflective wall on edge of sides
110# set outflow depth to mannings normal depth for flow to avoid drawdown impact upstream
111def outflow_depth(t):
112    return (-slope*length) + normal_depth
113Bo = Transmissive_Momentum_Set_Stage_boundary(domain=domain,function=outflow_depth)
114
115domain.set_boundary({'left': Br, 'right': Bo, 'top': Br, 'bottom': Br})
116
117#------------------------------------------------------------------------------
118# Evolve system through time
119#------------------------------------------------------------------------------
120
121for t in domain.evolve(yieldstep=100.0, finaltime=finaltime):
122    if verbose :
123        print domain.timestepping_statistics()
124
125
126#------------------------------------------------------------------------------
127# Compute flow across flowlines -v- ref_flow
128#------------------------------------------------------------------------------
129
130# Check flow across flowline at 500m (where  it should have normalised)
131q=domain.get_flow_through_cross_section([[500.0,0.0],[500.0,width]])
132print '90 degree flowline half way down channel: ANUGA Q = %f, Ref_flow = %f' %(q, ref_flow)
133
134# Check flow across flowline at 998m (wimmediately US of outflow bdry)
135q=domain.get_flow_through_cross_section([[998.0,0.0],[998.0,width]])
136print '90 degree flowline just US of outflow bdry: ANUGA Q = %f, Ref_flow = %f' %(q, ref_flow)
137
138#------------------------------------------------------------------------------
139# Record temporal flow characteristics just ds inflow bdry
140#------------------------------------------------------------------------------
141
142# Store temporal pattern of gauges at head/middle/bottom of channel in csv files
143sww2csv_gauges(sww_file  = 'test_flowhydraulics_in_vee_using_inflow.sww',
144               gauge_file= 'gauge_locations.csv',
145               out_name  = 'inflow_',
146               quantities=['stage','speed','elevation'],
147               verbose=True)
Note: See TracBrowser for help on using the repository browser.