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