source: anuga_work/development/ted_rigby/test_flow_in_vee_basic.py @ 7741

Last change on this file since 7741 was 7403, checked in by ole, 16 years ago

Played with Ted's V channel

File size: 5.5 KB
Line 
1"""test_flow_in_vee.py
2Test the ability of ANUGA to
3a) maintain the flow rate input into the channel at the upstream end
4
5The vee channel is 20m wide by 400m long with side slopes of 1:1
6The equations for dn are generalised with side slope as 1 V in Side_Slope H
7The test location is half way down the channel X=200m
8This script explores flow  as given by ANUGA and compares it with
9the ref_flow
10"""
11
12verbose = True
13import numpy as num
14
15#------------------------------------------------------------------------------
16# Import necessary modules
17#------------------------------------------------------------------------------
18from anuga.abstract_2d_finite_volumes.mesh_factory import rectangular_cross
19from anuga.shallow_water import Domain
20from anuga.shallow_water.shallow_water_domain import Reflective_boundary
21from anuga.shallow_water.shallow_water_domain import Dirichlet_boundary
22from anuga.shallow_water.shallow_water_domain import Transmissive_Momentum_Set_Stage_boundary
23from anuga.shallow_water.shallow_water_domain import Transmissive_boundary
24from anuga.shallow_water.shallow_water_domain import Inflow
25from anuga.shallow_water.data_manager import get_flow_through_cross_section
26from anuga.abstract_2d_finite_volumes.util import sww2csv_gauges, csv2timeseries_graphs
27
28
29#------------------------------------------------------------------------------
30# Setup computational domain
31#------------------------------------------------------------------------------
32
33finaltime = 1800.0    # 1/2 hour
34
35length     = 400.
36width      = 20.
37side_slope = 1.0
38dx = dy    = 2          # Resolution: of points (elev) grid on both axes
39ref_flow   = 5.0        # Inflow at head of vee
40slope      = 1.0/1000
41mannings_n = 0.150
42
43points, vertices, boundary = rectangular_cross(int(length/dx), int(width/dy),
44                                               len1=length, len2=width)
45
46
47
48domain = Domain(points, vertices, boundary)   
49domain.set_name('test_flow_in_vee')              # Output name
50print domain.statistics()
51
52
53#------------------------------------------------------------------------------
54# Seup Inflow and compute flow characteristics
55#------------------------------------------------------------------------------
56
57# Compute normal depth, and velocity for the vee using Mannings equation
58
59normal_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
60area          = (normal_depth**2.0) *side_slope
61wet_perimeter = 2*normal_depth*((1+(side_slope)**2.0)**0.5)
62hyd_radius    = area/wet_perimeter
63flow_velocity = ref_flow/area
64top_width     = 2*side_slope*normal_depth
65
66# Compute xmomentum to input into the ANUGA inflow boundary
67# assuming momentum is applied uniformly to inflow boundary by ANUGA
68
69#xmomentum = ref_flow/top_width  # this is all very unrealistic but should replicate ref_flow in ANUGA
70xmomentum = ref_flow/width       # This only applies where channel is flat.
71
72print 'ref_flow', ref_flow
73print 'xmomentum', xmomentum
74print 'normal_depth', normal_depth
75print 'width', width
76
77
78
79#------------------------------------------------------------------------------
80# Setup initial conditions
81#------------------------------------------------------------------------------
82
83def topography(x, y):
84    z = -x * slope + abs((y-10)*side_slope)
85   
86    # Let both ends of domain be square so that the applied xmomentum
87    # represents flow correctly
88    for i in range(len(x)):
89        if x[i] < 20 or x[i] > 380:
90            z[i] = -x[i] * slope
91           
92    return z
93   
94   
95def initial_stage(x, y):
96    """Set constant depth based on calculated normal flow
97    """
98
99    w = -x*slope + normal_depth
100    return w
101   
102   
103domain.set_quantity('elevation', topography)  # Use function for elevation
104domain.set_quantity('friction', mannings_n)   # Constant friction of conc surface   
105domain.set_quantity('stage', initial_stage) 
106domain.set_quantity('xmomentum', xmomentum) # Initial momentum commensurate with normal flow
107
108
109
110#------------------------------------------------------------------------------
111# Setup boundary conditions
112#------------------------------------------------------------------------------
113
114
115Br = Reflective_boundary(domain)                       # Solid reflective wall on edge of sides
116Bi = Dirichlet_boundary([normal_depth,xmomentum,0.0])  # inflow at top
117Bo = Dirichlet_boundary([-length*slope+normal_depth,xmomentum,0.0])  # Outflow at bottom
118
119domain.set_boundary({'left': Bi, 'right': Bo, 'top': Br, 'bottom': Br})
120
121#------------------------------------------------------------------------------
122# Evolve system through time
123#------------------------------------------------------------------------------
124
125for t in domain.evolve(yieldstep=100.0, finaltime=finaltime):
126    if verbose :
127        print domain.timestepping_statistics()
128     
129     
130    # Check flow across flowline at 200m at every yield step
131    q=domain.get_flow_through_cross_section([[200.0,0.0],[200.0,width]])
132    print '90 degree flowline: ANUGA Q = %f, Ref_flow = %f' %(q, ref_flow)     
133
134
135#------------------------------------------------------------------------------
136# Compute flow in vee cf inflow
137#------------------------------------------------------------------------------
138
139
140
141#------------------------------------------------------------------------------
142# Compute flow across flowline -v- ref_flow
143#------------------------------------------------------------------------------
144
145# Check flow across flowline at 200m
146q=domain.get_flow_through_cross_section([[200.0,0.0],[200.0,width]])
147print '90 degree flowline: ANUGA Q = %f, Ref_flow = %f' %(q, ref_flow)
148
Note: See TracBrowser for help on using the repository browser.