source: anuga_work/debug/inflow_investigation/inflow_flowline_test.py @ 6500

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

Added inflow test from Ted Rigby

File size: 4.0 KB
Line 
1"""
2This script tests the ability of a flowline to match inflow above the flowline by
3 creating constant inflow of 1 m3/sec onto a 5m dia circle at the head of a 20m
4 wide plane dipping at 1:300 with a flowline and gauge downstream of the inflow.
5
6
7
8"""
9
10#------------------------------------------------------------------------------
11# Import necessary modules
12#------------------------------------------------------------------------------
13from anuga.abstract_2d_finite_volumes.mesh_factory import rectangular_cross
14from anuga.shallow_water import Domain
15from anuga.shallow_water.shallow_water_domain import Reflective_boundary
16from anuga.shallow_water.shallow_water_domain import Dirichlet_boundary
17from anuga.shallow_water.shallow_water_domain import Inflow
18from anuga.shallow_water.data_manager import get_flow_through_cross_section
19from anuga.abstract_2d_finite_volumes.util import sww2csv_gauges, csv2timeseries_graphs
20
21
22
23#------------------------------------------------------------------------------
24# Setup computational domain
25#------------------------------------------------------------------------------
26
27
28
29length = 300.
30width  = 20.
31
32dx = dy = 1             # Resolution: of grid on both axes
33
34
35points, vertices, boundary = rectangular_cross(int(length/dx), int(width/dy),
36                                               len1=length, len2=width)
37domain = Domain(points, vertices, boundary)   
38domain.set_name('inflow_flowline_test')     # Output name
39domain.set_default_order(2)
40domain.H0 = 0.01
41domain.tight_slope_limiters = 1
42
43print 'Size', len(domain)
44
45#------------------------------------------------------------------------------
46# Setup initial conditions
47#------------------------------------------------------------------------------
48
49def topography(x, y):
50
51    # General Slope of plane is 1:100
52    z=-x/300
53    return z
54
55
56domain.set_quantity('elevation', topography)  # Use function for elevation
57domain.set_quantity('friction', 0.012)        # Constant friction of conc surface
58domain.set_quantity('stage',
59                    expression='elevation')   # Dry initial condition
60
61#
62#------------------------------------------------------------------------------
63# Setup boundary conditions
64#------------------------------------------------------------------------------
65
66Br = Reflective_boundary(domain)              # Solid reflective wall
67Bo = Dirichlet_boundary([-0.9, 0, 0])           # Outflow stsge at -0.9m d=0.1m
68
69domain.set_boundary({'left': Br, 'right': Bo, 'top': Br, 'bottom': Br})
70
71#------------------------------------------------------------------------------
72# Seup Inflow
73#------------------------------------------------------------------------------
74
75
76fixed_inflow = Inflow(domain,
77                      center=(10.0, 10.0),
78                      radius=5.00,
79                      rate=1.00)   # Fixed Flowrate onto Area
80
81domain.forcing_terms.append(fixed_inflow)
82
83
84#------------------------------------------------------------------------------
85# Evolve system through time
86#------------------------------------------------------------------------------
87
88for t in domain.evolve(yieldstep = 5.0, finaltime = 300):
89    domain.write_time() 
90
91
92#------------------------------------------------------------------------------
93# Compute flow thru flowline ds of inflow
94#------------------------------------------------------------------------------
95
96time, Q = get_flow_through_cross_section('inflow_flowline_test.sww',
97                                         [[30.0,0.0],[30.0,20.0]],
98                                         verbose=True)
99csv_fid= open('inflow_flowline_test.csv', 'w')
100for j in range(len(time)):
101    csv_fid.write('%f, %f\n' %(time[j], Q[j]))
102csv_fid.close()
103
104#------------------------------------------------------------------------------
105# Record stage hydrograph ds of inflow
106#------------------------------------------------------------------------------
107
108sww2csv_gauges('inflow_flowline_test.sww',
109               'gauges.csv',
110               quantities=['stage','elevation'],
111               verbose=True)
Note: See TracBrowser for help on using the repository browser.